@bessemer/cornerstone 0.5.97 → 0.5.99

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 (189) hide show
  1. package/dist/array.d.ts +62 -1
  2. package/dist/array.d.ts.map +1 -1
  3. package/dist/array.js +24 -11
  4. package/dist/array.js.map +1 -1
  5. package/dist/aspect-ratio.d.ts +1 -1
  6. package/dist/aspect-ratio.d.ts.map +1 -1
  7. package/dist/aspect-ratio.js +4 -4
  8. package/dist/aspect-ratio.js.map +1 -1
  9. package/dist/async-value.d.ts +10 -2
  10. package/dist/async-value.d.ts.map +1 -1
  11. package/dist/async-value.js +33 -2
  12. package/dist/async-value.js.map +1 -1
  13. package/dist/cache.js +1 -1
  14. package/dist/cache.js.map +1 -1
  15. package/dist/equalitor.d.ts +1 -0
  16. package/dist/equalitor.d.ts.map +1 -1
  17. package/dist/equalitor.js +3 -0
  18. package/dist/equalitor.js.map +1 -1
  19. package/dist/error/error-cause.d.ts +35 -0
  20. package/dist/error/error-cause.d.ts.map +1 -0
  21. package/dist/error/error-cause.js +97 -0
  22. package/dist/error/error-cause.js.map +1 -0
  23. package/dist/error/error-code.d.ts +17 -0
  24. package/dist/error/error-code.d.ts.map +1 -0
  25. package/dist/error/error-code.js +32 -0
  26. package/dist/error/error-code.js.map +1 -0
  27. package/dist/error/error-event.d.ts +29 -48
  28. package/dist/error/error-event.d.ts.map +1 -1
  29. package/dist/error/error-event.js +62 -151
  30. package/dist/error/error-event.js.map +1 -1
  31. package/dist/error/error-type.d.ts +1 -0
  32. package/dist/error/error-type.d.ts.map +1 -1
  33. package/dist/error/error-type.js +4 -2
  34. package/dist/error/error-type.js.map +1 -1
  35. package/dist/function.d.ts +1 -1
  36. package/dist/function.d.ts.map +1 -1
  37. package/dist/function.js +3 -2
  38. package/dist/function.js.map +1 -1
  39. package/dist/glob.d.ts +1 -1
  40. package/dist/glob.d.ts.map +1 -1
  41. package/dist/glob.js +4 -4
  42. package/dist/glob.js.map +1 -1
  43. package/dist/hex-code.d.ts +1 -1
  44. package/dist/hex-code.d.ts.map +1 -1
  45. package/dist/hex-code.js +4 -4
  46. package/dist/hex-code.js.map +1 -1
  47. package/dist/index.d.ts +10 -5
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +15 -5
  50. package/dist/index.js.map +1 -1
  51. package/dist/intl/country-code.d.ts +1 -1
  52. package/dist/intl/country-code.d.ts.map +1 -1
  53. package/dist/intl/country-code.js +4 -4
  54. package/dist/intl/country-code.js.map +1 -1
  55. package/dist/intl/country-subdivision-code.d.ts +1 -1
  56. package/dist/intl/country-subdivision-code.d.ts.map +1 -1
  57. package/dist/intl/country-subdivision-code.js +4 -4
  58. package/dist/intl/country-subdivision-code.js.map +1 -1
  59. package/dist/intl/currency-code.d.ts +1 -1
  60. package/dist/intl/currency-code.d.ts.map +1 -1
  61. package/dist/intl/currency-code.js +4 -4
  62. package/dist/intl/currency-code.js.map +1 -1
  63. package/dist/intl/language-code.d.ts +1 -1
  64. package/dist/intl/language-code.d.ts.map +1 -1
  65. package/dist/intl/language-code.js +4 -4
  66. package/dist/intl/language-code.js.map +1 -1
  67. package/dist/intl/locale.d.ts +1 -1
  68. package/dist/intl/locale.d.ts.map +1 -1
  69. package/dist/intl/locale.js +6 -6
  70. package/dist/intl/locale.js.map +1 -1
  71. package/dist/mime-type.d.ts +1 -1
  72. package/dist/mime-type.d.ts.map +1 -1
  73. package/dist/mime-type.js +4 -4
  74. package/dist/mime-type.js.map +1 -1
  75. package/dist/net/domain-name.d.ts +10 -0
  76. package/dist/net/domain-name.d.ts.map +1 -0
  77. package/dist/net/domain-name.js +30 -0
  78. package/dist/net/domain-name.js.map +1 -0
  79. package/dist/net/ipv4-address.d.ts +10 -0
  80. package/dist/net/ipv4-address.d.ts.map +1 -0
  81. package/dist/net/ipv4-address.js +30 -0
  82. package/dist/net/ipv4-address.js.map +1 -0
  83. package/dist/net/ipv6-address.d.ts +10 -0
  84. package/dist/net/ipv6-address.d.ts.map +1 -0
  85. package/dist/net/ipv6-address.js +30 -0
  86. package/dist/net/ipv6-address.js.map +1 -0
  87. package/dist/net/uri-host-name.d.ts +12 -0
  88. package/dist/net/uri-host-name.d.ts.map +1 -0
  89. package/dist/net/uri-host-name.js +44 -0
  90. package/dist/net/uri-host-name.js.map +1 -0
  91. package/dist/net/uri.d.ts +249 -0
  92. package/dist/net/uri.d.ts.map +1 -0
  93. package/dist/net/uri.js +444 -0
  94. package/dist/net/uri.js.map +1 -0
  95. package/dist/net/url.d.ts +58 -0
  96. package/dist/net/url.d.ts.map +1 -0
  97. package/dist/net/url.js +211 -0
  98. package/dist/net/url.js.map +1 -0
  99. package/dist/object/object-path.d.ts +1 -1
  100. package/dist/object/object-path.d.ts.map +1 -1
  101. package/dist/object/object-path.js +4 -4
  102. package/dist/object/object-path.js.map +1 -1
  103. package/dist/object/type-path.d.ts +1 -1
  104. package/dist/object/type-path.d.ts.map +1 -1
  105. package/dist/object/type-path.js +3 -3
  106. package/dist/object/type-path.js.map +1 -1
  107. package/dist/object.d.ts +1 -1
  108. package/dist/object.d.ts.map +1 -1
  109. package/dist/object.js +8 -6
  110. package/dist/object.js.map +1 -1
  111. package/dist/property.d.ts +2 -3
  112. package/dist/property.d.ts.map +1 -1
  113. package/dist/property.js.map +1 -1
  114. package/dist/resource-key.d.ts +7 -5
  115. package/dist/resource-key.d.ts.map +1 -1
  116. package/dist/resource-key.js +27 -15
  117. package/dist/resource-key.js.map +1 -1
  118. package/dist/result.d.ts.map +1 -1
  119. package/dist/result.js +3 -3
  120. package/dist/result.js.map +1 -1
  121. package/dist/string.d.ts +10 -21
  122. package/dist/string.d.ts.map +1 -1
  123. package/dist/string.js +54 -25
  124. package/dist/string.js.map +1 -1
  125. package/dist/tag.d.ts +2 -2
  126. package/dist/tag.d.ts.map +1 -1
  127. package/dist/tag.js +11 -12
  128. package/dist/tag.js.map +1 -1
  129. package/dist/temporal/duration.d.ts +4 -5
  130. package/dist/temporal/duration.d.ts.map +1 -1
  131. package/dist/temporal/duration.js +3 -7
  132. package/dist/temporal/duration.js.map +1 -1
  133. package/dist/temporal/instant.d.ts +4 -5
  134. package/dist/temporal/instant.d.ts.map +1 -1
  135. package/dist/temporal/instant.js +3 -7
  136. package/dist/temporal/instant.js.map +1 -1
  137. package/dist/temporal/plain-date-time.d.ts +4 -5
  138. package/dist/temporal/plain-date-time.d.ts.map +1 -1
  139. package/dist/temporal/plain-date-time.js +3 -7
  140. package/dist/temporal/plain-date-time.js.map +1 -1
  141. package/dist/temporal/plain-date.d.ts +8 -9
  142. package/dist/temporal/plain-date.d.ts.map +1 -1
  143. package/dist/temporal/plain-date.js +3 -7
  144. package/dist/temporal/plain-date.js.map +1 -1
  145. package/dist/temporal/plain-time.d.ts +6 -7
  146. package/dist/temporal/plain-time.d.ts.map +1 -1
  147. package/dist/temporal/plain-time.js +4 -8
  148. package/dist/temporal/plain-time.js.map +1 -1
  149. package/dist/temporal/time-zone-id.d.ts +1 -1
  150. package/dist/temporal/time-zone-id.d.ts.map +1 -1
  151. package/dist/temporal/time-zone-id.js +4 -4
  152. package/dist/temporal/time-zone-id.js.map +1 -1
  153. package/dist/temporal/time-zone-offset.d.ts +1 -1
  154. package/dist/temporal/time-zone-offset.d.ts.map +1 -1
  155. package/dist/temporal/time-zone-offset.js +4 -4
  156. package/dist/temporal/time-zone-offset.js.map +1 -1
  157. package/dist/temporal/zoned-date-time.d.ts +51 -0
  158. package/dist/temporal/zoned-date-time.d.ts.map +1 -0
  159. package/dist/temporal/zoned-date-time.js +106 -0
  160. package/dist/temporal/zoned-date-time.js.map +1 -0
  161. package/dist/types.d.ts +2 -2
  162. package/dist/types.d.ts.map +1 -1
  163. package/dist/{ulid.d.ts → uuid/ulid.d.ts} +2 -2
  164. package/dist/uuid/ulid.d.ts.map +1 -0
  165. package/dist/uuid/ulid.js +29 -0
  166. package/dist/uuid/ulid.js.map +1 -0
  167. package/dist/uuid/uuid-v4.d.ts +11 -0
  168. package/dist/uuid/uuid-v4.d.ts.map +1 -0
  169. package/dist/{uuid.js → uuid/uuid-v4.js} +11 -11
  170. package/dist/uuid/uuid-v4.js.map +1 -0
  171. package/dist/uuid/uuid-v7.d.ts +18 -0
  172. package/dist/uuid/uuid-v7.d.ts.map +1 -0
  173. package/dist/uuid/uuid-v7.js +44 -0
  174. package/dist/uuid/uuid-v7.js.map +1 -0
  175. package/package.json +1 -1
  176. package/dist/ulid.d.ts.map +0 -1
  177. package/dist/ulid.js +0 -29
  178. package/dist/ulid.js.map +0 -1
  179. package/dist/uri.d.ts +0 -52
  180. package/dist/uri.d.ts.map +0 -1
  181. package/dist/uri.js +0 -222
  182. package/dist/uri.js.map +0 -1
  183. package/dist/url.d.ts +0 -26
  184. package/dist/url.d.ts.map +0 -1
  185. package/dist/url.js +0 -120
  186. package/dist/url.js.map +0 -1
  187. package/dist/uuid.d.ts +0 -11
  188. package/dist/uuid.d.ts.map +0 -1
  189. package/dist/uuid.js.map +0 -1
package/dist/tag.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/tag.ts
2
- import { aggregate, compareBy, natural } from "@bessemer/cornerstone/comparator";
2
+ import * as Comparators from "@bessemer/cornerstone/comparator";
3
3
  import { fromComparator } from "@bessemer/cornerstone/equalitor";
4
4
  import { equalWith, isEmpty, sortWith } from "@bessemer/cornerstone/array";
5
5
  import { properPowerSet } from "@bessemer/cornerstone/set";
@@ -12,17 +12,16 @@ var tag = (type, value2) => {
12
12
  var value = (value2, tags) => {
13
13
  return {
14
14
  value: value2,
15
- tags: sortWith(tags, tagComparator())
15
+ tags: sortWith(tags, CompareBy)
16
16
  };
17
17
  };
18
- var tagComparator = () => {
19
- return aggregate([compareBy((it) => it.type, natural()), compareBy((it) => JSON.stringify(it.value), natural())]);
20
- };
21
- var tagEqualitor = () => {
22
- return fromComparator(tagComparator());
23
- };
18
+ var CompareBy = Comparators.aggregate([
19
+ Comparators.compareBy((it) => it.type, Comparators.natural()),
20
+ Comparators.compareBy((it) => JSON.stringify(it.value), Comparators.natural())
21
+ ]);
22
+ var EqualBy = fromComparator(CompareBy);
24
23
  var serializeTags = (tags) => {
25
- const serializedTags = sortWith(tags, tagComparator()).map(({ type, value: value2 }) => `${type}:${JSON.stringify(value2)}`).join(".");
24
+ const serializedTags = sortWith(tags, CompareBy).map(({ type, value: value2 }) => `${type}:${JSON.stringify(value2)}`).join(".");
26
25
  return serializedTags;
27
26
  };
28
27
  var resolve = (values, tags) => {
@@ -30,7 +29,7 @@ var resolve = (values, tags) => {
30
29
  };
31
30
  var resolveBy = (values, mapper, tags) => {
32
31
  const resolvedValues = properPowerSet(tags).flatMap((tags2) => {
33
- return values.filter((it) => equalWith(mapper(it), tags2, tagEqualitor()));
32
+ return values.filter((it) => equalWith(mapper(it), tags2, EqualBy));
34
33
  });
35
34
  if (isEmpty(resolvedValues)) {
36
35
  const defaultValues = values.filter((it) => isEmpty(mapper(it)));
@@ -39,12 +38,12 @@ var resolveBy = (values, mapper, tags) => {
39
38
  return resolvedValues.reverse();
40
39
  };
41
40
  export {
41
+ CompareBy,
42
+ EqualBy,
42
43
  resolve,
43
44
  resolveBy,
44
45
  serializeTags,
45
46
  tag,
46
- tagComparator,
47
- tagEqualitor,
48
47
  value
49
48
  };
50
49
  //# sourceMappingURL=tag.js.map
package/dist/tag.js.map CHANGED
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["../src/tag.ts"],"sourcesContent":["import { TaggedType } from '@bessemer/cornerstone/types'\nimport * as Comparators from '@bessemer/cornerstone/comparator'\nimport { Comparator } 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, CompareBy),\n }\n}\n\nexport const CompareBy: Comparator<Tag<any>> = Comparators.aggregate([\n Comparators.compareBy((it) => it.type, Comparators.natural()),\n Comparators.compareBy((it) => JSON.stringify(it.value), Comparators.natural()),\n])\n\nexport const EqualBy: Equalitor<Tag<any>> = fromComparator(CompareBy)\n\nexport type SerializedTags = TaggedType<string, 'SerializedTags'>\n\nexport const serializeTags = <T>(tags: Array<Tag<T>>): SerializedTags => {\n const serializedTags: SerializedTags = sortWith(tags, CompareBy)\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, EqualBy))\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,YAAY,iBAAiB;AAE7B,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,SAAS;AAAA,EAChC;AACF;AAEO,IAAM,YAA8C,sBAAU;AAAA,EACvD,sBAAU,CAAC,OAAO,GAAG,MAAkB,oBAAQ,CAAC;AAAA,EAChD,sBAAU,CAAC,OAAO,KAAK,UAAU,GAAG,KAAK,GAAe,oBAAQ,CAAC;AAC/E,CAAC;AAEM,IAAM,UAA+B,eAAe,SAAS;AAI7D,IAAM,gBAAgB,CAAI,SAAwC;AACvE,QAAM,iBAAiC,SAAS,MAAM,SAAS,EAC5D,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,OAAO,CAAC;AAAA,EACnE,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"]}
@@ -17,14 +17,13 @@ export type DurationBuilder = {
17
17
  nanoseconds?: number;
18
18
  };
19
19
  export type DurationLike = Duration | DurationLiteral | DurationBuilder;
20
- export declare function from(value: DurationLike): Duration;
21
- export declare function from(value: DurationLike | null): Duration | null;
22
- export declare function from(value: DurationLike | undefined): Duration | undefined;
23
- export declare function from(value: DurationLike | null | undefined): Duration | null | undefined;
20
+ export declare function from(value: DurationLike | string): Duration;
21
+ export declare function from(value: DurationLike | string | null): Duration | null;
22
+ export declare function from(value: DurationLike | string | undefined): Duration | undefined;
23
+ export declare function from(value: DurationLike | string | null | undefined): Duration | null | undefined;
24
24
  export declare const CompareBy: Comparator<Duration>;
25
25
  export declare const EqualBy: import("@bessemer/cornerstone/equalitor").Equalitor<Temporal.Duration>;
26
26
  export declare const parseString: (value: string) => Result<Duration, ErrorEvent>;
27
- export declare const fromString: (value: string) => Duration;
28
27
  export declare function toLiteral(value: DurationLike): DurationLiteral;
29
28
  export declare function toLiteral(value: DurationLike | null): DurationLiteral | null;
30
29
  export declare function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined;
@@ -1 +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;AAIhE,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,YAAY,GAAG,QAAQ,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AE,YAAY,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAA;AAC1F,wBAAgB,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AASpG,eAAO,MAAM,MAAM,GAAI,SAAS,YAAY,EAAE,OAAO,YAAY,KAAG,OAEnE,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,SAAS,YAAY,EAAE,OAAO,YAAY,KAAG,OAEtE,CAAA;AAED,eAAO,MAAM,IAAI,mBAA2B,CAAA;AAC5C,eAAO,MAAM,cAAc,mBAAsB,CAAA;AACjD,eAAO,MAAM,SAAS,mBAAiB,CAAA;AACvC,eAAO,MAAM,SAAS,mBAAiB,CAAA;AACvC,eAAO,MAAM,OAAO,mBAAe,CAAA;AACnC,eAAO,MAAM,MAAM,mBAAgB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  // src/temporal/duration.ts
2
2
  import Zod from "zod";
3
3
  import { Temporal } from "@js-temporal/polyfill";
4
- import { namespace } from "@bessemer/cornerstone/resource-key";
4
+ import { createNamespace } from "@bessemer/cornerstone/resource-key";
5
5
  import { fromComparator } from "@bessemer/cornerstone/equalitor";
6
6
  import { structuredTransform } from "@bessemer/cornerstone/zod-util";
7
7
  import { failure, mapResult, success } from "@bessemer/cornerstone/result";
@@ -10,7 +10,7 @@ import { isError } from "@bessemer/cornerstone/error/error";
10
10
  import { TimeUnit } from "@bessemer/cornerstone/temporal/chrono";
11
11
  import { isString } from "@bessemer/cornerstone/string";
12
12
  import { isNil } from "@bessemer/cornerstone/object";
13
- var Namespace = namespace("duration");
13
+ var Namespace = createNamespace("duration");
14
14
  function from(value) {
15
15
  if (isNil(value)) {
16
16
  return value;
@@ -19,7 +19,7 @@ function from(value) {
19
19
  return value;
20
20
  }
21
21
  if (isString(value)) {
22
- return fromString(value);
22
+ return unpackResult(parseString(value));
23
23
  }
24
24
  return Temporal.Duration.from(value);
25
25
  }
@@ -35,9 +35,6 @@ var parseString = (value) => {
35
35
  return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
36
36
  }
37
37
  };
38
- var fromString = (value) => {
39
- return unpackResult(parseString(value));
40
- };
41
38
  function toLiteral(value) {
42
39
  if (isNil(value)) {
43
40
  return value;
@@ -150,7 +147,6 @@ export {
150
147
  fromMilliseconds,
151
148
  fromMinutes,
152
149
  fromSeconds,
153
- fromString,
154
150
  fromUnit,
155
151
  isDuration,
156
152
  isEqual,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/duration.ts"],"sourcesContent":["import Zod from 'zod'\nimport { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\n\nexport type Duration = Temporal.Duration\nexport const Namespace = namespace('duration')\nexport type DurationLiteral = NominalType<string, typeof Namespace>\nexport type DurationBuilder = {\n hours?: number\n minutes?: number\n seconds?: number\n milliseconds?: number\n microseconds?: number\n nanoseconds?: number\n}\nexport type DurationLike = Duration | DurationLiteral | DurationBuilder\n\nexport function from(value: DurationLike): Duration\nexport function from(value: DurationLike | null): Duration | null\nexport function from(value: DurationLike | undefined): Duration | undefined\nexport function from(value: DurationLike | null | undefined): Duration | null | undefined\nexport function from(value: DurationLike | null | undefined): Duration | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Duration) {\n return value\n }\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.Duration.from(value)\n}\n\nexport const CompareBy: Comparator<Duration> = (first: Duration, second: Duration): number => Temporal.Duration.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<Duration, ErrorEvent> => {\n try {\n return success(Temporal.Duration.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): Duration => {\n return unpackResult(parseString(value))\n}\n\nexport function toLiteral(value: DurationLike): DurationLiteral\nexport function toLiteral(value: DurationLike | null): DurationLiteral | null\nexport function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return from(value).toString() as DurationLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isDuration = (value: unknown): value is Duration => {\n return value instanceof Temporal.Duration\n}\n\nexport const merge = (element: DurationLike, builder: DurationBuilder): Duration => {\n return from(element).with(builder)\n}\n\nexport const fromMilliseconds = (value: number): Duration => {\n return from({ milliseconds: value })\n}\n\nexport const toMilliseconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Millisecond)\n}\n\nexport const fromSeconds = (value: number): Duration => {\n return from({ seconds: value })\n}\n\nexport const toSeconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Second)\n}\n\nexport const fromMinutes = (value: number): Duration => {\n return from({ minutes: value })\n}\n\nexport const toMinutes = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Minute)\n}\n\nexport const fromHours = (value: number): Duration => {\n return from({ hours: value })\n}\n\nexport const toHours = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Hour)\n}\n\nexport const fromUnit = (value: number, timeUnit: TimeUnit): Duration => {\n switch (timeUnit) {\n case TimeUnit.Nanosecond:\n return from({ nanoseconds: value })\n case TimeUnit.Microsecond:\n return from({ microseconds: value })\n case TimeUnit.Millisecond:\n return from({ milliseconds: value })\n case TimeUnit.Second:\n return from({ seconds: value })\n case TimeUnit.Minute:\n return from({ minutes: value })\n case TimeUnit.Hour:\n return from({ hours: value })\n }\n}\n\nexport const toUnit = (duration: DurationLike, timeUnit: TimeUnit): number => {\n return from(duration).total(timeUnit)\n}\n\nexport const isZero = (duration: DurationLike): boolean => {\n return EqualBy(from(duration), Zero)\n}\n\nexport const round = (element: DurationLike, unit: TimeUnit): Duration => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport const add = (...durations: Array<DurationLike>): Duration => {\n return durations.map((it) => from(it)).reduce((first, second) => first.add(second), Zero)\n}\n\nexport const subtract = (...durations: Array<DurationLike>): Duration => {\n if (durations.length === 0) {\n return Zero\n }\n\n const instances = durations.map((it) => from(it))\n return instances.slice(1).reduce((result, current) => result.subtract(current), instances[0]!)\n}\n\nexport const negate = (element: DurationLike): Duration => {\n return from(element).negated()\n}\n\nexport function isEqual(element: DurationLike, other: DurationLike): boolean\nexport function isEqual(element: DurationLike | null, other: DurationLike | null): boolean\nexport function isEqual(element: DurationLike | undefined, other: DurationLike | undefined): boolean\nexport function isEqual(element: DurationLike | null | undefined, other: DurationLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isLess = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isGreater = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const Zero = from({ nanoseconds: 0 })\nexport const OneMillisecond = fromMilliseconds(1)\nexport const OneSecond = fromSeconds(1)\nexport const OneMinute = fromMinutes(1)\nexport const OneHour = fromHours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K,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,OAAO,KAAK,EAAE,aAAa,EAAE,CAAC;AACpC,IAAM,iBAAiB,iBAAiB,CAAC;AACzC,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,UAAU,UAAU,CAAC;AAC3B,IAAM,SAAS,UAAU,EAAE;","names":["it"]}
1
+ {"version":3,"sources":["../../src/temporal/duration.ts"],"sourcesContent":["import Zod from 'zod'\nimport { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\n\nexport type Duration = Temporal.Duration\nexport const Namespace = createNamespace('duration')\nexport type DurationLiteral = NominalType<string, typeof Namespace>\nexport type DurationBuilder = {\n hours?: number\n minutes?: number\n seconds?: number\n milliseconds?: number\n microseconds?: number\n nanoseconds?: number\n}\nexport type DurationLike = Duration | DurationLiteral | DurationBuilder\n\nexport function from(value: DurationLike | string): Duration\nexport function from(value: DurationLike | string | null): Duration | null\nexport function from(value: DurationLike | string | undefined): Duration | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Duration) {\n return value\n }\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.Duration.from(value)\n}\n\nexport const CompareBy: Comparator<Duration> = (first: Duration, second: Duration): number => Temporal.Duration.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<Duration, ErrorEvent> => {\n try {\n return success(Temporal.Duration.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport function toLiteral(value: DurationLike): DurationLiteral\nexport function toLiteral(value: DurationLike | null): DurationLiteral | null\nexport function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return from(value).toString() as DurationLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isDuration = (value: unknown): value is Duration => {\n return value instanceof Temporal.Duration\n}\n\nexport const merge = (element: DurationLike, builder: DurationBuilder): Duration => {\n return from(element).with(builder)\n}\n\nexport const fromMilliseconds = (value: number): Duration => {\n return from({ milliseconds: value })\n}\n\nexport const toMilliseconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Millisecond)\n}\n\nexport const fromSeconds = (value: number): Duration => {\n return from({ seconds: value })\n}\n\nexport const toSeconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Second)\n}\n\nexport const fromMinutes = (value: number): Duration => {\n return from({ minutes: value })\n}\n\nexport const toMinutes = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Minute)\n}\n\nexport const fromHours = (value: number): Duration => {\n return from({ hours: value })\n}\n\nexport const toHours = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Hour)\n}\n\nexport const fromUnit = (value: number, timeUnit: TimeUnit): Duration => {\n switch (timeUnit) {\n case TimeUnit.Nanosecond:\n return from({ nanoseconds: value })\n case TimeUnit.Microsecond:\n return from({ microseconds: value })\n case TimeUnit.Millisecond:\n return from({ milliseconds: value })\n case TimeUnit.Second:\n return from({ seconds: value })\n case TimeUnit.Minute:\n return from({ minutes: value })\n case TimeUnit.Hour:\n return from({ hours: value })\n }\n}\n\nexport const toUnit = (duration: DurationLike, timeUnit: TimeUnit): number => {\n return from(duration).total(timeUnit)\n}\n\nexport const isZero = (duration: DurationLike): boolean => {\n return EqualBy(from(duration), Zero)\n}\n\nexport const round = (element: DurationLike, unit: TimeUnit): Duration => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport const add = (...durations: Array<DurationLike>): Duration => {\n return durations.map((it) => from(it)).reduce((first, second) => first.add(second), Zero)\n}\n\nexport const subtract = (...durations: Array<DurationLike>): Duration => {\n if (durations.length === 0) {\n return Zero\n }\n\n const instances = durations.map((it) => from(it))\n return instances.slice(1).reduce((result, current) => result.subtract(current), instances[0]!)\n}\n\nexport const negate = (element: DurationLike): Duration => {\n return from(element).negated()\n}\n\nexport function isEqual(element: DurationLike, other: DurationLike): boolean\nexport function isEqual(element: DurationLike | null, other: DurationLike | null): boolean\nexport function isEqual(element: DurationLike | undefined, other: DurationLike | undefined): boolean\nexport function isEqual(element: DurationLike | null | undefined, other: DurationLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isLess = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isGreater = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const Zero = from({ nanoseconds: 0 })\nexport const OneMillisecond = fromMilliseconds(1)\nexport const OneSecond = fromSeconds(1)\nexport const OneMinute = fromMinutes(1)\nexport const OneHour = fromHours(1)\nexport const OneDay = fromHours(24)\n"],"mappings":";AAAA,OAAO,SAAS;AAChB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC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C/B,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,UAAU,UAAU,CAAC;AAC3B,IAAM,SAAS,UAAU,EAAE;","names":["it"]}
@@ -13,14 +13,13 @@ export type Instant = Temporal.Instant;
13
13
  export declare const Namespace: import("@bessemer/cornerstone/resource-key").ResourceNamespace<"instant">;
14
14
  export type InstantLiteral = NominalType<string, typeof Namespace>;
15
15
  export type InstantLike = Instant | Date | InstantLiteral;
16
- export declare function from(value: InstantLike): Instant;
17
- export declare function from(value: InstantLike | null): Instant | null;
18
- export declare function from(value: InstantLike | undefined): Instant | undefined;
19
- export declare function from(value: InstantLike | null | undefined): Instant | null | undefined;
16
+ export declare function from(value: InstantLike | string): Instant;
17
+ export declare function from(value: InstantLike | string | null): Instant | null;
18
+ export declare function from(value: InstantLike | string | undefined): Instant | undefined;
19
+ export declare function from(value: InstantLike | string | null | undefined): Instant | null | undefined;
20
20
  export declare const CompareBy: Comparator<Instant>;
21
21
  export declare const EqualBy: import("@bessemer/cornerstone/equalitor").Equalitor<Temporal.Instant>;
22
22
  export declare const parseString: (value: string) => Result<Instant, ErrorEvent>;
23
- export declare const fromString: (value: string) => Instant;
24
23
  export declare function toLiteral(value: InstantLike): InstantLiteral;
25
24
  export declare function toLiteral(value: InstantLike | null): InstantLiteral | null;
26
25
  export declare function toLiteral(value: InstantLike | undefined): InstantLiteral | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"instant.d.ts","sourceRoot":"","sources":["../../src/temporal/instant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,GAAG,MAAM,KAAK,CAAA;A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
  // src/temporal/instant.ts
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
- import { namespace } from "@bessemer/cornerstone/resource-key";
3
+ import { createNamespace } from "@bessemer/cornerstone/resource-key";
4
4
  import { fromComparator } from "@bessemer/cornerstone/equalitor";
5
5
  import { failure, mapResult, success } from "@bessemer/cornerstone/result";
6
6
  import { invalidValue, unpackResult } from "@bessemer/cornerstone/error/error-event";
@@ -13,7 +13,7 @@ import { _isInstant, instantToLiteral } from "@bessemer/cornerstone/temporal/chr
13
13
  import { isString } from "@bessemer/cornerstone/string";
14
14
  import { isNil } from "@bessemer/cornerstone/object";
15
15
  import { format as formatPlainDateTime, fromInstant } from "@bessemer/cornerstone/temporal/plain-date-time";
16
- var Namespace = namespace("instant");
16
+ var Namespace = createNamespace("instant");
17
17
  function from(value) {
18
18
  if (isNil(value)) {
19
19
  return value;
@@ -22,7 +22,7 @@ function from(value) {
22
22
  return value;
23
23
  }
24
24
  if (isString(value)) {
25
- return fromString(value);
25
+ return unpackResult(parseString(value));
26
26
  }
27
27
  return Temporal.Instant.fromEpochMilliseconds(value.getTime());
28
28
  }
@@ -38,9 +38,6 @@ var parseString = (value) => {
38
38
  return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
39
39
  }
40
40
  };
41
- var fromString = (value) => {
42
- return unpackResult(parseString(value));
43
- };
44
41
  function toLiteral(value) {
45
42
  if (isNil(value)) {
46
43
  return value;
@@ -96,7 +93,6 @@ export {
96
93
  add,
97
94
  format,
98
95
  from,
99
- fromString,
100
96
  isAfter,
101
97
  isBefore,
102
98
  isEqual,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/instant.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { _isInstant, instantToLiteral, TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateTimeFormatOptions, format as formatPlainDateTime, fromInstant } from '@bessemer/cornerstone/temporal/plain-date-time'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\n\nexport type Instant = Temporal.Instant\nexport const Namespace = namespace('instant')\nexport type InstantLiteral = NominalType<string, typeof Namespace>\nexport type InstantLike = Instant | Date | InstantLiteral\n\nexport function from(value: InstantLike): Instant\nexport function from(value: InstantLike | null): Instant | null\nexport function from(value: InstantLike | undefined): Instant | undefined\nexport function from(value: InstantLike | null | undefined): Instant | null | undefined\nexport function from(value: InstantLike | null | undefined): Instant | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Instant) {\n return value\n }\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.Instant.fromEpochMilliseconds(value.getTime())\n}\n\nexport const CompareBy: Comparator<Instant> = (first: Instant, second: Instant): number => Temporal.Instant.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<Instant, ErrorEvent> => {\n try {\n return success(Temporal.Instant.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): Instant => {\n return unpackResult(parseString(value))\n}\n\nexport function toLiteral(value: InstantLike): InstantLiteral\nexport function toLiteral(value: InstantLike | null): InstantLiteral | null\nexport function toLiteral(value: InstantLike | undefined): InstantLiteral | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return instantToLiteral(from(value))\n}\n\nexport function toDate(value: InstantLike): Date\nexport function toDate(value: InstantLike | null): Date | null\nexport function toDate(value: InstantLike | undefined): Date | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return new Date(from(value).epochMilliseconds)\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isInstant = _isInstant\n\nexport const now = (clock = DefaultClock): Instant => {\n return clock.instant()\n}\n\nexport const add = (element: InstantLike, duration: DurationLike): Instant => {\n return from(element).add(fromDuration(duration))\n}\n\nexport const subtract = (element: InstantLike, duration: DurationLike): Instant => {\n return from(element).subtract(fromDuration(duration))\n}\n\nexport const until = (element: InstantLike, other: InstantLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: InstantLike, unit: TimeUnit): Instant => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: InstantLike, other: InstantLike): boolean\nexport function isEqual(element: InstantLike | null, other: InstantLike | null): boolean\nexport function isEqual(element: InstantLike | undefined, other: InstantLike | undefined): boolean\nexport function isEqual(element: InstantLike | null | undefined, other: InstantLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const format = (element: InstantLike, timeZone: TimeZoneId, locale: Locale, options: DateTimeFormatOptions): string => {\n const plainDateTime = fromInstant(from(element), timeZone)\n return formatPlainDateTime(plainDateTime, locale, options)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,oBAAoB;AAC7D,SAAS,YAAY,wBAAkC;AACvD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAEtB,SAAgC,UAAU,qBAAqB,mBAAmB;AAI3E,IAAM,YAAY,UAAU,SAAS;AAQrC,SAAS,KAAK,OAAmE;AACtF,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,SAAO,SAAS,QAAQ,sBAAsB,MAAM,QAAQ,CAAC;AAC/D;AAEO,IAAM,YAAiC,CAAC,OAAgB,WAA4B,SAAS,QAAQ,QAAQ,OAAO,MAAM;AAC1H,IAAM,UAAU,eAAe,SAAS;AAExC,IAAM,cAAc,CAAC,UAA+C;AACzE,MAAI;AACF,WAAO,QAAQ,SAAS,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7C,SAAS,GAAG;AACV,QAAI,CAAC,QAAQ,CAAC,GAAG;AACf,YAAM;AAAA,IACR;AAEA,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,EAClF;AACF;AAEO,IAAM,aAAa,CAAC,UAA2B;AACpD,SAAO,aAAa,YAAY,KAAK,CAAC;AACxC;AAMO,SAAS,UAAU,OAA0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E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,SAAS,CAAC,SAAsB,UAAsB,QAAgB,YAA2C;AAC5H,QAAM,gBAAgB,YAAY,KAAK,OAAO,GAAG,QAAQ;AACzD,SAAO,oBAAoB,eAAe,QAAQ,OAAO;AAC3D;","names":["it"]}
1
+ {"version":3,"sources":["../../src/temporal/instant.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { _isInstant, instantToLiteral, TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateTimeFormatOptions, format as formatPlainDateTime, fromInstant } from '@bessemer/cornerstone/temporal/plain-date-time'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\n\nexport type Instant = Temporal.Instant\nexport const Namespace = createNamespace('instant')\nexport type InstantLiteral = NominalType<string, typeof Namespace>\nexport type InstantLike = Instant | Date | InstantLiteral\n\nexport function from(value: InstantLike | string): Instant\nexport function from(value: InstantLike | string | null): Instant | null\nexport function from(value: InstantLike | string | undefined): Instant | undefined\nexport function from(value: InstantLike | string | null | undefined): Instant | null | undefined\nexport function from(value: InstantLike | string | null | undefined): Instant | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Instant) {\n return value\n }\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.Instant.fromEpochMilliseconds(value.getTime())\n}\n\nexport const CompareBy: Comparator<Instant> = (first: Instant, second: Instant): number => Temporal.Instant.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<Instant, ErrorEvent> => {\n try {\n return success(Temporal.Instant.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport function toLiteral(value: InstantLike): InstantLiteral\nexport function toLiteral(value: InstantLike | null): InstantLiteral | null\nexport function toLiteral(value: InstantLike | undefined): InstantLiteral | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return instantToLiteral(from(value))\n}\n\nexport function toDate(value: InstantLike): Date\nexport function toDate(value: InstantLike | null): Date | null\nexport function toDate(value: InstantLike | undefined): Date | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return new Date(from(value).epochMilliseconds)\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isInstant = _isInstant\n\nexport const now = (clock = DefaultClock): Instant => {\n return clock.instant()\n}\n\nexport const add = (element: InstantLike, duration: DurationLike): Instant => {\n return from(element).add(fromDuration(duration))\n}\n\nexport const subtract = (element: InstantLike, duration: DurationLike): Instant => {\n return from(element).subtract(fromDuration(duration))\n}\n\nexport const until = (element: InstantLike, other: InstantLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: InstantLike, unit: TimeUnit): Instant => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: InstantLike, other: InstantLike): boolean\nexport function isEqual(element: InstantLike | null, other: InstantLike | null): boolean\nexport function isEqual(element: InstantLike | undefined, other: InstantLike | undefined): boolean\nexport function isEqual(element: InstantLike | null | undefined, other: InstantLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const format = (element: InstantLike, timeZone: TimeZoneId, locale: Locale, options: DateTimeFormatOptions): string => {\n const plainDateTime = fromInstant(from(element), timeZone)\n return formatPlainDateTime(plainDateTime, locale, options)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,oBAAoB;AAC7D,SAAS,YAAY,wBAAkC;AACvD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAEtB,SAAgC,UAAU,qBAAqB,mBAAmB;AAI3E,IAAM,YAAY,gBAAgB,SAAS;AAQ3C,SAAS,KAAK,OAA4E;AAC/F,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,aAAa,YAAY,KAAK,CAAC;AAAA,EACxC;AAEA,SAAO,SAAS,QAAQ,sBAAsB,MAAM,QAAQ,CAAC;AAC/D;AAEO,IAA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ACtE,SAAO,KAAK,OAAO,EAAE,MAAM,EAAE,cAAc,KAAK,CAAC;AACnD;AAKO,SAAS,QAAQ,SAAyC,OAAgD;AAC/G,MAAI,MAAM,OAAO,KAAK,MAAM,KAAK,GAAG;AAClC,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,WAAW,CAAC,SAAsB,UAAgC;AAC7E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,UAAU,CAAC,SAAsB,UAAgC;AAC5E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,SAAS,CAAC,SAAsB,UAAsB,QAAgB,YAA2C;AAC5H,QAAM,gBAAgB,YAAY,KAAK,OAAO,GAAG,QAAQ;AACzD,SAAO,oBAAoB,eAAe,QAAQ,OAAO;AAC3D;","names":["it"]}
@@ -16,14 +16,13 @@ export declare const Namespace: import("@bessemer/cornerstone/resource-key").Res
16
16
  export type PlainDateTimeLiteral = NominalType<string, typeof Namespace>;
17
17
  export type PlainDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder;
18
18
  export type PlainDateTimeLike = PlainDateTime | PlainDateTimeLiteral | PlainDateTimeBuilder;
19
- export declare function from(value: PlainDateTimeLike): PlainDateTime;
20
- export declare function from(value: PlainDateTimeLike | null): PlainDateTime | null;
21
- export declare function from(value: PlainDateTimeLike | undefined): PlainDateTime | undefined;
22
- export declare function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined;
19
+ export declare function from(value: PlainDateTimeLike | string): PlainDateTime;
20
+ export declare function from(value: PlainDateTimeLike | string | null): PlainDateTime | null;
21
+ export declare function from(value: PlainDateTimeLike | string | undefined): PlainDateTime | undefined;
22
+ export declare function from(value: PlainDateTimeLike | string | null | undefined): PlainDateTime | null | undefined;
23
23
  export declare const CompareBy: Comparator<PlainDateTime>;
24
24
  export declare const EqualBy: import("@bessemer/cornerstone/equalitor").Equalitor<Temporal.PlainDateTime>;
25
25
  export declare const parseString: (value: string) => Result<PlainDateTime, ErrorEvent>;
26
- export declare const fromString: (value: string) => PlainDateTime;
27
26
  export declare const fromInstant: (instant: InstantLike, zone: TimeZoneId) => PlainDateTime;
28
27
  export declare function toLiteral(likeValue: PlainDateTimeLike): PlainDateTimeLiteral;
29
28
  export declare function toLiteral(likeValue: PlainDateTimeLike | null): PlainDateTimeLiteral | null;
@@ -1 +1 @@
1
- {"version":3,"file":"plain-date-time.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAyB,MAAM,yCAAyC,CAAA;AACvG,OAAO,EAAwB,WAAW,EAAE,MAAM,wCAAwC,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAGhE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAA;AAE/F,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAA;AAClD,eAAO,MAAM,SAAS,mFAA+B,CAAA;AACrD,MAAM,MAA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AAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,iBAAiB,EAAE,SAAS,oBAAoB,KAAG,aAEjF,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,SAAS,iBAAiB,EAAE,UAAU,YAAY,KAAG,aAExE,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,SAAS,iBAAiB,EAAE,UAAU,YAAY,KAAG,aAE7E,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,iBAAiB,EAAE,OAAO,iBAAiB,KAAG,QAE5E,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,iBAAiB,EAAE,MAAM,QAAQ,KAAG,aAElE,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAA;AACtF,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAA;AACpG,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,EAAE,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAA;AAS9G,eAAO,MAAM,QAAQ,GAAI,SAAS,iBAAiB,EAAE,OAAO,iBAAiB,KAAG,OAE/E,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,SAAS,iBAAiB,EAAE,OAAO,iBAAiB,KAAG,OAE9E,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,iBAAiB,CAAA;AAEzE,eAAO,MAAM,MAAM,GAAI,SAAS,iBAAiB,EAAE,QAAQ,MAAM,EAAE,SAAS,qBAAqB,KAAG,MAgBnG,CAAA"}
@@ -1,6 +1,6 @@
1
1
  // src/temporal/plain-date-time.ts
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
- import { namespace } from "@bessemer/cornerstone/resource-key";
3
+ import { createNamespace } from "@bessemer/cornerstone/resource-key";
4
4
  import { fromComparator } from "@bessemer/cornerstone/equalitor";
5
5
  import { failure, mapResult, success } from "@bessemer/cornerstone/result";
6
6
  import { invalidValue, unpackResult } from "@bessemer/cornerstone/error/error-event";
@@ -12,7 +12,7 @@ import { from as _fromDuration } from "@bessemer/cornerstone/temporal/duration";
12
12
  import { from as _fromInstant } from "@bessemer/cornerstone/temporal/instant";
13
13
  import { isString } from "@bessemer/cornerstone/string";
14
14
  import { isNil } from "@bessemer/cornerstone/object";
15
- var Namespace = namespace("plain-date-time");
15
+ var Namespace = createNamespace("plain-date-time");
16
16
  function from(value) {
17
17
  if (isNil(value)) {
18
18
  return value;
@@ -21,7 +21,7 @@ function from(value) {
21
21
  return value;
22
22
  }
23
23
  if (isString(value)) {
24
- return fromString(value);
24
+ return unpackResult(parseString(value));
25
25
  }
26
26
  return Temporal.PlainDateTime.from(value);
27
27
  }
@@ -37,9 +37,6 @@ var parseString = (value) => {
37
37
  return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
38
38
  }
39
39
  };
40
- var fromString = (value) => {
41
- return unpackResult(parseString(value));
42
- };
43
40
  var fromInstant = (instant, zone) => {
44
41
  return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDateTime();
45
42
  };
@@ -110,7 +107,6 @@ export {
110
107
  format,
111
108
  from,
112
109
  fromInstant,
113
- fromString,
114
110
  isAfter,
115
111
  isBefore,
116
112
  isEqual,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/plain-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date'\n\nexport type PlainDateTime = Temporal.PlainDateTime\nexport const Namespace = namespace('plain-date-time')\nexport type PlainDateTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder\n\nexport type PlainDateTimeLike = PlainDateTime | PlainDateTimeLiteral | PlainDateTimeBuilder\n\nexport function from(value: PlainDateTimeLike): PlainDateTime\nexport function from(value: PlainDateTimeLike | null): PlainDateTime | null\nexport function from(value: PlainDateTimeLike | undefined): PlainDateTime | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDateTime) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDateTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDateTime> = (first: PlainDateTime, second: PlainDateTime): number =>\n Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDateTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainDateTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDateTime => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDateTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDateTime()\n}\n\nexport function toLiteral(likeValue: PlainDateTimeLike): PlainDateTimeLiteral\nexport function toLiteral(likeValue: PlainDateTimeLike | null): PlainDateTimeLiteral | null\nexport function toLiteral(likeValue: PlainDateTimeLike | undefined): PlainDateTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDateTime => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDateTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateTimeLike, builder: PlainDateTimeBuilder): PlainDateTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateTimeLike, other: PlainDateTimeLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainDateTimeLike, unit: TimeUnit): PlainDateTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainDateTimeLike, other: PlainDateTimeLike): boolean\nexport function isEqual(element: PlainDateTimeLike | null, other: PlainDateTimeLike | null): boolean\nexport function isEqual(element: PlainDateTimeLike | undefined, other: PlainDateTimeLike | undefined): boolean\nexport function isEqual(element: PlainDateTimeLike | null | undefined, other: PlainDateTimeLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateTimeFormatOptions = DateFormatOptions & TimeFormatOptions\n\nexport const format = (element: PlainDateTimeLike, locale: Locale, options: DateTimeFormatOptions): string => {\n const plainDateTime = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDateTime.year,\n plainDateTime.month - 1, // Date months are 0-based\n plainDateTime.day,\n plainDateTime.hour,\n plainDateTime.minute,\n plainDateTime.second,\n plainDateTime.millisecond\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,QAAQ,oBAAiC;AAGlD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAMf,IAAM,YAAY,UAAU,iBAAiB;AAU7C,SAAS,KAAK,OAA+E;AAClG,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,eAAe;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GA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aAA0C;AACxF,SAAO,KAAK,OAAO,EAAE,IAAI,cAAc,QAAQ,CAAC;AAClD;AAEO,IAAM,WAAW,CAAC,SAA4B,aAA0C;AAC7F,SAAO,KAAK,OAAO,EAAE,SAAS,cAAc,QAAQ,CAAC;AACvD;AAEO,IAAM,QAAQ,CAAC,SAA4B,UAAuC;AACvF,SAAO,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;AACxC;AAEO,IAAM,QAAQ,CAAC,SAA4B,SAAkC;AAClF,SAAO,KAAK,OAAO,EAAE,MAAM,EAAE,cAAc,KAAK,CAAC;AACnD;AAKO,SAAS,QAAQ,SAA+C,OAAsD;AAC3H,MAAI,MAAM,OAAO,KAAK,MAAM,KAAK,GAAG;AAClC,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,WAAW,CAAC,SAA4B,UAAsC;AACzF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,UAAU,CAAC,SAA4B,UAAsC;AACxF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAIO,IAAM,SAAS,CAAC,SAA4B,QAAgB,YAA2C;AAC5G,QAAM,gBAAgB,KAAK,OAAO;AAGlC,QAAM,OAAO,IAAI;AAAA,IACf,cAAc;AAAA,IACd,cAAc,QAAQ;AAAA;AAAA,IACtB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,EAChB;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;","names":["it"]}
1
+ {"version":3,"sources":["../../src/temporal/plain-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date'\n\nexport type PlainDateTime = Temporal.PlainDateTime\nexport const Namespace = createNamespace('plain-date-time')\nexport type PlainDateTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder\n\nexport type PlainDateTimeLike = PlainDateTime | PlainDateTimeLiteral | PlainDateTimeBuilder\n\nexport function from(value: PlainDateTimeLike | string): PlainDateTime\nexport function from(value: PlainDateTimeLike | string | null): PlainDateTime | null\nexport function from(value: PlainDateTimeLike | string | undefined): PlainDateTime | undefined\nexport function from(value: PlainDateTimeLike | string | null | undefined): PlainDateTime | null | undefined\nexport function from(value: PlainDateTimeLike | string | null | undefined): PlainDateTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDateTime) {\n return value\n }\n\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.PlainDateTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDateTime> = (first: PlainDateTime, second: PlainDateTime): number =>\n Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDateTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainDateTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDateTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDateTime()\n}\n\nexport function toLiteral(likeValue: PlainDateTimeLike): PlainDateTimeLiteral\nexport function toLiteral(likeValue: PlainDateTimeLike | null): PlainDateTimeLiteral | null\nexport function toLiteral(likeValue: PlainDateTimeLike | undefined): PlainDateTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDateTime => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDateTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateTimeLike, builder: PlainDateTimeBuilder): PlainDateTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateTimeLike, other: PlainDateTimeLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainDateTimeLike, unit: TimeUnit): PlainDateTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainDateTimeLike, other: PlainDateTimeLike): boolean\nexport function isEqual(element: PlainDateTimeLike | null, other: PlainDateTimeLike | null): boolean\nexport function isEqual(element: PlainDateTimeLike | undefined, other: PlainDateTimeLike | undefined): boolean\nexport function isEqual(element: PlainDateTimeLike | null | undefined, other: PlainDateTimeLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateTimeFormatOptions = DateFormatOptions & TimeFormatOptions\n\nexport const format = (element: PlainDateTimeLike, locale: Locale, options: DateTimeFormatOptions): string => {\n const plainDateTime = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDateTime.year,\n plainDateTime.month - 1, // Date months are 0-based\n plainDateTime.day,\n plainDateTime.hour,\n plainDateTime.minute,\n plainDateTime.second,\n plainDateTime.millisecond\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,QAAQ,oBAAiC;AAGlD,SAAS,gBAAgB;AACzB,S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AI;AAC9B;","names":["it"]}
@@ -12,19 +12,18 @@ export type PlainDate = Temporal.PlainDate;
12
12
  export declare const Namespace: import("@bessemer/cornerstone/resource-key").ResourceNamespace<"plain-date">;
13
13
  export type PlainDateLiteral = NominalType<string, typeof Namespace>;
14
14
  export type PlainDateBuilder = {
15
- year?: number;
16
- month?: number;
17
- day?: number;
15
+ year: number;
16
+ month: number;
17
+ day: number;
18
18
  };
19
19
  export type PlainDateLike = PlainDate | PlainDateLiteral | PlainDateBuilder;
20
- export declare function from(value: PlainDateLike): PlainDate;
21
- export declare function from(value: PlainDateLike | null): PlainDate | null;
22
- export declare function from(value: PlainDateLike | undefined): PlainDate | undefined;
23
- export declare function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined;
20
+ export declare function from(value: PlainDateLike | string): PlainDate;
21
+ export declare function from(value: PlainDateLike | string | null): PlainDate | null;
22
+ export declare function from(value: PlainDateLike | string | undefined): PlainDate | undefined;
23
+ export declare function from(value: PlainDateLike | string | null | undefined): PlainDate | null | undefined;
24
24
  export declare const CompareBy: Comparator<PlainDate>;
25
25
  export declare const EqualBy: import("@bessemer/cornerstone/equalitor").Equalitor<Temporal.PlainDate>;
26
26
  export declare const parseString: (value: string) => Result<PlainDate, ErrorEvent>;
27
- export declare const fromString: (value: string) => PlainDate;
28
27
  export declare const fromInstant: (instant: InstantLike, zone: TimeZoneId) => PlainDate;
29
28
  export declare function toLiteral(likeValue: PlainDateLike): PlainDateLiteral;
30
29
  export declare function toLiteral(likeValue: PlainDateLike | null): PlainDateLiteral | null;
@@ -38,7 +37,7 @@ export declare const now: (zone: TimeZoneId, clock?: {
38
37
  instant(): import("@bessemer/cornerstone/temporal/instant").Instant;
39
38
  withZone(zone: TimeZoneId): import("@bessemer/cornerstone/temporal/clock").Clock;
40
39
  }) => PlainDate;
41
- export declare const merge: (element: PlainDateLike, builder: PlainDateBuilder) => PlainDate;
40
+ export declare const merge: (element: PlainDateLike, builder: Partial<PlainDateBuilder>) => PlainDate;
42
41
  export declare const add: (element: PlainDateLike, duration: DurationLike) => PlainDate;
43
42
  export declare const subtract: (element: PlainDateLike, duration: DurationLike) => PlainDate;
44
43
  export declare const until: (element: PlainDateLike, other: PlainDateLike) => Duration;
@@ -1 +1 @@
1
- {"version":3,"file":"plain-date.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAyB,MAAM,yCAAyC,CAAA;AACvG,OAAO,EAAwB,WAAW,EAAE,MAAM,wCAAwC,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AAGxE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE1D,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;AAC1C,eAAO,MAAM,SAAS,8EAA0B,CAAA;AAChD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AACpE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,gBAAgB,GAAG,gBAAgB,CAAA;AAE3E,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAAA;AACrD,wBAAgB,IAAI,CA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a,EAAE,UAAU,YAAY,KAAG,SAEzE,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,aAAa,EAAE,OAAO,aAAa,KAAG,QAEpE,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAA;AAC9E,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAA;AAC5F,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAA;AAStG,eAAO,MAAM,QAAQ,GAAI,SAAS,aAAa,EAAE,OAAO,SAAS,KAAG,OAEnE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,SAAS,aAAa,EAAE,OAAO,SAAS,KAAG,OAElE,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC7C,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACjD,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IACxC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACvE,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,SAAS,aAAa,EAAE,QAAQ,MAAM,EAAE,SAAS,iBAAiB,KAAG,MAY3F,CAAA"}
@@ -1,6 +1,6 @@
1
1
  // src/temporal/plain-date.ts
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
- import { namespace } from "@bessemer/cornerstone/resource-key";
3
+ import { createNamespace } from "@bessemer/cornerstone/resource-key";
4
4
  import { fromComparator } from "@bessemer/cornerstone/equalitor";
5
5
  import { failure, mapResult, success } from "@bessemer/cornerstone/result";
6
6
  import { invalidValue, unpackResult } from "@bessemer/cornerstone/error/error-event";
@@ -12,7 +12,7 @@ import { from as _fromDuration } from "@bessemer/cornerstone/temporal/duration";
12
12
  import { from as _fromInstant } from "@bessemer/cornerstone/temporal/instant";
13
13
  import { isString } from "@bessemer/cornerstone/string";
14
14
  import { isNil } from "@bessemer/cornerstone/object";
15
- var Namespace = namespace("plain-date");
15
+ var Namespace = createNamespace("plain-date");
16
16
  function from(value) {
17
17
  if (isNil(value)) {
18
18
  return value;
@@ -21,7 +21,7 @@ function from(value) {
21
21
  return value;
22
22
  }
23
23
  if (isString(value)) {
24
- return fromString(value);
24
+ return unpackResult(parseString(value));
25
25
  }
26
26
  return Temporal.PlainDate.from(value);
27
27
  }
@@ -37,9 +37,6 @@ var parseString = (value) => {
37
37
  return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
38
38
  }
39
39
  };
40
- var fromString = (value) => {
41
- return unpackResult(parseString(value));
42
- };
43
40
  var fromInstant = (instant, zone) => {
44
41
  return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDate();
45
42
  };
@@ -103,7 +100,6 @@ export {
103
100
  format,
104
101
  from,
105
102
  fromInstant,
106
- fromString,
107
103
  isAfter,
108
104
  isBefore,
109
105
  isEqual,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/plain-date.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainDate = Temporal.PlainDate\nexport const Namespace = namespace('plain-date')\nexport type PlainDateLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateBuilder = {\n year?: number\n month?: number\n day?: number\n}\n\nexport type PlainDateLike = PlainDate | PlainDateLiteral | PlainDateBuilder\n\nexport function from(value: PlainDateLike): PlainDate\nexport function from(value: PlainDateLike | null): PlainDate | null\nexport function from(value: PlainDateLike | undefined): PlainDate | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDate) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDate.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDate> = (first: PlainDate, second: PlainDate): number => Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDate, ErrorEvent> => {\n try {\n return success(Temporal.PlainDate.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDate => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDate => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDate()\n}\n\nexport function toLiteral(likeValue: PlainDateLike): PlainDateLiteral\nexport function toLiteral(likeValue: PlainDateLike | null): PlainDateLiteral | null\nexport function toLiteral(likeValue: PlainDateLike | undefined): PlainDateLiteral | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDate => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDate => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateLike, builder: PlainDateBuilder): PlainDate => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateLike, other: PlainDateLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport function isEqual(element: PlainDateLike, other: PlainDateLike): boolean\nexport function isEqual(element: PlainDateLike | null, other: PlainDateLike | null): boolean\nexport function isEqual(element: PlainDateLike | undefined, other: PlainDateLike | undefined): boolean\nexport function isEqual(element: PlainDateLike | null | undefined, other: PlainDateLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateFormatOptions = {\n era?: 'long' | 'short' | 'narrow' | undefined\n weekday?: 'long' | 'short' | 'narrow' | undefined\n year?: 'numeric' | '2-digit' | undefined\n month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined\n day?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainDateLike, locale: Locale, options: DateFormatOptions): string => {\n const plainDate = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDate.year,\n plainDate.month - 1, // Date months are 0-based\n plainDate.day\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,QAAQ,oBAAiC;AAElD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAIf,IAAM,YAAY,UAAU,YAAY;AAcxC,SAAS,KAAK,OAAuE;AAC1F,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,WAAW;AACvC,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,SAAO,SAAS,UAAU,KAAK,KAAK;AACtC;AAEO,IAAM,YAAmC,CAAC,OAAkB,WAA8B,SAAS,cAAc,QAAQ,OAAO,MAAM;AACtI,IAAM,UAAU,eAAe,SAAS;AAExC,IAAM,cAAc,CAAC,UAAiD;AAC3E,MAAI;AACF,WAAO,QAAQ,SAAS,UAAU,KAAK,KAAK,CAAC;AAAA,EAC/C,SAAS,GAAG;AACV,QAAI,CAAC,QAAQ,CAAC,GAAG;AACf,YAAM;AAAA,IACR;AAEA,W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;AAAA,EACrB;AAEA,SAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,WAAW,CAAC,SAAwB,UAA8B;AAC7E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,UAAU,CAAC,SAAwB,UAA8B;AAC5E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAUO,IAAM,SAAS,CAAC,SAAwB,QAAgB,YAAuC;AACpG,QAAM,YAAY,KAAK,OAAO;AAG9B,QAAM,OAAO,IAAI;AAAA,IACf,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA;AAAA,IAClB,UAAU;AAAA,EACZ;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;","names":["it"]}
1
+ {"version":3,"sources":["../../src/temporal/plain-date.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainDate = Temporal.PlainDate\nexport const Namespace = createNamespace('plain-date')\nexport type PlainDateLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateBuilder = {\n year: number\n month: number\n day: number\n}\n\nexport type PlainDateLike = PlainDate | PlainDateLiteral | PlainDateBuilder\n\nexport function from(value: PlainDateLike | string): PlainDate\nexport function from(value: PlainDateLike | string | null): PlainDate | null\nexport function from(value: PlainDateLike | string | undefined): PlainDate | undefined\nexport function from(value: PlainDateLike | string | null | undefined): PlainDate | null | undefined\nexport function from(value: PlainDateLike | string | null | undefined): PlainDate | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDate) {\n return value\n }\n\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.PlainDate.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDate> = (first: PlainDate, second: PlainDate): number => Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDate, ErrorEvent> => {\n try {\n return success(Temporal.PlainDate.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDate => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDate()\n}\n\nexport function toLiteral(likeValue: PlainDateLike): PlainDateLiteral\nexport function toLiteral(likeValue: PlainDateLike | null): PlainDateLiteral | null\nexport function toLiteral(likeValue: PlainDateLike | undefined): PlainDateLiteral | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDate => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDate => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateLike, builder: Partial<PlainDateBuilder>): PlainDate => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateLike, other: PlainDateLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport function isEqual(element: PlainDateLike, other: PlainDateLike): boolean\nexport function isEqual(element: PlainDateLike | null, other: PlainDateLike | null): boolean\nexport function isEqual(element: PlainDateLike | undefined, other: PlainDateLike | undefined): boolean\nexport function isEqual(element: PlainDateLike | null | undefined, other: PlainDateLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateFormatOptions = {\n era?: 'long' | 'short' | 'narrow' | undefined\n weekday?: 'long' | 'short' | 'narrow' | undefined\n year?: 'numeric' | '2-digit' | undefined\n month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined\n day?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainDateLike, locale: Locale, options: DateFormatOptions): string => {\n const plainDate = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDate.year,\n plainDate.month - 1, // Date months are 0-based\n plainDate.day\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return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