@engine9-io/input-tools 1.3.7 → 1.3.8
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.
- package/index.js +23 -3
- package/package.json +2 -1
package/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
const fs = require('node:fs');
|
2
2
|
|
3
3
|
const path = require('node:path');
|
4
|
+
const dayjs = require('dayjs');
|
4
5
|
|
5
6
|
const debug = require('debug')('@engine9/input-tools');
|
6
7
|
|
@@ -9,6 +10,8 @@ const {
|
|
9
10
|
v4: uuidv4, v5: uuidv5, v7: uuidv7, validate: uuidIsValid,
|
10
11
|
} = require('uuid');
|
11
12
|
const archiver = require('archiver');
|
13
|
+
const handlebars = require('handlebars');
|
14
|
+
|
12
15
|
const FileUtilities = require('./file/FileUtilities');
|
13
16
|
|
14
17
|
const {
|
@@ -27,6 +30,22 @@ const ForEachEntry = require('./ForEachEntry');
|
|
27
30
|
|
28
31
|
const { TIMELINE_ENTRY_TYPES } = require('./timelineTypes');
|
29
32
|
|
33
|
+
function getFormattedDate(dateObject, format = 'MMM DD,YYYY') {
|
34
|
+
let d = dateObject;
|
35
|
+
if (d === 'now') d = new Date();
|
36
|
+
if (d) return dayjs(d).format(format);
|
37
|
+
return '';
|
38
|
+
}
|
39
|
+
|
40
|
+
handlebars.registerHelper('date', (d, f) => {
|
41
|
+
let format;
|
42
|
+
if (typeof f === 'string')format = f;
|
43
|
+
return getFormattedDate(d, format);
|
44
|
+
});
|
45
|
+
handlebars.registerHelper('json', (d) => JSON.stringify(d));
|
46
|
+
|
47
|
+
handlebars.registerHelper('percent', (a, b) => `${((100 * a) / b).toFixed(2)}%`);
|
48
|
+
|
30
49
|
function getStringArray(s, nonZeroLength) {
|
31
50
|
let a = s || [];
|
32
51
|
if (typeof a === 'number') a = String(a);
|
@@ -300,13 +319,12 @@ module.exports = {
|
|
300
319
|
bool,
|
301
320
|
create,
|
302
321
|
list,
|
322
|
+
downloadFile,
|
303
323
|
extract,
|
304
|
-
streamPacket,
|
305
324
|
getBatchTransform,
|
306
325
|
getDebatchTransform,
|
307
326
|
getManifest,
|
308
327
|
getFile,
|
309
|
-
downloadFile,
|
310
328
|
getStringArray,
|
311
329
|
getTempFilename,
|
312
330
|
getTimelineEntryUUID,
|
@@ -315,6 +333,8 @@ module.exports = {
|
|
315
333
|
getInputUUID,
|
316
334
|
getUUIDv7,
|
317
335
|
getUUIDTimestamp,
|
336
|
+
getEntryTypeId,
|
337
|
+
handlebars,
|
318
338
|
uuidIsValid,
|
319
339
|
uuidv4,
|
320
340
|
uuidv5,
|
@@ -322,6 +342,6 @@ module.exports = {
|
|
322
342
|
makeStrings,
|
323
343
|
ForEachEntry,
|
324
344
|
FileUtilities,
|
345
|
+
streamPacket,
|
325
346
|
TIMELINE_ENTRY_TYPES,
|
326
|
-
getEntryTypeId,
|
327
347
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@engine9-io/input-tools",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.8",
|
4
4
|
"description": "Tools for dealing with Engine9 inputs",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -21,6 +21,7 @@
|
|
21
21
|
"archiver": "^7.0.1",
|
22
22
|
"async-mutex": "^0.5.0",
|
23
23
|
"csv": "^6.3.11",
|
24
|
+
"dayjs": "^1.11.13",
|
24
25
|
"debug": "^4.3.4",
|
25
26
|
"detect-file-encoding-and-language": "^2.4.0",
|
26
27
|
"googleapis": "^148.0.0",
|