@deslop/opm 0.1.1241 → 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 +348 -66
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -3427,6 +3427,8 @@ const SuccessImpl = function(success) {
3427
3427
  SuccessImpl.prototype = SuccessProto;
3428
3428
  /** @internal */
3429
3429
  const succeed$10 = (success) => new SuccessImpl(success);
3430
+ /** @internal */
3431
+ const getSuccess$1 = (self) => isFailure$2(self) ? none$1 : some$3(self.success);
3430
3432
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Order.js
3431
3433
  /**
3432
3434
  * Defines comparison functions for ordered values.
@@ -5351,6 +5353,37 @@ const isFailure$1 = isFailure$2;
5351
5353
  */
5352
5354
  const isSuccess$1 = isSuccess$2;
5353
5355
  /**
5356
+ * Extracts the success value as an `Option`, discarding the failure.
5357
+ *
5358
+ * **When to use**
5359
+ *
5360
+ * Use when you need to extract the success value from a `Result` as an
5361
+ * `Option` and discard failure information.
5362
+ *
5363
+ * **Details**
5364
+ *
5365
+ * - `Success<A>` becomes `Some<A>`
5366
+ * - `Failure<E>` becomes `None`
5367
+ *
5368
+ * **Example** (Extracting the success as an Option)
5369
+ *
5370
+ * ```ts import.meta.vitest
5371
+ * import { Option, Result } from "effect"
5372
+ *
5373
+ * Result.getSuccess(Result.succeed("ok")) // => Option.some("ok")
5374
+ *
5375
+ * Result.getSuccess(Result.fail("err")) // => Option.none()
5376
+ * ```
5377
+ *
5378
+ * @see {@link getFailure} to extract the error instead
5379
+ * @see {@link fromOption} for the reverse conversion
5380
+ *
5381
+ * @stability stable
5382
+ * @category getters
5383
+ * @since 4.0.0
5384
+ */
5385
+ const getSuccess = getSuccess$1;
5386
+ /**
5354
5387
  * Transforms the success channel of a `Result`, leaving the failure channel unchanged.
5355
5388
  *
5356
5389
  * **When to use**
@@ -5994,7 +6027,7 @@ const makeEquivalence$2 = (equivalence) => {
5994
6027
  * @category constructors
5995
6028
  * @since 4.0.0
5996
6029
  */
5997
- const Array$1 = globalThis.Array;
6030
+ const Array$2 = globalThis.Array;
5998
6031
  /**
5999
6032
  * Converts an `Iterable` to an `Array`.
6000
6033
  *
@@ -6023,7 +6056,7 @@ const Array$1 = globalThis.Array;
6023
6056
  * @category constructors
6024
6057
  * @since 2.0.0
6025
6058
  */
6026
- const fromIterable$6 = (collection) => Array$1.isArray(collection) ? collection : Array$1.from(collection);
6059
+ const fromIterable$6 = (collection) => Array$2.isArray(collection) ? collection : Array$2.from(collection);
6027
6060
  /**
6028
6061
  * Normalizes a value that is either a single element or an array into an array.
6029
6062
  *
@@ -6054,7 +6087,7 @@ const fromIterable$6 = (collection) => Array$1.isArray(collection) ? collection
6054
6087
  * @category constructors
6055
6088
  * @since 3.3.0
6056
6089
  */
6057
- const ensure = (self) => Array$1.isArray(self) ? self : [self];
6090
+ const ensure = (self) => Array$2.isArray(self) ? self : [self];
6058
6091
  /**
6059
6092
  * Pattern-matches on an array, handling empty and non-empty cases separately.
6060
6093
  *
@@ -6167,7 +6200,7 @@ const append$3 = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
6167
6200
  * @category guards
6168
6201
  * @since 2.0.0
6169
6202
  */
6170
- const isArray = Array$1.isArray;
6203
+ const isArray = Array$2.isArray;
6171
6204
  /**
6172
6205
  * Checks whether a mutable `Array` is empty, narrowing the type to `[]`.
6173
6206
  *
@@ -6518,7 +6551,7 @@ const findLast = /*#__PURE__*/ dual(2, (self, f) => {
6518
6551
  * @category transforming
6519
6552
  * @since 2.0.0
6520
6553
  */
6521
- const reverse = (self) => Array$1.from(self).reverse();
6554
+ const reverse = (self) => Array$2.from(self).reverse();
6522
6555
  /**
6523
6556
  * Sorts an array by the given `Order`, returning a new array.
6524
6557
  *
@@ -6547,7 +6580,7 @@ const reverse = (self) => Array$1.from(self).reverse();
6547
6580
  * @since 2.0.0
6548
6581
  */
6549
6582
  const sort = /*#__PURE__*/ dual(2, (self, O) => {
6550
- const out = Array$1.from(self);
6583
+ const out = Array$2.from(self);
6551
6584
  out.sort(O);
6552
6585
  return out;
6553
6586
  });
@@ -6869,6 +6902,50 @@ const hashBucketsAdd = (buckets, value) => {
6869
6902
  bucket.push(value);
6870
6903
  return true;
6871
6904
  };
6905
+ const makeHashBuckets = (values) => {
6906
+ const buckets = /* @__PURE__ */ new Map();
6907
+ for (const value of values) hashBucketsAdd(buckets, value);
6908
+ return buckets;
6909
+ };
6910
+ const hashBucketsHas = (buckets, value) => {
6911
+ const bucket = buckets.get(hash(value));
6912
+ if (bucket === void 0) return false;
6913
+ for (const candidate of bucket) if (equals$1(candidate, value)) return true;
6914
+ return false;
6915
+ };
6916
+ /**
6917
+ * Computes elements in the first array that are not in the second, using
6918
+ * `Equal.asEquivalence()`.
6919
+ *
6920
+ * **When to use**
6921
+ *
6922
+ * Use when you need to keep values from the first array that are absent from
6923
+ * the second and the default `Equal.asEquivalence()` comparison is appropriate.
6924
+ *
6925
+ * **Example** (Computing array differences)
6926
+ *
6927
+ * ```ts import.meta.vitest
6928
+ * import { Array } from "effect"
6929
+ *
6930
+ * Array.difference([1, 2, 3], [2, 3, 4]) // => [1]
6931
+ * ```
6932
+ *
6933
+ * @see {@link differenceWith} — use custom equality
6934
+ * @see {@link union} — elements in either array
6935
+ * @see {@link intersection} — elements in both arrays
6936
+ *
6937
+ * @stability stable
6938
+ * @category set operations
6939
+ * @since 2.0.0
6940
+ */
6941
+ const difference = /*#__PURE__*/ dual(2, (self, that) => {
6942
+ const thatArray = fromIterable$6(that);
6943
+ const selfArray = fromIterable$6(self);
6944
+ if (selfArray.length === 0) return [];
6945
+ if (thatArray.length === 0) return selfArray.filter(() => true);
6946
+ const buckets = makeHashBuckets(thatArray);
6947
+ return selfArray.filter((value) => !hashBucketsHas(buckets, value));
6948
+ });
6872
6949
  /**
6873
6950
  * Creates an empty array.
6874
6951
  *
@@ -14930,7 +15007,7 @@ const isNonEmpty$1 = (self) => self.length > 0;
14930
15007
  * @category transforming
14931
15008
  * @since 2.0.0
14932
15009
  */
14933
- const split = /*#__PURE__*/ dual(2, (self, separator) => {
15010
+ const split$1 = /*#__PURE__*/ dual(2, (self, separator) => {
14934
15011
  const out = self.split(separator);
14935
15012
  return isArrayNonEmpty$1(out) ? out : [self];
14936
15013
  });
@@ -25425,7 +25502,7 @@ const encode = (input) => encodeBytes(typeof input === "string" ? encoder$4.enco
25425
25502
  * @category decoding
25426
25503
  * @since 4.0.0
25427
25504
  */
25428
- const decode = (str) => {
25505
+ const decode$1 = (str) => {
25429
25506
  const stripped = stripCrlf(str);
25430
25507
  const length = stripped.length;
25431
25508
  if (length % 4 !== 0) return fail$11(new EncodingError({
@@ -25471,20 +25548,20 @@ const encodeShort = (bytes) => {
25471
25548
  let result = "";
25472
25549
  let i = 2;
25473
25550
  for (; i < length; i += 3) {
25474
- result += alphabet[bytes[i - 2] >> 2];
25475
- result += alphabet[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
25476
- result += alphabet[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
25477
- result += alphabet[bytes[i] & 63];
25551
+ result += alphabet$1[bytes[i - 2] >> 2];
25552
+ result += alphabet$1[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
25553
+ result += alphabet$1[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
25554
+ result += alphabet$1[bytes[i] & 63];
25478
25555
  }
25479
25556
  if (i === length + 1) {
25480
- result += alphabet[bytes[i - 2] >> 2];
25481
- result += alphabet[(bytes[i - 2] & 3) << 4];
25557
+ result += alphabet$1[bytes[i - 2] >> 2];
25558
+ result += alphabet$1[(bytes[i - 2] & 3) << 4];
25482
25559
  result += "==";
25483
25560
  }
25484
25561
  if (i === length) {
25485
- result += alphabet[bytes[i - 2] >> 2];
25486
- result += alphabet[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
25487
- result += alphabet[(bytes[i - 1] & 15) << 2];
25562
+ result += alphabet$1[bytes[i - 2] >> 2];
25563
+ result += alphabet$1[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
25564
+ result += alphabet$1[(bytes[i - 1] & 15) << 2];
25488
25565
  result += "=";
25489
25566
  }
25490
25567
  return result;
@@ -25512,21 +25589,123 @@ const encodeLong = (bytes) => {
25512
25589
  result[j + 2] = alphabetCodes[(bytes[i - 1] & 15) << 2];
25513
25590
  result[j + 3] = paddingCode;
25514
25591
  }
25515
- return decoder.decode(result);
25592
+ return decoder$1.decode(result);
25516
25593
  };
25517
25594
  const encoder$4 = /*#__PURE__*/ new TextEncoder();
25518
- const decoder = /*#__PURE__*/ new TextDecoder();
25595
+ const decoder$1 = /*#__PURE__*/ new TextDecoder();
25519
25596
  const stripCrlf = (str) => str.replace(/[\n\r]/g, "");
25520
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
25521
- const alphabetCodes = /*#__PURE__*/ encoder$4.encode(alphabet);
25597
+ const alphabet$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
25598
+ const alphabetCodes = /*#__PURE__*/ encoder$4.encode(alphabet$1);
25522
25599
  const paddingCode = /*#__PURE__*/ "=".charCodeAt(0);
25523
- const codes = /*#__PURE__*/ (/* @__PURE__ */ new Uint8Array(123)).fill(255);
25524
- for (let i = 0; i < 64; i++) codes[/*#__PURE__*/ alphabet.charCodeAt(i)] = i;
25525
- codes[/*#__PURE__*/ "=".charCodeAt(0)] = 0;
25600
+ const codes$1 = /*#__PURE__*/ (/* @__PURE__ */ new Uint8Array(123)).fill(255);
25601
+ for (let i = 0; i < 64; i++) codes$1[/*#__PURE__*/ alphabet$1.charCodeAt(i)] = i;
25602
+ codes$1[/*#__PURE__*/ "=".charCodeAt(0)] = 0;
25526
25603
  const getCode = (charCode) => {
25527
- if (charCode >= codes.length || codes[charCode] === 255) throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`);
25528
- return codes[charCode];
25604
+ if (charCode >= codes$1.length || codes$1[charCode] === 255) throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`);
25605
+ return codes$1[charCode];
25529
25606
  };
25607
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/encoding/Base64Url.js
25608
+ /**
25609
+ * URL-safe Base64 encoding and decoding helpers.
25610
+ *
25611
+ * @stability stable
25612
+ * @since 4.0.0
25613
+ */
25614
+ /**
25615
+ * Decodes a padded or unpadded URL-safe Base64 string into bytes safely.
25616
+ *
25617
+ * **When to use**
25618
+ *
25619
+ * Use to decode Base64Url text into bytes without throwing on invalid input.
25620
+ *
25621
+ * **Details**
25622
+ *
25623
+ * Returns `Result.succeed` with a `Uint8Array` when decoding succeeds, or
25624
+ * `Result.fail` with an `EncodingError` when the input is not valid
25625
+ * Base64Url. Both padded and unpadded forms are accepted when otherwise valid.
25626
+ *
25627
+ * **Example** (Decoding URL-safe Base64 bytes)
25628
+ *
25629
+ * ```ts import.meta.vitest
25630
+ * import { Result } from "effect"
25631
+ * import { Base64Url } from "effect/encoding"
25632
+ *
25633
+ * Base64Url.decode("SGVsbG8_") // => Result.succeed(new Uint8Array([72, 101, 108, 108, 111, 63]))
25634
+ * ```
25635
+ *
25636
+ * @stability stable
25637
+ * @category decoding
25638
+ * @since 4.0.0
25639
+ */
25640
+ const decode = (str) => {
25641
+ const stripped = str.replace(/[\n\r]/g, "");
25642
+ const length = stripped.length;
25643
+ const padded = stripped.endsWith("=");
25644
+ if (padded ? length % 4 !== 0 : length % 4 === 1) return fail$11(new EncodingError({
25645
+ module: "Base64Url",
25646
+ kind: "Decode",
25647
+ input: stripped,
25648
+ message: padded ? `Padded length should be a multiple of 4, but is ${length}` : `Unpadded length should not be 1 more than a multiple of 4, but is ${length}`
25649
+ }));
25650
+ if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) return fail$11(new EncodingError({
25651
+ module: "Base64Url",
25652
+ kind: "Decode",
25653
+ input: stripped,
25654
+ message: "Invalid input"
25655
+ }));
25656
+ const end = !padded ? length : stripped.charCodeAt(length - 2) === 61 ? length - 2 : length - 1;
25657
+ const fullEnd = end & -4;
25658
+ const result = new Uint8Array(Math.floor(end * 3 / 4));
25659
+ let j = 0;
25660
+ for (let i = 0; i < fullEnd; i += 4) {
25661
+ const a = codes[stripped.charCodeAt(i)];
25662
+ const b = codes[stripped.charCodeAt(i + 1)];
25663
+ const c = codes[stripped.charCodeAt(i + 2)];
25664
+ const d = codes[stripped.charCodeAt(i + 3)];
25665
+ result[j++] = a << 2 | b >> 4;
25666
+ result[j++] = b << 4 | c >> 2;
25667
+ result[j++] = c << 6 | d;
25668
+ }
25669
+ if (end > fullEnd) {
25670
+ const a = codes[stripped.charCodeAt(fullEnd)];
25671
+ const b = codes[stripped.charCodeAt(fullEnd + 1)];
25672
+ result[j++] = a << 2 | b >> 4;
25673
+ if (end - fullEnd === 3) result[j] = b << 4 | codes[stripped.charCodeAt(fullEnd + 2)] >> 2;
25674
+ }
25675
+ return succeed$9(result);
25676
+ };
25677
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
25678
+ const codes = /*#__PURE__*/ new Uint8Array(128);
25679
+ for (let i = 0; i < 64; i++) codes[/*#__PURE__*/ alphabet.charCodeAt(i)] = i;
25680
+ /**
25681
+ * Decodes a padded or unpadded URL-safe Base64 string into UTF-8 text safely.
25682
+ *
25683
+ * **When to use**
25684
+ *
25685
+ * Use to decode Base64Url text into UTF-8 text without throwing on invalid
25686
+ * input.
25687
+ *
25688
+ * **Details**
25689
+ *
25690
+ * Returns `Result.succeed` with the decoded text when decoding succeeds, or
25691
+ * `Result.fail` with an `EncodingError` when the input is not valid
25692
+ * Base64Url.
25693
+ *
25694
+ * **Example** (Decoding URL-safe Base64 strings)
25695
+ *
25696
+ * ```ts import.meta.vitest
25697
+ * import { Result } from "effect"
25698
+ * import { Base64Url } from "effect/encoding"
25699
+ *
25700
+ * Base64Url.decodeString("aGVsbG8_") // => Result.succeed("hello?")
25701
+ * ```
25702
+ *
25703
+ * @stability stable
25704
+ * @category decoding
25705
+ * @since 4.0.0
25706
+ */
25707
+ const decodeString$1 = (str) => map$11(decode(str), (_) => decoder.decode(_));
25708
+ const decoder = /*#__PURE__*/ new TextDecoder();
25530
25709
  /**
25531
25710
  * SHA-1, with a 20-byte output.
25532
25711
  *
@@ -29373,6 +29552,39 @@ function joinKeyValue(options) {
29373
29552
  return transform$2((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
29374
29553
  }
29375
29554
  /**
29555
+ * Splits a string into an array of strings by a separator.
29556
+ *
29557
+ * **When to use**
29558
+ *
29559
+ * Use when you need a schema getter to split a present encoded string
29560
+ * containing a delimited list, such as CSV values.
29561
+ *
29562
+ * **Details**
29563
+ *
29564
+ * The getter is pure and never fails. It splits by `separator` (default `,`).
29565
+ * An empty string produces an empty array, not `[""]`.
29566
+ *
29567
+ * **Example** (Splitting a comma-separated string)
29568
+ *
29569
+ * ```ts import.meta.vitest
29570
+ * import { Effect, Option, SchemaGetter } from "effect"
29571
+ *
29572
+ * const splitComma = SchemaGetter.split<string>()
29573
+ * const result = Effect.runSync(SchemaGetter.run(splitComma, Option.some("a,b,c"), {}))
29574
+ * result // => Option.some(["a", "b", "c"])
29575
+ * ```
29576
+ *
29577
+ * @see {@link splitKeyValue} when values are key-value pairs
29578
+ *
29579
+ * @stability stable
29580
+ * @category splitting
29581
+ * @since 4.0.0
29582
+ */
29583
+ function split(options) {
29584
+ const separator = options?.separator ?? ",";
29585
+ return transform$2((input) => input === "" ? [] : input.split(separator));
29586
+ }
29587
+ /**
29376
29588
  * Encodes a `Uint8Array` or string to a Base64 string.
29377
29589
  *
29378
29590
  * **Details**
@@ -29425,7 +29637,7 @@ function encodeBase64() {
29425
29637
  * @since 4.0.0
29426
29638
  */
29427
29639
  function decodeBase64$1() {
29428
- return transformEffect$1((input, options) => mapErrorEager(fromResult(decode(input)), () => new InvalidValue$1({ expected: "a valid Base64 string" }, input, options)));
29640
+ return transformEffect$1((input, options) => mapErrorEager(fromResult(decode$1(input)), () => new InvalidValue$1({ expected: "a valid Base64 string" }, input, options)));
29429
29641
  }
29430
29642
  /**
29431
29643
  * Encodes a present string using `encodeURIComponent`.
@@ -42077,6 +42289,16 @@ function succeed$1(value) {
42077
42289
  function String$5(name) {
42078
42290
  return schema$1(String$6, name);
42079
42291
  }
42292
+ function Array$1(value, pathOrOptions, options) {
42293
+ const hasPath = isPath(pathOrOptions);
42294
+ const resolvedOptions = hasPath ? options : pathOrOptions;
42295
+ const array = ArraySchema(value);
42296
+ const separator = resolvedOptions?.separator ?? ",";
42297
+ return schema$1(Union([String$6.pipe(decodeTo(toCodecStringTree(array), {
42298
+ decode: split(resolvedOptions),
42299
+ encode: compose(passthrough$1({ strict: false }), transform$2((input) => input.join(separator)))
42300
+ })), array]), hasPath ? pathOrOptions : void 0);
42301
+ }
42080
42302
  function Record(key, value, pathOrOptions, options) {
42081
42303
  const hasPath = isPath(pathOrOptions);
42082
42304
  const record = Record$1(key, value);
@@ -44575,6 +44797,17 @@ const updateContentLength = (headers, body) => {
44575
44797
  };
44576
44798
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/Url.js
44577
44799
  /**
44800
+ * Parses and edits platform `URL` values.
44801
+ *
44802
+ * The HTTP modules use the standard `URL` object as their URL representation.
44803
+ * This module adds safe parsing and helpers that return updated copies when
44804
+ * changing credentials, host, path, protocol, query, or hash parts. Query
44805
+ * strings can also be read or updated through `UrlParams`.
44806
+ *
44807
+ * @stability unstable
44808
+ * @since 4.0.0
44809
+ */
44810
+ /**
44578
44811
  * Error returned when constructing a `URL` fails.
44579
44812
  *
44580
44813
  * @stability unstable
@@ -44615,6 +44848,51 @@ const baseUrl = () => {
44615
44848
  }
44616
44849
  }
44617
44850
  };
44851
+ /**
44852
+ * Parses a URL string safely into a `URL` object, returning a `Result` type for
44853
+ * error handling.
44854
+ *
44855
+ * **Details**
44856
+ *
44857
+ * This function converts a string into a `URL` object, enabling safe URL
44858
+ * parsing with built-in error handling. If the string is invalid or fails to
44859
+ * parse, this function does not throw an error; instead, it wraps the error in
44860
+ * a `IllegalArgumentError` and returns it as the `Failure` value of an
44861
+ * `Result`. The `Success` value contains the successfully parsed `URL`.
44862
+ *
44863
+ * An optional `base` parameter can be provided to resolve relative URLs. If
44864
+ * specified, the function interprets the input `url` as relative to this
44865
+ * `base`. This is especially useful when dealing with URLs that might not be
44866
+ * fully qualified.
44867
+ *
44868
+ * **Example** (Parsing absolute and relative URLs)
44869
+ *
44870
+ * ```ts import.meta.vitest
44871
+ * import { Result } from "effect"
44872
+ * import { Url } from "effect/http"
44873
+ *
44874
+ * // Parse an absolute URL
44875
+ * //
44876
+ * // ┌─── Result<URL, IllegalArgumentError>
44877
+ * // ▼
44878
+ * const parsed = Url.fromString("https://example.com/path")
44879
+ *
44880
+ * Result.map(parsed, (url) => url.toString()) // => Result.succeed("https://example.com/path")
44881
+ *
44882
+ * // Parse a relative URL with a base
44883
+ * const relativeParsed = Url.fromString("/relative-path", "https://example.com")
44884
+ *
44885
+ * Result.map(relativeParsed, (url) => url.toString()) // => Result.succeed("https://example.com/relative-path")
44886
+ * ```
44887
+ *
44888
+ * @stability unstable
44889
+ * @category constructors
44890
+ * @since 4.0.0
44891
+ */
44892
+ const fromString = (url, base) => try_$2({
44893
+ try: () => new URL(url, base),
44894
+ catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
44895
+ });
44618
44896
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/HttpClientRequest.js
44619
44897
  const TypeId$15 = "~effect/http/HttpClientRequest";
44620
44898
  /**
@@ -70922,32 +71200,23 @@ Struct({
70922
71200
  expires_in: Finite,
70923
71201
  refresh_token: NonEmptyString
70924
71202
  });
70925
- const Origin = String$6.check(makeFilter((value) => {
70926
- if (!URL.canParse(value)) return false;
70927
- const url = new URL(value);
70928
- return contains$1(["http:", "https:"], url.protocol) && url.username === "" && url.password === "" && url.hash === "";
70929
- }, { expected: "an HTTP(S) URL without credentials or a fragment" })).check(makeFilter((value) => {
70930
- if (!URL.canParse(value)) return false;
70931
- const url = new URL(value);
70932
- return url.pathname === "/" && url.search === "";
70933
- }, { expected: "an HTTP(S) origin without a path or query" }));
70934
- const SecureOrigin = Origin.check(makeFilter((value) => {
70935
- if (!URL.canParse(value)) return false;
70936
- const url = new URL(value);
70937
- return url.protocol === "https:" || contains$1([
70938
- "localhost",
70939
- "127.0.0.1",
70940
- "[::1]"
70941
- ], url.hostname);
70942
- }, { expected: "HTTPS outside loopback" }));
71203
+ const Origin = String$6.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => contains$1(["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" }));
71204
+ const SecureOrigin = Origin.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => url.protocol === "https:" || contains$1([
71205
+ "localhost",
71206
+ "127.0.0.1",
71207
+ "[::1]"
71208
+ ], url.hostname)), { expected: "HTTPS outside loopback" }));
70943
71209
  const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exists(parse$9(value), (port) => port >= 1 && port <= 65535), { expected: "a port between 1 and 65535" }));
70944
71210
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
71211
+ const RUNTIME_PATH = "/api/runtime";
70945
71212
  const RuntimeConfig = Struct({
70946
71213
  auth: optionalKey(String$6),
70947
71214
  name: String$6,
70948
71215
  traces: String$6,
70949
71216
  version: AppVersion
70950
71217
  });
71218
+ const RPC_PATH = "/api/rpc";
71219
+ const MANIFEST_PATH = "/manifest.webmanifest";
70951
71220
  const Account = Struct({
70952
71221
  ...User.fields,
70953
71222
  signOut: Boolean$5
@@ -71664,11 +71933,19 @@ function layerOtlp(serviceName, url, runtime, version) {
71664
71933
  }));
71665
71934
  }
71666
71935
  // ../../packages/runtime/src/auth/lib/utils.ts
71936
+ const APPS_PATH = "/api/apps";
71937
+ const SESSION_PATH = "/auth/session";
71938
+ const VERIFY_PATH = "/auth/verify";
71667
71939
  const DEVELOPER = {
71668
71940
  id: "github:0",
71669
71941
  name: "dev"
71670
71942
  };
71671
71943
  const localAuth = map$3(option(String$5("AUTH_URL")), isNone);
71944
+ gen(function* () {
71945
+ const listed = Array$1(String$6, "GITHUB_ADMINS");
71946
+ if (yield* localAuth) return yield* withDefault$2(listed, ["0"]);
71947
+ return yield* listed;
71948
+ });
71672
71949
  var CurrentUser = class extends Service$1()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
71673
71950
  var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
71674
71951
  static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
@@ -71711,7 +71988,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
71711
71988
  const canonical = new URL(yield* String$5("APP_URL")).origin;
71712
71989
  const client = filterStatusOk(yield* HttpClient);
71713
71990
  const access = fn("Auth.access")(function* (headers, audience) {
71714
- return yield* pipe(client.get(new URL("/auth/verify", issuer).href, {
71991
+ return yield* pipe(client.get(new URL(VERIFY_PATH, issuer).href, {
71715
71992
  headers: { authorization: headers["authorization"] ?? "" },
71716
71993
  urlParams: { resource: audience }
71717
71994
  }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
@@ -71720,7 +71997,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
71720
71997
  access,
71721
71998
  user: fn("Auth.user")(function* (headers) {
71722
71999
  if (isSome(get$6(headers, "authorization"))) return yield* access(headers, canonical);
71723
- return yield* pipe(client.get(new URL("/auth/session", issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
72000
+ return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
71724
72001
  }, rejected("Sign in first"))
71725
72002
  }));
71726
72003
  }));
@@ -71792,7 +72069,7 @@ const guard = make$17((app) => gen(function* () {
71792
72069
  const canonical = new URL(yield* String$5("APP_URL")).hostname;
71793
72070
  if (!exists(liftThrowable(() => new URL(`http://${host}`))(), (url) => url.hostname === canonical || isSome(match$3(LOOPBACK)(url.hostname)))) return empty$1({ status: 403 });
71794
72071
  }
71795
- if (exists(origin, (value) => !exists(liftThrowable(() => new URL(value).host)(), (originHost) => originHost === host)) && request.headers["sec-fetch-site"] !== "same-origin" && !contains$1(OTLP, headNonEmpty(split(request.url, "?")))) return empty$1({ status: 403 });
72072
+ if (exists(origin, (value) => !exists(liftThrowable(() => new URL(value).host)(), (originHost) => originHost === host)) && request.headers["sec-fetch-site"] !== "same-origin" && !contains$1(OTLP, headNonEmpty(split$1(request.url, "?")))) return empty$1({ status: 403 });
71796
72073
  return yield* app;
71797
72074
  }));
71798
72075
  function layerKeyValueStore(directory) {
@@ -71855,7 +72132,7 @@ const layerRoutes = use((router) => gen(function* () {
71855
72132
  })
71856
72133
  });
71857
72134
  });
71858
- yield* router.add("GET", "/api/runtime", gen(function* () {
72135
+ yield* router.add("GET", RUNTIME_PATH, gen(function* () {
71859
72136
  return yield* schemaJson(RuntimeConfig)({
71860
72137
  ...match$8(issuer, {
71861
72138
  onNone: () => ({}),
@@ -71883,7 +72160,7 @@ const layerAnnounce = effectDiscard(gen(function* () {
71883
72160
  yield* match$8(yield* option(String$5("AUTH_URL")), {
71884
72161
  onNone: () => void_$1,
71885
72162
  onSome: fnUntraced(function* (issuer) {
71886
- yield* pipe(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
72163
+ yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
71887
72164
  schedule: spaced("1 minute"),
71888
72165
  times: 60
71889
72166
  }), ignore$1({
@@ -71904,7 +72181,7 @@ const layerWeb = unwrap$8(gen(function* () {
71904
72181
  const client = fileURLToPath(new URL("./client", import.meta.url));
71905
72182
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$10;
71906
72183
  const name = capitalize(yield* appName);
71907
- return mergeAll$1(add$1("GET", "/manifest.webmanifest", succeed$5(jsonUnsafe({
72184
+ return mergeAll$1(add$1("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
71908
72185
  background_color: "#0a0a0a",
71909
72186
  display: "standalone",
71910
72187
  icons: [{
@@ -71933,6 +72210,14 @@ const layerWeb = unwrap$8(gen(function* () {
71933
72210
  spa: true
71934
72211
  }));
71935
72212
  }));
72213
+ function layerRpc(options) {
72214
+ return pipe(layerHttp({
72215
+ disableTracing: options.disableTracing,
72216
+ group: options.group,
72217
+ path: RPC_PATH,
72218
+ protocol: "websocket"
72219
+ }), provide$2(options.handlers));
72220
+ }
71936
72221
  const layerNodeHttpServer = layerConfig(createServer, {
71937
72222
  gracefulShutdownTimeout: succeed$1("1500 millis"),
71938
72223
  host: String$5("HOST"),
@@ -72055,7 +72340,7 @@ const update$1 = fnUntraced(function* (name) {
72055
72340
  yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
72056
72341
  yield* restart(name);
72057
72342
  const kept = [latest, ...toArray$1(map$12(previous, (link) => path.basename(path.resolve(link, "../../.."))))];
72058
- yield* forEach$1(filter$4(yield* fs.readDirectory(path.join(root, "releases")), (entry) => !contains$1(kept, entry)), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
72343
+ yield* forEach$1(difference(yield* fs.readDirectory(path.join(root, "releases")), kept), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
72059
72344
  return `Updated ${name} from ${running} to ${latest}\n`;
72060
72345
  });
72061
72346
  // ../../packages/runtime/src/cli.ts
@@ -118743,7 +119028,7 @@ function seriesOf(link) {
118743
119028
  function unwrapped(link) {
118744
119029
  return match$8(fromNullishOr(WRAPPED.exec(link)?.groups?.["encoded"]), {
118745
119030
  onNone: () => some$2(link),
118746
- onSome: (encoded) => pipe(liftThrowable(atob)(replaceAll("_", "/")(replaceAll("-", "+")(encoded))), filter$5(startsWith("https://")))
119031
+ onSome: (encoded) => pipe(getSuccess(decodeString$1(encoded)), filter$5(startsWith("https://")))
118747
119032
  });
118748
119033
  }
118749
119034
  function pageLink(page) {
@@ -119025,22 +119310,19 @@ var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters
119025
119310
  }));
119026
119311
  };
119027
119312
  const layerChapters = unwrap$8(pipe(dataDirectory, failed("The chapters folder could not be read."), map$6(Chapters.layer)));
119028
- // src/rpcs/handlers.ts
119029
- const RpcHandlers = RpcContracts.toLayer(gen(function* () {
119030
- const chapters = yield* Chapters;
119031
- return RpcContracts.of({
119032
- "chapters.read": (input) => chapters.read(input),
119033
- "devices.register": (input) => chapters.register(input.token),
119034
- "library.watch": () => chapters.changes
119035
- });
119036
- }));
119037
119313
  // src/main.server.ts
119038
119314
  runApp({
119039
119315
  icon: icon_default,
119040
- routes: pipe(layerHttp({
119316
+ routes: pipe(layerRpc({
119041
119317
  group: RpcContracts,
119042
- path: "/api/rpc",
119043
- protocol: "websocket"
119044
- }), provide$2(RpcHandlers), provide$2(layerJson$1), provide$2(layerChapters))
119318
+ handlers: RpcContracts.toLayer(gen(function* () {
119319
+ const chapters = yield* Chapters;
119320
+ return RpcContracts.of({
119321
+ "chapters.read": (input) => chapters.read(input),
119322
+ "devices.register": (input) => chapters.register(input.token),
119323
+ "library.watch": () => chapters.changes
119324
+ });
119325
+ }))
119326
+ }), provide$2(layerJson$1), provide$2(layerChapters))
119045
119327
  });
119046
119328
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/opm",
3
- "version": "0.1.1241",
3
+ "version": "0.1.1243",
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": "f4300b4832ff540cc4bbd1345db8a58e816533a9d837e5f0eea408b08968b3b2"
34
+ "fingerprint": "b1d8f9413ddc6ed22339d49b52604e6a217b46691bb3faf979f4d3b8faafd457"
35
35
  }