@engine9-io/input-tools 1.3.7 → 1.3.9
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/file/tools.js +1 -1
- package/index.js +25 -3
- package/package.json +2 -1
package/file/tools.js
CHANGED
@@ -226,12 +226,12 @@ function bool(x, _defaultVal) {
|
|
226
226
|
module.exports = {
|
227
227
|
bool,
|
228
228
|
getTempFilename,
|
229
|
+
getTempDir,
|
229
230
|
downloadFile,
|
230
231
|
getBatchTransform,
|
231
232
|
getDebatchTransform,
|
232
233
|
getFile,
|
233
234
|
getManifest,
|
234
235
|
getPacketFiles,
|
235
|
-
getTempDir,
|
236
236
|
streamPacket,
|
237
237
|
};
|
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 {
|
@@ -17,6 +20,7 @@ const {
|
|
17
20
|
getFile,
|
18
21
|
downloadFile,
|
19
22
|
getTempFilename,
|
23
|
+
getTempDir,
|
20
24
|
streamPacket,
|
21
25
|
getPacketFiles,
|
22
26
|
getBatchTransform,
|
@@ -27,6 +31,22 @@ const ForEachEntry = require('./ForEachEntry');
|
|
27
31
|
|
28
32
|
const { TIMELINE_ENTRY_TYPES } = require('./timelineTypes');
|
29
33
|
|
34
|
+
function getFormattedDate(dateObject, format = 'MMM DD,YYYY') {
|
35
|
+
let d = dateObject;
|
36
|
+
if (d === 'now') d = new Date();
|
37
|
+
if (d) return dayjs(d).format(format);
|
38
|
+
return '';
|
39
|
+
}
|
40
|
+
|
41
|
+
handlebars.registerHelper('date', (d, f) => {
|
42
|
+
let format;
|
43
|
+
if (typeof f === 'string')format = f;
|
44
|
+
return getFormattedDate(d, format);
|
45
|
+
});
|
46
|
+
handlebars.registerHelper('json', (d) => JSON.stringify(d));
|
47
|
+
|
48
|
+
handlebars.registerHelper('percent', (a, b) => `${((100 * a) / b).toFixed(2)}%`);
|
49
|
+
|
30
50
|
function getStringArray(s, nonZeroLength) {
|
31
51
|
let a = s || [];
|
32
52
|
if (typeof a === 'number') a = String(a);
|
@@ -300,14 +320,14 @@ module.exports = {
|
|
300
320
|
bool,
|
301
321
|
create,
|
302
322
|
list,
|
323
|
+
downloadFile,
|
303
324
|
extract,
|
304
|
-
streamPacket,
|
305
325
|
getBatchTransform,
|
306
326
|
getDebatchTransform,
|
307
327
|
getManifest,
|
308
328
|
getFile,
|
309
|
-
downloadFile,
|
310
329
|
getStringArray,
|
330
|
+
getTempDir,
|
311
331
|
getTempFilename,
|
312
332
|
getTimelineEntryUUID,
|
313
333
|
getPacketFiles,
|
@@ -315,6 +335,8 @@ module.exports = {
|
|
315
335
|
getInputUUID,
|
316
336
|
getUUIDv7,
|
317
337
|
getUUIDTimestamp,
|
338
|
+
getEntryTypeId,
|
339
|
+
handlebars,
|
318
340
|
uuidIsValid,
|
319
341
|
uuidv4,
|
320
342
|
uuidv5,
|
@@ -322,6 +344,6 @@ module.exports = {
|
|
322
344
|
makeStrings,
|
323
345
|
ForEachEntry,
|
324
346
|
FileUtilities,
|
347
|
+
streamPacket,
|
325
348
|
TIMELINE_ENTRY_TYPES,
|
326
|
-
getEntryTypeId,
|
327
349
|
};
|
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.9",
|
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",
|