@bessemer/cornerstone 0.5.86 → 0.5.88

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 (187) hide show
  1. package/dist/aspect-ratio.d.ts +7 -4
  2. package/dist/aspect-ratio.d.ts.map +1 -1
  3. package/dist/aspect-ratio.js +16 -7
  4. package/dist/aspect-ratio.js.map +1 -1
  5. package/dist/async.d.ts +1 -1
  6. package/dist/async.d.ts.map +1 -1
  7. package/dist/async.js +1 -1
  8. package/dist/async.js.map +1 -1
  9. package/dist/cache.d.ts +7 -6
  10. package/dist/cache.d.ts.map +1 -1
  11. package/dist/cache.js +12 -12
  12. package/dist/cache.js.map +1 -1
  13. package/dist/comparator.js +1 -1
  14. package/dist/comparator.js.map +1 -1
  15. package/dist/content.d.ts +5 -5
  16. package/dist/content.d.ts.map +1 -1
  17. package/dist/content.js.map +1 -1
  18. package/dist/data-size.d.ts +2 -2
  19. package/dist/data-size.d.ts.map +1 -1
  20. package/dist/data-size.js.map +1 -1
  21. package/dist/{error-event.d.ts → error/error-event.d.ts} +42 -23
  22. package/dist/error/error-event.d.ts.map +1 -0
  23. package/dist/{error-event.js → error/error-event.js} +82 -60
  24. package/dist/error/error-event.js.map +1 -0
  25. package/dist/error/error-type.d.ts +11 -0
  26. package/dist/error/error-type.d.ts.map +1 -0
  27. package/dist/error/error-type.js +20 -0
  28. package/dist/error/error-type.js.map +1 -0
  29. package/dist/error/error.d.ts.map +1 -0
  30. package/dist/{error.js → error/error.js} +1 -1
  31. package/dist/error/error.js.map +1 -0
  32. package/dist/expression.d.ts +2 -2
  33. package/dist/expression.d.ts.map +1 -1
  34. package/dist/expression.js.map +1 -1
  35. package/dist/glob.d.ts +7 -3
  36. package/dist/glob.d.ts.map +1 -1
  37. package/dist/glob.js +23 -15
  38. package/dist/glob.js.map +1 -1
  39. package/dist/hash.d.ts +2 -2
  40. package/dist/hash.d.ts.map +1 -1
  41. package/dist/hash.js.map +1 -1
  42. package/dist/hex-code.d.ts +7 -4
  43. package/dist/hex-code.d.ts.map +1 -1
  44. package/dist/hex-code.js +19 -5
  45. package/dist/hex-code.js.map +1 -1
  46. package/dist/index.d.ts +12 -5
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +18 -4
  49. package/dist/index.js.map +1 -1
  50. package/dist/intl/country-code.d.ts +7 -4
  51. package/dist/intl/country-code.d.ts.map +1 -1
  52. package/dist/intl/country-code.js +52 -43
  53. package/dist/intl/country-code.js.map +1 -1
  54. package/dist/intl/country-subdivision-code.d.ts +7 -4
  55. package/dist/intl/country-subdivision-code.d.ts.map +1 -1
  56. package/dist/intl/country-subdivision-code.js +16 -5
  57. package/dist/intl/country-subdivision-code.js.map +1 -1
  58. package/dist/intl/currency-code.d.ts +7 -4
  59. package/dist/intl/currency-code.d.ts.map +1 -1
  60. package/dist/intl/currency-code.js +20 -11
  61. package/dist/intl/currency-code.js.map +1 -1
  62. package/dist/intl/language-code.d.ts +7 -4
  63. package/dist/intl/language-code.d.ts.map +1 -1
  64. package/dist/intl/language-code.js +39 -30
  65. package/dist/intl/language-code.js.map +1 -1
  66. package/dist/intl/locale.d.ts +8 -5
  67. package/dist/intl/locale.d.ts.map +1 -1
  68. package/dist/intl/locale.js +37 -30
  69. package/dist/intl/locale.js.map +1 -1
  70. package/dist/math.d.ts +2 -0
  71. package/dist/math.d.ts.map +1 -1
  72. package/dist/math.js +12 -1
  73. package/dist/math.js.map +1 -1
  74. package/dist/mime-type.d.ts +7 -4
  75. package/dist/mime-type.d.ts.map +1 -1
  76. package/dist/mime-type.js +44 -35
  77. package/dist/mime-type.js.map +1 -1
  78. package/dist/monetary-amount.d.ts +3 -3
  79. package/dist/monetary-amount.d.ts.map +1 -1
  80. package/dist/monetary-amount.js +4 -4
  81. package/dist/monetary-amount.js.map +1 -1
  82. package/dist/object/object-path.d.ts +2 -2
  83. package/dist/object/object-path.d.ts.map +1 -1
  84. package/dist/object/object-path.js.map +1 -1
  85. package/dist/object/type-path.d.ts +2 -2
  86. package/dist/object/type-path.d.ts.map +1 -1
  87. package/dist/object/type-path.js.map +1 -1
  88. package/dist/object.d.ts +2 -2
  89. package/dist/object.d.ts.map +1 -1
  90. package/dist/object.js +3 -2
  91. package/dist/object.js.map +1 -1
  92. package/dist/range.d.ts +2 -2
  93. package/dist/range.d.ts.map +1 -1
  94. package/dist/range.js.map +1 -1
  95. package/dist/reference.d.ts +2 -2
  96. package/dist/reference.d.ts.map +1 -1
  97. package/dist/reference.js.map +1 -1
  98. package/dist/resource-key.d.ts +17 -8
  99. package/dist/resource-key.d.ts.map +1 -1
  100. package/dist/resource-key.js +42 -13
  101. package/dist/resource-key.js.map +1 -1
  102. package/dist/result.d.ts +6 -5
  103. package/dist/result.d.ts.map +1 -1
  104. package/dist/result.js +4 -4
  105. package/dist/result.js.map +1 -1
  106. package/dist/retry.d.ts +1 -1
  107. package/dist/retry.d.ts.map +1 -1
  108. package/dist/retry.js +1 -1
  109. package/dist/retry.js.map +1 -1
  110. package/dist/rich-text.d.ts +2 -2
  111. package/dist/rich-text.d.ts.map +1 -1
  112. package/dist/rich-text.js.map +1 -1
  113. package/dist/signature.d.ts.map +1 -1
  114. package/dist/signature.js +5 -1
  115. package/dist/signature.js.map +1 -1
  116. package/dist/sql.d.ts +2 -2
  117. package/dist/sql.d.ts.map +1 -1
  118. package/dist/sql.js.map +1 -1
  119. package/dist/tag.d.ts +3 -3
  120. package/dist/tag.d.ts.map +1 -1
  121. package/dist/tag.js.map +1 -1
  122. package/dist/temporal/chrono.d.ts +34 -0
  123. package/dist/temporal/chrono.d.ts.map +1 -0
  124. package/dist/temporal/chrono.js +34 -0
  125. package/dist/temporal/chrono.js.map +1 -0
  126. package/dist/temporal/clock.d.ts +21 -0
  127. package/dist/temporal/clock.d.ts.map +1 -0
  128. package/dist/temporal/clock.js +76 -0
  129. package/dist/temporal/clock.js.map +1 -0
  130. package/dist/temporal/date.d.ts +2 -0
  131. package/dist/temporal/date.d.ts.map +1 -0
  132. package/dist/temporal/date.js +8 -0
  133. package/dist/temporal/date.js.map +1 -0
  134. package/dist/temporal/duration.d.ts +54 -0
  135. package/dist/temporal/duration.d.ts.map +1 -0
  136. package/dist/temporal/duration.js +162 -0
  137. package/dist/temporal/duration.js.map +1 -0
  138. package/dist/temporal/instant.d.ts +35 -0
  139. package/dist/temporal/instant.d.ts.map +1 -0
  140. package/dist/temporal/instant.js +91 -0
  141. package/dist/temporal/instant.js.map +1 -0
  142. package/dist/temporal/plain-time.d.ts +49 -0
  143. package/dist/temporal/plain-time.d.ts.map +1 -0
  144. package/dist/temporal/plain-time.js +110 -0
  145. package/dist/temporal/plain-time.js.map +1 -0
  146. package/dist/temporal/time-zone-id.d.ts +12 -0
  147. package/dist/temporal/time-zone-id.d.ts.map +1 -0
  148. package/dist/temporal/time-zone-id.js +35 -0
  149. package/dist/temporal/time-zone-id.js.map +1 -0
  150. package/dist/temporal/time-zone-offset.d.ts +22 -0
  151. package/dist/temporal/time-zone-offset.d.ts.map +1 -0
  152. package/dist/temporal/time-zone-offset.js +145 -0
  153. package/dist/temporal/time-zone-offset.js.map +1 -0
  154. package/dist/types.d.ts +12 -12
  155. package/dist/types.d.ts.map +1 -1
  156. package/dist/ulid.d.ts +7 -4
  157. package/dist/ulid.d.ts.map +1 -1
  158. package/dist/ulid.js +14 -5
  159. package/dist/ulid.js.map +1 -1
  160. package/dist/unit.d.ts +2 -2
  161. package/dist/unit.d.ts.map +1 -1
  162. package/dist/unit.js.map +1 -1
  163. package/dist/uri.d.ts +2 -2
  164. package/dist/uri.d.ts.map +1 -1
  165. package/dist/uri.js.map +1 -1
  166. package/dist/uuid.d.ts +7 -4
  167. package/dist/uuid.d.ts.map +1 -1
  168. package/dist/uuid.js +14 -5
  169. package/dist/uuid.js.map +1 -1
  170. package/dist/zod-util.d.ts +5 -0
  171. package/dist/zod-util.d.ts.map +1 -1
  172. package/dist/zod-util.js +28 -2
  173. package/dist/zod-util.js.map +1 -1
  174. package/package.json +2 -2
  175. package/dist/date.d.ts +0 -13
  176. package/dist/date.d.ts.map +0 -1
  177. package/dist/date.js +0 -40
  178. package/dist/date.js.map +0 -1
  179. package/dist/duration.d.ts +0 -18
  180. package/dist/duration.d.ts.map +0 -1
  181. package/dist/duration.js +0 -53
  182. package/dist/duration.js.map +0 -1
  183. package/dist/error-event.d.ts.map +0 -1
  184. package/dist/error-event.js.map +0 -1
  185. package/dist/error.d.ts.map +0 -1
  186. package/dist/error.js.map +0 -1
  187. /package/dist/{error.d.ts → error/error.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/result.ts"],"sourcesContent":["import { left, Left, right, Right } from '@bessemer/cornerstone/either'\nimport { Throwable } from '@bessemer/cornerstone/types'\nimport { isPromise } from '@bessemer/cornerstone/promise'\n\nexport type Success<T> = Right<T> & {\n isSuccess: true\n}\n\nexport type Failure = Left<Throwable | null> & {\n isSuccess: false\n}\n\nexport type Result<T> = Success<T> | Failure\nexport type AsyncResult<T> = Promise<Result<T>>\n\nexport const success = <T>(value: T): Success<T> => {\n return { ...right(value), isSuccess: true }\n}\n\nexport const failure = (failure?: Throwable): Failure => {\n return { ...left(failure ?? null), isSuccess: false }\n}\n\nexport const getValueOrThrow = <T>(result: Result<T>): T => {\n if (result.isSuccess) {\n return result.value\n } else {\n throw result.value\n }\n}\n\nexport function tryValue<SOURCE_VALUE>(resolver: () => Promise<SOURCE_VALUE>): AsyncResult<SOURCE_VALUE>\nexport function tryValue<SOURCE_VALUE>(resolver: () => SOURCE_VALUE): Result<SOURCE_VALUE>\nexport function tryValue<SOURCE_VALUE>(resolver: () => SOURCE_VALUE | Promise<SOURCE_VALUE>): Result<SOURCE_VALUE> | Promise<Result<SOURCE_VALUE>> {\n try {\n let result = resolver()\n if (isPromise(result)) {\n return result.then((it) => success(it)).catch((it) => failure(it))\n } else {\n return success(result)\n }\n } catch (e: any) {\n return failure(e)\n }\n}\n\nexport function tryResult<SOURCE_VALUE>(resolver: () => Result<SOURCE_VALUE>): Result<SOURCE_VALUE>\nexport function tryResult<SOURCE_VALUE>(resolver: () => AsyncResult<SOURCE_VALUE>): AsyncResult<SOURCE_VALUE>\nexport function tryResult<SOURCE_VALUE>(resolver: () => Result<SOURCE_VALUE> | AsyncResult<SOURCE_VALUE>): ReturnType<typeof resolver> {\n try {\n let result = resolver()\n if (isPromise(result)) {\n return result.catch((it) => failure(it))\n } else {\n return result\n }\n } catch (e: any) {\n return failure(e)\n }\n}\n\nexport function map<SOURCE_VALUE, TARGET_VALUE>(\n result: Result<SOURCE_VALUE>,\n valueMapper: (element: SOURCE_VALUE) => TARGET_VALUE\n): Result<TARGET_VALUE> {\n if (result.isSuccess) {\n return {\n ...result,\n value: valueMapper(result.value),\n }\n } else {\n return result\n }\n}\n"],"mappings":";AAAA,SAAS,MAAY,aAAoB;AAEzC,SAAS,iBAAiB;AAanB,IAAM,UAAU,CAAI,UAAyB;AAClD,SAAO,EAAE,GAAG,MAAM,KAAK,GAAG,WAAW,KAAK;AAC5C;AAEO,IAAM,UAAU,CAACA,aAAiC;AACvD,SAAO,EAAE,GAAG,KAAKA,YAAW,IAAI,GAAG,WAAW,MAAM;AACtD;AAEO,IAAM,kBAAkB,CAAI,WAAyB;AAC1D,MAAI,OAAO,WAAW;AACpB,WAAO,OAAO;AAAA,EAChB,OAAO;AACL,UAAM,OAAO;AAAA,EACf;AACF;AAIO,SAAS,SAAuB,UAA4G;AACjJ,MAAI;AACF,QAAI,SAAS,SAAS;AACtB,QAAI,UAAU,MAAM,GAAG;AACrB,aAAO,OAAO,KAAK,CAAC,OAAO,QAAQ,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC;AAAA,IACnE,OAAO;AACL,aAAO,QAAQ,MAAM;AAAA,IACvB;AAAA,EACF,SAAS,GAAQ;AACf,WAAO,QAAQ,CAAC;AAAA,EAClB;AACF;AAIO,SAAS,UAAwB,UAA+F;AACrI,MAAI;AACF,QAAI,SAAS,SAAS;AACtB,QAAI,UAAU,MAAM,GAAG;AACrB,aAAO,OAAO,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC;AAAA,IACzC,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAQ;AACf,WAAO,QAAQ,CAAC;AAAA,EAClB;AACF;AAEO,SAAS,IACd,QACA,aACsB;AACtB,MAAI,OAAO,WAAW;AACpB,WAAO;AAAA,MACL,GAAG;AAAA,MACH,OAAO,YAAY,OAAO,KAAK;AAAA,IACjC;AAAA,EACF,OAAO;AACL,WAAO;AAAA,EACT;AACF;","names":["failure"]}
1
+ {"version":3,"sources":["../src/result.ts"],"sourcesContent":["import { left, Left, right, Right } from '@bessemer/cornerstone/either'\nimport { Throwable } from '@bessemer/cornerstone/types'\nimport { isPromise } from '@bessemer/cornerstone/promise'\n\nexport type Success<T> = Right<T> & {\n isSuccess: true\n}\n\nexport type Failure<N = Throwable> = Left<N> & {\n isSuccess: false\n}\n\nexport type Result<T, N = Throwable> = Success<T> | Failure<N>\n\nexport type AsyncResult<T, N = Throwable> = Promise<Result<T, N>>\n\nexport const success = <T>(value: T): Success<T> => {\n return { ...right(value), isSuccess: true }\n}\n\nexport function failure(): Failure<never>\nexport function failure<N>(failure: N): Failure<N>\nexport function failure(failure?: unknown): Failure {\n return { ...left(failure ?? null), isSuccess: false }\n}\n\nexport const getValueOrThrow = <T>(result: Result<T>): T => {\n if (result.isSuccess) {\n return result.value\n } else {\n throw result.value\n }\n}\n\nexport function tryValue<SOURCE_VALUE>(resolver: () => Promise<SOURCE_VALUE>): AsyncResult<SOURCE_VALUE>\nexport function tryValue<SOURCE_VALUE>(resolver: () => SOURCE_VALUE): Result<SOURCE_VALUE>\nexport function tryValue<SOURCE_VALUE>(resolver: () => SOURCE_VALUE | Promise<SOURCE_VALUE>): Result<SOURCE_VALUE> | Promise<Result<SOURCE_VALUE>> {\n try {\n let result = resolver()\n if (isPromise(result)) {\n return result.then((it) => success(it)).catch((it) => failure(it))\n } else {\n return success(result)\n }\n } catch (e: any) {\n return failure(e)\n }\n}\n\nexport function tryResult<SOURCE_VALUE>(resolver: () => Result<SOURCE_VALUE>): Result<SOURCE_VALUE>\nexport function tryResult<SOURCE_VALUE>(resolver: () => AsyncResult<SOURCE_VALUE>): AsyncResult<SOURCE_VALUE>\nexport function tryResult<SOURCE_VALUE>(resolver: () => Result<SOURCE_VALUE> | AsyncResult<SOURCE_VALUE>): ReturnType<typeof resolver> {\n try {\n let result = resolver()\n if (isPromise(result)) {\n return result.catch((it) => failure(it))\n } else {\n return result\n }\n } catch (e: any) {\n return failure(e)\n }\n}\n\nexport function mapResult<SourceType, TargetType, ErrorType>(\n result: Result<SourceType, ErrorType>,\n valueMapper: (element: SourceType) => TargetType\n): Result<TargetType, ErrorType> {\n if (result.isSuccess) {\n return {\n ...result,\n value: valueMapper(result.value),\n }\n } else {\n return result\n }\n}\n"],"mappings":";AAAA,SAAS,MAAY,aAAoB;AAEzC,SAAS,iBAAiB;AAcnB,IAAM,UAAU,CAAI,UAAyB;AAClD,SAAO,EAAE,GAAG,MAAM,KAAK,GAAG,WAAW,KAAK;AAC5C;AAIO,SAAS,QAAQA,UAA4B;AAClD,SAAO,EAAE,GAAG,KAAKA,YAAW,IAAI,GAAG,WAAW,MAAM;AACtD;AAEO,IAAM,kBAAkB,CAAI,WAAyB;AAC1D,MAAI,OAAO,WAAW;AACpB,WAAO,OAAO;AAAA,EAChB,OAAO;AACL,UAAM,OAAO;AAAA,EACf;AACF;AAIO,SAAS,SAAuB,UAA4G;AACjJ,MAAI;AACF,QAAI,SAAS,SAAS;AACtB,QAAI,UAAU,MAAM,GAAG;AACrB,aAAO,OAAO,KAAK,CAAC,OAAO,QAAQ,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC;AAAA,IACnE,OAAO;AACL,aAAO,QAAQ,MAAM;AAAA,IACvB;AAAA,EACF,SAAS,GAAQ;AACf,WAAO,QAAQ,CAAC;AAAA,EAClB;AACF;AAIO,SAAS,UAAwB,UAA+F;AACrI,MAAI;AACF,QAAI,SAAS,SAAS;AACtB,QAAI,UAAU,MAAM,GAAG;AACrB,aAAO,OAAO,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC;AAAA,IACzC,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAQ;AACf,WAAO,QAAQ,CAAC;AAAA,EAClB;AACF;AAEO,SAAS,UACd,QACA,aAC+B;AAC/B,MAAI,OAAO,WAAW;AACpB,WAAO;AAAA,MACL,GAAG;AAAA,MACH,OAAO,YAAY,OAAO,KAAK;AAAA,IACjC;AAAA,EACF,OAAO;AACL,WAAO;AAAA,EACT;AACF;","names":["failure"]}
package/dist/retry.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Duration } from '@bessemer/cornerstone/duration';
1
+ import { Duration } from '@bessemer/cornerstone/temporal/duration';
2
2
  import { AsyncResult, Result } from '@bessemer/cornerstone/result';
3
3
  import { PartialDeep } from 'type-fest';
4
4
  export type RetryProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA0C,MAAM,gCAAgC,CAAA;AACjG,OAAO,EAAE,WAAW,EAAW,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAMvC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;AAElD,eAAO,MAAM,IAAI,EAAE,UAGlB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,UAG/B,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,eAA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@@
1
1
  // src/retry.ts
2
- import { fromMilliseconds, toMilliseconds, Zero } from "@bessemer/cornerstone/duration";
2
+ import { fromMilliseconds, toMilliseconds, Zero } from "@bessemer/cornerstone/temporal/duration";
3
3
  import { failure } from "@bessemer/cornerstone/result";
4
4
  import { deepMerge, isUndefined } from "@bessemer/cornerstone/object";
5
5
  import { sleep } from "@bessemer/cornerstone/async";
package/dist/retry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/retry.ts"],"sourcesContent":["import { Duration, fromMilliseconds, toMilliseconds, Zero } from '@bessemer/cornerstone/duration'\nimport { AsyncResult, failure, Result } from '@bessemer/cornerstone/result'\nimport { PartialDeep } from 'type-fest'\nimport { deepMerge, isUndefined } from '@bessemer/cornerstone/object'\nimport { sleep } from '@bessemer/cornerstone/async'\nimport { random } from '@bessemer/cornerstone/math'\nimport { assert } from '@bessemer/cornerstone/assertion'\n\nexport type RetryProps = {\n attempts: number\n delay: Duration\n}\n\nexport type RetryOptions = PartialDeep<RetryProps>\n\nexport const None: RetryProps = {\n attempts: 0,\n delay: Zero,\n}\n\nexport const DefaultRetryProps: RetryProps = {\n attempts: 3,\n delay: fromMilliseconds(500),\n}\n\nexport type RetryState = {\n attempt: number\n props: RetryProps\n}\n\nexport const initialize = (initialOptions?: RetryOptions): RetryState => {\n const props = deepMerge(DefaultRetryProps, initialOptions)\n assert(props.attempts >= 0, () => 'usingRetry attempts must be >= 0')\n\n return {\n attempt: 0,\n props,\n }\n}\n\nexport const retry = async (state: RetryState): Promise<RetryState | undefined> => {\n if (state.attempt >= state.props.attempts - 1) {\n return undefined\n }\n\n const delayMs = toMilliseconds(state.props.delay)\n const maxJitterMs = delayMs * 0.3 // We calculate max jitter as 30% of the delay\n await sleep(fromMilliseconds(delayMs + random(0, maxJitterMs)))\n\n return {\n props: state.props,\n attempt: state.attempt + 1,\n }\n}\n\nexport const usingRetry = async <T>(runnable: () => Promise<Result<T>>, initialOptions?: RetryOptions): AsyncResult<T> => {\n let retryState: RetryState | undefined = initialize(initialOptions)\n let previousResult: Result<T> = failure()\n\n do {\n // JOHN Should this be a try/catch? it was causing debugging problems\n const result = await runnable()\n previousResult = result\n\n if (result.isSuccess) {\n return result\n }\n\n retryState = await retry(retryState)\n } while (!isUndefined(retryState))\n\n return previousResult\n}\n"],"mappings":";AAAA,SAAmB,kBAAkB,gBAAgB,YAAY;AACjE,SAAsB,eAAuB;AAE7C,SAAS,WAAW,mBAAmB;AACvC,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AAShB,IAAM,OAAmB;AAAA,EAC9B,UAAU;AAAA,EACV,OAAO;AACT;AAEO,IAAM,oBAAgC;AAAA,EAC3C,UAAU;AAAA,EACV,OAAO,iBAAiB,GAAG;AAC7B;AAOO,IAAM,aAAa,CAAC,mBAA8C;AACvE,QAAM,QAAQ,UAAU,mBAAmB,cAAc;AACzD,SAAO,MAAM,YAAY,GAAG,MAAM,kCAAkC;AAEpE,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,OAAO,UAAuD;AACjF,MAAI,MAAM,WAAW,MAAM,MAAM,WAAW,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,eAAe,MAAM,MAAM,KAAK;AAChD,QAAM,cAAc,UAAU;AAC9B,QAAM,MAAM,iBAAiB,UAAU,OAAO,GAAG,WAAW,CAAC,CAAC;AAE9D,SAAO;AAAA,IACL,OAAO,MAAM;AAAA,IACb,SAAS,MAAM,UAAU;AAAA,EAC3B;AACF;AAEO,IAAM,aAAa,OAAU,UAAoC,mBAAkD;AACxH,MAAI,aAAqC,WAAW,cAAc;AAClE,MAAI,iBAA4B,QAAQ;AAExC,KAAG;AAED,UAAM,SAAS,MAAM,SAAS;AAC9B,qBAAiB;AAEjB,QAAI,OAAO,WAAW;AACpB,aAAO;AAAA,IACT;AAEA,iBAAa,MAAM,MAAM,UAAU;AAAA,EACrC,SAAS,CAAC,YAAY,UAAU;AAEhC,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/retry.ts"],"sourcesContent":["import { Duration, fromMilliseconds, toMilliseconds, Zero } from '@bessemer/cornerstone/temporal/duration'\nimport { AsyncResult, failure, Result } from '@bessemer/cornerstone/result'\nimport { PartialDeep } from 'type-fest'\nimport { deepMerge, isUndefined } from '@bessemer/cornerstone/object'\nimport { sleep } from '@bessemer/cornerstone/async'\nimport { random } from '@bessemer/cornerstone/math'\nimport { assert } from '@bessemer/cornerstone/assertion'\n\nexport type RetryProps = {\n attempts: number\n delay: Duration\n}\n\nexport type RetryOptions = PartialDeep<RetryProps>\n\nexport const None: RetryProps = {\n attempts: 0,\n delay: Zero,\n}\n\nexport const DefaultRetryProps: RetryProps = {\n attempts: 3,\n delay: fromMilliseconds(500),\n}\n\nexport type RetryState = {\n attempt: number\n props: RetryProps\n}\n\nexport const initialize = (initialOptions?: RetryOptions): RetryState => {\n const props = deepMerge(DefaultRetryProps, initialOptions)\n assert(props.attempts >= 0, () => 'usingRetry attempts must be >= 0')\n\n return {\n attempt: 0,\n props,\n }\n}\n\nexport const retry = async (state: RetryState): Promise<RetryState | undefined> => {\n if (state.attempt >= state.props.attempts - 1) {\n return undefined\n }\n\n const delayMs = toMilliseconds(state.props.delay)\n const maxJitterMs = delayMs * 0.3 // We calculate max jitter as 30% of the delay\n await sleep(fromMilliseconds(delayMs + random(0, maxJitterMs)))\n\n return {\n props: state.props,\n attempt: state.attempt + 1,\n }\n}\n\nexport const usingRetry = async <T>(runnable: () => Promise<Result<T>>, initialOptions?: RetryOptions): AsyncResult<T> => {\n let retryState: RetryState | undefined = initialize(initialOptions)\n let previousResult: Result<T> = failure()\n\n do {\n // JOHN Should this be a try/catch? it was causing debugging problems\n const result = await runnable()\n previousResult = result\n\n if (result.isSuccess) {\n return result\n }\n\n retryState = await retry(retryState)\n } while (!isUndefined(retryState))\n\n return previousResult\n}\n"],"mappings":";AAAA,SAAmB,kBAAkB,gBAAgB,YAAY;AACjE,SAAsB,eAAuB;AAE7C,SAAS,WAAW,mBAAmB;AACvC,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AAShB,IAAM,OAAmB;AAAA,EAC9B,UAAU;AAAA,EACV,OAAO;AACT;AAEO,IAAM,oBAAgC;AAAA,EAC3C,UAAU;AAAA,EACV,OAAO,iBAAiB,GAAG;AAC7B;AAOO,IAAM,aAAa,CAAC,mBAA8C;AACvE,QAAM,QAAQ,UAAU,mBAAmB,cAAc;AACzD,SAAO,MAAM,YAAY,GAAG,MAAM,kCAAkC;AAEpE,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,OAAO,UAAuD;AACjF,MAAI,MAAM,WAAW,MAAM,MAAM,WAAW,GAAG;AAC7C,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,eAAe,MAAM,MAAM,KAAK;AAChD,QAAM,cAAc,UAAU;AAC9B,QAAM,MAAM,iBAAiB,UAAU,OAAO,GAAG,WAAW,CAAC,CAAC;AAE9D,SAAO;AAAA,IACL,OAAO,MAAM;AAAA,IACb,SAAS,MAAM,UAAU;AAAA,EAC3B;AACF;AAEO,IAAM,aAAa,OAAU,UAAoC,mBAAkD;AACxH,MAAI,aAAqC,WAAW,cAAc;AAClE,MAAI,iBAA4B,QAAQ;AAExC,KAAG;AAED,UAAM,SAAS,MAAM,SAAS;AAC9B,qBAAiB;AAEjB,QAAI,OAAO,WAAW;AACpB,aAAO;AAAA,IACT;AAEA,iBAAa,MAAM,MAAM,UAAU;AAAA,EACrC,SAAS,CAAC,YAAY,UAAU;AAEhC,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
- import { NominalType } from '@bessemer/cornerstone/types';
1
+ import { TaggedType } from '@bessemer/cornerstone/types';
2
2
  export type RichTextJson = {
3
3
  type?: string;
4
4
  attrs?: Record<string, any>;
@@ -11,7 +11,7 @@ export type RichTextJson = {
11
11
  text?: string;
12
12
  [key: string]: any;
13
13
  };
14
- export type RichTextString = NominalType<string, 'RichTextString'>;
14
+ export type RichTextString = TaggedType<string, 'RichTextString'>;
15
15
  export type RichText = RichTextString | RichTextJson;
16
16
  export declare const isJson: (text: RichText) => text is RichTextJson;
17
17
  //# sourceMappingURL=rich-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../src/rich-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAIzD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB,EAAE,CAAA;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAElE,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAA;AAEpD,eAAO,MAAM,MAAM,GAAI,MAAM,QAAQ,KAAG,IAAI,IAAI,YAE/C,CAAA"}
1
+ {"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../src/rich-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAIxD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB,EAAE,CAAA;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAEjE,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAA;AAEpD,eAAO,MAAM,MAAM,GAAI,MAAM,QAAQ,KAAG,IAAI,IAAI,YAE/C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rich-text.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport { isObject } from '@bessemer/cornerstone/object'\n\n// These are to match TipTap types, but without us having to depend on the TipTap library\nexport type RichTextJson = {\n type?: string\n attrs?: Record<string, any>\n content?: RichTextJson[]\n marks?: {\n type: string\n attrs?: Record<string, any>\n [key: string]: any\n }[]\n text?: string\n [key: string]: any\n}\n\nexport type RichTextString = NominalType<string, 'RichTextString'>\n\nexport type RichText = RichTextString | RichTextJson\n\nexport const isJson = (text: RichText): text is RichTextJson => {\n return isObject(text)\n}\n"],"mappings":";AACA,SAAS,gBAAgB;AAoBlB,IAAM,SAAS,CAAC,SAAyC;AAC9D,SAAO,SAAS,IAAI;AACtB;","names":[]}
1
+ {"version":3,"sources":["../src/rich-text.ts"],"sourcesContent":["import { TaggedType } from '@bessemer/cornerstone/types'\nimport { isObject } from '@bessemer/cornerstone/object'\n\n// These are to match TipTap types, but without us having to depend on the TipTap library\nexport type RichTextJson = {\n type?: string\n attrs?: Record<string, any>\n content?: RichTextJson[]\n marks?: {\n type: string\n attrs?: Record<string, any>\n [key: string]: any\n }[]\n text?: string\n [key: string]: any\n}\n\nexport type RichTextString = TaggedType<string, 'RichTextString'>\n\nexport type RichText = RichTextString | RichTextJson\n\nexport const isJson = (text: RichText): text is RichTextJson => {\n return isObject(text)\n}\n"],"mappings":";AACA,SAAS,gBAAgB;AAoBlB,IAAM,SAAS,CAAC,SAAyC;AAC9D,SAAO,SAAS,IAAI;AACtB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAOvD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;CAAE,CAAA;AAC3F,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAE9C,eAAO,MAAM,IAAI,GAAI,OAAO,QAAQ,KAAG,SAyBtC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAG,KAAK,CAAC,SAAS,CAEhE,CAAA"}
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AASvD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;CAAE,CAAA;AAC3F,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAE9C,eAAO,MAAM,IAAI,GAAI,OAAO,QAAQ,KAAG,SA6BtC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAG,KAAK,CAAC,SAAS,CAEhE,CAAA"}
package/dist/signature.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // src/signature.ts
2
2
  import { isReferencable } from "@bessemer/cornerstone/reference";
3
3
  import { isObject } from "@bessemer/cornerstone/object";
4
- import { isDate } from "@bessemer/cornerstone/date";
4
+ import { isDate } from "@bessemer/cornerstone/temporal/date";
5
+ import { _isInstant, _toLiteral } from "@bessemer/cornerstone/temporal/chrono";
5
6
  var sign = (value) => {
6
7
  if (value === null) {
7
8
  return null;
@@ -16,6 +17,9 @@ var sign = (value) => {
16
17
  if (isDate(value)) {
17
18
  return value.getTime();
18
19
  }
20
+ if (_isInstant(value)) {
21
+ return _toLiteral(value);
22
+ }
19
23
  if (value === true) {
20
24
  return 1;
21
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/signature.ts"],"sourcesContent":["import { isReferencable, Reference } from '@bessemer/cornerstone/reference'\nimport { BasicType } from '@bessemer/cornerstone/types'\nimport { isObject } from '@bessemer/cornerstone/object'\nimport { isDate } from '@bessemer/cornerstone/date'\n\n// JOHN it is probably worth revisiting this in the context of using this library code more frequently... in particular\n// all of these things have similar properties (\"primitives\", sortable, value equality, etc.) but this method of implementation\n// forces them all to be converted to strings or numbers first which is an expensive operation.\nexport type Signable = BasicType | null | { id: string } | { reference: Reference<string> }\nexport type Signature = string | number | null\n\nexport const sign = (value: Signable): Signature => {\n if (value === null) {\n return null\n }\n\n if (isObject(value)) {\n if (isReferencable(value)) {\n return value.reference.id\n } else {\n return value.id\n }\n }\n\n if (isDate(value)) {\n return value.getTime()\n }\n\n if (value === true) {\n return 1\n }\n if (value === false) {\n return 0\n }\n\n return value\n}\n\nexport const signAll = (values: Array<Signable>): Array<Signature> => {\n return values.map(sign)\n}\n"],"mappings":";AAAA,SAAS,sBAAiC;AAE1C,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAQhB,IAAM,OAAO,CAAC,UAA+B;AAClD,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM,UAAU;AAAA,IACzB,OAAO;AACL,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,GAAG;AACjB,WAAO,MAAM,QAAQ;AAAA,EACvB;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AACA,MAAI,UAAU,OAAO;AACnB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,IAAM,UAAU,CAAC,WAA8C;AACpE,SAAO,OAAO,IAAI,IAAI;AACxB;","names":[]}
1
+ {"version":3,"sources":["../src/signature.ts"],"sourcesContent":["import { isReferencable, Reference } from '@bessemer/cornerstone/reference'\nimport { BasicType } from '@bessemer/cornerstone/types'\nimport { isObject } from '@bessemer/cornerstone/object'\nimport { isDate } from '@bessemer/cornerstone/temporal/date'\nimport { _isInstant, _toLiteral } from '@bessemer/cornerstone/temporal/chrono'\n\n// JOHN it is probably worth revisiting this in the context of using this library code more frequently... in particular\n// all of these things have similar properties (\"primitives\", sortable, value equality, etc.) but this method of implementation\n// forces them all to be converted to strings or numbers first which is an expensive operation.\n\nexport type Signable = BasicType | null | { id: string } | { reference: Reference<string> }\nexport type Signature = string | number | null\n\nexport const sign = (value: Signable): Signature => {\n if (value === null) {\n return null\n }\n\n if (isObject(value)) {\n if (isReferencable(value)) {\n return value.reference.id\n } else {\n return value.id\n }\n }\n\n if (isDate(value)) {\n return value.getTime()\n }\n\n if (_isInstant(value)) {\n return _toLiteral(value)\n }\n\n if (value === true) {\n return 1\n }\n if (value === false) {\n return 0\n }\n\n return value\n}\n\nexport const signAll = (values: Array<Signable>): Array<Signature> => {\n return values.map(sign)\n}\n"],"mappings":";AAAA,SAAS,sBAAiC;AAE1C,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,YAAY,kBAAkB;AAShC,IAAM,OAAO,CAAC,UAA+B;AAClD,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM,UAAU;AAAA,IACzB,OAAO;AACL,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,MAAI,OAAO,KAAK,GAAG;AACjB,WAAO,MAAM,QAAQ;AAAA,EACvB;AAEA,MAAI,WAAW,KAAK,GAAG;AACrB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AACA,MAAI,UAAU,OAAO;AACnB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,IAAM,UAAU,CAAC,WAA8C;AACpE,SAAO,OAAO,IAAI,IAAI;AACxB;","names":[]}
package/dist/sql.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as Sql from '@bessemer/cornerstone/sql/sql';
2
- import { BasicType, Dictionary, NominalType } from '@bessemer/cornerstone/types';
2
+ import { BasicType, Dictionary, TaggedType } from '@bessemer/cornerstone/types';
3
3
  export { Sql };
4
- export type SqlFragment = NominalType<string, 'SqlFragment'>;
4
+ export type SqlFragment = TaggedType<string, 'SqlFragment'>;
5
5
  export type SqlParameterMap = Dictionary<BasicType | Array<BasicType>>;
6
6
  //# sourceMappingURL=sql.d.ts.map
package/dist/sql.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,+BAA+B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEhF,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAC5D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,+BAA+B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAC3D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA"}
package/dist/sql.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sql.ts"],"sourcesContent":["import * as Sql from '@bessemer/cornerstone/sql/sql'\nimport { BasicType, Dictionary, NominalType } from '@bessemer/cornerstone/types'\n\nexport { Sql }\n\nexport type SqlFragment = NominalType<string, 'SqlFragment'>\nexport type SqlParameterMap = Dictionary<BasicType | Array<BasicType>>\n"],"mappings":";AAAA,YAAY,SAAS;","names":[]}
1
+ {"version":3,"sources":["../src/sql.ts"],"sourcesContent":["import * as Sql from '@bessemer/cornerstone/sql/sql'\nimport { BasicType, Dictionary, TaggedType } from '@bessemer/cornerstone/types'\n\nexport { Sql }\n\nexport type SqlFragment = TaggedType<string, 'SqlFragment'>\nexport type SqlParameterMap = Dictionary<BasicType | Array<BasicType>>\n"],"mappings":";AAAA,YAAY,SAAS;","names":[]}
package/dist/tag.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { NominalType } from '@bessemer/cornerstone/types';
1
+ import { TaggedType } from '@bessemer/cornerstone/types';
2
2
  import { Comparator } from '@bessemer/cornerstone/comparator';
3
3
  import { Equalitor } from '@bessemer/cornerstone/equalitor';
4
- export type TagType<DataType> = NominalType<string, ['TagType', DataType]>;
4
+ export type TagType<DataType> = TaggedType<string, ['TagType', DataType]>;
5
5
  export type Tag<DataType = unknown> = {
6
6
  type: TagType<DataType>;
7
7
  value: DataType;
@@ -17,7 +17,7 @@ export declare const value: <T>(value: T, tags: Array<Tag>) => {
17
17
  };
18
18
  export declare const tagComparator: <T>() => Comparator<Tag<T>>;
19
19
  export declare const tagEqualitor: <T>() => Equalitor<Tag<T>>;
20
- export type SerializedTags = NominalType<string, 'SerializedTags'>;
20
+ export type SerializedTags = TaggedType<string, 'SerializedTags'>;
21
21
  export declare const serializeTags: <T>(tags: Array<Tag<T>>) => SerializedTags;
22
22
  export declare const resolve: <T>(values: Array<TaggedValue<T>>, tags: Array<Tag>) => Array<TaggedValue<T>>;
23
23
  export declare const resolveBy: <T>(values: Array<T>, mapper: (value: T) => Array<Tag>, tags: Array<Tag>) => Array<T>;
package/dist/tag.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../src/tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAa,UAAU,EAAsB,MAAM,kCAAkC,CAAA;AAC5F,OAAO,EAAE,SAAS,EAAkB,MAAM,iCAAiC,CAAA;AAI3E,MAAM,MAAM,OAAO,CAAC,QAAQ,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE1E,MAAM,MAAM,GAAG,CAAC,QAAQ,GAAG,OAAO,IAAI;IACpC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,KAAK,EAAE,CAAC,CAAA;IACR,IAAI,EAA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E,QAAQ,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,KAAG,KAAK,CAAC,CAAC,CAW1G,CAAA"}
package/dist/tag.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tag.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport { aggregate, Comparator, compareBy, natural } from '@bessemer/cornerstone/comparator'\nimport { Equalitor, fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { equalWith, isEmpty, sortWith } from '@bessemer/cornerstone/array'\nimport { properPowerSet } from '@bessemer/cornerstone/set'\n\nexport type TagType<DataType> = NominalType<string, ['TagType', DataType]>\n\nexport type Tag<DataType = unknown> = {\n type: TagType<DataType>\n value: DataType\n}\n\nexport type TaggedValue<T> = {\n value: T\n tags: Array<Tag>\n}\n\nexport const tag = <T>(type: TagType<T>, value: T): Tag<T> => {\n return {\n type,\n value,\n }\n}\n\nexport const value = <T>(value: T, tags: Array<Tag>) => {\n return {\n value,\n tags: sortWith(tags, tagComparator()),\n }\n}\n\nexport const tagComparator = <T>(): Comparator<Tag<T>> => {\n return aggregate([compareBy((it) => it.type, natural()), compareBy((it) => JSON.stringify(it.value), natural())])\n}\n\nexport const tagEqualitor = <T>(): Equalitor<Tag<T>> => {\n return fromComparator(tagComparator())\n}\n\nexport type SerializedTags = NominalType<string, 'SerializedTags'>\n\nexport const serializeTags = <T>(tags: Array<Tag<T>>): SerializedTags => {\n const serializedTags: SerializedTags = sortWith(tags, tagComparator())\n .map(({ type, value }) => `${type}:${JSON.stringify(value)}`)\n .join('.')\n\n return serializedTags\n}\n\nexport const resolve = <T>(values: Array<TaggedValue<T>>, tags: Array<Tag>): Array<TaggedValue<T>> => {\n return resolveBy(values, (it) => it.tags, tags)\n}\n\nexport const resolveBy = <T>(values: Array<T>, mapper: (value: T) => Array<Tag>, tags: Array<Tag>): Array<T> => {\n const resolvedValues = properPowerSet(tags).flatMap((tags) => {\n return values.filter((it) => equalWith(mapper(it), tags, tagEqualitor()))\n })\n\n if (isEmpty(resolvedValues)) {\n const defaultValues = values.filter((it) => isEmpty(mapper(it)))\n return defaultValues\n }\n\n return resolvedValues.reverse()\n}\n"],"mappings":";AACA,SAAS,WAAuB,WAAW,eAAe;AAC1D,SAAoB,sBAAsB;AAC1C,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,sBAAsB;AAcxB,IAAM,MAAM,CAAI,MAAkBA,WAAqB;AAC5D,SAAO;AAAA,IACL;AAAA,IACA,OAAAA;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,CAAIA,QAAU,SAAqB;AACtD,SAAO;AAAA,IACL,OAAAA;AAAA,IACA,MAAM,SAAS,MAAM,cAAc,CAAC;AAAA,EACtC;AACF;AAEO,IAAM,gBAAgB,MAA6B;AACxD,SAAO,UAAU,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,UAAU,CAAC,OAAO,KAAK,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;AAClH;AAEO,IAAM,eAAe,MAA4B;AACtD,SAAO,eAAe,cAAc,CAAC;AACvC;AAIO,IAAM,gBAAgB,CAAI,SAAwC;AACvE,QAAM,iBAAiC,SAAS,MAAM,cAAc,CAAC,EAClE,IAAI,CAAC,EAAE,MAAM,OAAAA,OAAM,MAAM,GAAG,IAAI,IAAI,KAAK,UAAUA,MAAK,CAAC,EAAE,EAC3D,KAAK,GAAG;AAEX,SAAO;AACT;AAEO,IAAM,UAAU,CAAI,QAA+B,SAA4C;AACpG,SAAO,UAAU,QAAQ,CAAC,OAAO,GAAG,MAAM,IAAI;AAChD;AAEO,IAAM,YAAY,CAAI,QAAkB,QAAkC,SAA+B;AAC9G,QAAM,iBAAiB,eAAe,IAAI,EAAE,QAAQ,CAACC,UAAS;AAC5D,WAAO,OAAO,OAAO,CAAC,OAAO,UAAU,OAAO,EAAE,GAAGA,OAAM,aAAa,CAAC,CAAC;AAAA,EAC1E,CAAC;AAED,MAAI,QAAQ,cAAc,GAAG;AAC3B,UAAM,gBAAgB,OAAO,OAAO,CAAC,OAAO,QAAQ,OAAO,EAAE,CAAC,CAAC;AAC/D,WAAO;AAAA,EACT;AAEA,SAAO,eAAe,QAAQ;AAChC;","names":["value","tags"]}
1
+ {"version":3,"sources":["../src/tag.ts"],"sourcesContent":["import { TaggedType } from '@bessemer/cornerstone/types'\nimport { aggregate, Comparator, compareBy, natural } from '@bessemer/cornerstone/comparator'\nimport { Equalitor, fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { equalWith, isEmpty, sortWith } from '@bessemer/cornerstone/array'\nimport { properPowerSet } from '@bessemer/cornerstone/set'\n\nexport type TagType<DataType> = TaggedType<string, ['TagType', DataType]>\n\nexport type Tag<DataType = unknown> = {\n type: TagType<DataType>\n value: DataType\n}\n\nexport type TaggedValue<T> = {\n value: T\n tags: Array<Tag>\n}\n\nexport const tag = <T>(type: TagType<T>, value: T): Tag<T> => {\n return {\n type,\n value,\n }\n}\n\nexport const value = <T>(value: T, tags: Array<Tag>) => {\n return {\n value,\n tags: sortWith(tags, tagComparator()),\n }\n}\n\nexport const tagComparator = <T>(): Comparator<Tag<T>> => {\n return aggregate([compareBy((it) => it.type, natural()), compareBy((it) => JSON.stringify(it.value), natural())])\n}\n\nexport const tagEqualitor = <T>(): Equalitor<Tag<T>> => {\n return fromComparator(tagComparator())\n}\n\nexport type SerializedTags = TaggedType<string, 'SerializedTags'>\n\nexport const serializeTags = <T>(tags: Array<Tag<T>>): SerializedTags => {\n const serializedTags: SerializedTags = sortWith(tags, tagComparator())\n .map(({ type, value }) => `${type}:${JSON.stringify(value)}`)\n .join('.')\n\n return serializedTags\n}\n\nexport const resolve = <T>(values: Array<TaggedValue<T>>, tags: Array<Tag>): Array<TaggedValue<T>> => {\n return resolveBy(values, (it) => it.tags, tags)\n}\n\nexport const resolveBy = <T>(values: Array<T>, mapper: (value: T) => Array<Tag>, tags: Array<Tag>): Array<T> => {\n const resolvedValues = properPowerSet(tags).flatMap((tags) => {\n return values.filter((it) => equalWith(mapper(it), tags, tagEqualitor()))\n })\n\n if (isEmpty(resolvedValues)) {\n const defaultValues = values.filter((it) => isEmpty(mapper(it)))\n return defaultValues\n }\n\n return resolvedValues.reverse()\n}\n"],"mappings":";AACA,SAAS,WAAuB,WAAW,eAAe;AAC1D,SAAoB,sBAAsB;AAC1C,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,sBAAsB;AAcxB,IAAM,MAAM,CAAI,MAAkBA,WAAqB;AAC5D,SAAO;AAAA,IACL;AAAA,IACA,OAAAA;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,CAAIA,QAAU,SAAqB;AACtD,SAAO;AAAA,IACL,OAAAA;AAAA,IACA,MAAM,SAAS,MAAM,cAAc,CAAC;AAAA,EACtC;AACF;AAEO,IAAM,gBAAgB,MAA6B;AACxD,SAAO,UAAU,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,UAAU,CAAC,OAAO,KAAK,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;AAClH;AAEO,IAAM,eAAe,MAA4B;AACtD,SAAO,eAAe,cAAc,CAAC;AACvC;AAIO,IAAM,gBAAgB,CAAI,SAAwC;AACvE,QAAM,iBAAiC,SAAS,MAAM,cAAc,CAAC,EAClE,IAAI,CAAC,EAAE,MAAM,OAAAA,OAAM,MAAM,GAAG,IAAI,IAAI,KAAK,UAAUA,MAAK,CAAC,EAAE,EAC3D,KAAK,GAAG;AAEX,SAAO;AACT;AAEO,IAAM,UAAU,CAAI,QAA+B,SAA4C;AACpG,SAAO,UAAU,QAAQ,CAAC,OAAO,GAAG,MAAM,IAAI;AAChD;AAEO,IAAM,YAAY,CAAI,QAAkB,QAAkC,SAA+B;AAC9G,QAAM,iBAAiB,eAAe,IAAI,EAAE,QAAQ,CAACC,UAAS;AAC5D,WAAO,OAAO,OAAO,CAAC,OAAO,UAAU,OAAO,EAAE,GAAGA,OAAM,aAAa,CAAC,CAAC;AAAA,EAC1E,CAAC;AAED,MAAI,QAAQ,cAAc,GAAG;AAC3B,UAAM,gBAAgB,OAAO,OAAO,CAAC,OAAO,QAAQ,OAAO,EAAE,CAAC,CAAC;AAC/D,WAAO;AAAA,EACT;AAEA,SAAO,eAAe,QAAQ;AAChC;","names":["value","tags"]}
@@ -0,0 +1,34 @@
1
+ import { ValueOf } from 'type-fest';
2
+ import { Instant, InstantLiteral } from '@bessemer/cornerstone/temporal/instant';
3
+ export declare const TimeUnit: {
4
+ readonly Hour: "hour";
5
+ readonly Minute: "minute";
6
+ readonly Second: "second";
7
+ readonly Millisecond: "millisecond";
8
+ readonly Microsecond: "microsecond";
9
+ readonly Nanosecond: "nanosecond";
10
+ };
11
+ export type TimeUnit = ValueOf<typeof TimeUnit>;
12
+ export declare const DateUnit: {
13
+ readonly Year: "year";
14
+ readonly Month: "month";
15
+ readonly Week: "week";
16
+ readonly Day: "day";
17
+ };
18
+ export type DateUnit = ValueOf<typeof DateUnit>;
19
+ export declare const ChronoUnit: {
20
+ readonly Year: "year";
21
+ readonly Month: "month";
22
+ readonly Week: "week";
23
+ readonly Day: "day";
24
+ readonly Hour: "hour";
25
+ readonly Minute: "minute";
26
+ readonly Second: "second";
27
+ readonly Millisecond: "millisecond";
28
+ readonly Microsecond: "microsecond";
29
+ readonly Nanosecond: "nanosecond";
30
+ };
31
+ export type ChronoUnit = ValueOf<typeof ChronoUnit>;
32
+ export declare const _toLiteral: (value: Instant) => InstantLiteral;
33
+ export declare const _isInstant: (value: unknown) => value is Instant;
34
+ //# sourceMappingURL=chrono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrono.d.ts","sourceRoot":"","sources":["../../src/temporal/chrono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAGhF,eAAO,MAAM,QAAQ;;;;;;;CAOX,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C,eAAO,MAAM,QAAQ;;;;;CAKX,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C,eAAO,MAAM,UAAU;;;;;;;;;;;CAGb,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAAA;AAGnD,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,cAE3C,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAEpD,CAAA"}
@@ -0,0 +1,34 @@
1
+ // src/temporal/chrono.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ var TimeUnit = {
4
+ Hour: "hour",
5
+ Minute: "minute",
6
+ Second: "second",
7
+ Millisecond: "millisecond",
8
+ Microsecond: "microsecond",
9
+ Nanosecond: "nanosecond"
10
+ };
11
+ var DateUnit = {
12
+ Year: "year",
13
+ Month: "month",
14
+ Week: "week",
15
+ Day: "day"
16
+ };
17
+ var ChronoUnit = {
18
+ ...TimeUnit,
19
+ ...DateUnit
20
+ };
21
+ var _toLiteral = (value) => {
22
+ return value.toJSON();
23
+ };
24
+ var _isInstant = (value) => {
25
+ return value instanceof Temporal.Instant;
26
+ };
27
+ export {
28
+ ChronoUnit,
29
+ DateUnit,
30
+ TimeUnit,
31
+ _isInstant,
32
+ _toLiteral
33
+ };
34
+ //# sourceMappingURL=chrono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/temporal/chrono.ts"],"sourcesContent":["import { ValueOf } from 'type-fest'\nimport { Instant, InstantLiteral } from '@bessemer/cornerstone/temporal/instant'\nimport { Temporal } from '@js-temporal/polyfill'\n\nexport const TimeUnit = {\n Hour: 'hour',\n Minute: 'minute',\n Second: 'second',\n Millisecond: 'millisecond',\n Microsecond: 'microsecond',\n Nanosecond: 'nanosecond',\n} as const\n\nexport type TimeUnit = ValueOf<typeof TimeUnit>\n\nexport const DateUnit = {\n Year: 'year',\n Month: 'month',\n Week: 'week',\n Day: 'day',\n} as const\n\nexport type DateUnit = ValueOf<typeof DateUnit>\n\nexport const ChronoUnit = {\n ...TimeUnit,\n ...DateUnit,\n} as const\n\nexport type ChronoUnit = ValueOf<typeof ChronoUnit>\n\n// These methods are here to avoid circular dependencies\nexport const _toLiteral = (value: Instant): InstantLiteral => {\n return value.toJSON() as InstantLiteral\n}\n\nexport const _isInstant = (value: unknown): value is Instant => {\n return value instanceof Temporal.Instant\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AAElB,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,aAAa;AAAA,EACb,YAAY;AACd;AAIO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AACP;AAIO,IAAM,aAAa;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AACL;AAKO,IAAM,aAAa,CAAC,UAAmC;AAC5D,SAAO,MAAM,OAAO;AACtB;AAEO,IAAM,aAAa,CAAC,UAAqC;AAC9D,SAAO,iBAAiB,SAAS;AACnC;","names":[]}
@@ -0,0 +1,21 @@
1
+ import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
2
+ import { DurationInput } from '@bessemer/cornerstone/temporal/duration';
3
+ import { Instant, InstantInput } from '@bessemer/cornerstone/temporal/instant';
4
+ export interface Clock {
5
+ readonly zone: TimeZoneId;
6
+ withZone: (zone: TimeZoneId) => Clock;
7
+ instant: () => Instant;
8
+ }
9
+ declare class SystemClock implements Clock {
10
+ readonly zone: TimeZoneId;
11
+ constructor(zone: TimeZoneId);
12
+ instant(): Instant;
13
+ withZone(zone: TimeZoneId): Clock;
14
+ }
15
+ export declare const SystemUtc: SystemClock;
16
+ export declare const Default: SystemClock;
17
+ export declare const system: (zone?: TimeZoneId) => Clock;
18
+ export declare const fixed: (fixedInstant: InstantInput, zone?: TimeZoneId) => Clock;
19
+ export declare const offset: (clock: Clock, offset: DurationInput) => Clock;
20
+ export {};
21
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../src/temporal/clock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAO,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAY,aAAa,EAAgC,MAAM,yCAAyC,CAAA;AAC/G,OAAO,EAAuB,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAGnG,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IAEzB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,KAAK,CAAA;IAErC,OAAO,EAAE,MAAM,OAAO,CAAA;CACvB;AAED,cAAM,WAAY,YAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,UAAU;gBAAhB,IAAI,EAAE,UAAU;IAErC,OAAO,IAAI,OAAO;IAIlB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK;CAOlC;AAsCD,eAAO,MAAM,SAAS,aAAuB,CAAA;AAC7C,eAAO,MAAM,OAAO,aAAY,CAAA;AAEhC,eAAO,MAAM,MAAM,GAAI,OAAM,UAAgB,KAAG,KAM/C,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,cAAc,YAAY,EAAE,OAAM,UAAgB,KAAG,KAE1E,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,QAAQ,aAAa,KAAG,KAM5D,CAAA"}
@@ -0,0 +1,76 @@
1
+ // src/temporal/clock.ts
2
+ import { Utc } from "@bessemer/cornerstone/temporal/time-zone-id";
3
+ import { from as fromDuration, isZero } from "@bessemer/cornerstone/temporal/duration";
4
+ import { from as fromInstant } from "@bessemer/cornerstone/temporal/instant";
5
+ import { Temporal } from "@js-temporal/polyfill";
6
+ var SystemClock = class _SystemClock {
7
+ constructor(zone) {
8
+ this.zone = zone;
9
+ }
10
+ instant() {
11
+ return Temporal.Now.instant();
12
+ }
13
+ withZone(zone) {
14
+ if (zone === this.zone) {
15
+ return this;
16
+ }
17
+ return new _SystemClock(zone);
18
+ }
19
+ };
20
+ var FixedClock = class _FixedClock {
21
+ constructor(fixedInstant, zone) {
22
+ this.fixedInstant = fixedInstant;
23
+ this.zone = zone;
24
+ }
25
+ instant() {
26
+ return this.fixedInstant;
27
+ }
28
+ withZone(zone) {
29
+ if (zone === this.zone) {
30
+ return this;
31
+ }
32
+ return new _FixedClock(this.fixedInstant, zone);
33
+ }
34
+ };
35
+ var OffsetClock = class _OffsetClock {
36
+ constructor(clock, offset2) {
37
+ this.clock = clock;
38
+ this.offset = offset2;
39
+ this.zone = this.clock.zone;
40
+ }
41
+ zone;
42
+ instant() {
43
+ return this.clock.instant().add(this.offset);
44
+ }
45
+ withZone(zone) {
46
+ if (zone === this.clock.zone) {
47
+ return this;
48
+ }
49
+ return new _OffsetClock(this.clock.withZone(zone), this.offset);
50
+ }
51
+ };
52
+ var SystemUtc = new SystemClock(Utc);
53
+ var Default = SystemUtc;
54
+ var system = (zone = Utc) => {
55
+ if (zone == Utc) {
56
+ return SystemUtc;
57
+ }
58
+ return new SystemClock(zone);
59
+ };
60
+ var fixed = (fixedInstant, zone = Utc) => {
61
+ return new FixedClock(fromInstant(fixedInstant), zone);
62
+ };
63
+ var offset = (clock, offset2) => {
64
+ if (isZero(offset2)) {
65
+ return clock;
66
+ }
67
+ return new OffsetClock(clock, fromDuration(offset2));
68
+ };
69
+ export {
70
+ Default,
71
+ SystemUtc,
72
+ fixed,
73
+ offset,
74
+ system
75
+ };
76
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/temporal/clock.ts"],"sourcesContent":["import { TimeZoneId, Utc } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { Duration, DurationInput, from as fromDuration, isZero } from '@bessemer/cornerstone/temporal/duration'\nimport { from as fromInstant, Instant, InstantInput } from '@bessemer/cornerstone/temporal/instant'\nimport { Temporal } from '@js-temporal/polyfill'\n\nexport interface Clock {\n readonly zone: TimeZoneId\n\n withZone: (zone: TimeZoneId) => Clock\n\n instant: () => Instant\n}\n\nclass SystemClock implements Clock {\n constructor(readonly zone: TimeZoneId) {}\n\n instant(): Instant {\n return Temporal.Now.instant()\n }\n\n withZone(zone: TimeZoneId): Clock {\n if (zone === this.zone) {\n return this\n }\n\n return new SystemClock(zone)\n }\n}\n\nclass FixedClock implements Clock {\n constructor(private fixedInstant: Instant, readonly zone: TimeZoneId) {}\n\n instant(): Instant {\n return this.fixedInstant\n }\n\n withZone(zone: TimeZoneId): Clock {\n if (zone === this.zone) {\n return this\n }\n\n return new FixedClock(this.fixedInstant, zone)\n }\n}\n\nclass OffsetClock implements Clock {\n readonly zone: TimeZoneId\n\n constructor(private clock: Clock, private offset: Duration) {\n this.zone = this.clock.zone\n }\n\n instant(): Instant {\n return this.clock.instant().add(this.offset)\n }\n\n withZone(zone: TimeZoneId): Clock {\n if (zone === this.clock.zone) {\n return this\n }\n\n return new OffsetClock(this.clock.withZone(zone), this.offset)\n }\n}\n\nexport const SystemUtc = new SystemClock(Utc)\nexport const Default = SystemUtc\n\nexport const system = (zone: TimeZoneId = Utc): Clock => {\n if (zone == Utc) {\n return SystemUtc\n }\n\n return new SystemClock(zone)\n}\n\nexport const fixed = (fixedInstant: InstantInput, zone: TimeZoneId = Utc): Clock => {\n return new FixedClock(fromInstant(fixedInstant), zone)\n}\n\nexport const offset = (clock: Clock, offset: DurationInput): Clock => {\n if (isZero(offset)) {\n return clock\n }\n\n return new OffsetClock(clock, f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AI,YAAY,IAAI;AAC7B;AAEO,IAAM,QAAQ,CAAC,cAA4B,OAAmB,QAAe;AAClF,SAAO,IAAI,WAAW,YAAY,YAAY,GAAG,IAAI;AACvD;AAEO,IAAM,SAAS,CAAC,OAAcA,YAAiC;AACpE,MAAI,OAAOA,OAAM,GAAG;AAClB,WAAO;AAAA,EACT;AAEA,SAAO,IAAI,YAAY,OAAO,aAAaA,OAAM,CAAC;AACpD;","names":["offset"]}
@@ -0,0 +1,2 @@
1
+ export declare const isDate: (value: unknown) => value is Date;
2
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/temporal/date.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAEhD,CAAA"}
@@ -0,0 +1,8 @@
1
+ // src/temporal/date.ts
2
+ var isDate = (value) => {
3
+ return value instanceof Date && !isNaN(value.getTime());
4
+ };
5
+ export {
6
+ isDate
7
+ };
8
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/temporal/date.ts"],"sourcesContent":["export const isDate = (value: unknown): value is Date => {\n return value instanceof Date && !isNaN(value.getTime())\n}\n"],"mappings":";AAAO,IAAM,SAAS,CAAC,UAAkC;AACvD,SAAO,iBAAiB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC;AACxD;","names":[]}
@@ -0,0 +1,54 @@
1
+ import Zod from 'zod';
2
+ import { Temporal } from '@js-temporal/polyfill';
3
+ import { NominalType } from '@bessemer/cornerstone/types';
4
+ import { Comparator } from '@bessemer/cornerstone/comparator';
5
+ import { Result } from '@bessemer/cornerstone/result';
6
+ import { ErrorEvent } from '@bessemer/cornerstone/error/error-event';
7
+ import { TimeUnit } from '@bessemer/cornerstone/temporal/chrono';
8
+ export type Duration = Temporal.Duration;
9
+ export declare const Namespace: import("@bessemer/cornerstone/resource-key").ResourceNamespace<"duration">;
10
+ export type DurationLiteral = NominalType<string, typeof Namespace>;
11
+ export type DurationBuilder = {
12
+ hours?: number;
13
+ minutes?: number;
14
+ seconds?: number;
15
+ milliseconds?: number;
16
+ microseconds?: number;
17
+ nanoseconds?: number;
18
+ };
19
+ export type DurationInput = Duration | DurationLiteral | DurationBuilder;
20
+ export declare const from: (value: DurationInput) => Duration;
21
+ export declare const CompareBy: Comparator<Duration>;
22
+ export declare const EqualBy: import("@bessemer/cornerstone/equalitor").Equalitor<Temporal.Duration>;
23
+ export declare const parseString: (value: string) => Result<Duration, ErrorEvent>;
24
+ export declare const fromString: (value: string) => Duration;
25
+ export declare const toLiteral: (value: Duration) => DurationLiteral;
26
+ export declare const SchemaLiteral: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<DurationLiteral, string>>;
27
+ export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<Temporal.Duration, string>>;
28
+ export declare const isDuration: (value: unknown) => value is Duration;
29
+ export declare const merge: (element: DurationInput, builder: DurationBuilder) => Duration;
30
+ export declare const fromMilliseconds: (value: number) => Duration;
31
+ export declare const toMilliseconds: (duration: DurationInput) => number;
32
+ export declare const fromSeconds: (value: number) => Duration;
33
+ export declare const toSeconds: (duration: DurationInput) => number;
34
+ export declare const fromMinutes: (value: number) => Duration;
35
+ export declare const toMinutes: (duration: DurationInput) => number;
36
+ export declare const fromHours: (value: number) => Duration;
37
+ export declare const toHours: (duration: DurationInput) => number;
38
+ export declare const fromUnit: (value: number, timeUnit: TimeUnit) => Duration;
39
+ export declare const toUnit: (duration: DurationInput, timeUnit: TimeUnit) => number;
40
+ export declare const isZero: (duration: DurationInput) => boolean;
41
+ export declare const round: (element: DurationInput, unit: TimeUnit) => Duration;
42
+ export declare const add: (...durations: Array<DurationInput>) => Duration;
43
+ export declare const subtract: (...durations: Array<DurationInput>) => Duration;
44
+ export declare const negate: (element: DurationInput) => Duration;
45
+ export declare const isEqual: (element: DurationInput, other: DurationInput) => boolean;
46
+ export declare const isLess: (element: DurationInput, other: DurationInput) => boolean;
47
+ export declare const isGreater: (element: DurationInput, other: DurationInput) => boolean;
48
+ export declare const Zero: Temporal.Duration;
49
+ export declare const OneMillisecond: Temporal.Duration;
50
+ export declare const OneSecond: Temporal.Duration;
51
+ export declare const OneMinute: Temporal.Duration;
52
+ export declare const OneHour: Temporal.Duration;
53
+ export declare const OneDay: Temporal.Duration;
54
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/temporal/duration.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAG7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAGhE,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;AACxC,eAAO,MAAM,SAAS,4EAAwB,CAAA;AAC9C,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AACnE,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AACD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,eAAe,GAAG,eAAe,CAAA;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