@dereekb/util 0.0.1

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 (212) hide show
  1. package/README.md +7 -0
  2. package/package.json +10 -0
  3. package/src/index.d.ts +2 -0
  4. package/src/index.js +6 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/array/array.boolean.d.ts +28 -0
  7. package/src/lib/array/array.boolean.js +59 -0
  8. package/src/lib/array/array.boolean.js.map +1 -0
  9. package/src/lib/array/array.d.ts +60 -0
  10. package/src/lib/array/array.filter.d.ts +13 -0
  11. package/src/lib/array/array.filter.js +48 -0
  12. package/src/lib/array/array.filter.js.map +1 -0
  13. package/src/lib/array/array.js +149 -0
  14. package/src/lib/array/array.js.map +1 -0
  15. package/src/lib/array/array.limit.d.ts +13 -0
  16. package/src/lib/array/array.limit.js +19 -0
  17. package/src/lib/array/array.limit.js.map +1 -0
  18. package/src/lib/array/array.map.d.ts +18 -0
  19. package/src/lib/array/array.map.js +26 -0
  20. package/src/lib/array/array.map.js.map +1 -0
  21. package/src/lib/array/array.number.d.ts +21 -0
  22. package/src/lib/array/array.number.js +58 -0
  23. package/src/lib/array/array.number.js.map +1 -0
  24. package/src/lib/array/array.set.d.ts +20 -0
  25. package/src/lib/array/array.set.js +64 -0
  26. package/src/lib/array/array.set.js.map +1 -0
  27. package/src/lib/array/array.string.d.ts +8 -0
  28. package/src/lib/array/array.string.js +36 -0
  29. package/src/lib/array/array.string.js.map +1 -0
  30. package/src/lib/array/array.unique.d.ts +6 -0
  31. package/src/lib/array/array.unique.js +29 -0
  32. package/src/lib/array/array.unique.js.map +1 -0
  33. package/src/lib/array/array.value.d.ts +3 -0
  34. package/src/lib/array/array.value.js +17 -0
  35. package/src/lib/array/array.value.js.map +1 -0
  36. package/src/lib/array/index.d.ts +10 -0
  37. package/src/lib/array/index.js +14 -0
  38. package/src/lib/array/index.js.map +1 -0
  39. package/src/lib/assertion/assert.d.ts +15 -0
  40. package/src/lib/assertion/assert.error.d.ts +32 -0
  41. package/src/lib/assertion/assert.error.js +43 -0
  42. package/src/lib/assertion/assert.error.js.map +1 -0
  43. package/src/lib/assertion/assert.js +3 -0
  44. package/src/lib/assertion/assert.js.map +1 -0
  45. package/src/lib/assertion/assertion.d.ts +18 -0
  46. package/src/lib/assertion/assertion.generic.d.ts +3 -0
  47. package/src/lib/assertion/assertion.generic.js +10 -0
  48. package/src/lib/assertion/assertion.generic.js.map +1 -0
  49. package/src/lib/assertion/assertion.js +40 -0
  50. package/src/lib/assertion/assertion.js.map +1 -0
  51. package/src/lib/assertion/assertion.number.d.ts +3 -0
  52. package/src/lib/assertion/assertion.number.js +20 -0
  53. package/src/lib/assertion/assertion.number.js.map +1 -0
  54. package/src/lib/assertion/index.d.ts +5 -0
  55. package/src/lib/assertion/index.js +9 -0
  56. package/src/lib/assertion/index.js.map +1 -0
  57. package/src/lib/boolean.d.ts +5 -0
  58. package/src/lib/boolean.js +30 -0
  59. package/src/lib/boolean.js.map +1 -0
  60. package/src/lib/contact/domain.d.ts +16 -0
  61. package/src/lib/contact/domain.js +45 -0
  62. package/src/lib/contact/domain.js.map +1 -0
  63. package/src/lib/contact/email.d.ts +17 -0
  64. package/src/lib/contact/email.js +32 -0
  65. package/src/lib/contact/email.js.map +1 -0
  66. package/src/lib/contact/index.d.ts +3 -0
  67. package/src/lib/contact/index.js +7 -0
  68. package/src/lib/contact/index.js.map +1 -0
  69. package/src/lib/contact/phone.d.ts +8 -0
  70. package/src/lib/contact/phone.js +3 -0
  71. package/src/lib/contact/phone.js.map +1 -0
  72. package/src/lib/context/context.d.ts +1 -0
  73. package/src/lib/context/context.js +6 -0
  74. package/src/lib/context/context.js.map +1 -0
  75. package/src/lib/context/index.d.ts +0 -0
  76. package/src/lib/context/index.js +2 -0
  77. package/src/lib/context/index.js.map +1 -0
  78. package/src/lib/date/date.d.ts +52 -0
  79. package/src/lib/date/date.js +12 -0
  80. package/src/lib/date/date.js.map +1 -0
  81. package/src/lib/date/date.time.d.ts +29 -0
  82. package/src/lib/date/date.time.js +27 -0
  83. package/src/lib/date/date.time.js.map +1 -0
  84. package/src/lib/date/index.d.ts +2 -0
  85. package/src/lib/date/index.js +6 -0
  86. package/src/lib/date/index.js.map +1 -0
  87. package/src/lib/error/error.d.ts +30 -0
  88. package/src/lib/error/error.js +36 -0
  89. package/src/lib/error/error.js.map +1 -0
  90. package/src/lib/error/error.server.d.ts +37 -0
  91. package/src/lib/error/error.server.js +22 -0
  92. package/src/lib/error/error.server.js.map +1 -0
  93. package/src/lib/error/index.d.ts +2 -0
  94. package/src/lib/error/index.js +6 -0
  95. package/src/lib/error/index.js.map +1 -0
  96. package/src/lib/filter/filter.d.ts +5 -0
  97. package/src/lib/filter/filter.js +3 -0
  98. package/src/lib/filter/filter.js.map +1 -0
  99. package/src/lib/filter/index.d.ts +1 -0
  100. package/src/lib/filter/index.js +5 -0
  101. package/src/lib/filter/index.js.map +1 -0
  102. package/src/lib/getter.d.ts +16 -0
  103. package/src/lib/getter.js +19 -0
  104. package/src/lib/getter.js.map +1 -0
  105. package/src/lib/grouping.d.ts +98 -0
  106. package/src/lib/grouping.js +164 -0
  107. package/src/lib/grouping.js.map +1 -0
  108. package/src/lib/hash.d.ts +5 -0
  109. package/src/lib/hash.js +21 -0
  110. package/src/lib/hash.js.map +1 -0
  111. package/src/lib/index.d.ts +26 -0
  112. package/src/lib/index.js +31 -0
  113. package/src/lib/index.js.map +1 -0
  114. package/src/lib/iterate.d.ts +6 -0
  115. package/src/lib/iterate.js +16 -0
  116. package/src/lib/iterate.js.map +1 -0
  117. package/src/lib/key.d.ts +11 -0
  118. package/src/lib/key.js +3 -0
  119. package/src/lib/key.js.map +1 -0
  120. package/src/lib/lifecycle.d.ts +12 -0
  121. package/src/lib/lifecycle.js +3 -0
  122. package/src/lib/lifecycle.js.map +1 -0
  123. package/src/lib/map.d.ts +2 -0
  124. package/src/lib/map.js +3 -0
  125. package/src/lib/map.js.map +1 -0
  126. package/src/lib/model.d.ts +74 -0
  127. package/src/lib/model.js +138 -0
  128. package/src/lib/model.js.map +1 -0
  129. package/src/lib/number.d.ts +18 -0
  130. package/src/lib/number.js +29 -0
  131. package/src/lib/number.js.map +1 -0
  132. package/src/lib/object/index.d.ts +3 -0
  133. package/src/lib/object/index.js +7 -0
  134. package/src/lib/object/index.js.map +1 -0
  135. package/src/lib/object/object.array.d.ts +9 -0
  136. package/src/lib/object/object.array.js +35 -0
  137. package/src/lib/object/object.array.js.map +1 -0
  138. package/src/lib/object/object.d.ts +12 -0
  139. package/src/lib/object/object.equal.d.ts +4 -0
  140. package/src/lib/object/object.equal.js +12 -0
  141. package/src/lib/object/object.equal.js.map +1 -0
  142. package/src/lib/object/object.js +38 -0
  143. package/src/lib/object/object.js.map +1 -0
  144. package/src/lib/page/index.d.ts +3 -0
  145. package/src/lib/page/index.js +7 -0
  146. package/src/lib/page/index.js.map +1 -0
  147. package/src/lib/page/page.calculator.d.ts +24 -0
  148. package/src/lib/page/page.calculator.js +37 -0
  149. package/src/lib/page/page.calculator.js.map +1 -0
  150. package/src/lib/page/page.d.ts +28 -0
  151. package/src/lib/page/page.filter.d.ts +54 -0
  152. package/src/lib/page/page.filter.js +68 -0
  153. package/src/lib/page/page.filter.js.map +1 -0
  154. package/src/lib/page/page.js +30 -0
  155. package/src/lib/page/page.js.map +1 -0
  156. package/src/lib/promise/index.d.ts +2 -0
  157. package/src/lib/promise/index.js +6 -0
  158. package/src/lib/promise/index.js.map +1 -0
  159. package/src/lib/promise/promise.d.ts +42 -0
  160. package/src/lib/promise/promise.js +117 -0
  161. package/src/lib/promise/promise.js.map +1 -0
  162. package/src/lib/promise/promise.loop.d.ts +12 -0
  163. package/src/lib/promise/promise.loop.js +30 -0
  164. package/src/lib/promise/promise.loop.js.map +1 -0
  165. package/src/lib/relation/index.d.ts +1 -0
  166. package/src/lib/relation/index.js +5 -0
  167. package/src/lib/relation/index.js.map +1 -0
  168. package/src/lib/relation/relation.d.ts +95 -0
  169. package/src/lib/relation/relation.js +209 -0
  170. package/src/lib/relation/relation.js.map +1 -0
  171. package/src/lib/set.d.ts +0 -0
  172. package/src/lib/set.hashset.d.ts +28 -0
  173. package/src/lib/set.hashset.js +66 -0
  174. package/src/lib/set.hashset.js.map +1 -0
  175. package/src/lib/set.js +2 -0
  176. package/src/lib/set.js.map +1 -0
  177. package/src/lib/sort.d.ts +45 -0
  178. package/src/lib/sort.js +25 -0
  179. package/src/lib/sort.js.map +1 -0
  180. package/src/lib/storage/index.d.ts +4 -0
  181. package/src/lib/storage/index.js +8 -0
  182. package/src/lib/storage/index.js.map +1 -0
  183. package/src/lib/storage/storage.d.ts +11 -0
  184. package/src/lib/storage/storage.error.d.ts +12 -0
  185. package/src/lib/storage/storage.error.js +20 -0
  186. package/src/lib/storage/storage.error.js.map +1 -0
  187. package/src/lib/storage/storage.js +3 -0
  188. package/src/lib/storage/storage.js.map +1 -0
  189. package/src/lib/storage/storage.memory.d.ts +14 -0
  190. package/src/lib/storage/storage.memory.js +47 -0
  191. package/src/lib/storage/storage.memory.js.map +1 -0
  192. package/src/lib/storage/storage.object.d.ts +32 -0
  193. package/src/lib/storage/storage.object.js +39 -0
  194. package/src/lib/storage/storage.object.js.map +1 -0
  195. package/src/lib/string.d.ts +19 -0
  196. package/src/lib/string.js +27 -0
  197. package/src/lib/string.js.map +1 -0
  198. package/src/lib/type.d.ts +9 -0
  199. package/src/lib/type.js +3 -0
  200. package/src/lib/type.js.map +1 -0
  201. package/src/lib/value.d.ts +43 -0
  202. package/src/lib/value.js +28 -0
  203. package/src/lib/value.js.map +1 -0
  204. package/src/test/index.d.ts +2 -0
  205. package/src/test/index.js +6 -0
  206. package/src/test/index.js.map +1 -0
  207. package/src/test/jest.d.ts +80 -0
  208. package/src/test/jest.js +80 -0
  209. package/src/test/jest.js.map +1 -0
  210. package/src/test/jest.wrap.d.ts +61 -0
  211. package/src/test/jest.wrap.js +66 -0
  212. package/src/test/jest.wrap.js.map +1 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceToEmailParticipants = exports.convertEmailParticipantStringToParticipant = exports.convertParticipantToEmailParticipantString = void 0;
4
+ const array_1 = require("../array");
5
+ function convertParticipantToEmailParticipantString(participant) {
6
+ var _a, _b;
7
+ return `${(_b = (_a = participant.name) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''}<${participant.email}>`;
8
+ }
9
+ exports.convertParticipantToEmailParticipantString = convertParticipantToEmailParticipantString;
10
+ function convertEmailParticipantStringToParticipant(participantString) {
11
+ const split = participantString.split('<');
12
+ const name = split[0] || undefined;
13
+ const email = split[1].substring(0, split[1].length - 1);
14
+ return {
15
+ name,
16
+ email
17
+ };
18
+ }
19
+ exports.convertEmailParticipantStringToParticipant = convertEmailParticipantStringToParticipant;
20
+ function coerceToEmailParticipants({ participants = [], emails = [] }) {
21
+ var _a;
22
+ if (!(emails === null || emails === void 0 ? void 0 : emails.length)) {
23
+ return participants;
24
+ }
25
+ else {
26
+ const participantEmails = (_a = participants === null || participants === void 0 ? void 0 : participants.map(x => x.email)) !== null && _a !== void 0 ? _a : [];
27
+ const emailsWithoutParticipants = (0, array_1.excludeValuesFromArray)(emails, participantEmails);
28
+ return participants.concat(emailsWithoutParticipants.map(email => ({ email })));
29
+ }
30
+ }
31
+ exports.coerceToEmailParticipants = coerceToEmailParticipants;
32
+ //# sourceMappingURL=email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/contact/email.ts"],"names":[],"mappings":";;;AAAA,oCAAkD;AAgBlD,SAAgB,0CAA0C,CAAC,WAA6B;;IACtF,OAAO,GAAG,MAAA,MAAA,WAAW,CAAC,IAAI,0CAAE,IAAI,EAAE,mCAAI,EAAE,IAAI,WAAW,CAAC,KAAK,GAAG,CAAC;AACnE,CAAC;AAFD,gGAEC;AAED,SAAgB,0CAA0C,CAAC,iBAAyC;IAClG,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzD,OAAO;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC;AARD,gGAQC;AAED,SAAgB,yBAAyB,CAAC,EAAE,YAAY,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAkE;;IAC1I,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA,EAAE;QACnB,OAAO,YAAY,CAAC;KACrB;SAAM;QACL,MAAM,iBAAiB,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,mCAAI,EAAE,CAAC;QAChE,MAAM,yBAAyB,GAAG,IAAA,8BAAsB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QACpF,OAAO,YAAY,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;KACjF;AACH,CAAC;AARD,8DAQC"}
@@ -0,0 +1,3 @@
1
+ export * from './domain';
2
+ export * from './email';
3
+ export * from './phone';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./domain"), exports);
5
+ (0, tslib_1.__exportStar)(require("./email"), exports);
6
+ (0, tslib_1.__exportStar)(require("./phone"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/contact/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,uDAAwB;AACxB,uDAAwB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Phone number string input. No format specified.
3
+ */
4
+ export declare type PhoneNumber = string;
5
+ /**
6
+ * E.164 Standardized Phone Number
7
+ */
8
+ export declare type E164PhoneNumber = string;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=phone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/contact/phone.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // export type UseContext<T>
4
+ // export interface Context extends Initialized, Destroyable {}
5
+ // export type ContextFactory<T> = () => Context<T>;
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/context/context.ts"],"names":[],"mappings":";;AAEA,4BAA4B;AAE5B,+DAA+D;AAE/D,oDAAoD"}
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/context/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import { Maybe } from "../value";
2
+ /**
3
+ * A valid ISO8601 formatted date string.
4
+ */
5
+ export declare type ISO8601DateString = string;
6
+ /**
7
+ * A full ISO8601 date string that is in UTC.
8
+ *
9
+ * I.E. 2020-04-30T00:00:00.000Z
10
+ */
11
+ export declare type ISO8601DateStringUTCFull = string;
12
+ /**
13
+ * A valid timezone string.
14
+ */
15
+ export declare type TimezoneString = string;
16
+ export declare const UTC_TIMEZONE_STRING = "UTC";
17
+ /**
18
+ * Whether or not the input timezone string is considered UTC.
19
+ *
20
+ * @param timezone
21
+ * @returns
22
+ */
23
+ export declare function isConsideredUtcTimezoneString(timezone: Maybe<TimezoneString>): boolean;
24
+ export declare function isConsideredUtcTimezoneString(timezone: TimezoneString): boolean;
25
+ export declare function isConsideredUtcTimezoneString(timezone: 'UTC'): true;
26
+ export declare function isConsideredUtcTimezoneString(timezone: null): true;
27
+ export declare function isConsideredUtcTimezoneString(timezone: undefined): true;
28
+ /**
29
+ * A Date or an ISO8601DateString.
30
+ */
31
+ export declare type DateOrDateString = Date | ISO8601DateString;
32
+ /**
33
+ * A full date string Formatted as ISO8601.
34
+ *
35
+ * I.E. 1921-06-23
36
+ */
37
+ export declare type ISO8601DayString = string;
38
+ /**
39
+ * Time in seconds (instead of ms) since the epoch.
40
+ */
41
+ export declare type UnixDateTimeNumber = number;
42
+ /**
43
+ * A date or a unix timestamp
44
+ */
45
+ export declare type DateOrUnixDateTimeNumber = Date | UnixDateTimeNumber;
46
+ export declare type Seconds = number;
47
+ export declare type Minutes = number;
48
+ export declare type Hours = number;
49
+ export declare type Days = number;
50
+ export declare const MINUTES_IN_DAY = 1440;
51
+ export declare const MS_IN_MINUTE: number;
52
+ export declare const MS_IN_HOUR: number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_HOUR = exports.MS_IN_MINUTE = exports.MINUTES_IN_DAY = exports.isConsideredUtcTimezoneString = exports.UTC_TIMEZONE_STRING = void 0;
4
+ exports.UTC_TIMEZONE_STRING = 'UTC';
5
+ function isConsideredUtcTimezoneString(timezone) {
6
+ return (timezone == null || timezone === exports.UTC_TIMEZONE_STRING);
7
+ }
8
+ exports.isConsideredUtcTimezoneString = isConsideredUtcTimezoneString;
9
+ exports.MINUTES_IN_DAY = 1440;
10
+ exports.MS_IN_MINUTE = 1000 * 60;
11
+ exports.MS_IN_HOUR = exports.MS_IN_MINUTE * 60;
12
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/date.ts"],"names":[],"mappings":";;;AAmBa,QAAA,mBAAmB,GAAG,KAAK,CAAC;AAazC,SAAgB,6BAA6B,CAAC,QAA+B;IAC3E,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,2BAAmB,CAAC,CAAC;AAChE,CAAC;AAFD,sEAEC;AA6BY,QAAA,cAAc,GAAG,IAAI,CAAC;AACtB,QAAA,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AACzB,QAAA,UAAU,GAAG,oBAAY,GAAG,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { Maybe } from "../value";
2
+ /**
3
+ * Represents a string for a time. This may be human-input, and
4
+ * can be interpreted in various ways depending on the input.
5
+ *
6
+ * Examples:
7
+ * - 1:20AM
8
+ * - 1:20
9
+ * - 120AM
10
+ * - 120
11
+ */
12
+ export declare type ReadableTimeString = string;
13
+ export declare enum TimeAM {
14
+ AM = "AM",
15
+ PM = "PM"
16
+ }
17
+ export declare type DateNow = 'now';
18
+ export declare const DATE_NOW_VALUE = "now";
19
+ /**
20
+ * A date that is characterized by either a known string value, or a Date.
21
+ */
22
+ export declare type LogicalDate = Date | DateNow;
23
+ /**
24
+ * Returns a Date value from the input LogicalDate.
25
+ *
26
+ * @param logicalDate
27
+ */
28
+ export declare function dateFromLogicalDate(logicalDate: Maybe<LogicalDate>): Maybe<Date>;
29
+ export declare function dateFromLogicalDate(logicalDate: LogicalDate): Date;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateFromLogicalDate = exports.DATE_NOW_VALUE = exports.TimeAM = void 0;
4
+ var TimeAM;
5
+ (function (TimeAM) {
6
+ TimeAM["AM"] = "AM";
7
+ TimeAM["PM"] = "PM";
8
+ })(TimeAM = exports.TimeAM || (exports.TimeAM = {}));
9
+ exports.DATE_NOW_VALUE = 'now';
10
+ function dateFromLogicalDate(logicalDate) {
11
+ let result;
12
+ if (typeof logicalDate === 'string') {
13
+ switch (logicalDate.toLocaleLowerCase()) {
14
+ case exports.DATE_NOW_VALUE:
15
+ result = new Date();
16
+ break;
17
+ default:
18
+ throw new Error(`Unknown logical date string "${logicalDate}"`);
19
+ }
20
+ }
21
+ else {
22
+ result = logicalDate;
23
+ }
24
+ return result;
25
+ }
26
+ exports.dateFromLogicalDate = dateFromLogicalDate;
27
+ //# sourceMappingURL=date.time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.time.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/date.time.ts"],"names":[],"mappings":";;;AAcA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,mBAAS,CAAA;IACT,mBAAS,CAAA;AACX,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB;AAGY,QAAA,cAAc,GAAG,KAAK,CAAC;AAcpC,SAAgB,mBAAmB,CAAC,WAA+B;IACjE,IAAI,MAAM,CAAC;IAEX,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,QAAQ,WAAW,CAAC,iBAAiB,EAAE,EAAE;YACvC,KAAK,sBAAc;gBACjB,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACpB,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,GAAG,CAAC,CAAC;SACnE;KACF;SAAM;QACL,MAAM,GAAG,WAAW,CAAC;KACtB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAhBD,kDAgBC"}
@@ -0,0 +1,2 @@
1
+ export * from './date';
2
+ export * from './date.time';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./date"), exports);
5
+ (0, tslib_1.__exportStar)(require("./date.time"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/index.ts"],"names":[],"mappings":";;;AAAA,sDAAuB;AACvB,2DAA4B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A unique identifier for a specific error.
3
+ */
4
+ export declare type StringErrorCode = string;
5
+ /**
6
+ * An error that is identified by a unique code.
7
+ */
8
+ export interface CodedError {
9
+ code: StringErrorCode;
10
+ }
11
+ /**
12
+ * An error with a human-readable message.
13
+ */
14
+ export interface ReadableError extends Partial<CodedError> {
15
+ message: string;
16
+ }
17
+ export interface ReadableDataError<T = any> extends ReadableError {
18
+ data?: T;
19
+ }
20
+ export interface ErrorWrapper {
21
+ data: ReadableError | CodedError;
22
+ }
23
+ export declare type ErrorInput = ErrorWrapper | CodedError | ReadableError;
24
+ /**
25
+ * Converts the input error content to a ReadableError or CodedError.
26
+ *
27
+ * @param inputError
28
+ * @returns
29
+ */
30
+ export declare function convertToReadableError(inputError: ErrorInput | undefined): CodedError | ReadableError | undefined;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToReadableError = void 0;
4
+ const make_error_1 = require("make-error");
5
+ /**
6
+ * Converts the input error content to a ReadableError or CodedError.
7
+ *
8
+ * @param inputError
9
+ * @returns
10
+ */
11
+ function convertToReadableError(inputError) {
12
+ let error;
13
+ if (inputError) {
14
+ if (inputError.code) {
15
+ error = inputError;
16
+ }
17
+ else if (inputError.data) {
18
+ error = inputError.data;
19
+ }
20
+ else if (inputError instanceof make_error_1.BaseError) {
21
+ error = {
22
+ code: inputError.code || inputError.name,
23
+ message: inputError.message
24
+ };
25
+ }
26
+ else {
27
+ error = {
28
+ code: 'ERROR',
29
+ message: inputError.message || ''
30
+ };
31
+ }
32
+ }
33
+ return error;
34
+ }
35
+ exports.convertToReadableError = convertToReadableError;
36
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAgCvC;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,UAAkC;IACvE,IAAI,KAA6C,CAAC;IAElD,IAAI,UAAU,EAAE;QACd,IAAK,UAAyB,CAAC,IAAI,EAAE;YACnC,KAAK,GAAG,UAA2B,CAAC;SACrC;aAAM,IAAK,UAA2B,CAAC,IAAI,EAAE;YAC5C,KAAK,GAAI,UAA2B,CAAC,IAAqB,CAAC;SAC5D;aAAM,IAAI,UAAU,YAAY,sBAAS,EAAE;YAC1C,KAAK,GAAG;gBACN,IAAI,EAAG,UAAkB,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI;gBACjD,OAAO,EAAE,UAAU,CAAC,OAAO;aAC5B,CAAC;SACH;aAAM;YACL,KAAK,GAAG;gBACN,IAAI,EAAE,OAAO;gBACb,OAAO,EAAG,UAAkB,CAAC,OAAO,IAAI,EAAE;aAC3C,CAAC;SACH;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAtBD,wDAsBC"}
@@ -0,0 +1,37 @@
1
+ import { StringErrorCode, ReadableDataError } from './error';
2
+ /**
3
+ * The expected error object returned from the server.
4
+ */
5
+ export interface ServerErrorResponseData {
6
+ /**
7
+ * Unique identifier of the error returned, if available.
8
+ */
9
+ code?: StringErrorCode;
10
+ /**
11
+ * User-readable message of the error returned.
12
+ */
13
+ message?: string;
14
+ /**
15
+ * Additional keys/data returned in the error data.
16
+ */
17
+ [key: string]: any;
18
+ }
19
+ /**
20
+ * Human-readable server error with additional data and a status code.
21
+ */
22
+ export interface ServerError<T = any> extends ReadableDataError<T> {
23
+ status: number;
24
+ }
25
+ /**
26
+ * Base server-error class.
27
+ */
28
+ export declare class ServerErrorResponse<T extends ServerErrorResponseData = ServerErrorResponseData> implements ServerError<T> {
29
+ readonly code?: string;
30
+ readonly status: number;
31
+ readonly message: string;
32
+ readonly data?: T;
33
+ constructor({ code, status, data, message }: ServerError<T>);
34
+ }
35
+ export declare class UnauthorizedServerErrorResponse extends ServerErrorResponse {
36
+ constructor({ code, data, message }: Partial<ServerError>);
37
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnauthorizedServerErrorResponse = exports.ServerErrorResponse = void 0;
4
+ /**
5
+ * Base server-error class.
6
+ */
7
+ class ServerErrorResponse {
8
+ constructor({ code, status, data, message }) {
9
+ this.code = code;
10
+ this.message = message;
11
+ this.status = status;
12
+ this.data = data;
13
+ }
14
+ }
15
+ exports.ServerErrorResponse = ServerErrorResponse;
16
+ class UnauthorizedServerErrorResponse extends ServerErrorResponse {
17
+ constructor({ code, data, message }) {
18
+ super({ status: 401, message: message !== null && message !== void 0 ? message : 'Unauthorized', data, code });
19
+ }
20
+ }
21
+ exports.UnauthorizedServerErrorResponse = UnauthorizedServerErrorResponse;
22
+ //# sourceMappingURL=error.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.server.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.server.ts"],"names":[],"mappings":";;;AA2BA;;GAEG;AACH,MAAa,mBAAmB;IAO9B,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAkB;QACzD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAEF;AAdD,kDAcC;AAED,MAAa,+BAAgC,SAAQ,mBAAmB;IAEtE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAwB;QACvD,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;CAEF;AAND,0EAMC"}
@@ -0,0 +1,2 @@
1
+ export * from './error.server';
2
+ export * from './error';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./error.server"), exports);
5
+ (0, tslib_1.__exportStar)(require("./error"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/index.ts"],"names":[],"mappings":";;;AAAA,8DAA+B;AAC/B,uDAAwB"}
@@ -0,0 +1,5 @@
1
+ export interface Filter<F> {
2
+ filter?: F;
3
+ }
4
+ export interface OptionalFilter<F> extends Partial<Filter<F>> {
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/filter/filter.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './filter';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./filter"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/filter/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Function that returns a value.
3
+ */
4
+ export declare type Getter<T> = () => T;
5
+ /**
6
+ * Either a Getter, or an instance of the item.
7
+ */
8
+ export declare type ObjectOrGetter<T> = T | Getter<T>;
9
+ export declare type StringOrGetter = ObjectOrGetter<string>;
10
+ /**
11
+ * If the input is a function, it is executed. Otherwise, the value is returned.
12
+ *
13
+ * @param input
14
+ * @returns
15
+ */
16
+ export declare function getValueFromObjectOrGetter<T>(input: ObjectOrGetter<T>): T;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getValueFromObjectOrGetter = void 0;
4
+ /**
5
+ * If the input is a function, it is executed. Otherwise, the value is returned.
6
+ *
7
+ * @param input
8
+ * @returns
9
+ */
10
+ function getValueFromObjectOrGetter(input) {
11
+ if (typeof input === 'function') {
12
+ return input();
13
+ }
14
+ else {
15
+ return input;
16
+ }
17
+ }
18
+ exports.getValueFromObjectOrGetter = getValueFromObjectOrGetter;
19
+ //# sourceMappingURL=getter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getter.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/getter.ts"],"names":[],"mappings":";;;AAaA;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAI,KAAwB;IACpE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAQ,KAAiB,EAAE,CAAC;KAC7B;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gEAMC"}
@@ -0,0 +1,98 @@
1
+ import { PrimativeKey, ReadKeyFunction } from "./key";
2
+ import { Maybe } from "./value";
3
+ export interface SeparateResult<T> {
4
+ included: T[];
5
+ excluded: T[];
6
+ }
7
+ export interface GroupingResult<T> {
8
+ [key: string]: T[];
9
+ }
10
+ export declare type KeyedGroupingResult<T, O, K extends keyof O = keyof O> = {
11
+ [k in K]: T[];
12
+ };
13
+ export interface PairsGroupingResult<T> {
14
+ pairs: T[][];
15
+ unpaired: T[];
16
+ }
17
+ export interface ArrayContentsDifferentParams<T, K extends PrimativeKey = PrimativeKey> {
18
+ groupKeyFn: ReadKeyFunction<T, K>;
19
+ isEqual: (a: T, b: T) => boolean;
20
+ }
21
+ /**
22
+ * Configuration for RestoreOrderParams.
23
+ */
24
+ export interface RestoreOrderParams<T, K extends number | string = number | string> {
25
+ readKey: ReadKeyFunction<T, K>;
26
+ /**
27
+ * Optional function used to decide which value should be retained.
28
+ */
29
+ chooseRetainedValue?: (values: T[]) => T;
30
+ /**
31
+ * Whether or not new items should be excluded. If false, the new items are appended to the end of the result in the order they are accessed.
32
+ *
33
+ * By default this is false.
34
+ */
35
+ excludeNewItems?: boolean;
36
+ }
37
+ /**
38
+ * Batches items from the input array into several batches of a maximum size.
39
+ *
40
+ * @param array
41
+ * @param batchSize
42
+ * @returns
43
+ */
44
+ export declare function batch<T>(array: T[], batchSize: number): T[][];
45
+ /**
46
+ * Convenience function for calling restoreOrder with two arrays of values, instead of an array of keys and array of values.
47
+ *
48
+ * @param orderValues
49
+ * @param values
50
+ * @param params
51
+ * @returns
52
+ */
53
+ export declare function restoreOrderWithValues<T, K extends PrimativeKey = PrimativeKey>(orderValues: T[], values: T[], params: RestoreOrderParams<T, K>): T[];
54
+ /**
55
+ * Restores the order to the input values based on their keys.
56
+ *
57
+ * Duplicate values are passed to the chooseRetainedValue function past. When no function is provided, duplicates are ignored.
58
+ */
59
+ export declare function restoreOrder<T, K extends PrimativeKey = PrimativeKey>(orderKeys: K[], values: T[], { readKey, chooseRetainedValue, excludeNewItems }: RestoreOrderParams<T, K>): T[];
60
+ /**
61
+ * Returns true if the input differs from eachother.
62
+ *
63
+ * Input items are uniquely keyed in some fashion. The same items are paired up.
64
+ */
65
+ export declare function arrayContentsDiffer<T, K extends PrimativeKey = PrimativeKey>(a: T[] | undefined, b: T[] | undefined, { groupKeyFn, isEqual }: ArrayContentsDifferentParams<T, K>): boolean;
66
+ export declare function pairGroupValues<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): PairsGroupingResult<T>;
67
+ /**
68
+ * Creates a tuples array of key and value pairs.
69
+ *
70
+ * @param values
71
+ * @param keyFn
72
+ * @returns
73
+ */
74
+ export declare function makeKeyPairs<T, K extends string | number = string | number>(values: T[], keyFn: ReadKeyFunction<T, K>): [Maybe<K>, T][];
75
+ /**
76
+ * Separates the input values into an included and excluded group.
77
+ *
78
+ * @param values
79
+ * @param checkInclusion
80
+ * @returns
81
+ */
82
+ export declare function separateValues<T>(values: T[], checkInclusion: (x: T) => boolean): SeparateResult<T>;
83
+ /**
84
+ * Convenience function for makeValuesGroupMap that returns a POJO instead of a Map.
85
+ *
86
+ * @param values
87
+ * @param groupKeyFn
88
+ */
89
+ export declare function groupValues<T, R, K extends PrimativeKey & keyof R>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): KeyedGroupingResult<T, R, K>;
90
+ export declare function groupValues<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): GroupingResult<T>;
91
+ /**
92
+ * Reads keys from the values in the arrays, and groups them together into a Map.
93
+ *
94
+ * @param values
95
+ * @param groupKeyFn
96
+ * @returns
97
+ */
98
+ export declare function makeValuesGroupMap<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): Map<Maybe<K>, T[]>;