@deslop/trips 0.1.1239 → 0.1.1243

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 +287 -99
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -3481,6 +3481,8 @@ const SuccessImpl = function(success) {
3481
3481
  SuccessImpl.prototype = SuccessProto;
3482
3482
  /** @internal */
3483
3483
  const succeed$10 = (success) => new SuccessImpl(success);
3484
+ /** @internal */
3485
+ const getSuccess$1 = (self) => isFailure$2(self) ? none$1 : some$2(self.success);
3484
3486
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Order.js
3485
3487
  /**
3486
3488
  * Defines comparison functions for ordered values.
@@ -5462,6 +5464,37 @@ const isFailure$1 = isFailure$2;
5462
5464
  */
5463
5465
  const isSuccess$1 = isSuccess$2;
5464
5466
  /**
5467
+ * Extracts the success value as an `Option`, discarding the failure.
5468
+ *
5469
+ * **When to use**
5470
+ *
5471
+ * Use when you need to extract the success value from a `Result` as an
5472
+ * `Option` and discard failure information.
5473
+ *
5474
+ * **Details**
5475
+ *
5476
+ * - `Success<A>` becomes `Some<A>`
5477
+ * - `Failure<E>` becomes `None`
5478
+ *
5479
+ * **Example** (Extracting the success as an Option)
5480
+ *
5481
+ * ```ts import.meta.vitest
5482
+ * import { Option, Result } from "effect"
5483
+ *
5484
+ * Result.getSuccess(Result.succeed("ok")) // => Option.some("ok")
5485
+ *
5486
+ * Result.getSuccess(Result.fail("err")) // => Option.none()
5487
+ * ```
5488
+ *
5489
+ * @see {@link getFailure} to extract the error instead
5490
+ * @see {@link fromOption} for the reverse conversion
5491
+ *
5492
+ * @stability stable
5493
+ * @category getters
5494
+ * @since 4.0.0
5495
+ */
5496
+ const getSuccess = getSuccess$1;
5497
+ /**
5465
5498
  * Transforms the success channel of a `Result`, leaving the failure channel unchanged.
5466
5499
  *
5467
5500
  * **When to use**
@@ -6171,7 +6204,7 @@ const makeEquivalence$3 = (equivalence) => {
6171
6204
  * @category constructors
6172
6205
  * @since 4.0.0
6173
6206
  */
6174
- const Array$1 = globalThis.Array;
6207
+ const Array$2 = globalThis.Array;
6175
6208
  /**
6176
6209
  * Converts an `Iterable` to an `Array`.
6177
6210
  *
@@ -6200,7 +6233,7 @@ const Array$1 = globalThis.Array;
6200
6233
  * @category constructors
6201
6234
  * @since 2.0.0
6202
6235
  */
6203
- const fromIterable$6 = (collection) => Array$1.isArray(collection) ? collection : Array$1.from(collection);
6236
+ const fromIterable$6 = (collection) => Array$2.isArray(collection) ? collection : Array$2.from(collection);
6204
6237
  /**
6205
6238
  * Normalizes a value that is either a single element or an array into an array.
6206
6239
  *
@@ -6231,7 +6264,7 @@ const fromIterable$6 = (collection) => Array$1.isArray(collection) ? collection
6231
6264
  * @category constructors
6232
6265
  * @since 3.3.0
6233
6266
  */
6234
- const ensure = (self) => Array$1.isArray(self) ? self : [self];
6267
+ const ensure = (self) => Array$2.isArray(self) ? self : [self];
6235
6268
  /**
6236
6269
  * Pattern-matches on an array, handling empty and non-empty cases separately.
6237
6270
  *
@@ -6348,7 +6381,7 @@ const appendAll$1 = /*#__PURE__*/ dual(2, (self, that) => fromIterable$6(self).c
6348
6381
  * @category guards
6349
6382
  * @since 2.0.0
6350
6383
  */
6351
- const isArray = Array$1.isArray;
6384
+ const isArray = Array$2.isArray;
6352
6385
  /**
6353
6386
  * Checks whether a mutable `Array` is empty, narrowing the type to `[]`.
6354
6387
  *
@@ -6748,7 +6781,7 @@ const findLast = /*#__PURE__*/ dual(2, (self, f) => {
6748
6781
  * @category transforming
6749
6782
  * @since 2.0.0
6750
6783
  */
6751
- const reverse = (self) => Array$1.from(self).reverse();
6784
+ const reverse = (self) => Array$2.from(self).reverse();
6752
6785
  /**
6753
6786
  * Sorts an array by the given `Order`, returning a new array.
6754
6787
  *
@@ -6777,7 +6810,7 @@ const reverse = (self) => Array$1.from(self).reverse();
6777
6810
  * @since 2.0.0
6778
6811
  */
6779
6812
  const sort = /*#__PURE__*/ dual(2, (self, O) => {
6780
- const out = Array$1.from(self);
6813
+ const out = Array$2.from(self);
6781
6814
  out.sort(O);
6782
6815
  return out;
6783
6816
  });
@@ -6844,6 +6877,50 @@ const hashBucketsAdd = (buckets, value) => {
6844
6877
  bucket.push(value);
6845
6878
  return true;
6846
6879
  };
6880
+ const makeHashBuckets = (values) => {
6881
+ const buckets = /* @__PURE__ */ new Map();
6882
+ for (const value of values) hashBucketsAdd(buckets, value);
6883
+ return buckets;
6884
+ };
6885
+ const hashBucketsHas = (buckets, value) => {
6886
+ const bucket = buckets.get(hash(value));
6887
+ if (bucket === void 0) return false;
6888
+ for (const candidate of bucket) if (equals$2(candidate, value)) return true;
6889
+ return false;
6890
+ };
6891
+ /**
6892
+ * Computes elements in the first array that are not in the second, using
6893
+ * `Equal.asEquivalence()`.
6894
+ *
6895
+ * **When to use**
6896
+ *
6897
+ * Use when you need to keep values from the first array that are absent from
6898
+ * the second and the default `Equal.asEquivalence()` comparison is appropriate.
6899
+ *
6900
+ * **Example** (Computing array differences)
6901
+ *
6902
+ * ```ts import.meta.vitest
6903
+ * import { Array } from "effect"
6904
+ *
6905
+ * Array.difference([1, 2, 3], [2, 3, 4]) // => [1]
6906
+ * ```
6907
+ *
6908
+ * @see {@link differenceWith} — use custom equality
6909
+ * @see {@link union} — elements in either array
6910
+ * @see {@link intersection} — elements in both arrays
6911
+ *
6912
+ * @stability stable
6913
+ * @category set operations
6914
+ * @since 2.0.0
6915
+ */
6916
+ const difference = /*#__PURE__*/ dual(2, (self, that) => {
6917
+ const thatArray = fromIterable$6(that);
6918
+ const selfArray = fromIterable$6(self);
6919
+ if (selfArray.length === 0) return [];
6920
+ if (thatArray.length === 0) return selfArray.filter(() => true);
6921
+ const buckets = makeHashBuckets(thatArray);
6922
+ return selfArray.filter((value) => !hashBucketsHas(buckets, value));
6923
+ });
6847
6924
  /**
6848
6925
  * Creates an empty array.
6849
6926
  *
@@ -15181,7 +15258,7 @@ const length$1 = (self) => self.length;
15181
15258
  * @category transforming
15182
15259
  * @since 2.0.0
15183
15260
  */
15184
- const split = /*#__PURE__*/ dual(2, (self, separator) => {
15261
+ const split$1 = /*#__PURE__*/ dual(2, (self, separator) => {
15185
15262
  const out = self.split(separator);
15186
15263
  return isArrayNonEmpty$1(out) ? out : [self];
15187
15264
  });
@@ -30901,6 +30978,39 @@ function joinKeyValue(options) {
30901
30978
  return transform$3((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
30902
30979
  }
30903
30980
  /**
30981
+ * Splits a string into an array of strings by a separator.
30982
+ *
30983
+ * **When to use**
30984
+ *
30985
+ * Use when you need a schema getter to split a present encoded string
30986
+ * containing a delimited list, such as CSV values.
30987
+ *
30988
+ * **Details**
30989
+ *
30990
+ * The getter is pure and never fails. It splits by `separator` (default `,`).
30991
+ * An empty string produces an empty array, not `[""]`.
30992
+ *
30993
+ * **Example** (Splitting a comma-separated string)
30994
+ *
30995
+ * ```ts import.meta.vitest
30996
+ * import { Effect, Option, SchemaGetter } from "effect"
30997
+ *
30998
+ * const splitComma = SchemaGetter.split<string>()
30999
+ * const result = Effect.runSync(SchemaGetter.run(splitComma, Option.some("a,b,c"), {}))
31000
+ * result // => Option.some(["a", "b", "c"])
31001
+ * ```
31002
+ *
31003
+ * @see {@link splitKeyValue} when values are key-value pairs
31004
+ *
31005
+ * @stability stable
31006
+ * @category splitting
31007
+ * @since 4.0.0
31008
+ */
31009
+ function split(options) {
31010
+ const separator = options?.separator ?? ",";
31011
+ return transform$3((input) => input === "" ? [] : input.split(separator));
31012
+ }
31013
+ /**
30904
31014
  * Encodes a `Uint8Array` or string to a Base64 string.
30905
31015
  *
30906
31016
  * **Details**
@@ -46853,6 +46963,16 @@ function succeed$1(value) {
46853
46963
  function String$5(name) {
46854
46964
  return schema$1(String$6, name);
46855
46965
  }
46966
+ function Array$1(value, pathOrOptions, options) {
46967
+ const hasPath = isPath(pathOrOptions);
46968
+ const resolvedOptions = hasPath ? options : pathOrOptions;
46969
+ const array = ArraySchema(value);
46970
+ const separator = resolvedOptions?.separator ?? ",";
46971
+ return schema$1(Union([String$6.pipe(decodeTo(toCodecStringTree(array), {
46972
+ decode: split(resolvedOptions),
46973
+ encode: compose(passthrough$1({ strict: false }), transform$3((input) => input.join(separator)))
46974
+ })), array]), hasPath ? pathOrOptions : void 0);
46975
+ }
46856
46976
  function Record(key, value, pathOrOptions, options) {
46857
46977
  const hasPath = isPath(pathOrOptions);
46858
46978
  const record = Record$1(key, value);
@@ -49567,6 +49687,17 @@ const updateContentLength = (headers, body) => {
49567
49687
  };
49568
49688
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/Url.js
49569
49689
  /**
49690
+ * Parses and edits platform `URL` values.
49691
+ *
49692
+ * The HTTP modules use the standard `URL` object as their URL representation.
49693
+ * This module adds safe parsing and helpers that return updated copies when
49694
+ * changing credentials, host, path, protocol, query, or hash parts. Query
49695
+ * strings can also be read or updated through `UrlParams`.
49696
+ *
49697
+ * @stability unstable
49698
+ * @since 4.0.0
49699
+ */
49700
+ /**
49570
49701
  * Error returned when constructing a `URL` fails.
49571
49702
  *
49572
49703
  * @stability unstable
@@ -49607,6 +49738,51 @@ const baseUrl = () => {
49607
49738
  }
49608
49739
  }
49609
49740
  };
49741
+ /**
49742
+ * Parses a URL string safely into a `URL` object, returning a `Result` type for
49743
+ * error handling.
49744
+ *
49745
+ * **Details**
49746
+ *
49747
+ * This function converts a string into a `URL` object, enabling safe URL
49748
+ * parsing with built-in error handling. If the string is invalid or fails to
49749
+ * parse, this function does not throw an error; instead, it wraps the error in
49750
+ * a `IllegalArgumentError` and returns it as the `Failure` value of an
49751
+ * `Result`. The `Success` value contains the successfully parsed `URL`.
49752
+ *
49753
+ * An optional `base` parameter can be provided to resolve relative URLs. If
49754
+ * specified, the function interprets the input `url` as relative to this
49755
+ * `base`. This is especially useful when dealing with URLs that might not be
49756
+ * fully qualified.
49757
+ *
49758
+ * **Example** (Parsing absolute and relative URLs)
49759
+ *
49760
+ * ```ts import.meta.vitest
49761
+ * import { Result } from "effect"
49762
+ * import { Url } from "effect/http"
49763
+ *
49764
+ * // Parse an absolute URL
49765
+ * //
49766
+ * // ┌─── Result<URL, IllegalArgumentError>
49767
+ * // ▼
49768
+ * const parsed = Url.fromString("https://example.com/path")
49769
+ *
49770
+ * Result.map(parsed, (url) => url.toString()) // => Result.succeed("https://example.com/path")
49771
+ *
49772
+ * // Parse a relative URL with a base
49773
+ * const relativeParsed = Url.fromString("/relative-path", "https://example.com")
49774
+ *
49775
+ * Result.map(relativeParsed, (url) => url.toString()) // => Result.succeed("https://example.com/relative-path")
49776
+ * ```
49777
+ *
49778
+ * @stability unstable
49779
+ * @category constructors
49780
+ * @since 4.0.0
49781
+ */
49782
+ const fromString = (url, base) => try_$2({
49783
+ try: () => new URL(url, base),
49784
+ catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
49785
+ });
49610
49786
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/HttpClientRequest.js
49611
49787
  const TypeId$20 = "~effect/http/HttpClientRequest";
49612
49788
  /**
@@ -76047,32 +76223,23 @@ Struct({
76047
76223
  expires_in: Finite,
76048
76224
  refresh_token: NonEmptyString
76049
76225
  });
76050
- const Origin = String$6.check(makeFilter((value) => {
76051
- if (!URL.canParse(value)) return false;
76052
- const url = new URL(value);
76053
- return contains(["http:", "https:"], url.protocol) && url.username === "" && url.password === "" && url.hash === "";
76054
- }, { expected: "an HTTP(S) URL without credentials or a fragment" })).check(makeFilter((value) => {
76055
- if (!URL.canParse(value)) return false;
76056
- const url = new URL(value);
76057
- return url.pathname === "/" && url.search === "";
76058
- }, { expected: "an HTTP(S) origin without a path or query" }));
76059
- const SecureOrigin = Origin.check(makeFilter((value) => {
76060
- if (!URL.canParse(value)) return false;
76061
- const url = new URL(value);
76062
- return url.protocol === "https:" || contains([
76063
- "localhost",
76064
- "127.0.0.1",
76065
- "[::1]"
76066
- ], url.hostname);
76067
- }, { expected: "HTTPS outside loopback" }));
76226
+ const Origin = String$6.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => contains(["http:", "https:"], url.protocol) && url.username === "" && url.password === "" && url.hash === ""), { expected: "an HTTP(S) URL without credentials or a fragment" })).check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => url.pathname === "/" && url.search === ""), { expected: "an HTTP(S) origin without a path or query" }));
76227
+ const SecureOrigin = Origin.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => url.protocol === "https:" || contains([
76228
+ "localhost",
76229
+ "127.0.0.1",
76230
+ "[::1]"
76231
+ ], url.hostname)), { expected: "HTTPS outside loopback" }));
76068
76232
  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" }));
76069
76233
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
76234
+ const RUNTIME_PATH = "/api/runtime";
76070
76235
  const RuntimeConfig = Struct({
76071
76236
  auth: optionalKey(String$6),
76072
76237
  name: String$6,
76073
76238
  traces: String$6,
76074
76239
  version: AppVersion
76075
76240
  });
76241
+ const RPC_PATH = "/api/rpc";
76242
+ const MANIFEST_PATH = "/manifest.webmanifest";
76076
76243
  const Account = Struct({
76077
76244
  ...User.fields,
76078
76245
  signOut: Boolean$5
@@ -81969,11 +82136,19 @@ function layerOtlp(serviceName, url, runtime, version) {
81969
82136
  }));
81970
82137
  }
81971
82138
  // ../../packages/runtime/src/auth/lib/utils.ts
82139
+ const APPS_PATH = "/api/apps";
82140
+ const SESSION_PATH = "/auth/session";
82141
+ const VERIFY_PATH = "/auth/verify";
81972
82142
  const DEVELOPER = {
81973
82143
  id: "github:0",
81974
82144
  name: "dev"
81975
82145
  };
81976
82146
  const localAuth = map$2(option(String$5("AUTH_URL")), isNone);
82147
+ gen(function* () {
82148
+ const listed = Array$1(String$6, "GITHUB_ADMINS");
82149
+ if (yield* localAuth) return yield* withDefault$2(listed, ["0"]);
82150
+ return yield* listed;
82151
+ });
81977
82152
  var CurrentUser = class extends Service$1()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
81978
82153
  var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
81979
82154
  static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
@@ -82016,7 +82191,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
82016
82191
  const canonical = new URL(yield* String$5("APP_URL")).origin;
82017
82192
  const client = filterStatusOk(yield* HttpClient);
82018
82193
  const access = fn("Auth.access")(function* (headers, audience) {
82019
- return yield* pipe(client.get(new URL("/auth/verify", issuer).href, {
82194
+ return yield* pipe(client.get(new URL(VERIFY_PATH, issuer).href, {
82020
82195
  headers: { authorization: headers["authorization"] ?? "" },
82021
82196
  urlParams: { resource: audience }
82022
82197
  }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
@@ -82025,7 +82200,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
82025
82200
  access,
82026
82201
  user: fn("Auth.user")(function* (headers) {
82027
82202
  if (isSome(get$5(headers, "authorization"))) return yield* access(headers, canonical);
82028
- return yield* pipe(client.get(new URL("/auth/session", issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
82203
+ return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
82029
82204
  }, rejected("Sign in first"))
82030
82205
  }));
82031
82206
  }));
@@ -82097,7 +82272,7 @@ const guard = make$24((app) => gen(function* () {
82097
82272
  const canonical = new URL(yield* String$5("APP_URL")).hostname;
82098
82273
  if (!exists(liftThrowable(() => new URL(`http://${host}`))(), (url) => url.hostname === canonical || isSome(match$3(LOOPBACK)(url.hostname)))) return empty$2({ status: 403 });
82099
82274
  }
82100
- if (exists(origin, (value) => !exists(liftThrowable(() => new URL(value).host)(), (originHost) => originHost === host)) && request.headers["sec-fetch-site"] !== "same-origin" && !contains(OTLP, headNonEmpty(split(request.url, "?")))) return empty$2({ status: 403 });
82275
+ if (exists(origin, (value) => !exists(liftThrowable(() => new URL(value).host)(), (originHost) => originHost === host)) && request.headers["sec-fetch-site"] !== "same-origin" && !contains(OTLP, headNonEmpty(split$1(request.url, "?")))) return empty$2({ status: 403 });
82101
82276
  return yield* app;
82102
82277
  }));
82103
82278
  function layerKeyValueStore(directory) {
@@ -82184,7 +82359,7 @@ const layerRoutes = use((router) => gen(function* () {
82184
82359
  })
82185
82360
  });
82186
82361
  });
82187
- yield* router.add("GET", "/api/runtime", gen(function* () {
82362
+ yield* router.add("GET", RUNTIME_PATH, gen(function* () {
82188
82363
  return yield* schemaJson(RuntimeConfig)({
82189
82364
  ...match$8(issuer, {
82190
82365
  onNone: () => ({}),
@@ -82212,7 +82387,7 @@ const layerAnnounce = effectDiscard(gen(function* () {
82212
82387
  yield* match$8(yield* option(String$5("AUTH_URL")), {
82213
82388
  onNone: () => void_$1,
82214
82389
  onSome: fnUntraced(function* (issuer) {
82215
- yield* pipe(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
82390
+ yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
82216
82391
  schedule: spaced("1 minute"),
82217
82392
  times: 60
82218
82393
  }), ignore$1({
@@ -82233,7 +82408,7 @@ const layerWeb = unwrap$7(gen(function* () {
82233
82408
  const client = fileURLToPath(new URL("./client", import.meta.url));
82234
82409
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$11;
82235
82410
  const name = capitalize(yield* appName);
82236
- return mergeAll$2(add("GET", "/manifest.webmanifest", succeed$5(jsonUnsafe({
82411
+ return mergeAll$2(add("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
82237
82412
  background_color: "#0a0a0a",
82238
82413
  display: "standalone",
82239
82414
  icons: [{
@@ -82262,6 +82437,14 @@ const layerWeb = unwrap$7(gen(function* () {
82262
82437
  spa: true
82263
82438
  }));
82264
82439
  }));
82440
+ function layerRpc(options) {
82441
+ return pipe(layerHttp({
82442
+ disableTracing: options.disableTracing,
82443
+ group: options.group,
82444
+ path: RPC_PATH,
82445
+ protocol: "websocket"
82446
+ }), provide$2(options.handlers));
82447
+ }
82265
82448
  const layerNodeHttpServer = layerConfig(createServer, {
82266
82449
  gracefulShutdownTimeout: succeed$1("1500 millis"),
82267
82450
  host: String$5("HOST"),
@@ -82376,6 +82559,7 @@ const update = fnUntraced(function* (name) {
82376
82559
  "--no-audit",
82377
82560
  "--no-fund",
82378
82561
  "--omit=dev",
82562
+ "--prefer-online",
82379
82563
  "--registry=https://registry.npmjs.org",
82380
82564
  `@deslop/${name}@${latest}`
82381
82565
  ]), timeout("5 minutes"));
@@ -82383,7 +82567,7 @@ const update = fnUntraced(function* (name) {
82383
82567
  yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
82384
82568
  yield* restart(name);
82385
82569
  const kept = [latest, ...toArray(map$11(previous, (link) => path.basename(path.resolve(link, "../../.."))))];
82386
- yield* forEach$1(filter$5(yield* fs.readDirectory(path.join(root, "releases")), (entry) => !contains(kept, entry)), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
82570
+ yield* forEach$1(difference(yield* fs.readDirectory(path.join(root, "releases")), kept), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
82387
82571
  return `Updated ${name} from ${running} to ${latest}\n`;
82388
82572
  });
82389
82573
  // ../../packages/runtime/src/cli.ts
@@ -82499,21 +82683,21 @@ const Place = Struct({
82499
82683
  });
82500
82684
  const ReservationStatus = Literals(["confirmed", "cancelled"]);
82501
82685
  const FlightTracking = Struct({
82502
- aircraft: optional$2(String$6),
82503
- arrivalActual: optional$2(Finite),
82504
- arrivalEstimated: optional$2(Finite),
82505
- arrivalGate: optional$2(String$6),
82506
- arrivalTerminal: optional$2(String$6),
82507
- belt: optional$2(String$6),
82686
+ aircraft: optionalKey(String$6),
82687
+ arrivalActual: optionalKey(Finite),
82688
+ arrivalEstimated: optionalKey(Finite),
82689
+ arrivalGate: optionalKey(String$6),
82690
+ arrivalTerminal: optionalKey(String$6),
82691
+ belt: optionalKey(String$6),
82508
82692
  checkedAt: Finite,
82509
- departureActual: optional$2(Finite),
82510
- departureEstimated: optional$2(Finite),
82511
- departureGate: optional$2(String$6),
82512
- departureTerminal: optional$2(String$6),
82513
- landingActual: optional$2(Finite),
82514
- previousGate: optional$2(String$6),
82515
- progress: optional$2(Finite),
82516
- providerId: optional$2(String$6),
82693
+ departureActual: optionalKey(Finite),
82694
+ departureEstimated: optionalKey(Finite),
82695
+ departureGate: optionalKey(String$6),
82696
+ departureTerminal: optionalKey(String$6),
82697
+ landingActual: optionalKey(Finite),
82698
+ previousGate: optionalKey(String$6),
82699
+ progress: optionalKey(Finite),
82700
+ providerId: optionalKey(String$6),
82517
82701
  state: Literals([
82518
82702
  "scheduled",
82519
82703
  "departed",
@@ -82523,7 +82707,7 @@ const FlightTracking = Struct({
82523
82707
  "cancelled",
82524
82708
  "diverted"
82525
82709
  ]),
82526
- takeoffActual: optional$2(Finite)
82710
+ takeoffActual: optionalKey(Finite)
82527
82711
  });
82528
82712
  const Flight = TaggedStruct("flight", {
82529
82713
  airline: String$6,
@@ -82549,13 +82733,13 @@ const TrainOperator = Literals([
82549
82733
  "other"
82550
82734
  ]);
82551
82735
  const TrainTracking = Struct({
82552
- arrivalPlatform: optional$2(String$6),
82736
+ arrivalPlatform: optionalKey(String$6),
82553
82737
  checkedAt: Finite,
82554
82738
  delayMinutes: Finite,
82555
- departureDelay: optional$2(Finite),
82556
- departurePlatform: optional$2(String$6),
82557
- departurePlatformPlanned: optional$2(String$6),
82558
- lastSeen: optional$2(Struct({
82739
+ departureDelay: optionalKey(Finite),
82740
+ departurePlatform: optionalKey(String$6),
82741
+ departurePlatformPlanned: optionalKey(String$6),
82742
+ lastSeen: optionalKey(Struct({
82559
82743
  at: Finite,
82560
82744
  station: String$6
82561
82745
  })),
@@ -92461,7 +92645,7 @@ const GENERIC = [
92461
92645
  "stazione"
92462
92646
  ];
92463
92647
  function words(text) {
92464
- return pipe(text, normalize$2("NFD"), replaceAll(/[̀-ͯ]/gu, ""), toLowerCase, split(/[^a-z0-9]+/u));
92648
+ return pipe(text, normalize$2("NFD"), replaceAll(/[̀-ͯ]/gu, ""), toLowerCase, split$1(/[^a-z0-9]+/u));
92465
92649
  }
92466
92650
  function namesIt(name, match) {
92467
92651
  const own = words(`${match.name} ${join$3(map$8(match.areas ?? [], (area) => area.name), " ")}`);
@@ -92517,7 +92701,7 @@ var Places = class Places extends Service$1()("@deslop/trips/services/bookings/l
92517
92701
  code: match.id,
92518
92702
  latitude: match.lat,
92519
92703
  longitude: match.lon,
92520
- name: pipe(toLowerCase(match.name), split(" "), map$8((word) => `${toUpperCase(slice$1(0, 1)(word))}${slice$1(1)(word)}`), join$3(" "))
92704
+ name: pipe(toLowerCase(match.name), split$1(" "), map$8((word) => `${toUpperCase(slice$1(0, 1)(word))}${slice$1(1)(word)}`), join$3(" "))
92521
92705
  })
92522
92706
  });
92523
92707
  yield* update$1(stations, set$4(key, place));
@@ -119775,7 +119959,7 @@ function holds(record, window, now) {
119775
119959
  return record.token !== void 0 || record.channel !== void 0 || now - record.claimedAt < 12e4;
119776
119960
  }
119777
119961
  function announced(sent, key) {
119778
- const category = headNonEmpty(split(":")(key));
119962
+ const category = headNonEmpty(split$1(":")(key));
119779
119963
  if (category === key || category === "delay") return contains(sent, key);
119780
119964
  return exists(findLast(sent, (found) => startsWith(`${category}:`)(found)), (found) => found === key);
119781
119965
  }
@@ -120195,23 +120379,27 @@ function flightState(answer) {
120195
120379
  function flightTracking(answer, checkedAt, previous) {
120196
120380
  const gate = text(answer.gate_origin);
120197
120381
  return {
120198
- aircraft: getOrUndefined$1(text(answer.aircraft_type)),
120199
- arrivalActual: getOrUndefined$1(instant(answer.actual_in)),
120200
- arrivalEstimated: getOrUndefined$1(instant(answer.estimated_in)),
120201
- arrivalGate: getOrUndefined$1(text(answer.gate_destination)),
120202
- arrivalTerminal: getOrUndefined$1(text(answer.terminal_destination)),
120203
- belt: getOrUndefined$1(text(answer.baggage_claim)),
120382
+ ...getSomes$1({
120383
+ aircraft: text(answer.aircraft_type),
120384
+ arrivalGate: text(answer.gate_destination),
120385
+ arrivalTerminal: text(answer.terminal_destination),
120386
+ belt: text(answer.baggage_claim),
120387
+ departureGate: gate,
120388
+ departureTerminal: text(answer.terminal_origin),
120389
+ previousGate: flatMap$8(gate, (current) => orElse$1(filter$7(fromUndefinedOr(previous?.departureGate), (before) => before !== current), () => filter$7(fromUndefinedOr(previous?.previousGate), () => previous?.departureGate === current))),
120390
+ providerId: fromNullishOr(answer.fa_flight_id)
120391
+ }),
120204
120392
  checkedAt,
120205
- departureActual: getOrUndefined$1(instant(answer.actual_out)),
120206
- departureEstimated: getOrUndefined$1(instant(answer.estimated_out)),
120207
- departureGate: getOrUndefined$1(gate),
120208
- departureTerminal: getOrUndefined$1(text(answer.terminal_origin)),
120209
- landingActual: getOrUndefined$1(instant(answer.actual_on)),
120210
- previousGate: getOrUndefined$1(flatMap$8(gate, (current) => orElse$1(filter$7(fromUndefinedOr(previous?.departureGate), (before) => before !== current), () => filter$7(fromUndefinedOr(previous?.previousGate), () => previous?.departureGate === current)))),
120211
- progress: getOrUndefined$1(fromNullishOr(answer.progress_percent)),
120212
- providerId: answer.fa_flight_id,
120213
- state: flightState(answer),
120214
- takeoffActual: getOrUndefined$1(instant(answer.actual_off))
120393
+ ...getSomes$1({
120394
+ arrivalActual: instant(answer.actual_in),
120395
+ arrivalEstimated: instant(answer.estimated_in),
120396
+ departureActual: instant(answer.actual_out),
120397
+ departureEstimated: instant(answer.estimated_out),
120398
+ landingActual: instant(answer.actual_on),
120399
+ progress: fromNullishOr(answer.progress_percent),
120400
+ takeoffActual: instant(answer.actual_off)
120401
+ }),
120402
+ state: flightState(answer)
120215
120403
  };
120216
120404
  }
120217
120405
  function normalized(name) {
@@ -120232,19 +120420,22 @@ function trainTracking(answer, train, checkedAt) {
120232
120420
  const from = stopFor(answer.fermate, train.from);
120233
120421
  const to = stopFor(answer.fermate, train.to);
120234
120422
  if (!exists(from, (stop) => exists(fromNullishOr(stop.programmata), (planned) => Math.abs(planned - train.departs) <= 108e5))) return none();
120235
- return some$1({
120236
- arrivalPlatform: getOrUndefined$1(flatMap$8(to, (stop) => orElse$1(text(stop.binarioEffettivoArrivoDescrizione), () => text(stop.binarioProgrammatoArrivoDescrizione)))),
120423
+ const tracking = {
120424
+ ...getSomes$1({
120425
+ arrivalPlatform: flatMap$8(to, (stop) => orElse$1(text(stop.binarioEffettivoArrivoDescrizione), () => text(stop.binarioProgrammatoArrivoDescrizione))),
120426
+ departurePlatform: flatMap$8(from, (stop) => orElse$1(text(stop.binarioEffettivoPartenzaDescrizione), () => text(stop.binarioProgrammatoPartenzaDescrizione))),
120427
+ departurePlatformPlanned: flatMap$8(from, (stop) => text(stop.binarioProgrammatoPartenzaDescrizione))
120428
+ }),
120237
120429
  checkedAt,
120238
120430
  delayMinutes: getOrElse(orElse$1(flatMap$8(filter$7(to, (stop) => stop.actualFermataType === 1), (stop) => fromNullishOr(stop.ritardo)), () => fromNullishOr(answer.ritardo)), () => 0),
120239
- departureDelay: getOrUndefined$1(flatMap$8(filter$7(from, left), (stop) => fromNullishOr(stop.ritardo))),
120240
- departurePlatform: getOrUndefined$1(flatMap$8(from, (stop) => orElse$1(text(stop.binarioEffettivoPartenzaDescrizione), () => text(stop.binarioProgrammatoPartenzaDescrizione)))),
120241
- departurePlatformPlanned: getOrUndefined$1(flatMap$8(from, (stop) => text(stop.binarioProgrammatoPartenzaDescrizione))),
120242
- lastSeen: getOrUndefined$1(filter$7(all$4({
120431
+ ...getSomes$1({ departureDelay: flatMap$8(filter$7(from, left), (stop) => fromNullishOr(stop.ritardo)) }),
120432
+ ...getSomes$1({ lastSeen: filter$7(all$4({
120243
120433
  at: fromNullishOr(answer.oraUltimoRilevamento),
120244
120434
  station: text(answer.stazioneUltimoRilevamento)
120245
- }), (seen) => seen.station !== "--")),
120435
+ }), (seen) => seen.station !== "--") }),
120246
120436
  state: trainState(from, to)
120247
- });
120437
+ };
120438
+ return some$1(tracking);
120248
120439
  }
120249
120440
  // src/services/tracking/schema.ts
120250
120441
  function Nullable(schema) {
@@ -120412,30 +120603,27 @@ var Tracker = class Tracker extends Service$1()("@deslop/trips/services/tracking
120412
120603
  return Tracker.of({ refresh });
120413
120604
  }));
120414
120605
  };
120415
- // src/rpcs/handlers.ts
120416
- const RpcHandlers = RpcContracts.toLayer(gen(function* () {
120417
- const bookings = yield* Bookings;
120418
- const push = yield* Push;
120419
- const tracker = yield* Tracker;
120420
- return RpcContracts.of({
120421
- "activities.claim": (input) => push.claim(input),
120422
- "activities.register": (input) => push.activity(input),
120423
- "bookings.refresh": (input) => tracker.refresh(input.id),
120424
- "bookings.remove": (input) => bookings.remove(input.id),
120425
- "bookings.restore": (input) => bookings.restore(input),
120426
- "bookings.save": (input) => bookings.save(input),
120427
- "bookings.watch": () => bookings.events,
120428
- "devices.register": (input) => push.register(input)
120429
- });
120430
- }));
120431
120606
  // src/main.server.ts
120432
120607
  runApp({
120433
120608
  icon: icon_default,
120434
- routes: pipe(layerHttp({
120609
+ routes: pipe(layerRpc({
120435
120610
  group: RpcContracts,
120436
- path: "/api/rpc",
120437
- protocol: "websocket"
120438
- }), provide$2(RpcHandlers), provide$2(layerJson$1), provide$2(mergeAll$2(Push.layer, Tracker.layer)), provide$2(Bookings.layer), provide$2(mergeAll$2(Places.layer, Extractor.layer)), provide$2(layerDataStore)),
120611
+ handlers: RpcContracts.toLayer(gen(function* () {
120612
+ const bookings = yield* Bookings;
120613
+ const push = yield* Push;
120614
+ const tracker = yield* Tracker;
120615
+ return RpcContracts.of({
120616
+ "activities.claim": (input) => push.claim(input),
120617
+ "activities.register": (input) => push.activity(input),
120618
+ "bookings.refresh": (input) => tracker.refresh(input.id),
120619
+ "bookings.remove": (input) => bookings.remove(input.id),
120620
+ "bookings.restore": (input) => bookings.restore(input),
120621
+ "bookings.save": (input) => bookings.save(input),
120622
+ "bookings.watch": () => bookings.events,
120623
+ "devices.register": (input) => push.register(input)
120624
+ });
120625
+ }))
120626
+ }), provide$2(layerJson$1), provide$2(mergeAll$2(Push.layer, Tracker.layer)), provide$2(Bookings.layer), provide$2(mergeAll$2(Places.layer, Extractor.layer)), provide$2(layerDataStore)),
120439
120627
  settings: {
120440
120628
  APNS_KEY_ID: {
120441
120629
  description: "The APNs signing key's id",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/trips",
3
- "version": "0.1.1239",
3
+ "version": "0.1.1243",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -30,5 +30,5 @@
30
30
  "engines": {
31
31
  "node": ">=26"
32
32
  },
33
- "fingerprint": "48b3df7debe1d4f0eca73f7cd6fc2e935097dda8843890c50461d42a5c8c3375"
33
+ "fingerprint": "f509d7be1d84c6ebc29b29868ba4b4d53a5cb6c7aa5e69d1363ce4254bf2e682"
34
34
  }