@deephaven/jsapi-utils 0.22.3-embed-pandas.11 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/ConnectionUtils.js +3 -7
  2. package/dist/ConnectionUtils.js.map +1 -1
  3. package/dist/DateUtils.js +12 -58
  4. package/dist/DateUtils.js.map +1 -1
  5. package/dist/Formatter.d.ts +1 -1
  6. package/dist/Formatter.d.ts.map +1 -1
  7. package/dist/Formatter.js +10 -35
  8. package/dist/Formatter.js.map +1 -1
  9. package/dist/FormatterUtils.js +1 -2
  10. package/dist/FormatterUtils.js.map +1 -1
  11. package/dist/TableUtils.d.ts +11 -9
  12. package/dist/TableUtils.d.ts.map +1 -1
  13. package/dist/TableUtils.js +26 -291
  14. package/dist/TableUtils.js.map +1 -1
  15. package/dist/formatters/BooleanColumnFormatter.js +0 -6
  16. package/dist/formatters/BooleanColumnFormatter.js.map +1 -1
  17. package/dist/formatters/CharColumnFormatter.js +0 -4
  18. package/dist/formatters/CharColumnFormatter.js.map +1 -1
  19. package/dist/formatters/DateTimeColumnFormatter.d.ts +1 -1
  20. package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -1
  21. package/dist/formatters/DateTimeColumnFormatter.js +4 -28
  22. package/dist/formatters/DateTimeColumnFormatter.js.map +1 -1
  23. package/dist/formatters/DecimalColumnFormatter.d.ts +2 -2
  24. package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -1
  25. package/dist/formatters/DecimalColumnFormatter.js +8 -28
  26. package/dist/formatters/DecimalColumnFormatter.js.map +1 -1
  27. package/dist/formatters/DefaultColumnFormatter.js +0 -4
  28. package/dist/formatters/DefaultColumnFormatter.js.map +1 -1
  29. package/dist/formatters/IntegerColumnFormatter.d.ts +2 -2
  30. package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -1
  31. package/dist/formatters/IntegerColumnFormatter.js +9 -25
  32. package/dist/formatters/IntegerColumnFormatter.js.map +1 -1
  33. package/dist/formatters/StringColumnFormatter.js +0 -2
  34. package/dist/formatters/StringColumnFormatter.js.map +1 -1
  35. package/dist/formatters/TableColumnFormatter.d.ts +2 -2
  36. package/dist/formatters/TableColumnFormatter.d.ts.map +1 -1
  37. package/dist/formatters/TableColumnFormatter.js +4 -13
  38. package/dist/formatters/TableColumnFormatter.js.map +1 -1
  39. package/dist/formatters/index.js.map +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/package.json +7 -7
@@ -1,7 +1,8 @@
1
1
  import { TimeoutError } from '@deephaven/utils';
2
- /** Default timeout for fetching a variable definition */
3
2
 
3
+ /** Default timeout for fetching a variable definition */
4
4
  export var FETCH_TIMEOUT = 10000;
5
+
5
6
  /**
6
7
  * Fetch the definition for a variable given a connection. Subscribes to field updates and triggers when the variable is found.
7
8
  * @param connection Connection to get the variable from
@@ -9,34 +10,29 @@ export var FETCH_TIMEOUT = 10000;
9
10
  * @param timeout Timeout for the fetch
10
11
  * @returns Promise the resolves to the variable definition if found, or rejects if there's an error or the timeout has exceeded
11
12
  */
12
-
13
13
  export function fetchVariableDefinition(connection, name) {
14
14
  var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FETCH_TIMEOUT;
15
15
  return new Promise((resolve, reject) => {
16
16
  var removeListener;
17
17
  var timeoutId = setTimeout(() => {
18
18
  var _removeListener;
19
-
20
19
  (_removeListener = removeListener) === null || _removeListener === void 0 ? void 0 : _removeListener();
21
20
  reject(new TimeoutError("Variable ".concat(name, " not found")));
22
21
  }, timeout);
22
+
23
23
  /**
24
24
  * Checks if the variable we're looking for is in the changes, and resolves the promise if it does
25
25
  * @param changes Variables changes that have occurred
26
26
  */
27
-
28
27
  function handleFieldUpdates(changes) {
29
28
  var definition = changes.created.find(def => def.title === name);
30
-
31
29
  if (definition != null) {
32
30
  var _removeListener2;
33
-
34
31
  clearTimeout(timeoutId);
35
32
  (_removeListener2 = removeListener) === null || _removeListener2 === void 0 ? void 0 : _removeListener2();
36
33
  resolve(definition);
37
34
  }
38
35
  }
39
-
40
36
  removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);
41
37
  });
42
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionUtils.js","names":["TimeoutError","FETCH_TIMEOUT","fetchVariableDefinition","connection","name","timeout","Promise","resolve","reject","removeListener","timeoutId","setTimeout","handleFieldUpdates","changes","definition","created","find","def","title","clearTimeout","subscribeToFieldUpdates"],"sources":["../src/ConnectionUtils.ts"],"sourcesContent":["import {\n IdeConnection,\n VariableChanges,\n VariableDefinition,\n} from '@deephaven/jsapi-shim';\nimport { TimeoutError } from '@deephaven/utils';\n\n/** Default timeout for fetching a variable definition */\nexport const FETCH_TIMEOUT = 10_000;\n\n/**\n * Fetch the definition for a variable given a connection. Subscribes to field updates and triggers when the variable is found.\n * @param connection Connection to get the variable from\n * @param name Name of the definition to fetch\n * @param timeout Timeout for the fetch\n * @returns Promise the resolves to the variable definition if found, or rejects if there's an error or the timeout has exceeded\n */\nexport function fetchVariableDefinition(\n connection: IdeConnection,\n name: string,\n timeout = FETCH_TIMEOUT\n): Promise<VariableDefinition> {\n return new Promise<VariableDefinition>((resolve, reject) => {\n let removeListener: () => void;\n\n const timeoutId = setTimeout(() => {\n removeListener?.();\n reject(new TimeoutError(`Variable ${name} not found`));\n }, timeout);\n\n /**\n * Checks if the variable we're looking for is in the changes, and resolves the promise if it does\n * @param changes Variables changes that have occurred\n */\n function handleFieldUpdates(changes: VariableChanges): void {\n const definition = changes.created.find(def => def.title === name);\n if (definition != null) {\n clearTimeout(timeoutId);\n removeListener?.();\n resolve(definition);\n }\n }\n\n removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);\n });\n}\n"],"mappings":"AAKA,SAASA,YAAT,QAA6B,kBAA7B;AAEA;;AACA,OAAO,IAAMC,aAAa,GAAG,KAAtB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,uBAAT,CACLC,UADK,EAELC,IAFK,EAIwB;EAAA,IAD7BC,OAC6B,uEADnBJ,aACmB;EAC7B,OAAO,IAAIK,OAAJ,CAAgC,CAACC,OAAD,EAAUC,MAAV,KAAqB;IAC1D,IAAIC,cAAJ;IAEA,IAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;MAAA;;MACjC,mBAAAF,cAAc,UAAd;MACAD,MAAM,CAAC,IAAIR,YAAJ,oBAA6BI,IAA7B,gBAAD,CAAN;IACD,CAH2B,EAGzBC,OAHyB,CAA5B;IAKA;AACJ;AACA;AACA;;IACI,SAASO,kBAAT,CAA4BC,OAA5B,EAA4D;MAC1D,IAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBC,IAAhB,CAAqBC,GAAG,IAAIA,GAAG,CAACC,KAAJ,KAAcd,IAA1C,CAAnB;;MACA,IAAIU,UAAU,IAAI,IAAlB,EAAwB;QAAA;;QACtBK,YAAY,CAACT,SAAD,CAAZ;QACA,oBAAAD,cAAc,UAAd;QACAF,OAAO,CAACO,UAAD,CAAP;MACD;IACF;;IAEDL,cAAc,GAAGN,UAAU,CAACiB,uBAAX,CAAmCR,kBAAnC,CAAjB;EACD,CAtBM,CAAP;AAuBD"}
1
+ {"version":3,"file":"ConnectionUtils.js","names":["TimeoutError","FETCH_TIMEOUT","fetchVariableDefinition","connection","name","timeout","Promise","resolve","reject","removeListener","timeoutId","setTimeout","handleFieldUpdates","changes","definition","created","find","def","title","clearTimeout","subscribeToFieldUpdates"],"sources":["../src/ConnectionUtils.ts"],"sourcesContent":["import {\n IdeConnection,\n VariableChanges,\n VariableDefinition,\n} from '@deephaven/jsapi-shim';\nimport { TimeoutError } from '@deephaven/utils';\n\n/** Default timeout for fetching a variable definition */\nexport const FETCH_TIMEOUT = 10_000;\n\n/**\n * Fetch the definition for a variable given a connection. Subscribes to field updates and triggers when the variable is found.\n * @param connection Connection to get the variable from\n * @param name Name of the definition to fetch\n * @param timeout Timeout for the fetch\n * @returns Promise the resolves to the variable definition if found, or rejects if there's an error or the timeout has exceeded\n */\nexport function fetchVariableDefinition(\n connection: IdeConnection,\n name: string,\n timeout = FETCH_TIMEOUT\n): Promise<VariableDefinition> {\n return new Promise<VariableDefinition>((resolve, reject) => {\n let removeListener: () => void;\n\n const timeoutId = setTimeout(() => {\n removeListener?.();\n reject(new TimeoutError(`Variable ${name} not found`));\n }, timeout);\n\n /**\n * Checks if the variable we're looking for is in the changes, and resolves the promise if it does\n * @param changes Variables changes that have occurred\n */\n function handleFieldUpdates(changes: VariableChanges): void {\n const definition = changes.created.find(def => def.title === name);\n if (definition != null) {\n clearTimeout(timeoutId);\n removeListener?.();\n resolve(definition);\n }\n }\n\n removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);\n });\n}\n"],"mappings":"AAKA,SAASA,YAAY,QAAQ,kBAAkB;;AAE/C;AACA,OAAO,IAAMC,aAAa,GAAG,KAAM;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuB,CACrCC,UAAyB,EACzBC,IAAY,EAEiB;EAAA,IAD7BC,OAAO,uEAAGJ,aAAa;EAEvB,OAAO,IAAIK,OAAO,CAAqB,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC1D,IAAIC,cAA0B;IAE9B,IAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;MAAA;MACjC,mBAAAF,cAAc,oDAAd,iBAAkB;MAClBD,MAAM,CAAC,IAAIR,YAAY,oBAAaI,IAAI,gBAAa,CAAC;IACxD,CAAC,EAAEC,OAAO,CAAC;;IAEX;AACJ;AACA;AACA;IACI,SAASO,kBAAkB,CAACC,OAAwB,EAAQ;MAC1D,IAAMC,UAAU,GAAGD,OAAO,CAACE,OAAO,CAACC,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,KAAK,KAAKd,IAAI,CAAC;MAClE,IAAIU,UAAU,IAAI,IAAI,EAAE;QAAA;QACtBK,YAAY,CAACT,SAAS,CAAC;QACvB,oBAAAD,cAAc,qDAAd,kBAAkB;QAClBF,OAAO,CAACO,UAAU,CAAC;MACrB;IACF;IAEAL,cAAc,GAAGN,UAAU,CAACiB,uBAAuB,CAACR,kBAAkB,CAAC;EACzE,CAAC,CAAC;AACJ"}
package/dist/DateUtils.js CHANGED
@@ -1,5 +1,4 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
2
  import dh from '@deephaven/jsapi-shim';
4
3
  export class DateUtils {
5
4
  /**
@@ -20,11 +19,9 @@ export class DateUtils {
20
19
  var minute = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
21
20
  var second = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
22
21
  var ns = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
23
-
24
22
  if (!timeZone) {
25
23
  throw new Error('No timezone provided');
26
24
  }
27
-
28
25
  var yearString = "".concat(year).padStart(4, '0');
29
26
  var monthString = "".concat(month + 1).padStart(2, '0');
30
27
  var dayString = "".concat(day).padStart(2, '0');
@@ -35,28 +32,26 @@ export class DateUtils {
35
32
  var dateString = "".concat(yearString, "-").concat(monthString, "-").concat(dayString, " ").concat(hourString, ":").concat(minuteString, ":").concat(secondString, ".").concat(nanoString);
36
33
  return dh.i18n.DateTimeFormat.parse(DateUtils.FULL_DATE_FORMAT, dateString, dh.i18n.TimeZone.getTimeZone(timeZone));
37
34
  }
35
+
38
36
  /**
39
37
  * Takes the string the user entered and returns the next nanos value
40
38
  * @param nanoString The nano string to get the next one of
41
39
  * @returns The value of the next nanos
42
40
  */
43
-
44
-
45
41
  static getNextNanos(nanoString) {
46
- var sigNanos = parseInt(nanoString, 10); // Get the zeroes needed for padding before adding one so we handle overflow properly.
47
-
42
+ var sigNanos = parseInt(nanoString, 10);
43
+ // Get the zeroes needed for padding before adding one so we handle overflow properly.
48
44
  var zeros = '0'.repeat(9 - nanoString.length);
49
45
  var nextNanoString = "".concat(sigNanos + 1).concat(zeros);
50
46
  return parseInt(nextNanoString, 10);
51
47
  }
48
+
52
49
  /**
53
50
  * @param components The string components that were parsed from the original string
54
51
  * @param values The values that were parsed from the components
55
52
  * @param timeZone The time zone to parse the date in. E.g. America/New_York
56
53
  * @returns Returns the DateWrapper for the next date, or null if a full date was passed in
57
54
  */
58
-
59
-
60
55
  static getNextDate(components, values, timeZone) {
61
56
  var {
62
57
  year,
@@ -67,15 +62,12 @@ export class DateUtils {
67
62
  seconds,
68
63
  nanos
69
64
  } = values;
70
-
71
65
  if (components.nanos != null) {
72
66
  if (components.nanos.length === 9) {
73
67
  // They want an exact match
74
68
  return null;
75
69
  }
76
-
77
70
  nanos = DateUtils.getNextNanos(components.nanos);
78
-
79
71
  if (nanos > 999999999) {
80
72
  // There's an overflow, add it to the seconds manually
81
73
  seconds += 1;
@@ -93,35 +85,30 @@ export class DateUtils {
93
85
  month += 1;
94
86
  } else {
95
87
  year += 1;
96
- } // Use the JS date to handle overflow rather than doing our own logic
88
+ }
89
+
90
+ // Use the JS date to handle overflow rather than doing our own logic
97
91
  // Because handling leap years and stuff is a pain
98
92
  // Still need to add nanos after, and the overflow from that is already added to seconds above
99
-
100
-
101
93
  var jsDate = new Date(year, month, date, hours, minutes, seconds);
102
94
  return DateUtils.makeDateWrapper(timeZone, jsDate.getFullYear(), jsDate.getMonth(), jsDate.getDate(), jsDate.getHours(), jsDate.getMinutes(), jsDate.getSeconds(), nanos);
103
95
  }
96
+
104
97
  /**
105
98
  * Get the JS month value for the provided string.
106
99
  * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)
107
100
  * @param monthString The string to parse to a JS month value
108
101
  * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed
109
102
  */
110
-
111
-
112
103
  static parseMonth(monthString) {
113
104
  var month = parseInt(monthString, 10);
114
-
115
105
  if (!Number.isNaN(month)) {
116
106
  if (month >= 1 && month <= 12) {
117
107
  return month - 1;
118
108
  }
119
-
120
109
  return NaN;
121
110
  }
122
-
123
111
  var cleanMonthString = monthString.trim().toLowerCase();
124
-
125
112
  if (cleanMonthString.length >= 3) {
126
113
  for (var i = 0; i < DateUtils.months.length; i += 1) {
127
114
  if (DateUtils.months[i].startsWith(cleanMonthString)) {
@@ -129,9 +116,9 @@ export class DateUtils {
129
116
  }
130
117
  }
131
118
  }
132
-
133
119
  return NaN;
134
120
  }
121
+
135
122
  /**
136
123
  * Parse a date object out of the provided string segments.
137
124
  * Also using `parseMonth` to get month names like Aug/August rather than
@@ -144,8 +131,6 @@ export class DateUtils {
144
131
  * @param secondString The second part of the string
145
132
  * @param nanoString The milli part of the string
146
133
  */
147
-
148
-
149
134
  static parseDateValues(yearString, monthString, dayString, hourString, minuteString, secondString, nanoString) {
150
135
  var year = parseInt(yearString, 10);
151
136
  var month = monthString != null ? this.parseMonth(monthString) : 0;
@@ -154,11 +139,9 @@ export class DateUtils {
154
139
  var minutes = minuteString != null ? parseInt(minuteString, 10) : 0;
155
140
  var seconds = secondString != null ? parseInt(secondString, 10) : 0;
156
141
  var nanos = nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;
157
-
158
142
  if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(date) || Number.isNaN(hours) || Number.isNaN(minutes) || Number.isNaN(seconds) || Number.isNaN(nanos)) {
159
143
  return null;
160
144
  }
161
-
162
145
  return {
163
146
  year,
164
147
  month,
@@ -169,6 +152,7 @@ export class DateUtils {
169
152
  nanos
170
153
  };
171
154
  }
155
+
172
156
  /**
173
157
  * Parse out a date time string into it's string components.
174
158
  * Anything that is not captured in the string will be undefined.
@@ -176,22 +160,16 @@ export class DateUtils {
176
160
  * @param dateTimeString The date time string to parse
177
161
  * @returns Containing the date time components
178
162
  */
179
-
180
-
181
163
  static parseDateTimeString(dateTimeString) {
182
164
  var regex = /\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/;
183
165
  var result = regex.exec(dateTimeString);
184
-
185
166
  if (result == null) {
186
167
  throw new Error("Unexpected date string: ".concat(dateTimeString));
187
168
  }
188
-
189
169
  var [, year,, month,, date,, hours,, minutes,, seconds,, nanos, overflow] = result;
190
-
191
170
  if (overflow != null && overflow.length > 0) {
192
171
  throw new Error("Unexpected characters after date string '".concat(dateTimeString, "': ").concat(overflow));
193
172
  }
194
-
195
173
  return {
196
174
  year,
197
175
  month,
@@ -202,88 +180,64 @@ export class DateUtils {
202
180
  nanos
203
181
  };
204
182
  }
183
+
205
184
  /**
206
185
  * Parses the date range provided from a string of text.
207
186
  * @param text The string to parse the date from. Can be a keyword like "today", or in the format "2018-08-04"
208
187
  * @param timeZone The time zone to parse this range in. E.g. America/New_York
209
188
  * @returns A tuple with the start and end value/null for that date range, or both null
210
189
  */
211
-
212
-
213
190
  static parseDateRange(text, timeZone) {
214
191
  var cleanText = text.trim().toLowerCase();
215
-
216
192
  if (cleanText.length === 0) {
217
193
  throw new Error('Cannot parse date range from empty string');
218
194
  }
219
-
220
195
  if (cleanText === 'null') {
221
196
  return [null, null];
222
197
  }
223
-
224
198
  if (cleanText === 'today') {
225
199
  var now = new Date(Date.now());
226
-
227
200
  var _startDate = DateUtils.makeDateWrapper(timeZone, now.getFullYear(), now.getMonth(), now.getDate());
228
-
229
201
  var _endDate = DateUtils.makeDateWrapper(timeZone, now.getFullYear(), now.getMonth(), now.getDate() + 1);
230
-
231
202
  return [_startDate, _endDate];
232
203
  }
233
-
234
204
  if (cleanText === 'yesterday') {
235
205
  var _now = new Date(Date.now());
236
-
237
206
  var _startDate2 = DateUtils.makeDateWrapper(timeZone, _now.getFullYear(), _now.getMonth(), _now.getDate() - 1);
238
-
239
207
  var _endDate2 = DateUtils.makeDateWrapper(timeZone, _now.getFullYear(), _now.getMonth(), _now.getDate());
240
-
241
208
  return [_startDate2, _endDate2];
242
209
  }
243
-
244
210
  if (cleanText === 'now') {
245
211
  var _now2 = new Date(Date.now());
246
-
247
212
  var date = dh.DateWrapper.ofJsDate(_now2);
248
213
  return [date, null];
249
214
  }
250
-
251
215
  var components = DateUtils.parseDateTimeString(cleanText);
252
-
253
216
  if (components.year == null && components.month == null && components.date == null) {
254
217
  throw new Error("Unable to extract year, month, or day ".concat(cleanText));
255
218
  }
256
-
257
219
  var values = DateUtils.parseDateValues(components.year, components.month, components.date, components.hours, components.minutes, components.seconds, components.nanos);
258
-
259
220
  if (values == null) {
260
221
  throw new Error("Unable to extract date values from ".concat(components));
261
222
  }
262
-
263
223
  var startDate = DateUtils.makeDateWrapper(timeZone, values.year, values.month, values.date, values.hours, values.minutes, values.seconds, values.nanos);
264
224
  var endDate = DateUtils.getNextDate(components, values, timeZone);
265
225
  return [startDate, endDate];
266
226
  }
227
+
267
228
  /**
268
229
  * Gets the Js Date object from the provided DateWrapper.
269
230
  * In unit test, DateWrapper is just a number provided in millis, so handles that case.
270
231
  * @param dateWrapper The DateWrapper object, or time in millis
271
232
  */
272
-
273
-
274
233
  static getJsDate(dateWrapper) {
275
234
  if (typeof dateWrapper === 'number') {
276
235
  return new Date(dateWrapper);
277
236
  }
278
-
279
237
  return dateWrapper.asDate();
280
238
  }
281
-
282
239
  }
283
-
284
240
  _defineProperty(DateUtils, "FULL_DATE_FORMAT", 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS');
285
-
286
241
  _defineProperty(DateUtils, "months", ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']);
287
-
288
242
  export default DateUtils;
289
243
  //# sourceMappingURL=DateUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtils.js","names":["dh","DateUtils","makeDateWrapper","timeZone","year","month","day","hour","minute","second","ns","Error","yearString","padStart","monthString","dayString","hourString","minuteString","secondString","nanoString","dateString","i18n","DateTimeFormat","parse","FULL_DATE_FORMAT","TimeZone","getTimeZone","getNextNanos","sigNanos","parseInt","zeros","repeat","length","nextNanoString","getNextDate","components","values","date","hours","minutes","seconds","nanos","jsDate","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","parseMonth","Number","isNaN","NaN","cleanMonthString","trim","toLowerCase","i","months","startsWith","parseDateValues","padEnd","parseDateTimeString","dateTimeString","regex","result","exec","overflow","parseDateRange","text","cleanText","now","startDate","endDate","DateWrapper","ofJsDate","getJsDate","dateWrapper","asDate"],"sources":["../src/DateUtils.ts"],"sourcesContent":["import dh from '@deephaven/jsapi-shim';\nimport type { DateWrapper } from '@deephaven/jsapi-shim';\n\ninterface DateParts<T> {\n year: T;\n month: T;\n date: T;\n hours: T;\n minutes: T;\n seconds: T;\n nanos: T;\n}\n\nexport class DateUtils {\n static FULL_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS';\n\n static months = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ];\n\n /**\n *\n * @param timeZone The time zone to parse this time in. E.g. America/New_York\n * @param year The year for the date\n * @param month The month, starting at 0\n * @param day The day, starting at 1\n * @param hour The hours\n * @param minute The minutes\n * @param second The seconds\n * @param ns The nanoseconds\n */\n static makeDateWrapper(\n timeZone: string,\n year: number,\n month = 0,\n day = 1,\n hour = 0,\n minute = 0,\n second = 0,\n ns = 0\n ): DateWrapper {\n if (!timeZone) {\n throw new Error('No timezone provided');\n }\n const yearString = `${year}`.padStart(4, '0');\n const monthString = `${month + 1}`.padStart(2, '0');\n const dayString = `${day}`.padStart(2, '0');\n const hourString = `${hour}`.padStart(2, '0');\n const minuteString = `${minute}`.padStart(2, '0');\n const secondString = `${second}`.padStart(2, '0');\n const nanoString = `${ns}`.padStart(9, '0');\n\n const dateString = `${yearString}-${monthString}-${dayString} ${hourString}:${minuteString}:${secondString}.${nanoString}`;\n return dh.i18n.DateTimeFormat.parse(\n DateUtils.FULL_DATE_FORMAT,\n dateString,\n dh.i18n.TimeZone.getTimeZone(timeZone)\n );\n }\n\n /**\n * Takes the string the user entered and returns the next nanos value\n * @param nanoString The nano string to get the next one of\n * @returns The value of the next nanos\n */\n static getNextNanos(nanoString: string): number {\n const sigNanos = parseInt(nanoString, 10);\n // Get the zeroes needed for padding before adding one so we handle overflow properly.\n const zeros = '0'.repeat(9 - nanoString.length);\n const nextNanoString = `${sigNanos + 1}${zeros}`;\n return parseInt(nextNanoString, 10);\n }\n\n /**\n * @param components The string components that were parsed from the original string\n * @param values The values that were parsed from the components\n * @param timeZone The time zone to parse the date in. E.g. America/New_York\n * @returns Returns the DateWrapper for the next date, or null if a full date was passed in\n */\n static getNextDate(\n components: DateParts<string>,\n values: DateParts<number>,\n timeZone: string\n ): DateWrapper | null {\n let { year, month, date, hours, minutes, seconds, nanos } = values;\n\n if (components.nanos != null) {\n if (components.nanos.length === 9) {\n // They want an exact match\n return null;\n }\n nanos = DateUtils.getNextNanos(components.nanos);\n if (nanos > 999999999) {\n // There's an overflow, add it to the seconds manually\n seconds += 1;\n nanos = 0;\n }\n } else if (components.seconds != null) {\n seconds += 1;\n } else if (components.minutes != null) {\n minutes += 1;\n } else if (components.hours != null) {\n hours += 1;\n } else if (components.date != null) {\n date += 1;\n } else if (components.month != null) {\n month += 1;\n } else {\n year += 1;\n }\n\n // Use the JS date to handle overflow rather than doing our own logic\n // Because handling leap years and stuff is a pain\n // Still need to add nanos after, and the overflow from that is already added to seconds above\n const jsDate = new Date(year, month, date, hours, minutes, seconds);\n return DateUtils.makeDateWrapper(\n timeZone,\n jsDate.getFullYear(),\n jsDate.getMonth(),\n jsDate.getDate(),\n jsDate.getHours(),\n jsDate.getMinutes(),\n jsDate.getSeconds(),\n nanos\n );\n }\n\n /**\n * Get the JS month value for the provided string.\n * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)\n * @param monthString The string to parse to a JS month value\n * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed\n */\n static parseMonth(monthString: string): number {\n const month = parseInt(monthString, 10);\n if (!Number.isNaN(month)) {\n if (month >= 1 && month <= 12) {\n return month - 1;\n }\n return NaN;\n }\n\n const cleanMonthString = monthString.trim().toLowerCase();\n if (cleanMonthString.length >= 3) {\n for (let i = 0; i < DateUtils.months.length; i += 1) {\n if (DateUtils.months[i].startsWith(cleanMonthString)) {\n return i;\n }\n }\n }\n\n return NaN;\n }\n\n /**\n * Parse a date object out of the provided string segments.\n * Also using `parseMonth` to get month names like Aug/August rather than\n * simply doing `parseInt`.\n * @param yearString The year part of the string\n * @param monthString The month part of the string\n * @param dayString The day part of the string\n * @param hourString The hour part of the string\n * @param minuteString The minute part of the string\n * @param secondString The second part of the string\n * @param nanoString The milli part of the string\n */\n static parseDateValues(\n yearString: string,\n monthString: string,\n dayString: string,\n hourString: string,\n minuteString: string,\n secondString: string,\n nanoString: string\n ): DateParts<number> | null {\n const year = parseInt(yearString, 10);\n const month = monthString != null ? this.parseMonth(monthString) : 0;\n const date = dayString != null ? parseInt(dayString, 10) : 1;\n const hours = hourString != null ? parseInt(hourString, 10) : 0;\n const minutes = minuteString != null ? parseInt(minuteString, 10) : 0;\n const seconds = secondString != null ? parseInt(secondString, 10) : 0;\n const nanos =\n nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;\n if (\n Number.isNaN(year) ||\n Number.isNaN(month) ||\n Number.isNaN(date) ||\n Number.isNaN(hours) ||\n Number.isNaN(minutes) ||\n Number.isNaN(seconds) ||\n Number.isNaN(nanos)\n ) {\n return null;\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parse out a date time string into it's string components.\n * Anything that is not captured in the string will be undefined.\n *\n * @param dateTimeString The date time string to parse\n * @returns Containing the date time components\n */\n static parseDateTimeString(dateTimeString: string): DateParts<string> {\n const regex = /\\s*(\\d{4})([-./]([\\da-z]+))?([-./](\\d{1,2}))?([tT\\s](\\d{2})([:](\\d{2}))?([:](\\d{2}))?([.](\\d{1,9}))?)?(.*)/;\n const result = regex.exec(dateTimeString);\n if (result == null) {\n throw new Error(`Unexpected date string: ${dateTimeString}`);\n }\n\n const [\n ,\n year,\n ,\n month,\n ,\n date,\n ,\n hours,\n ,\n minutes,\n ,\n seconds,\n ,\n nanos,\n overflow,\n ] = result;\n if (overflow != null && overflow.length > 0) {\n throw new Error(\n `Unexpected characters after date string '${dateTimeString}': ${overflow}`\n );\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parses the date range provided from a string of text.\n * @param text The string to parse the date from. Can be a keyword like \"today\", or in the format \"2018-08-04\"\n * @param timeZone The time zone to parse this range in. E.g. America/New_York\n * @returns A tuple with the start and end value/null for that date range, or both null\n */\n static parseDateRange(\n text: string,\n timeZone: string\n ): [DateWrapper, DateWrapper | null] | [null, null] {\n const cleanText = text.trim().toLowerCase();\n if (cleanText.length === 0) {\n throw new Error('Cannot parse date range from empty string');\n }\n\n if (cleanText === 'null') {\n return [null, null];\n }\n\n if (cleanText === 'today') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() + 1\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'yesterday') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() - 1\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'now') {\n const now = new Date(Date.now());\n const date = dh.DateWrapper.ofJsDate(now);\n return [date, null];\n }\n\n const components = DateUtils.parseDateTimeString(cleanText);\n if (\n components.year == null &&\n components.month == null &&\n components.date == null\n ) {\n throw new Error(`Unable to extract year, month, or day ${cleanText}`);\n }\n\n const values = DateUtils.parseDateValues(\n components.year,\n components.month,\n components.date,\n components.hours,\n components.minutes,\n components.seconds,\n components.nanos\n );\n\n if (values == null) {\n throw new Error(`Unable to extract date values from ${components}`);\n }\n\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n values.year,\n values.month,\n values.date,\n values.hours,\n values.minutes,\n values.seconds,\n values.nanos\n );\n\n const endDate = DateUtils.getNextDate(components, values, timeZone);\n return [startDate, endDate];\n }\n\n /**\n * Gets the Js Date object from the provided DateWrapper.\n * In unit test, DateWrapper is just a number provided in millis, so handles that case.\n * @param dateWrapper The DateWrapper object, or time in millis\n */\n static getJsDate(dateWrapper: DateWrapper | number): Date {\n if (typeof dateWrapper === 'number') {\n return new Date(dateWrapper);\n }\n return dateWrapper.asDate();\n }\n}\n\nexport default DateUtils;\n"],"mappings":";;AAAA,OAAOA,EAAP,MAAe,uBAAf;AAaA,OAAO,MAAMC,SAAN,CAAgB;EAkBrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACwB,OAAfC,eAAe,CACpBC,QADoB,EAEpBC,IAFoB,EASP;IAAA,IANbC,KAMa,uEANL,CAMK;IAAA,IALbC,GAKa,uEALP,CAKO;IAAA,IAJbC,IAIa,uEAJN,CAIM;IAAA,IAHbC,MAGa,uEAHJ,CAGI;IAAA,IAFbC,MAEa,uEAFJ,CAEI;IAAA,IADbC,EACa,uEADR,CACQ;;IACb,IAAI,CAACP,QAAL,EAAe;MACb,MAAM,IAAIQ,KAAJ,CAAU,sBAAV,CAAN;IACD;;IACD,IAAMC,UAAU,GAAG,UAAGR,IAAH,EAAUS,QAAV,CAAmB,CAAnB,EAAsB,GAAtB,CAAnB;IACA,IAAMC,WAAW,GAAG,UAAGT,KAAK,GAAG,CAAX,EAAeQ,QAAf,CAAwB,CAAxB,EAA2B,GAA3B,CAApB;IACA,IAAME,SAAS,GAAG,UAAGT,GAAH,EAASO,QAAT,CAAkB,CAAlB,EAAqB,GAArB,CAAlB;IACA,IAAMG,UAAU,GAAG,UAAGT,IAAH,EAAUM,QAAV,CAAmB,CAAnB,EAAsB,GAAtB,CAAnB;IACA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CAACM,KAPE,CAAf;;IAUA,IAAIL,MAAM,IAAI,IAAd,EAAoB;MAClB,MAAM,IAAIzB,KAAJ,8CAAgDwB,UAAhD,EAAN;IACD;;IAED,IAAMqC,SAAS,GAAGvE,SAAS,CAACC,eAAV,CAChBC,QADgB,EAEhBiC,MAAM,CAAChC,IAFS,EAGhBgC,MAAM,CAAC/B,KAHS,EAIhB+B,MAAM,CAACC,IAJS,EAKhBD,MAAM,CAACE,KALS,EAMhBF,MAAM,CAACG,OANS,EAOhBH,MAAM,CAACI,OAPS,EAQhBJ,MAAM,CAACK,KARS,CAAlB;IAWA,IAAMgC,OAAO,GAAGxE,SAAS,CAACiC,WAAV,CAAsBC,UAAtB,EAAkCC,MAAlC,EAA0CjC,QAA1C,CAAhB;IACA,OAAO,CAACqE,SAAD,EAAYC,OAAZ,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACkB,OAATG,SAAS,CAACC,WAAD,EAA0C;IACxD,IAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;MACnC,OAAO,IAAIlC,IAAJ,CAASkC,WAAT,CAAP;IACD;;IACD,OAAOA,WAAW,CAACC,MAAZ,EAAP;EACD;;AAvVoB;;gBAAV7E,S,sBACe,+B;;gBADfA,S,YAGK,CACd,SADc,EAEd,UAFc,EAGd,OAHc,EAId,OAJc,EAKd,KALc,EAMd,MANc,EAOd,MAPc,EAQd,QARc,EASd,WATc,EAUd,SAVc,EAWd,UAXc,EAYd,UAZc,C;;AAuVlB,eAAeA,SAAf"}
1
+ {"version":3,"file":"DateUtils.js","names":["dh","DateUtils","makeDateWrapper","timeZone","year","month","day","hour","minute","second","ns","Error","yearString","padStart","monthString","dayString","hourString","minuteString","secondString","nanoString","dateString","i18n","DateTimeFormat","parse","FULL_DATE_FORMAT","TimeZone","getTimeZone","getNextNanos","sigNanos","parseInt","zeros","repeat","length","nextNanoString","getNextDate","components","values","date","hours","minutes","seconds","nanos","jsDate","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","parseMonth","Number","isNaN","NaN","cleanMonthString","trim","toLowerCase","i","months","startsWith","parseDateValues","padEnd","parseDateTimeString","dateTimeString","regex","result","exec","overflow","parseDateRange","text","cleanText","now","startDate","endDate","DateWrapper","ofJsDate","getJsDate","dateWrapper","asDate"],"sources":["../src/DateUtils.ts"],"sourcesContent":["import dh from '@deephaven/jsapi-shim';\nimport type { DateWrapper } from '@deephaven/jsapi-shim';\n\ninterface DateParts<T> {\n year: T;\n month: T;\n date: T;\n hours: T;\n minutes: T;\n seconds: T;\n nanos: T;\n}\n\nexport class DateUtils {\n static FULL_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS';\n\n static months = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ];\n\n /**\n *\n * @param timeZone The time zone to parse this time in. E.g. America/New_York\n * @param year The year for the date\n * @param month The month, starting at 0\n * @param day The day, starting at 1\n * @param hour The hours\n * @param minute The minutes\n * @param second The seconds\n * @param ns The nanoseconds\n */\n static makeDateWrapper(\n timeZone: string,\n year: number,\n month = 0,\n day = 1,\n hour = 0,\n minute = 0,\n second = 0,\n ns = 0\n ): DateWrapper {\n if (!timeZone) {\n throw new Error('No timezone provided');\n }\n const yearString = `${year}`.padStart(4, '0');\n const monthString = `${month + 1}`.padStart(2, '0');\n const dayString = `${day}`.padStart(2, '0');\n const hourString = `${hour}`.padStart(2, '0');\n const minuteString = `${minute}`.padStart(2, '0');\n const secondString = `${second}`.padStart(2, '0');\n const nanoString = `${ns}`.padStart(9, '0');\n\n const dateString = `${yearString}-${monthString}-${dayString} ${hourString}:${minuteString}:${secondString}.${nanoString}`;\n return dh.i18n.DateTimeFormat.parse(\n DateUtils.FULL_DATE_FORMAT,\n dateString,\n dh.i18n.TimeZone.getTimeZone(timeZone)\n );\n }\n\n /**\n * Takes the string the user entered and returns the next nanos value\n * @param nanoString The nano string to get the next one of\n * @returns The value of the next nanos\n */\n static getNextNanos(nanoString: string): number {\n const sigNanos = parseInt(nanoString, 10);\n // Get the zeroes needed for padding before adding one so we handle overflow properly.\n const zeros = '0'.repeat(9 - nanoString.length);\n const nextNanoString = `${sigNanos + 1}${zeros}`;\n return parseInt(nextNanoString, 10);\n }\n\n /**\n * @param components The string components that were parsed from the original string\n * @param values The values that were parsed from the components\n * @param timeZone The time zone to parse the date in. E.g. America/New_York\n * @returns Returns the DateWrapper for the next date, or null if a full date was passed in\n */\n static getNextDate(\n components: DateParts<string>,\n values: DateParts<number>,\n timeZone: string\n ): DateWrapper | null {\n let { year, month, date, hours, minutes, seconds, nanos } = values;\n\n if (components.nanos != null) {\n if (components.nanos.length === 9) {\n // They want an exact match\n return null;\n }\n nanos = DateUtils.getNextNanos(components.nanos);\n if (nanos > 999999999) {\n // There's an overflow, add it to the seconds manually\n seconds += 1;\n nanos = 0;\n }\n } else if (components.seconds != null) {\n seconds += 1;\n } else if (components.minutes != null) {\n minutes += 1;\n } else if (components.hours != null) {\n hours += 1;\n } else if (components.date != null) {\n date += 1;\n } else if (components.month != null) {\n month += 1;\n } else {\n year += 1;\n }\n\n // Use the JS date to handle overflow rather than doing our own logic\n // Because handling leap years and stuff is a pain\n // Still need to add nanos after, and the overflow from that is already added to seconds above\n const jsDate = new Date(year, month, date, hours, minutes, seconds);\n return DateUtils.makeDateWrapper(\n timeZone,\n jsDate.getFullYear(),\n jsDate.getMonth(),\n jsDate.getDate(),\n jsDate.getHours(),\n jsDate.getMinutes(),\n jsDate.getSeconds(),\n nanos\n );\n }\n\n /**\n * Get the JS month value for the provided string.\n * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)\n * @param monthString The string to parse to a JS month value\n * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed\n */\n static parseMonth(monthString: string): number {\n const month = parseInt(monthString, 10);\n if (!Number.isNaN(month)) {\n if (month >= 1 && month <= 12) {\n return month - 1;\n }\n return NaN;\n }\n\n const cleanMonthString = monthString.trim().toLowerCase();\n if (cleanMonthString.length >= 3) {\n for (let i = 0; i < DateUtils.months.length; i += 1) {\n if (DateUtils.months[i].startsWith(cleanMonthString)) {\n return i;\n }\n }\n }\n\n return NaN;\n }\n\n /**\n * Parse a date object out of the provided string segments.\n * Also using `parseMonth` to get month names like Aug/August rather than\n * simply doing `parseInt`.\n * @param yearString The year part of the string\n * @param monthString The month part of the string\n * @param dayString The day part of the string\n * @param hourString The hour part of the string\n * @param minuteString The minute part of the string\n * @param secondString The second part of the string\n * @param nanoString The milli part of the string\n */\n static parseDateValues(\n yearString: string,\n monthString: string,\n dayString: string,\n hourString: string,\n minuteString: string,\n secondString: string,\n nanoString: string\n ): DateParts<number> | null {\n const year = parseInt(yearString, 10);\n const month = monthString != null ? this.parseMonth(monthString) : 0;\n const date = dayString != null ? parseInt(dayString, 10) : 1;\n const hours = hourString != null ? parseInt(hourString, 10) : 0;\n const minutes = minuteString != null ? parseInt(minuteString, 10) : 0;\n const seconds = secondString != null ? parseInt(secondString, 10) : 0;\n const nanos =\n nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;\n if (\n Number.isNaN(year) ||\n Number.isNaN(month) ||\n Number.isNaN(date) ||\n Number.isNaN(hours) ||\n Number.isNaN(minutes) ||\n Number.isNaN(seconds) ||\n Number.isNaN(nanos)\n ) {\n return null;\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parse out a date time string into it's string components.\n * Anything that is not captured in the string will be undefined.\n *\n * @param dateTimeString The date time string to parse\n * @returns Containing the date time components\n */\n static parseDateTimeString(dateTimeString: string): DateParts<string> {\n const regex = /\\s*(\\d{4})([-./]([\\da-z]+))?([-./](\\d{1,2}))?([tT\\s](\\d{2})([:](\\d{2}))?([:](\\d{2}))?([.](\\d{1,9}))?)?(.*)/;\n const result = regex.exec(dateTimeString);\n if (result == null) {\n throw new Error(`Unexpected date string: ${dateTimeString}`);\n }\n\n const [\n ,\n year,\n ,\n month,\n ,\n date,\n ,\n hours,\n ,\n minutes,\n ,\n seconds,\n ,\n nanos,\n overflow,\n ] = result;\n if (overflow != null && overflow.length > 0) {\n throw new Error(\n `Unexpected characters after date string '${dateTimeString}': ${overflow}`\n );\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parses the date range provided from a string of text.\n * @param text The string to parse the date from. Can be a keyword like \"today\", or in the format \"2018-08-04\"\n * @param timeZone The time zone to parse this range in. E.g. America/New_York\n * @returns A tuple with the start and end value/null for that date range, or both null\n */\n static parseDateRange(\n text: string,\n timeZone: string\n ): [DateWrapper, DateWrapper | null] | [null, null] {\n const cleanText = text.trim().toLowerCase();\n if (cleanText.length === 0) {\n throw new Error('Cannot parse date range from empty string');\n }\n\n if (cleanText === 'null') {\n return [null, null];\n }\n\n if (cleanText === 'today') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() + 1\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'yesterday') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() - 1\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'now') {\n const now = new Date(Date.now());\n const date = dh.DateWrapper.ofJsDate(now);\n return [date, null];\n }\n\n const components = DateUtils.parseDateTimeString(cleanText);\n if (\n components.year == null &&\n components.month == null &&\n components.date == null\n ) {\n throw new Error(`Unable to extract year, month, or day ${cleanText}`);\n }\n\n const values = DateUtils.parseDateValues(\n components.year,\n components.month,\n components.date,\n components.hours,\n components.minutes,\n components.seconds,\n components.nanos\n );\n\n if (values == null) {\n throw new Error(`Unable to extract date values from ${components}`);\n }\n\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n values.year,\n values.month,\n values.date,\n values.hours,\n values.minutes,\n values.seconds,\n values.nanos\n );\n\n const endDate = DateUtils.getNextDate(components, values, timeZone);\n return [startDate, endDate];\n }\n\n /**\n * Gets the Js Date object from the provided DateWrapper.\n * In unit test, DateWrapper is just a number provided in millis, so handles that case.\n * @param dateWrapper The DateWrapper object, or time in millis\n */\n static getJsDate(dateWrapper: DateWrapper | number): Date {\n if (typeof dateWrapper === 'number') {\n return new Date(dateWrapper);\n }\n return dateWrapper.asDate();\n }\n}\n\nexport default DateUtils;\n"],"mappings":";AAAA,OAAOA,EAAE,MAAM,uBAAuB;AAatC,OAAO,MAAMC,SAAS,CAAC;EAkBrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,eAAe,CACpBC,QAAgB,EAChBC,IAAY,EAOC;IAAA,IANbC,KAAK,uEAAG,CAAC;IAAA,IACTC,GAAG,uEAAG,CAAC;IAAA,IACPC,IAAI,uEAAG,CAAC;IAAA,IACRC,MAAM,uEAAG,CAAC;IAAA,IACVC,MAAM,uEAAG,CAAC;IAAA,IACVC,EAAE,uEAAG,CAAC;IAEN,IAAI,CAACP,QAAQ,EAAE;MACb,MAAM,IAAIQ,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,IAAMC,UAAU,GAAG,UAAGR,IAAI,EAAGS,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7C,IAAMC,WAAW,GAAG,UAAGT,KAAK,GAAG,CAAC,EAAGQ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IACnD,IAAME,SAAS,GAAG,UAAGT,GAAG,EAAGO,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAC3C,IAAMG,UAAU,GAAG,UAAGT,IAAI,EAAGM,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7C,IAAMI,YAAY,GAAG,UAAGT,MAAM,EAAGK,QAAQ,CAAC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IAAI,EACXD,MAAM,CAACE,KAAK,EACZF,MAAM,CAACG,OAAO,EACdH,MAAM,CAACI,OAAO,EACdJ,MAAM,CAACK,KAAK,CACb;IAED,IAAMgC,OAAO,GAAGxE,SAAS,CAACiC,WAAW,CAACC,UAAU,EAAEC,MAAM,EAAEjC,QAAQ,CAAC;IACnE,OAAO,CAACqE,SAAS,EAAEC,OAAO,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOG,SAAS,CAACC,WAAiC,EAAQ;IACxD,IAAI,OAAOA,WAAW,KAAK,QAAQ,EAAE;MACnC,OAAO,IAAIlC,IAAI,CAACkC,WAAW,CAAC;IAC9B;IACA,OAAOA,WAAW,CAACC,MAAM,EAAE;EAC7B;AACF;AAAC,gBAxVY7E,SAAS,sBACM,+BAA+B;AAAA,gBAD9CA,SAAS,YAGJ,CACd,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,CACX;AA0UH,eAAeA,SAAS"}
@@ -1,6 +1,6 @@
1
1
  import { DataType } from './TableUtils';
2
2
  import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter, TableColumnFormat, TableColumnFormatter } from './formatters';
3
- declare type ColumnName = string;
3
+ export type ColumnName = string;
4
4
  export interface FormattingRule {
5
5
  columnType: string;
6
6
  columnName: ColumnName;
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,uBAAuB,EACvB,sBAAsB,EAEtB,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,aAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,WAAW,cAAc;IAC7B,UAAU,EAA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ACJ,wBAAwB,UAAQ;IAiClC,sBAAsB,EAAE,oBAAoB,CAAC;IAE7C,gBAAgB,EAAE,GAAG,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEtD,eAAe,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE/D,wBAAwB,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;IACH,yBAAyB,CACvB,UAAU,EAAE,MAAM,EAClB,iBAAiB,UAAQ,GACxB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAY7C;;;;;OAKG;IACH,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,UAAU,GACrB,iBAAiB,GAAG,IAAI;IAK3B,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAUhE;;;;;;OAMG;IACH,kBAAkB,CAChB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,EACf,cAAc,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAC1C,MAAM;IAYT;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAKrB;CACF;AAED,eAAe,SAAS,CAAC"}
package/dist/Formatter.js CHANGED
@@ -1,5 +1,4 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
2
  import TableUtils from "./TableUtils.js";
4
3
  import { BooleanColumnFormatter, CharColumnFormatter, DateTimeColumnFormatter, DecimalColumnFormatter, DefaultColumnFormatter, IntegerColumnFormatter, StringColumnFormatter } from "./formatters/index.js";
5
4
  export class Formatter {
@@ -12,31 +11,26 @@ export class Formatter {
12
11
  if (columnFormattingRules == null) {
13
12
  return new Map();
14
13
  }
15
-
16
14
  return columnFormattingRules.reduce((map, next) => {
17
15
  var dataType = TableUtils.getNormalizedType(next.columnType);
18
-
19
16
  if (dataType === null) {
20
17
  return map;
21
18
  }
22
-
23
19
  if (!map.has(dataType)) {
24
20
  map.set(dataType, new Map());
25
21
  }
26
-
27
22
  var formatMap = map.get(dataType);
28
23
  formatMap === null || formatMap === void 0 ? void 0 : formatMap.set(next.columnName, next.format);
29
24
  return map;
30
25
  }, new Map());
31
26
  }
27
+
32
28
  /**
33
29
  * Creates a column formatting rule
34
30
  * @param columnType Normalized data type
35
31
  * @param columnName Column name
36
32
  * @param format Format object
37
33
  */
38
-
39
-
40
34
  static makeColumnFormattingRule(columnType, columnName, format) {
41
35
  return {
42
36
  columnType,
@@ -44,6 +38,7 @@ export class Formatter {
44
38
  format
45
39
  };
46
40
  }
41
+
47
42
  /**
48
43
  * @param columnFormattingRules Optional array of column formatting rules
49
44
  * @param dateTimeOptions Optional object with DateTime configuration
@@ -51,35 +46,30 @@ export class Formatter {
51
46
  * @param integerFormatOptions Optional object with Integer configuration
52
47
  * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
53
48
  */
54
-
55
-
56
49
  constructor() {
57
50
  var columnFormattingRules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
58
51
  var dateTimeOptions = arguments.length > 1 ? arguments[1] : undefined;
59
52
  var decimalFormatOptions = arguments.length > 2 ? arguments[2] : undefined;
60
53
  var integerFormatOptions = arguments.length > 3 ? arguments[3] : undefined;
61
54
  var truncateNumbersWithPound = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
62
-
63
55
  _defineProperty(this, "defaultColumnFormatter", void 0);
64
-
65
56
  _defineProperty(this, "typeFormatterMap", void 0);
66
-
67
57
  _defineProperty(this, "columnFormatMap", void 0);
68
-
69
58
  _defineProperty(this, "truncateNumbersWithPound", void 0);
70
-
71
59
  // Formatting order:
72
60
  // - columnFormatMap[type][name]
73
61
  // - typeFormatterMap[type]
74
62
  // - defaultColumnFormatter
75
- this.defaultColumnFormatter = new DefaultColumnFormatter(); // Default formatters by data type
76
63
 
77
- this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter(decimalFormatOptions)], [TableUtils.dataType.INT, new IntegerColumnFormatter(integerFormatOptions)], [TableUtils.dataType.STRING, new StringColumnFormatter()]]); // Formats indexed by data type and column name
64
+ this.defaultColumnFormatter = new DefaultColumnFormatter();
65
+
66
+ // Default formatters by data type
67
+ this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter(decimalFormatOptions)], [TableUtils.dataType.INT, new IntegerColumnFormatter(integerFormatOptions)], [TableUtils.dataType.STRING, new StringColumnFormatter()]]);
78
68
 
69
+ // Formats indexed by data type and column name
79
70
  this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
80
71
  this.truncateNumbersWithPound = truncateNumbersWithPound;
81
72
  }
82
-
83
73
  /**
84
74
  * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
85
75
  * @param columnType column type
@@ -89,44 +79,36 @@ export class Formatter {
89
79
  getColumnFormatMapForType(columnType) {
90
80
  var createIfNecessary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
91
81
  var dataType = TableUtils.getNormalizedType(columnType);
92
-
93
82
  if (dataType === null) {
94
83
  return undefined;
95
84
  }
96
-
97
85
  if (createIfNecessary && !this.columnFormatMap.has(dataType)) {
98
86
  this.columnFormatMap.set(dataType, new Map());
99
87
  }
100
-
101
88
  return this.columnFormatMap.get(dataType);
102
89
  }
90
+
103
91
  /**
104
92
  * Gets a column format object for a given column type and name
105
93
  * @param columnType column type
106
94
  * @param columnName column name
107
95
  * @returns format object or null for Default
108
96
  */
109
-
110
-
111
97
  getColumnFormat(columnType, columnName) {
112
98
  var _columnFormatMap$get;
113
-
114
99
  var columnFormatMap = this.getColumnFormatMapForType(columnType);
115
100
  return (_columnFormatMap$get = columnFormatMap === null || columnFormatMap === void 0 ? void 0 : columnFormatMap.get(columnName)) !== null && _columnFormatMap$get !== void 0 ? _columnFormatMap$get : null;
116
101
  }
117
-
118
102
  getColumnTypeFormatter(columnType) {
119
103
  var dataType = TableUtils.getNormalizedType(columnType);
120
104
  var columnTypeFormatter = this.defaultColumnFormatter;
121
-
122
105
  if (dataType) {
123
106
  var _this$typeFormatterMa;
124
-
125
107
  columnTypeFormatter = (_this$typeFormatterMa = this.typeFormatterMap.get(dataType)) !== null && _this$typeFormatterMa !== void 0 ? _this$typeFormatterMa : columnTypeFormatter;
126
108
  }
127
-
128
109
  return columnTypeFormatter;
129
110
  }
111
+
130
112
  /**
131
113
  * Gets formatted string for a given value, column type and name
132
114
  * @param value Value to format
@@ -134,33 +116,26 @@ export class Formatter {
134
116
  * @param columnName Column name used to determine the formatting settings
135
117
  * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
136
118
  */
137
-
138
-
139
119
  getFormattedString(value, columnType) {
140
120
  var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
141
121
  var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
142
-
143
122
  if (value == null) {
144
123
  return '';
145
124
  }
146
-
147
125
  var formatter = this.getColumnTypeFormatter(columnType);
148
126
  var format = formatOverride || this.getColumnFormat(columnType, columnName);
149
127
  return formatter.format(value, format !== null && format !== void 0 ? format : undefined);
150
128
  }
129
+
151
130
  /**
152
131
  * Gets the timeZone name
153
132
  * @returns The time zone name E.g. America/New_York
154
133
  */
155
-
156
-
157
134
  get timeZone() {
158
135
  var _formatter$dhTimeZone;
159
-
160
136
  var formatter = this.typeFormatterMap.get(TableUtils.dataType.DATETIME);
161
137
  return formatter === null || formatter === void 0 ? void 0 : (_formatter$dhTimeZone = formatter.dhTimeZone) === null || _formatter$dhTimeZone === void 0 ? void 0 : _formatter$dhTimeZone.id;
162
138
  }
163
-
164
139
  }
165
140
  export default Formatter;
166
141
  //# sourceMappingURL=Formatter.js.map