@evolu/common 8.8.0 → 8.10.0

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 (242) hide show
  1. package/dist/src/Assert.d.ts +21 -1
  2. package/dist/src/Assert.d.ts.map +1 -1
  3. package/dist/src/Assert.js +31 -27
  4. package/dist/src/Bytes.d.ts +647 -0
  5. package/dist/src/Bytes.d.ts.map +1 -0
  6. package/dist/src/{Binary.js → Bytes.js} +266 -16
  7. package/dist/src/Config.d.ts +142 -0
  8. package/dist/src/Config.d.ts.map +1 -0
  9. package/dist/src/Config.js +181 -0
  10. package/dist/src/Fs.d.ts +302 -0
  11. package/dist/src/Fs.d.ts.map +1 -0
  12. package/dist/src/Fs.js +111 -0
  13. package/dist/src/Number.d.ts +50 -7
  14. package/dist/src/Number.d.ts.map +1 -1
  15. package/dist/src/Number.js +47 -8
  16. package/dist/src/Object.d.ts +32 -0
  17. package/dist/src/Object.d.ts.map +1 -1
  18. package/dist/src/Object.js +41 -0
  19. package/dist/src/Polyfills.d.ts +6 -0
  20. package/dist/src/Polyfills.d.ts.map +1 -1
  21. package/dist/src/Polyfills.js +6 -0
  22. package/dist/src/Sqlite.js +1 -1
  23. package/dist/src/Time.d.ts +74 -12
  24. package/dist/src/Time.d.ts.map +1 -1
  25. package/dist/src/Time.js +40 -2
  26. package/dist/src/Type.d.ts +1451 -79
  27. package/dist/src/Type.d.ts.map +1 -1
  28. package/dist/src/Type.js +1303 -96
  29. package/dist/src/index.d.ts +3 -1
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +3 -1
  32. package/dist/src/intl/_en.d.ts +24 -1
  33. package/dist/src/intl/_en.d.ts.map +1 -1
  34. package/dist/src/intl/_en.js +20 -0
  35. package/dist/src/intl/ar.d.ts +24 -1
  36. package/dist/src/intl/ar.d.ts.map +1 -1
  37. package/dist/src/intl/ar.js +20 -0
  38. package/dist/src/intl/bn.d.ts +24 -1
  39. package/dist/src/intl/bn.d.ts.map +1 -1
  40. package/dist/src/intl/bn.js +20 -0
  41. package/dist/src/intl/ca.d.ts +24 -1
  42. package/dist/src/intl/ca.d.ts.map +1 -1
  43. package/dist/src/intl/ca.js +20 -0
  44. package/dist/src/intl/cs.d.ts +24 -1
  45. package/dist/src/intl/cs.d.ts.map +1 -1
  46. package/dist/src/intl/cs.js +20 -0
  47. package/dist/src/intl/da.d.ts +24 -1
  48. package/dist/src/intl/da.d.ts.map +1 -1
  49. package/dist/src/intl/da.js +20 -0
  50. package/dist/src/intl/de.d.ts +24 -1
  51. package/dist/src/intl/de.d.ts.map +1 -1
  52. package/dist/src/intl/de.js +20 -0
  53. package/dist/src/intl/el.d.ts +24 -1
  54. package/dist/src/intl/el.d.ts.map +1 -1
  55. package/dist/src/intl/el.js +20 -0
  56. package/dist/src/intl/es.d.ts +24 -1
  57. package/dist/src/intl/es.d.ts.map +1 -1
  58. package/dist/src/intl/es.js +20 -0
  59. package/dist/src/intl/fa.d.ts +24 -1
  60. package/dist/src/intl/fa.d.ts.map +1 -1
  61. package/dist/src/intl/fa.js +20 -0
  62. package/dist/src/intl/fi.d.ts +24 -1
  63. package/dist/src/intl/fi.d.ts.map +1 -1
  64. package/dist/src/intl/fi.js +20 -0
  65. package/dist/src/intl/fil.d.ts +24 -1
  66. package/dist/src/intl/fil.d.ts.map +1 -1
  67. package/dist/src/intl/fil.js +20 -0
  68. package/dist/src/intl/fr.d.ts +24 -1
  69. package/dist/src/intl/fr.d.ts.map +1 -1
  70. package/dist/src/intl/fr.js +20 -0
  71. package/dist/src/intl/he.d.ts +24 -1
  72. package/dist/src/intl/he.d.ts.map +1 -1
  73. package/dist/src/intl/he.js +20 -0
  74. package/dist/src/intl/hi.d.ts +24 -1
  75. package/dist/src/intl/hi.d.ts.map +1 -1
  76. package/dist/src/intl/hi.js +20 -0
  77. package/dist/src/intl/hr.d.ts +24 -1
  78. package/dist/src/intl/hr.d.ts.map +1 -1
  79. package/dist/src/intl/hr.js +20 -0
  80. package/dist/src/intl/hu.d.ts +22 -1
  81. package/dist/src/intl/hu.d.ts.map +1 -1
  82. package/dist/src/intl/hu.js +18 -0
  83. package/dist/src/intl/id.d.ts +24 -1
  84. package/dist/src/intl/id.d.ts.map +1 -1
  85. package/dist/src/intl/id.js +20 -0
  86. package/dist/src/intl/it.d.ts +24 -1
  87. package/dist/src/intl/it.d.ts.map +1 -1
  88. package/dist/src/intl/it.js +20 -0
  89. package/dist/src/intl/ja.d.ts +24 -1
  90. package/dist/src/intl/ja.d.ts.map +1 -1
  91. package/dist/src/intl/ja.js +20 -0
  92. package/dist/src/intl/ko.d.ts +24 -1
  93. package/dist/src/intl/ko.d.ts.map +1 -1
  94. package/dist/src/intl/ko.js +20 -0
  95. package/dist/src/intl/ml.d.ts +24 -1
  96. package/dist/src/intl/ml.d.ts.map +1 -1
  97. package/dist/src/intl/ml.js +20 -0
  98. package/dist/src/intl/mr.d.ts +24 -1
  99. package/dist/src/intl/mr.d.ts.map +1 -1
  100. package/dist/src/intl/mr.js +20 -0
  101. package/dist/src/intl/ms.d.ts +24 -1
  102. package/dist/src/intl/ms.d.ts.map +1 -1
  103. package/dist/src/intl/ms.js +20 -0
  104. package/dist/src/intl/nb.d.ts +22 -1
  105. package/dist/src/intl/nb.d.ts.map +1 -1
  106. package/dist/src/intl/nb.js +18 -0
  107. package/dist/src/intl/nl.d.ts +24 -1
  108. package/dist/src/intl/nl.d.ts.map +1 -1
  109. package/dist/src/intl/nl.js +20 -0
  110. package/dist/src/intl/pa.d.ts +24 -1
  111. package/dist/src/intl/pa.d.ts.map +1 -1
  112. package/dist/src/intl/pa.js +20 -0
  113. package/dist/src/intl/pl.d.ts +23 -0
  114. package/dist/src/intl/pl.d.ts.map +1 -1
  115. package/dist/src/intl/pl.js +20 -0
  116. package/dist/src/intl/pt-BR.d.ts +24 -1
  117. package/dist/src/intl/pt-BR.d.ts.map +1 -1
  118. package/dist/src/intl/pt-BR.js +20 -0
  119. package/dist/src/intl/pt.d.ts +24 -1
  120. package/dist/src/intl/pt.d.ts.map +1 -1
  121. package/dist/src/intl/pt.js +20 -0
  122. package/dist/src/intl/ro.d.ts +24 -1
  123. package/dist/src/intl/ro.d.ts.map +1 -1
  124. package/dist/src/intl/ro.js +20 -0
  125. package/dist/src/intl/sk.d.ts +24 -1
  126. package/dist/src/intl/sk.d.ts.map +1 -1
  127. package/dist/src/intl/sk.js +20 -0
  128. package/dist/src/intl/sl.d.ts +24 -1
  129. package/dist/src/intl/sl.d.ts.map +1 -1
  130. package/dist/src/intl/sl.js +20 -0
  131. package/dist/src/intl/sv.d.ts +24 -1
  132. package/dist/src/intl/sv.d.ts.map +1 -1
  133. package/dist/src/intl/sv.js +20 -0
  134. package/dist/src/intl/sw.d.ts +21 -0
  135. package/dist/src/intl/sw.d.ts.map +1 -1
  136. package/dist/src/intl/sw.js +18 -0
  137. package/dist/src/intl/ta.d.ts +24 -1
  138. package/dist/src/intl/ta.d.ts.map +1 -1
  139. package/dist/src/intl/ta.js +20 -0
  140. package/dist/src/intl/te.d.ts +24 -1
  141. package/dist/src/intl/te.d.ts.map +1 -1
  142. package/dist/src/intl/te.js +20 -0
  143. package/dist/src/intl/th.d.ts +24 -1
  144. package/dist/src/intl/th.d.ts.map +1 -1
  145. package/dist/src/intl/th.js +20 -0
  146. package/dist/src/intl/tr.d.ts +24 -1
  147. package/dist/src/intl/tr.d.ts.map +1 -1
  148. package/dist/src/intl/tr.js +20 -0
  149. package/dist/src/intl/uk.d.ts +80 -57
  150. package/dist/src/intl/uk.d.ts.map +1 -1
  151. package/dist/src/intl/uk.js +174 -149
  152. package/dist/src/intl/ur.d.ts +24 -1
  153. package/dist/src/intl/ur.d.ts.map +1 -1
  154. package/dist/src/intl/ur.js +20 -0
  155. package/dist/src/intl/vi.d.ts +24 -1
  156. package/dist/src/intl/vi.d.ts.map +1 -1
  157. package/dist/src/intl/vi.js +20 -0
  158. package/dist/src/intl/zh-CN.d.ts +24 -1
  159. package/dist/src/intl/zh-CN.d.ts.map +1 -1
  160. package/dist/src/intl/zh-CN.js +20 -0
  161. package/dist/src/intl/zh-TW.d.ts +24 -1
  162. package/dist/src/intl/zh-TW.d.ts.map +1 -1
  163. package/dist/src/intl/zh-TW.js +20 -0
  164. package/dist/src/local-first/Protocol.d.ts +1 -1
  165. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  166. package/dist/src/local-first/Protocol.js +1 -1
  167. package/dist/src/local-first/Schema.d.ts +10 -0
  168. package/dist/src/local-first/Schema.d.ts.map +1 -1
  169. package/dist/src/local-first/Storage.js +1 -1
  170. package/dist/src/local-first/Timestamp.js +1 -1
  171. package/package.json +1 -1
  172. package/src/Assert.test.ts +51 -0
  173. package/src/Assert.ts +56 -4
  174. package/src/{Binary.test.ts → Bytes.test.ts} +286 -1
  175. package/src/{Binary.ts → Bytes.ts} +652 -21
  176. package/src/Config.test.ts +672 -0
  177. package/src/Config.ts +410 -0
  178. package/src/Fs.test.ts +105 -0
  179. package/src/Fs.ts +414 -0
  180. package/src/Number.test.ts +82 -18
  181. package/src/Number.ts +76 -8
  182. package/src/Object.test.ts +115 -1
  183. package/src/Object.ts +44 -0
  184. package/src/Polyfills.ts +6 -0
  185. package/src/Sqlite.ts +1 -1
  186. package/src/Time.test.ts +82 -11
  187. package/src/Time.ts +141 -16
  188. package/src/Type.test.ts +3114 -157
  189. package/src/Type.ts +2553 -196
  190. package/src/index.ts +3 -1
  191. package/src/intl/_en.ts +70 -0
  192. package/src/intl/ar.ts +71 -0
  193. package/src/intl/bn.ts +70 -0
  194. package/src/intl/ca.ts +70 -0
  195. package/src/intl/cs.ts +70 -0
  196. package/src/intl/da.ts +70 -0
  197. package/src/intl/de.ts +70 -0
  198. package/src/intl/el.ts +70 -0
  199. package/src/intl/es.ts +70 -0
  200. package/src/intl/fa.ts +70 -0
  201. package/src/intl/fi.ts +70 -0
  202. package/src/intl/fil.ts +70 -0
  203. package/src/intl/fr.ts +70 -0
  204. package/src/intl/he.ts +70 -0
  205. package/src/intl/hi.ts +70 -0
  206. package/src/intl/hr.ts +70 -0
  207. package/src/intl/hu.ts +69 -0
  208. package/src/intl/id.ts +70 -0
  209. package/src/intl/intl.test.ts +819 -1
  210. package/src/intl/it.ts +70 -0
  211. package/src/intl/ja.ts +70 -0
  212. package/src/intl/ko.ts +68 -0
  213. package/src/intl/ml.ts +70 -0
  214. package/src/intl/mr.ts +70 -0
  215. package/src/intl/ms.ts +71 -0
  216. package/src/intl/nb.ts +69 -0
  217. package/src/intl/nl.ts +70 -0
  218. package/src/intl/pa.ts +70 -0
  219. package/src/intl/pl.ts +63 -0
  220. package/src/intl/pt-BR.ts +70 -0
  221. package/src/intl/pt.ts +71 -0
  222. package/src/intl/ro.ts +70 -0
  223. package/src/intl/sk.ts +71 -0
  224. package/src/intl/sl.ts +70 -0
  225. package/src/intl/sv.ts +70 -0
  226. package/src/intl/sw.ts +62 -0
  227. package/src/intl/ta.ts +70 -0
  228. package/src/intl/te.ts +70 -0
  229. package/src/intl/th.ts +68 -0
  230. package/src/intl/tr.ts +70 -0
  231. package/src/intl/uk.ts +228 -155
  232. package/src/intl/ur.ts +70 -0
  233. package/src/intl/vi.ts +70 -0
  234. package/src/intl/zh-CN.ts +68 -0
  235. package/src/intl/zh-TW.ts +68 -0
  236. package/src/local-first/Protocol.test.ts +1 -1
  237. package/src/local-first/Protocol.ts +1 -1
  238. package/src/local-first/Schema.ts +11 -0
  239. package/src/local-first/Storage.ts +1 -1
  240. package/src/local-first/Timestamp.ts +1 -1
  241. package/dist/src/Binary.d.ts +0 -254
  242. package/dist/src/Binary.d.ts.map +0 -1
@@ -1,16 +1,29 @@
1
1
  /**
2
- * Binary data handling and byte array utilities.
2
+ * Bytes: `Uint8Array` helpers, the {@link Buffer} codec, and byte sizes.
3
3
  *
4
- * Buffer-based decoding functions intentionally throw errors instead of
5
- * returning {@link Result}. This is a deliberate micro-optimization for Evolu
6
- * Protocol's hot paths: Result is inexpensive, but returning decoded values
7
- * directly avoids its success-case allocation, and using `Error` objects
8
- * preserves stack traces. In the future, we will try returning `Error` objects
9
- * in `Result` values to measure the real-world performance impact.
4
+ * Sizes follow the same pattern as durations in Time.ts:
5
+ *
6
+ * - {@link ByteLength} is the canonical unit, a validated number of bytes.
7
+ * - {@link ByteSizeLiteral} is the human-readable form, such as `"10MiB"`,
8
+ * validated at compile time and runtime.
9
+ * - {@link ByteSize} is what APIs accept: `ByteSizeLiteral | ByteLength`.
10
+ * - {@link byteSizeToByteLength} normalizes a `ByteSize` to a `ByteLength`.
11
+ * - {@link ByteLengthFromString} parses either form from text.
12
+ *
13
+ * Buffer-based decoding functions throw instead of returning {@link Result}.
14
+ * Result is not slow, but every successful decode would allocate one, and a
15
+ * protocol message decodes many values. Throwing is the safe bet for that hot
16
+ * path until benchmarks cover the alternatives. Callers convert a thrown error
17
+ * into a Result once, at the boundary, as `parseProtocolHeader` in Protocol.ts
18
+ * does.
10
19
  *
11
20
  * @module
12
21
  */
13
22
  import { bytesToUtf8, utf8ToBytes } from "@noble/ciphers/utils.js";
23
+ import { assert } from "./Assert.js";
24
+ import { err, ok } from "./Result.js";
25
+ import { safelyStringifyUnknownValue } from "./String.js";
26
+ import { brand, createTypeWithError, Digit, Digit1To9, NonNegativeInt, String, templateLiteral, transform, union, } from "./Type.js";
14
27
  export { bytesToHex, concatBytes, hexToBytes } from "@noble/ciphers/utils.js";
15
28
  export { bytesToUtf8, utf8ToBytes };
16
29
  /**
@@ -27,7 +40,7 @@ export class BufferError extends Error {
27
40
  /** Creates a {@link Buffer} for efficient byte operations. */
28
41
  export const createBuffer = (arrayLike) => {
29
42
  const initialLength = arrayLike?.length ?? 0;
30
- assertNonNegativeInt(initialLength, "arrayLike.length");
43
+ assertBufferNonNegativeInt(initialLength, "arrayLike.length");
31
44
  let value = arrayLike ? new Uint8Array(arrayLike) : new Uint8Array(512);
32
45
  let length = initialLength;
33
46
  const buffer = {
@@ -35,9 +48,9 @@ export const createBuffer = (arrayLike) => {
35
48
  getLength: () => length,
36
49
  extend: (arg) => {
37
50
  const argLength = arg.length;
38
- assertNonNegativeInt(argLength, "arg.length");
51
+ assertBufferNonNegativeInt(argLength, "arg.length");
39
52
  const targetSize = length + argLength;
40
- assertNonNegativeInt(targetSize, "Buffer length");
53
+ assertBufferNonNegativeInt(targetSize, "Buffer length");
41
54
  if (value.length < targetSize) {
42
55
  const oldValue = value;
43
56
  const newCapacity = Math.max(value.length * 2, targetSize);
@@ -188,12 +201,12 @@ export const decodeNonNegativeInt = (buffer) => {
188
201
  throw new BufferError("Variable-length quantity must terminate within 8 bytes.");
189
202
  }
190
203
  const value = Number(result);
191
- assertNonNegativeInt(value, "Decoded integer");
204
+ assertBufferNonNegativeInt(value, "Decoded integer");
192
205
  return value;
193
206
  };
194
207
  /** Encodes the length of an array-like value. */
195
208
  export const encodeLength = (buffer, value) => {
196
- assertNonNegativeInt(value.length, "Array-like length");
209
+ assertBufferNonNegativeInt(value.length, "Array-like length");
197
210
  encodeNonNegativeInt(buffer, value.length);
198
211
  };
199
212
  /** Decodes an array-like value length. */
@@ -272,7 +285,7 @@ let jsonDecoderSource = emptyJsonDecoderSource;
272
285
  let jsonDecoderView = emptyJsonDecoderView;
273
286
  let jsonDecoderPosition = 0;
274
287
  let jsonDecoderDepth = 0;
275
- const jsonStringFromCharCode = String.fromCharCode;
288
+ const jsonStringFromCharCode = globalThis.String.fromCharCode;
276
289
  // Cache only short keys and use a fixed table to bound retained memory.
277
290
  const jsonKeyCache = Array.from({ length: jsonKeyCacheSize }, () => undefined);
278
291
  /**
@@ -559,11 +572,11 @@ const writeJsonEncoderByte = (value) => {
559
572
  };
560
573
  const ensureJsonEncoderCapacity = (additionalLength) => {
561
574
  const requiredLength = jsonEncoderPosition + additionalLength;
562
- assertNonNegativeInt(requiredLength, "Encoded JSON value length");
575
+ assertBufferNonNegativeInt(requiredLength, "Encoded JSON value length");
563
576
  if (requiredLength <= jsonEncoderTarget.length)
564
577
  return;
565
578
  const newCapacity = Math.max(jsonEncoderTarget.length * 2, requiredLength);
566
- assertNonNegativeInt(newCapacity, "JSON encoder capacity");
579
+ assertBufferNonNegativeInt(newCapacity, "JSON encoder capacity");
567
580
  const oldTarget = jsonEncoderTarget;
568
581
  jsonEncoderTarget = new Uint8Array(newCapacity);
569
582
  jsonEncoderTarget.set(oldTarget.subarray(0, jsonEncoderPosition));
@@ -946,7 +959,7 @@ const assertJsonDecoderHasRemainingBytes = (requiredBytes) => {
946
959
  throw new BufferError("Buffer parse ended prematurely");
947
960
  }
948
961
  };
949
- const assertNonNegativeInt = (value, name) => {
962
+ const assertBufferNonNegativeInt = (value, name) => {
950
963
  if (!Number.isSafeInteger(value) || value < 0) {
951
964
  throw new BufferError(`${name} must be a non-negative safe integer.`);
952
965
  }
@@ -956,3 +969,240 @@ const assertBufferHasRemainingBytes = (remainingBytes, requiredBytes) => {
956
969
  throw new BufferError("Buffer parse ended prematurely");
957
970
  }
958
971
  };
972
+ /**
973
+ * Non-negative safe integer number of bytes.
974
+ *
975
+ * The canonical unit for sizes, as milliseconds are for time. APIs accept
976
+ * {@link ByteSize} and normalize it with {@link byteSizeToByteLength}. Parse text
977
+ * such as an environment variable with {@link ByteLengthFromString}. Negative
978
+ * zero is rejected so zero has one canonical representation.
979
+ *
980
+ * ### Example
981
+ *
982
+ * ```ts
983
+ * import { assertErr, assertOk, ByteLength } from "@evolu/common";
984
+ *
985
+ * assertOk(ByteLength.fromUnknown(0), 0);
986
+ * assertOk(ByteLength.fromUnknown(1024), 1024);
987
+ * assertErr(ByteLength.fromUnknown(-0));
988
+ * assertErr(ByteLength.fromUnknown(-1));
989
+ * assertErr(ByteLength.fromUnknown(1.5));
990
+ * ```
991
+ */
992
+ export const ByteLength = /*#__PURE__*/ brand("ByteLength", NonNegativeInt, (value) => Object.is(value, -0)
993
+ ? err({ type: "ByteLength", value })
994
+ : ok(), () => "The value -0 is not a byte length. Use 0 instead.");
995
+ const Digit0To1 = /*#__PURE__*/ union("0", "1");
996
+ const Digit0To3 = /*#__PURE__*/ union("0", "1", "2", "3");
997
+ // Keep these annotations concrete. Generic unit wrappers add thousands of
998
+ // compiler instantiations to pnpm bench:type.
999
+ /** Bytes: `"0B"` to `"1023B"`. See {@link ByteSizeLiteral}. */
1000
+ export const ByteSizeLiteralBytes = /*#__PURE__*/ union(
1001
+ /*#__PURE__*/ templateLiteral(Digit, "B"),
1002
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "B"),
1003
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "B"),
1004
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, "B"),
1005
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, "B"));
1006
+ /**
1007
+ * KiB: `"1KiB"` to `"1023KiB"` or `"1.5KiB"` to `"1023.5KiB"`. See
1008
+ * {@link ByteSizeLiteral}.
1009
+ */
1010
+ export const ByteSizeLiteralKiB = /*#__PURE__*/ union(
1011
+ /*#__PURE__*/ templateLiteral(Digit1To9, "KiB"),
1012
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "KiB"),
1013
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "KiB"),
1014
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, "KiB"),
1015
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, "KiB"),
1016
+ /*#__PURE__*/ templateLiteral(Digit1To9, ".5KiB"),
1017
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, ".5KiB"),
1018
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, ".5KiB"),
1019
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, ".5KiB"),
1020
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, ".5KiB"));
1021
+ /**
1022
+ * MiB: `"1MiB"` to `"1023MiB"` or `"1.5MiB"` to `"1023.5MiB"`. See
1023
+ * {@link ByteSizeLiteral}.
1024
+ */
1025
+ export const ByteSizeLiteralMiB = /*#__PURE__*/ union(
1026
+ /*#__PURE__*/ templateLiteral(Digit1To9, "MiB"),
1027
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "MiB"),
1028
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "MiB"),
1029
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, "MiB"),
1030
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, "MiB"),
1031
+ /*#__PURE__*/ templateLiteral(Digit1To9, ".5MiB"),
1032
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, ".5MiB"),
1033
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, ".5MiB"),
1034
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, ".5MiB"),
1035
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, ".5MiB"));
1036
+ /**
1037
+ * GiB: `"1GiB"` to `"1023GiB"` or `"1.5GiB"` to `"1023.5GiB"`. See
1038
+ * {@link ByteSizeLiteral}.
1039
+ */
1040
+ export const ByteSizeLiteralGiB = /*#__PURE__*/ union(
1041
+ /*#__PURE__*/ templateLiteral(Digit1To9, "GiB"),
1042
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "GiB"),
1043
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "GiB"),
1044
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, "GiB"),
1045
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, "GiB"),
1046
+ /*#__PURE__*/ templateLiteral(Digit1To9, ".5GiB"),
1047
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, ".5GiB"),
1048
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, ".5GiB"),
1049
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, ".5GiB"),
1050
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, ".5GiB"));
1051
+ /**
1052
+ * TiB: `"1TiB"` to `"1023TiB"` or `"1.5TiB"` to `"1023.5TiB"`. See
1053
+ * {@link ByteSizeLiteral}.
1054
+ */
1055
+ export const ByteSizeLiteralTiB = /*#__PURE__*/ union(
1056
+ /*#__PURE__*/ templateLiteral(Digit1To9, "TiB"),
1057
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "TiB"),
1058
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "TiB"),
1059
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, "TiB"),
1060
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, "TiB"),
1061
+ /*#__PURE__*/ templateLiteral(Digit1To9, ".5TiB"),
1062
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, ".5TiB"),
1063
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, ".5TiB"),
1064
+ /*#__PURE__*/ templateLiteral("10", Digit0To1, Digit, ".5TiB"),
1065
+ /*#__PURE__*/ templateLiteral("102", Digit0To3, ".5TiB"));
1066
+ const byteSizeLiteralSyntax = /*#__PURE__*/ union(ByteSizeLiteralBytes, ByteSizeLiteralKiB, ByteSizeLiteralMiB, ByteSizeLiteralGiB, ByteSizeLiteralTiB);
1067
+ /**
1068
+ * Byte length literal Type with compile-time and runtime validation.
1069
+ *
1070
+ * Supported formats:
1071
+ *
1072
+ * - Bytes: `0B` to `1023B`
1073
+ * - KiB: `1KiB` to `1023KiB` or `1.5KiB` to `1023.5KiB`
1074
+ * - MiB: `1MiB` to `1023MiB` or `1.5MiB` to `1023.5MiB`
1075
+ * - GiB: `1GiB` to `1023GiB` or `1.5GiB` to `1023.5GiB`
1076
+ * - TiB: `1TiB` to `1023TiB` or `1.5TiB` to `1023.5TiB`
1077
+ *
1078
+ * Units are the binary ones defined by IEC, named kibibyte (`KiB`, 1024 bytes),
1079
+ * mebibyte (`MiB`), gibibyte (`GiB`), and tebibyte (`TiB`), each 1024 times the
1080
+ * previous. Memory, storage quotas, and caches are measured in them. The
1081
+ * familiar `MB` is ambiguous: SI defines it as a million bytes, storage vendors
1082
+ * use that meaning, and most software uses 1048576 instead, which is why a "1
1083
+ * TB" drive shows as 931 "GB". `MiB` has only one meaning, so a literal never
1084
+ * depends on a convention.
1085
+ *
1086
+ * Each unit is bounded below 1024, so equivalent representations are avoided:
1087
+ * `1024KiB` must be written as `"1MiB"`. A half is the only decimal allowed,
1088
+ * because it is the only single decimal digit that is exact in every binary
1089
+ * unit; `1.1KiB` would be 1126.4 bytes. For other exact values, use
1090
+ * {@link ByteLength} directly.
1091
+ *
1092
+ * See {@link ByteSize} for a type that also accepts {@link ByteLength}. Use
1093
+ * {@link byteSizeToByteLength} to convert.
1094
+ *
1095
+ * Invalid values produce a {@link ByteSizeLiteralError}.
1096
+ *
1097
+ * ### Example
1098
+ *
1099
+ * ```ts
1100
+ * import {
1101
+ * assertEqual,
1102
+ * assertErr,
1103
+ * assertFalse,
1104
+ * assertOk,
1105
+ * assertType,
1106
+ * ByteSizeLiteral,
1107
+ * } from "@evolu/common";
1108
+ *
1109
+ * // The TypeScript type accepts valid spellings and rejects the rest.
1110
+ * const literal: ByteSizeLiteral = "1023MiB";
1111
+ * assertType<
1112
+ * Extract<ByteSizeLiteral, "1024KiB" | "1.1KiB" | "1MB">,
1113
+ * never
1114
+ * >();
1115
+ *
1116
+ * // The runtime Type validates the same grammar.
1117
+ * assertOk(ByteSizeLiteral.fromUnknown(literal), "1023MiB");
1118
+ * assertFalse(ByteSizeLiteral.is("1024KiB"));
1119
+ *
1120
+ * const invalid = ByteSizeLiteral.fromUnknown("1MB");
1121
+ * assertErr(invalid);
1122
+ * assertEqual(invalid.error.type, "ByteSizeLiteral");
1123
+ * assertEqual(
1124
+ * ByteSizeLiteral.formatError(invalid.error),
1125
+ * 'The value "1MB" is not a byte-size literal. Use a value such as "512KiB" or "1MiB".',
1126
+ * );
1127
+ * ```
1128
+ */
1129
+ export const ByteSizeLiteral = /*#__PURE__*/ createTypeWithError("ByteSizeLiteral", byteSizeLiteralSyntax, (cause, value) => ({
1130
+ type: "ByteSizeLiteral",
1131
+ value,
1132
+ cause,
1133
+ }), (error) => `The value ${safelyStringifyUnknownValue(error.value)} is not a byte-size literal. Use a value such as "512KiB" or "1MiB".`);
1134
+ const bytesByByteLengthUnit = {
1135
+ B: 1,
1136
+ KiB: 1024,
1137
+ MiB: 1024 ** 2,
1138
+ GiB: 1024 ** 3,
1139
+ TiB: 1024 ** 4,
1140
+ };
1141
+ /**
1142
+ * Converts a {@link ByteSize} to a {@link ByteLength}. A {@link ByteLength} is
1143
+ * returned unchanged.
1144
+ *
1145
+ * ### Example
1146
+ *
1147
+ * ```ts
1148
+ * import { assertEqual, byteSizeToByteLength } from "@evolu/common";
1149
+ *
1150
+ * assertEqual(byteSizeToByteLength("0B"), 0);
1151
+ * assertEqual(byteSizeToByteLength("2KiB"), 2048);
1152
+ * assertEqual(byteSizeToByteLength("1GiB"), 1073741824);
1153
+ * ```
1154
+ */
1155
+ export const byteSizeToByteLength = (value) => {
1156
+ if (typeof value === "number")
1157
+ return value;
1158
+ const unit = value.endsWith("iB") ? value.slice(-3) : "B";
1159
+ assert(unit in bytesByByteLengthUnit, `Unknown byte length unit: ${unit}`);
1160
+ return ByteLength.orThrow(Number.parseFloat(value) *
1161
+ bytesByByteLengthUnit[unit]);
1162
+ };
1163
+ /**
1164
+ * Transforms a number of bytes or a {@link ByteSizeLiteral} in text into a
1165
+ * {@link ByteLength}.
1166
+ *
1167
+ * This is useful for inputs that carry sizes as text, such as environment
1168
+ * variables and configuration files, where `"10MiB"` reads better than
1169
+ * `"10485760"`. Encoding produces the number of bytes.
1170
+ *
1171
+ * ### Example
1172
+ *
1173
+ * ```ts
1174
+ * import {
1175
+ * assertEqual,
1176
+ * assertErr,
1177
+ * assertOk,
1178
+ * ByteLengthFromString,
1179
+ * } from "@evolu/common";
1180
+ *
1181
+ * assertOk(ByteLengthFromString.fromUnknown("10MiB"), 10485760);
1182
+ * assertOk(ByteLengthFromString.fromUnknown("1048576"), 1048576);
1183
+ * assertEqual(
1184
+ * ByteLengthFromString.to(ByteLengthFromString.orThrow("1KiB")),
1185
+ * "1024",
1186
+ * );
1187
+ *
1188
+ * const invalid = ByteLengthFromString.fromUnknown("10MB");
1189
+ * assertErr(invalid, { type: "ByteLengthFromString", value: "10MB" });
1190
+ * assertEqual(
1191
+ * ByteLengthFromString.formatError(invalid.error),
1192
+ * 'The value "10MB" is not a byte length. Use a number of bytes or a literal such as 10MiB.',
1193
+ * );
1194
+ * ```
1195
+ */
1196
+ export const ByteLengthFromString = /*#__PURE__*/ transform("ByteLengthFromString", String, ByteLength, {
1197
+ from: (value) => {
1198
+ if (ByteSizeLiteral.is(value))
1199
+ return ok(byteSizeToByteLength(value));
1200
+ if (/^\d+$/u.test(value)) {
1201
+ const number = Number(value);
1202
+ if (Number.isSafeInteger(number))
1203
+ return ok(number);
1204
+ }
1205
+ return err({ type: "ByteLengthFromString", value });
1206
+ },
1207
+ to: (value) => globalThis.String(value),
1208
+ }, (error) => `The value ${safelyStringifyUnknownValue(error.value)} is not a byte length. Use a number of bytes or a literal such as 10MiB.`);
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Strict configuration Types with explicit application policy.
3
+ *
4
+ * Decode configuration at startup, then pass validated values to constructors
5
+ * or Tasks. The application decides how to load configuration, combine sources,
6
+ * and apply defaults. Declare defaults with {@link withDefault}, or use `??`
7
+ * where a value is consumed. Invalid supplied values still fail decoding.
8
+ *
9
+ * Resolve source precedence before replacing absence with defaults. If a source
10
+ * Type already provides defaults and later composition needs to distinguish
11
+ * them from supplied values, use `strategy: "preserve"` and inspect
12
+ * `defaultUsed` explicitly. Preserving this evidence does not choose a merging
13
+ * policy: the application still decides which source wins.
14
+ *
15
+ * {@link env} creates a pure, reversible codec. It does not read global state,
16
+ * load files, merge sources, or introduce a Run dependency. Tests can pass
17
+ * ordinary objects; a Node.js entry point can pass `process.env`.
18
+ *
19
+ * @module
20
+ */
21
+ import { CamelCaseIdentifier, String, Unknown, type AnyType, type InferErrors, type ValidateLiteral, type ObjectKeysType, type ObjectProps, type ObjectType, type TransformType, type TypeNode } from "./Type.ts";
22
+ import type { CompileTimeError, IsUnion, UnionToIntersection } from "./Types.ts";
23
+ /**
24
+ * An environment variable name in Evolu's configuration convention.
25
+ *
26
+ * Names are {@link ConstantCaseIdentifier}s of at most 255 characters, including
27
+ * the application prefix. This is an Evolu convention, not an operating-system
28
+ * limit. Double underscores do not introduce nesting.
29
+ *
30
+ * ### Example
31
+ *
32
+ * ```ts
33
+ * import { assertErr, assertOk, EnvName } from "@evolu/common";
34
+ *
35
+ * assertOk(
36
+ * EnvName.fromUnknown("APP_MAX_OWNER_BYTES"),
37
+ * "APP_MAX_OWNER_BYTES",
38
+ * );
39
+ * assertErr(EnvName.fromUnknown("APP_maxOwnerBytes"));
40
+ * assertErr(EnvName.fromUnknown("APP_DB__PORT"));
41
+ * ```
42
+ */
43
+ export declare const EnvName: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").Type<"String", string, string, import("./Type.ts").TypeOfError<"String">, null, import("./Type.ts").TypeOfError<"String">, never, string, true>, "ConstantCaseIdentifier", import("./Type.ts").IdentifierError<"CONSTANT_CASE">>, "MaxLength255", import("./Type.ts").MaxLengthError<255>>;
44
+ export type EnvName = typeof EnvName.Output;
45
+ /** Fields and one-level namespace groups used to construct an {@link env} Type. */
46
+ export type EnvProps = Readonly<Record<string, ObjectProps[string] | ObjectProps>>;
47
+ type EnvDeclarationKind<Key> = Key extends string ? Key extends Uppercase<Key> ? "group" : Key extends Uncapitalize<Key> ? "field" : "invalid" : "invalid";
48
+ type EnvFlatProps<Props extends EnvProps> = UnionToIntersection<{
49
+ [Key in keyof Props]: EnvDeclarationKind<Key> extends "group" ? Props[Key] : EnvDeclarationKind<Key> extends "field" ? {
50
+ readonly [Field in Key]: Props[Key];
51
+ } : never;
52
+ }[keyof Props]> extends infer Flat extends ObjectProps ? Flat : {};
53
+ type EnvFieldType<Field> = Field extends TypeNode ? Field : Field extends {
54
+ readonly type: infer T extends TypeNode;
55
+ } ? T : never;
56
+ type EnvKeysValidation<Props> = (string extends keyof Props ? CompileTimeError<"Env", "Environment properties must use fixed string keys."> : never) | (IsUnion<Props> extends true ? CompileTimeError<"Env", "Environment properties must use one concrete schema."> : never) | {
57
+ [Key in keyof Props]: Key extends string ? ValidateLiteral<Key> extends Key ? never : CompileTimeError<"Env", "Environment properties must use fixed string keys."> : CompileTimeError<"Env", "Environment properties must use fixed string keys.">;
58
+ }[keyof Props];
59
+ type EnvFieldValidation<Field> = IsUnion<Field> extends true ? CompileTimeError<"Env", "Environment fields must use one concrete Type."> : EnvFieldType<Field> extends infer T extends AnyType ? IsUnion<T> extends true ? CompileTimeError<"Env", "Environment fields must use one concrete Type."> : [T["CanonicalInput"]] extends [string] ? Extract<"ObjectMissingProperty" | "ObjectPropertyAccess" | "ObjectExcessProperty", InferErrors<T>["type"]> extends never ? never : CompileTimeError<"Env", "Environment fields must not use error tags reserved for Object structure."> : CompileTimeError<"Env", "Environment fields must encode to strings."> : CompileTimeError<"Env", "Environment fields must use one concrete Type.">;
60
+ type EnvFieldsValidation<Props extends ObjectProps> = EnvKeysValidation<Props> | {
61
+ [Key in keyof Props]: EnvDeclarationKind<Key> extends "field" ? EnvFieldValidation<Props[Key]> : CompileTimeError<"Env", "Environment fields must use camelCase names.">;
62
+ }[keyof Props];
63
+ type EnvValidation<Props extends EnvProps> = EnvKeysValidation<Props> | {
64
+ [Key in keyof Props]: EnvDeclarationKind<Key> extends "group" ? Props[Key] extends ObjectProps ? EnvFieldsValidation<Props[Key]> : CompileTimeError<"Env", "Environment namespaces must contain a group of fields."> : EnvDeclarationKind<Key> extends "field" ? Props[Key] extends ObjectProps[string] ? EnvFieldValidation<Props[Key]> : CompileTimeError<"Env", "Environment fields must be Types, optional properties, or defaulted properties."> : CompileTimeError<"Env", "Environment declarations must use camelCase field names or CONSTANT_CASE namespace names.">;
65
+ }[keyof Props];
66
+ type EnvKeyType = TransformType<typeof String, typeof CamelCaseIdentifier, "EnvKey", never, string>;
67
+ /** The configuration codec returned by {@link env}. */
68
+ export interface EnvType<Props extends EnvProps> extends TransformType<typeof Unknown, ObjectKeysType<EnvKeyType, ObjectType<EnvFlatProps<Props>>>, "Env", never, Readonly<Record<string, ObjectType<EnvFlatProps<Props>>["CanonicalInput"][keyof ObjectType<EnvFlatProps<Props>>["CanonicalInput"]]>>> {
69
+ }
70
+ /**
71
+ * Creates a reversible environment-variable codec with a flat decoded output.
72
+ *
73
+ * Declare camelCase fields directly, or put them in one-level CONSTANT_CASE
74
+ * namespace groups. A direct `port` field reads `PORT`; a `maxOwnerBytes` field
75
+ * in an `EVOLU_RELAY` group reads `EVOLU_RELAY_MAX_OWNER_BYTES`. Groups affect
76
+ * external names only. Duplicate decoded fields or encoded names are rejected
77
+ * during construction, even when their Types are identical.
78
+ *
79
+ * Selects exact declared unprefixed names and all keys within declared
80
+ * namespaces. Namespace selection ignores casing so incorrectly cased names
81
+ * fail validation instead of being ignored. Selected names must match their
82
+ * exact declared spelling. Unrelated variables are ignored; misspelled
83
+ * unprefixed names or namespace prefixes can therefore still look absent.
84
+ *
85
+ * Field Types must encode to strings. Optional fields may be absent, but
86
+ * explicit `undefined` values are rejected. Empty strings remain present and
87
+ * must satisfy the field Type. Compose {@link withDefault} to supply defaults.
88
+ * Encoding emits canonical external names and string values, preserving absence
89
+ * when the field codec does. Errors retain external names and nested paths.
90
+ *
91
+ * Reads own string properties from any non-null object, including
92
+ * `process.env`. Selected properties must be enumerable data properties;
93
+ * getters are never read. Prototypes and internal contents such as Map entries
94
+ * are ignored. Non-object inputs fail with standard object errors. Schema names
95
+ * must satisfy {@link EnvName}; groups cannot be nested. Loading and source
96
+ * precedence remain explicit application code.
97
+ *
98
+ * ### Example
99
+ *
100
+ * ```ts
101
+ * import {
102
+ * assertEqual,
103
+ * assertErr,
104
+ * assertOk,
105
+ * assertType,
106
+ * ByteSizeLiteral,
107
+ * env,
108
+ * optional,
109
+ * Port,
110
+ * PortFromString,
111
+ * withDefault,
112
+ * } from "@evolu/common";
113
+ *
114
+ * const RelayEnv = env({
115
+ * port: withDefault(optional(PortFromString), Port.orThrow(4000)),
116
+ * EVOLU_RELAY: {
117
+ * maxOwnerBytes: optional(ByteSizeLiteral),
118
+ * },
119
+ * });
120
+ *
121
+ * const result = RelayEnv.fromUnknown({
122
+ * PORT: "04000",
123
+ * EVOLU_RELAY_MAX_OWNER_BYTES: "512KiB",
124
+ * HOME: "/home/evolu",
125
+ * });
126
+ *
127
+ * assertOk(result, { port: 4000, maxOwnerBytes: "512KiB" });
128
+ * assertType<typeof result.value.port, Port>();
129
+ * assertEqual(RelayEnv.to(result.value), {
130
+ * PORT: "4000",
131
+ * EVOLU_RELAY_MAX_OWNER_BYTES: "512KiB",
132
+ * });
133
+ *
134
+ * assertOk(RelayEnv.fromUnknown({}), { port: 4000 });
135
+ * assertErr(RelayEnv.fromUnknown({ PORT: "" }));
136
+ * assertErr(RelayEnv.fromUnknown({ EVOLU_RELAY_MAX_OWENR_BYTES: "1MiB" }));
137
+ * assertErr(RelayEnv.fromUnknown({ evolu_relay_max_owner_bytes: "1MiB" }));
138
+ * ```
139
+ */
140
+ export declare const env: <const Props extends EnvProps>(props: Props, ..._validation: [EnvValidation<Props>] extends [never] ? [] : [EnvValidation<Props>]) => EnvType<Props>;
141
+ export {};
142
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,EACL,mBAAmB,EAOnB,MAAM,EAEN,OAAO,EACP,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,QAAQ,EAEd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACpB,MAAM,YAAY,C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