@utilarium/dreadcabinet 0.0.16-dev.0 → 0.0.17-dev.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.
- package/dist/defaults.js +6 -1
- package/dist/defaults.js.map +1 -1
- package/dist/dreadcabinet.cjs +86 -38
- package/dist/dreadcabinet.cjs.map +1 -1
- package/dist/dreadcabinet.js +1 -1
- package/dist/input/structured.d.ts +3 -3
- package/dist/input/structured.js +46 -16
- package/dist/input/structured.js.map +1 -1
- package/dist/output.d.ts +1 -1
- package/dist/output.js +5 -4
- package/dist/output.js.map +1 -1
- package/dist/read.js +2 -0
- package/dist/read.js.map +1 -1
- package/dist/util/dates.js +2 -1
- package/dist/util/dates.js.map +1 -1
- package/dist/util/storage.js +18 -8
- package/dist/util/storage.js.map +1 -1
- package/dist/validate.js +8 -8
- package/dist/validate.js.map +1 -1
- package/package.json +2 -2
- package/output/kodrdriv/250703-0645-commit-message.md +0 -21
- package/output/kodrdriv/250703-0653-commit-message.md +0 -1
- package/output/kodrdriv/250703-0654-commit-message.md +0 -1
- package/output/kodrdriv/250703-0655-release-notes.md +0 -51
- package/output/kodrdriv/250703-0700-commit-message.md +0 -1
- package/output/kodrdriv/250703-0700-release-notes.md +0 -8
- package/output/kodrdriv/250703-0706-commit-message.md +0 -1
- package/output/kodrdriv/250703-0706-release-notes.md +0 -11
- package/output/kodrdriv/250703-0717-commit-message.md +0 -1
- package/output/kodrdriv/250703-0719-commit-message.md +0 -1
- package/output/kodrdriv/250703-0719-release-notes.md +0 -17
- package/output/kodrdriv/250703-0730-commit-message.md +0 -1
- package/output/kodrdriv/250703-0730-release-notes.md +0 -11
- package/output/kodrdriv/250703-1510-commit-message.md +0 -1
- package/output/kodrdriv/250710-0805-commit-message.md +0 -3
- package/output/kodrdriv/250710-0815-commit-message.md +0 -1
- package/output/kodrdriv/250710-0815-release-notes.md +0 -39
- package/output/kodrdriv/260107-2021-commit-message.md +0 -37
- package/output/kodrdriv/260108-0432-commit-message.md +0 -6
- package/output/kodrdriv/260108-0435-commit-message.md +0 -3
- package/output/kodrdriv/260108-0436-commit-message.md +0 -4
- package/output/kodrdriv/260108-0439-release-notes.md +0 -63
- package/output/kodrdriv/260108-0543-commit-message.md +0 -19
- package/output/kodrdriv/260108-0550-commit-message.md +0 -3
- package/output/kodrdriv/260108-0550-release-notes.md +0 -19
- package/output/kodrdriv/260108-0600-commit-message.md +0 -3
- package/output/kodrdriv/260110-0717-commit-message.md +0 -4
- package/output/kodrdriv/260110-1152-commit-message.md +0 -1
- package/output/kodrdriv/260110-1850-commit-message.md +0 -1
- package/output/kodrdriv/260110-1852-release-notes.md +0 -33
- package/output/kodrdriv/260112-2257-commit-message.md +0 -5
- package/output/kodrdriv/260112-2317-commit-message.md +0 -1
- package/output/kodrdriv/260112-2318-release-notes.md +0 -42
- package/output/kodrdriv/260113-0053-commit-message.md +0 -1
- package/output/kodrdriv/260113-0054-commit-message.md +0 -1
- package/output/kodrdriv/260113-0054-release-notes.md +0 -49
- package/output/kodrdriv/260130-1132-commit-message.md +0 -1
- package/output/kodrdriv/260130-1135-commit-message.md +0 -1
- package/output/kodrdriv/260130-1335-commit-message.md +0 -10
- package/output/kodrdriv/RELEASE_NOTES.md +0 -47
- package/output/kodrdriv/RELEASE_TITLE.md +0 -1
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T04-21-54-623Z.md +0 -372
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T12-32-36-513Z.md +0 -55
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T12-35-58-580Z.md +0 -105
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T12-36-05-658Z.md +0 -53
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T13-43-55-498Z.md +0 -178
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T13-50-10-230Z.md +0 -53
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T13-50-35-136Z.md +0 -52
- package/output/kodrdriv/agentic-reflection-commit-2026-01-08T14-00-30-772Z.md +0 -52
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T15-17-43-324Z.md +0 -53
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T19-52-47-424Z.md +0 -97
- package/output/kodrdriv/agentic-reflection-commit-2026-01-11T02-50-23-123Z.md +0 -138
- package/output/kodrdriv/agentic-reflection-commit-2026-01-11T02-50-45-038Z.md +0 -114
- package/output/kodrdriv/agentic-reflection-commit-2026-01-11T02-50-49-467Z.md +0 -114
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T06-57-00-384Z.md +0 -169
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T07-17-29-292Z.md +0 -114
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T07-17-47-579Z.md +0 -114
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T08-48-55-599Z.md +0 -144
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T08-53-53-725Z.md +0 -114
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T08-54-11-600Z.md +0 -97
- package/output/kodrdriv/agentic-reflection-commit-2026-01-30T19-32-17-053Z.md +0 -174
- package/output/kodrdriv/agentic-reflection-commit-2026-01-30T19-35-00-887Z.md +0 -152
- package/output/kodrdriv/agentic-reflection-commit-2026-01-30T21-02-16-553Z.md +0 -236
- package/output/kodrdriv/agentic-reflection-commit-2026-01-30T21-17-22-227Z.md +0 -347
- package/output/kodrdriv/agentic-reflection-release-2026-01-08T12-39-08-279Z.md +0 -507
- package/output/kodrdriv/agentic-reflection-release-2026-01-08T13-50-57-683Z.md +0 -183
- package/output/kodrdriv/agentic-reflection-release-2026-01-11T02-52-39-082Z.md +0 -347
- package/output/kodrdriv/agentic-reflection-release-2026-01-13T07-18-21-218Z.md +0 -315
- package/output/kodrdriv/agentic-reflection-release-2026-01-13T08-54-59-340Z.md +0 -354
package/dist/defaults.js
CHANGED
|
@@ -9,7 +9,12 @@ const applyDefaults = (config, features, defaults)=>{
|
|
|
9
9
|
var _ref;
|
|
10
10
|
configWithDefaults.recursive = config.recursive === undefined ? (_ref = defaults === null || defaults === void 0 ? void 0 : defaults.recursive) !== null && _ref !== void 0 ? _ref : DEFAULT_RECURSIVE : config.recursive;
|
|
11
11
|
configWithDefaults.inputDirectory = config.inputDirectory || (defaults === null || defaults === void 0 ? void 0 : defaults.inputDirectory) || DEFAULT_INPUT_DIRECTORY;
|
|
12
|
-
|
|
12
|
+
// Ensure concurrency is a valid positive integer, otherwise use default
|
|
13
|
+
if (config.concurrency === undefined || !Number.isInteger(config.concurrency) || config.concurrency < 1) {
|
|
14
|
+
configWithDefaults.concurrency = (defaults === null || defaults === void 0 ? void 0 : defaults.concurrency) || DEFAULT_CONCURRENCY;
|
|
15
|
+
} else {
|
|
16
|
+
configWithDefaults.concurrency = config.concurrency;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
if (features.includes('output')) {
|
|
15
20
|
configWithDefaults.outputDirectory = config.outputDirectory || (defaults === null || defaults === void 0 ? void 0 : defaults.outputDirectory) || DEFAULT_OUTPUT_DIRECTORY;
|
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sources":["../src/defaults.ts"],"sourcesContent":["import { Config } from './dreadcabinet';\nimport { DEFAULT_CONCURRENCY, DEFAULT_EXTENSIONS, DEFAULT_INPUT_DIRECTORY, DEFAULT_INPUT_FILENAME_OPTIONS, DEFAULT_INPUT_STRUCTURE, DEFAULT_OUTPUT_DIRECTORY, DEFAULT_OUTPUT_FILENAME_OPTIONS, DEFAULT_OUTPUT_STRUCTURE, DEFAULT_RECURSIVE, DEFAULT_TIMEZONE } from './constants';\nimport { DefaultOptions, Feature } from './dreadcabinet';\n\nexport const applyDefaults = (config: Partial<Config>, features: Feature[], defaults: DefaultOptions): Config => {\n const configWithDefaults = {\n ...config,\n }\n\n configWithDefaults.timezone = config.timezone || (defaults?.timezone || DEFAULT_TIMEZONE);\n if (features.includes('input')) {\n configWithDefaults.recursive = config.recursive === undefined ? (defaults?.recursive ?? DEFAULT_RECURSIVE) : config.recursive;\n configWithDefaults.inputDirectory = config.inputDirectory || (defaults?.inputDirectory || DEFAULT_INPUT_DIRECTORY);\n
|
|
1
|
+
{"version":3,"file":"defaults.js","sources":["../src/defaults.ts"],"sourcesContent":["import { Config } from './dreadcabinet';\nimport { DEFAULT_CONCURRENCY, DEFAULT_EXTENSIONS, DEFAULT_INPUT_DIRECTORY, DEFAULT_INPUT_FILENAME_OPTIONS, DEFAULT_INPUT_STRUCTURE, DEFAULT_OUTPUT_DIRECTORY, DEFAULT_OUTPUT_FILENAME_OPTIONS, DEFAULT_OUTPUT_STRUCTURE, DEFAULT_RECURSIVE, DEFAULT_TIMEZONE } from './constants';\nimport { DefaultOptions, Feature } from './dreadcabinet';\n\nexport const applyDefaults = (config: Partial<Config>, features: Feature[], defaults: DefaultOptions): Config => {\n const configWithDefaults = {\n ...config,\n }\n\n configWithDefaults.timezone = config.timezone || (defaults?.timezone || DEFAULT_TIMEZONE);\n if (features.includes('input')) {\n configWithDefaults.recursive = config.recursive === undefined ? (defaults?.recursive ?? DEFAULT_RECURSIVE) : config.recursive;\n configWithDefaults.inputDirectory = config.inputDirectory || (defaults?.inputDirectory || DEFAULT_INPUT_DIRECTORY);\n // Ensure concurrency is a valid positive integer, otherwise use default\n if (config.concurrency === undefined || !Number.isInteger(config.concurrency) || config.concurrency < 1) {\n configWithDefaults.concurrency = defaults?.concurrency || DEFAULT_CONCURRENCY;\n } else {\n configWithDefaults.concurrency = config.concurrency;\n }\n }\n if (features.includes('output')) {\n configWithDefaults.outputDirectory = config.outputDirectory || (defaults?.outputDirectory || DEFAULT_OUTPUT_DIRECTORY);\n }\n if (features.includes('structured-output')) {\n configWithDefaults.outputStructure = config.outputStructure || (defaults?.outputStructure || DEFAULT_OUTPUT_STRUCTURE);\n configWithDefaults.outputFilenameOptions = config.outputFilenameOptions || (defaults?.outputFilenameOptions || DEFAULT_OUTPUT_FILENAME_OPTIONS);\n }\n if (features.includes('extensions')) {\n configWithDefaults.extensions = config.extensions || (defaults?.extensions || DEFAULT_EXTENSIONS);\n }\n\n if (features.includes('structured-input')) {\n configWithDefaults.inputStructure = config.inputStructure || (defaults?.inputStructure || DEFAULT_INPUT_STRUCTURE);\n configWithDefaults.inputFilenameOptions = config.inputFilenameOptions || (defaults?.inputFilenameOptions || DEFAULT_INPUT_FILENAME_OPTIONS);\n }\n\n return configWithDefaults as Config;\n}\n\n"],"names":["applyDefaults","config","features","defaults","configWithDefaults","timezone","DEFAULT_TIMEZONE","includes","recursive","undefined","DEFAULT_RECURSIVE","inputDirectory","DEFAULT_INPUT_DIRECTORY","concurrency","Number","isInteger","DEFAULT_CONCURRENCY","outputDirectory","DEFAULT_OUTPUT_DIRECTORY","outputStructure","DEFAULT_OUTPUT_STRUCTURE","outputFilenameOptions","DEFAULT_OUTPUT_FILENAME_OPTIONS","extensions","DEFAULT_EXTENSIONS","inputStructure","DEFAULT_INPUT_STRUCTURE","inputFilenameOptions","DEFAULT_INPUT_FILENAME_OPTIONS"],"mappings":"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"}
|
package/dist/dreadcabinet.cjs
CHANGED
|
@@ -156,7 +156,12 @@ const applyDefaults = (config, features, defaults)=>{
|
|
|
156
156
|
var _ref;
|
|
157
157
|
configWithDefaults.recursive = config.recursive === undefined ? (_ref = defaults === null || defaults === void 0 ? void 0 : defaults.recursive) !== null && _ref !== void 0 ? _ref : DEFAULT_RECURSIVE : config.recursive;
|
|
158
158
|
configWithDefaults.inputDirectory = config.inputDirectory || (defaults === null || defaults === void 0 ? void 0 : defaults.inputDirectory) || DEFAULT_INPUT_DIRECTORY;
|
|
159
|
-
|
|
159
|
+
// Ensure concurrency is a valid positive integer, otherwise use default
|
|
160
|
+
if (config.concurrency === undefined || !Number.isInteger(config.concurrency) || config.concurrency < 1) {
|
|
161
|
+
configWithDefaults.concurrency = (defaults === null || defaults === void 0 ? void 0 : defaults.concurrency) || DEFAULT_CONCURRENCY;
|
|
162
|
+
} else {
|
|
163
|
+
configWithDefaults.concurrency = config.concurrency;
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
166
|
if (features.includes('output')) {
|
|
162
167
|
configWithDefaults.outputDirectory = config.outputDirectory || (defaults === null || defaults === void 0 ? void 0 : defaults.outputDirectory) || DEFAULT_OUTPUT_DIRECTORY;
|
|
@@ -183,7 +188,9 @@ const read = async (args, features)=>{
|
|
|
183
188
|
config.timezone = args.timezone;
|
|
184
189
|
if (features.includes('input')) {
|
|
185
190
|
config.inputDirectory = args.inputDirectory;
|
|
191
|
+
config.recursive = args.recursive;
|
|
186
192
|
config.limit = args.limit;
|
|
193
|
+
config.concurrency = args.concurrency;
|
|
187
194
|
}
|
|
188
195
|
if (features.includes('structured-input')) {
|
|
189
196
|
config.inputStructure = args.inputStructure;
|
|
@@ -808,7 +815,7 @@ const create$5 = (parameters)=>{
|
|
|
808
815
|
};
|
|
809
816
|
const today = ()=>{
|
|
810
817
|
// Return today's date formatted as YYYY-M-D in the specified timezone
|
|
811
|
-
return dayjs().tz(timezone).format(
|
|
818
|
+
return dayjs().tz(timezone).format(DATE_FORMAT_YEAR_MONTH_DAY);
|
|
812
819
|
};
|
|
813
820
|
const date = (date)=>{
|
|
814
821
|
let value;
|
|
@@ -974,27 +981,37 @@ const create$4 = (params)=>{
|
|
|
974
981
|
pattern: '*.*'
|
|
975
982
|
})=>{
|
|
976
983
|
try {
|
|
977
|
-
|
|
984
|
+
// NOTE: glob loads all matching files into memory before processing.
|
|
985
|
+
// For directories with millions of files, this can cause out-of-memory errors.
|
|
986
|
+
// Consider using streaming glob or incremental processing for very large directories.
|
|
978
987
|
const files = await glob.glob(options.pattern, {
|
|
979
988
|
cwd: directory,
|
|
980
989
|
nodir: true
|
|
981
990
|
});
|
|
982
991
|
const concurrency = options.concurrency || 1;
|
|
983
|
-
|
|
992
|
+
const limit = options.limit || files.length;
|
|
993
|
+
// Use a queue-based approach to avoid race conditions
|
|
994
|
+
const fileQueue = files.slice(0, limit);
|
|
995
|
+
let filesProcessed = 0;
|
|
984
996
|
async function worker() {
|
|
985
|
-
while(
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
997
|
+
while(fileQueue.length > 0 && filesProcessed < limit){
|
|
998
|
+
// Atomically get next file from queue
|
|
999
|
+
const file = fileQueue.shift();
|
|
1000
|
+
if (!file) break;
|
|
1001
|
+
await callback(path__namespace.join(directory, file));
|
|
1002
|
+
// Atomically increment counter
|
|
989
1003
|
filesProcessed++;
|
|
1004
|
+
if (filesProcessed >= limit) {
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
990
1007
|
}
|
|
991
1008
|
}
|
|
992
1009
|
const workers = Array.from({
|
|
993
1010
|
length: concurrency
|
|
994
1011
|
}, ()=>worker());
|
|
995
1012
|
await Promise.all(workers);
|
|
996
|
-
if (
|
|
997
|
-
log(`Reached limit of ${
|
|
1013
|
+
if (filesProcessed >= limit) {
|
|
1014
|
+
log(`Reached limit of ${limit} files, stopping`);
|
|
998
1015
|
}
|
|
999
1016
|
} catch (err) {
|
|
1000
1017
|
throw new Error(`Failed to glob pattern ${options.pattern} in ${directory}: ${err.message}`);
|
|
@@ -1030,15 +1047,10 @@ const create$4 = (params)=>{
|
|
|
1030
1047
|
};
|
|
1031
1048
|
|
|
1032
1049
|
const validate = async (config, options)=>{
|
|
1033
|
-
const logger = console;
|
|
1034
1050
|
const storage = create$4({
|
|
1035
|
-
log: logger.debug
|
|
1051
|
+
log: options.logger.debug
|
|
1036
1052
|
});
|
|
1037
1053
|
const validateInputDirectory = async (inputDirectory)=>{
|
|
1038
|
-
// eslint-disable-next-line no-console
|
|
1039
|
-
const storage = create$4({
|
|
1040
|
-
log: console.log
|
|
1041
|
-
});
|
|
1042
1054
|
if (!storage.isDirectoryReadable(inputDirectory)) {
|
|
1043
1055
|
throw new Error(`Input directory does not exist: ${inputDirectory}`);
|
|
1044
1056
|
}
|
|
@@ -1057,7 +1069,7 @@ const validate = async (config, options)=>{
|
|
|
1057
1069
|
}
|
|
1058
1070
|
};
|
|
1059
1071
|
const validateOutputFilenameOptions = (outputFilenameOptions, outputStructure)=>{
|
|
1060
|
-
if (outputFilenameOptions) {
|
|
1072
|
+
if (outputFilenameOptions && outputFilenameOptions.length > 0) {
|
|
1061
1073
|
var _options_allowed;
|
|
1062
1074
|
// Check if first argument contains commas - likely a comma-separated list
|
|
1063
1075
|
if (outputFilenameOptions[0].includes(',')) {
|
|
@@ -1088,7 +1100,7 @@ const validate = async (config, options)=>{
|
|
|
1088
1100
|
}
|
|
1089
1101
|
};
|
|
1090
1102
|
const validateInputFilenameOptions = (inputFilenameOptions, inputStructure)=>{
|
|
1091
|
-
if (inputFilenameOptions) {
|
|
1103
|
+
if (inputFilenameOptions && inputFilenameOptions.length > 0) {
|
|
1092
1104
|
var _options_allowed;
|
|
1093
1105
|
// Check if first argument contains commas - likely a comma-separated list
|
|
1094
1106
|
if (inputFilenameOptions[0].includes(',')) {
|
|
@@ -1138,6 +1150,11 @@ const validate = async (config, options)=>{
|
|
|
1138
1150
|
throw new ArgumentError('--limit', 'Limit must be greater than 0');
|
|
1139
1151
|
}
|
|
1140
1152
|
}
|
|
1153
|
+
if (options.features.includes('input') && config.concurrency !== undefined) {
|
|
1154
|
+
if (!Number.isInteger(config.concurrency) || config.concurrency < 1) {
|
|
1155
|
+
throw new ArgumentError('--concurrency', 'Concurrency must be a positive integer');
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1141
1158
|
if (options.features.includes('output') && config.outputDirectory) {
|
|
1142
1159
|
await validateOutputDirectory(config.outputDirectory);
|
|
1143
1160
|
}
|
|
@@ -1188,7 +1205,7 @@ const getFilePattern = (features, extensions, logger)=>{
|
|
|
1188
1205
|
};
|
|
1189
1206
|
// Helper function to parse date string based on expected format
|
|
1190
1207
|
// Returns null if parsing fails
|
|
1191
|
-
const parseDateFromString = (dateStr, format, shouldParseTime, year, month, day)=>{
|
|
1208
|
+
const parseDateFromString = (dateStr, format, shouldParseTime, timezone, year, month, day)=>{
|
|
1192
1209
|
// Basic validation
|
|
1193
1210
|
if (!dateStr) return null;
|
|
1194
1211
|
try {
|
|
@@ -1270,11 +1287,41 @@ const parseDateFromString = (dateStr, format, shouldParseTime, year, month, day)
|
|
|
1270
1287
|
if (mo < 0 || mo > 11 || d < 1 || d > 31 || h < 0 || h > 23 || mi < 0 || mi > 59) {
|
|
1271
1288
|
throw new Error(`Invalid date components in date string "${dateStr}" with format ${format}: Y:${y} M:${mo + 1} D:${d} H:${h} m:${mi}`);
|
|
1272
1289
|
}
|
|
1273
|
-
|
|
1274
|
-
//
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1290
|
+
// Create timezone-aware date
|
|
1291
|
+
// For UTC timezone, use Date.UTC for efficiency and exact matching
|
|
1292
|
+
// For other timezones, use timezone-aware parsing
|
|
1293
|
+
let date;
|
|
1294
|
+
if (timezone === 'UTC' || timezone === 'Etc/UTC') {
|
|
1295
|
+
date = new Date(Date.UTC(y, mo, d, h, mi));
|
|
1296
|
+
// Validate that Date didn't adjust invalid dates (e.g., Feb 30 -> Mar 2)
|
|
1297
|
+
if (date.getUTCFullYear() !== y || date.getUTCMonth() !== mo || date.getUTCDate() !== d || date.getUTCHours() !== h || date.getUTCMinutes() !== mi) {
|
|
1298
|
+
return null;
|
|
1299
|
+
}
|
|
1300
|
+
} else {
|
|
1301
|
+
// Use timezone-aware parsing for non-UTC timezones
|
|
1302
|
+
const dates = create$5({
|
|
1303
|
+
timezone
|
|
1304
|
+
});
|
|
1305
|
+
const monthStr = String(mo + 1).padStart(2, '0');
|
|
1306
|
+
const dayStr = String(d).padStart(2, '0');
|
|
1307
|
+
const hourStr = String(h).padStart(2, '0');
|
|
1308
|
+
const minuteStr = String(mi).padStart(2, '0');
|
|
1309
|
+
const dateStrFormatted = `${y}-${monthStr}-${dayStr}T${hourStr}:${minuteStr}:00`;
|
|
1310
|
+
try {
|
|
1311
|
+
date = dates.date(dateStrFormatted);
|
|
1312
|
+
// Validate that the date components match in the timezone context
|
|
1313
|
+
const formattedYear = parseInt(dates.format(date, 'YYYY'), 10);
|
|
1314
|
+
const formattedMonth = parseInt(dates.format(date, 'M'), 10);
|
|
1315
|
+
const formattedDay = parseInt(dates.format(date, 'D'), 10);
|
|
1316
|
+
const formattedHour = parseInt(dates.format(date, 'H'), 10);
|
|
1317
|
+
const formattedMinute = parseInt(dates.format(date, 'm'), 10);
|
|
1318
|
+
// Check if date was adjusted (e.g., Feb 30 -> Mar 2)
|
|
1319
|
+
if (formattedYear !== y || formattedMonth !== mo + 1 || formattedDay !== d || formattedHour !== h || formattedMinute !== mi) {
|
|
1320
|
+
return null;
|
|
1321
|
+
}
|
|
1322
|
+
} catch {
|
|
1323
|
+
return null;
|
|
1324
|
+
}
|
|
1278
1325
|
}
|
|
1279
1326
|
return date;
|
|
1280
1327
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1332,7 +1379,7 @@ const calculateDateRange = (timezone, startDate, endDate)=>{
|
|
|
1332
1379
|
return range;
|
|
1333
1380
|
};
|
|
1334
1381
|
// Parse date from file path based on the input structure
|
|
1335
|
-
const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTime, logger)=>{
|
|
1382
|
+
const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTime, timezone, logger)=>{
|
|
1336
1383
|
const pathParts = relativePath.split(path__namespace.sep);
|
|
1337
1384
|
const filenameWithoutExt = path__namespace.basename(filename, path__namespace.extname(filename));
|
|
1338
1385
|
let parsedDate = null;
|
|
@@ -1342,14 +1389,14 @@ const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTim
|
|
|
1342
1389
|
switch(structure){
|
|
1343
1390
|
case 'none':
|
|
1344
1391
|
// Filename format: YYYY-M-D-HHmm...
|
|
1345
|
-
parsedDate = parseDateFromString(filenameWithoutExt, 'YYYY-M-D-HHmm', shouldParseTime);
|
|
1392
|
+
parsedDate = parseDateFromString(filenameWithoutExt, 'YYYY-M-D-HHmm', shouldParseTime, timezone);
|
|
1346
1393
|
break;
|
|
1347
1394
|
case 'year':
|
|
1348
1395
|
// Path: YYYY / M-D-HHmm...
|
|
1349
1396
|
if (pathParts.length >= 1) {
|
|
1350
1397
|
year = parseInt(pathParts[0], 10);
|
|
1351
1398
|
if (!isNaN(year)) {
|
|
1352
|
-
parsedDate = parseDateFromString(filenameWithoutExt, 'M-D-HHmm', shouldParseTime, year);
|
|
1399
|
+
parsedDate = parseDateFromString(filenameWithoutExt, 'M-D-HHmm', shouldParseTime, timezone, year);
|
|
1353
1400
|
} else {
|
|
1354
1401
|
logger.warn(`Invalid year format in path: ${pathParts[0]}`);
|
|
1355
1402
|
}
|
|
@@ -1364,7 +1411,7 @@ const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTim
|
|
|
1364
1411
|
const monthDir = parseInt(pathParts[1], 10); // Month from dir (1-indexed)
|
|
1365
1412
|
if (!isNaN(year) && !isNaN(monthDir) && monthDir >= 1 && monthDir <= 12) {
|
|
1366
1413
|
month = monthDir - 1; // Adjust month for Date object (0-indexed)
|
|
1367
|
-
parsedDate = parseDateFromString(filenameWithoutExt, 'D-HHmm', shouldParseTime, year, month);
|
|
1414
|
+
parsedDate = parseDateFromString(filenameWithoutExt, 'D-HHmm', shouldParseTime, timezone, year, month);
|
|
1368
1415
|
} else {
|
|
1369
1416
|
logger.warn(`Invalid year/month format in path: ${pathParts[0]}/${pathParts[1]}`);
|
|
1370
1417
|
}
|
|
@@ -1380,7 +1427,7 @@ const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTim
|
|
|
1380
1427
|
day = parseInt(pathParts[2], 10); // Day from dir (1-indexed)
|
|
1381
1428
|
if (!isNaN(year) && !isNaN(monthDir) && monthDir >= 1 && monthDir <= 12 && !isNaN(day) && day >= 1 && day <= 31) {
|
|
1382
1429
|
month = monthDir - 1; // Adjust month (0-indexed)
|
|
1383
|
-
parsedDate = parseDateFromString(filenameWithoutExt, 'HHmm', shouldParseTime, year, month, day);
|
|
1430
|
+
parsedDate = parseDateFromString(filenameWithoutExt, 'HHmm', shouldParseTime, timezone, year, month, day);
|
|
1384
1431
|
} else {
|
|
1385
1432
|
logger.warn(`Invalid year/month/day format in path: ${pathParts[0]}/${pathParts[1]}/${pathParts[2]}`);
|
|
1386
1433
|
}
|
|
@@ -1395,7 +1442,7 @@ const parseDateFromFilePath = (relativePath, filename, structure, shouldParseTim
|
|
|
1395
1442
|
return parsedDate;
|
|
1396
1443
|
};
|
|
1397
1444
|
// Process a single file from the structured input
|
|
1398
|
-
const processStructuredFile = async (filePath, inputDirectory, structure, shouldParseTime, callback, pattern, dateRange, logger)=>{
|
|
1445
|
+
const processStructuredFile = async (filePath, inputDirectory, structure, shouldParseTime, timezone, callback, pattern, dateRange, logger)=>{
|
|
1399
1446
|
// Skip if filePath somehow points to the inputDirectory itself or is not a file
|
|
1400
1447
|
if (filePath === inputDirectory || !path__namespace.extname(filePath) && pattern.endsWith('*.*')) {
|
|
1401
1448
|
return false;
|
|
@@ -1408,7 +1455,7 @@ const processStructuredFile = async (filePath, inputDirectory, structure, should
|
|
|
1408
1455
|
return false;
|
|
1409
1456
|
}
|
|
1410
1457
|
try {
|
|
1411
|
-
const parsedDate = parseDateFromFilePath(relativePath, filename, structure, shouldParseTime, logger);
|
|
1458
|
+
const parsedDate = parseDateFromFilePath(relativePath, filename, structure, shouldParseTime, timezone, logger);
|
|
1412
1459
|
if (parsedDate) {
|
|
1413
1460
|
// Apply date range filtering
|
|
1414
1461
|
if (isDateInRange(parsedDate, dateRange)) {
|
|
@@ -1441,10 +1488,10 @@ const process$2 = async (inputStructure, inputFilenameOptions, extensions, timez
|
|
|
1441
1488
|
let fileCount = 0;
|
|
1442
1489
|
// Validate date range dates if provided
|
|
1443
1490
|
if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (!dateRange.start || isNaN(dateRange.start.getTime()))) {
|
|
1444
|
-
|
|
1491
|
+
throw new Error(`Invalid start date provided in dateRange: ${dateRange.start}`);
|
|
1445
1492
|
}
|
|
1446
1493
|
if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && (!dateRange.end || isNaN(dateRange.end.getTime()))) {
|
|
1447
|
-
|
|
1494
|
+
throw new Error(`Invalid end date provided in dateRange: ${dateRange.end}`);
|
|
1448
1495
|
}
|
|
1449
1496
|
// Structured Input Logic
|
|
1450
1497
|
const structure = inputStructure !== null && inputStructure !== void 0 ? inputStructure : 'none'; // Default to 'none' if not specified
|
|
@@ -1459,7 +1506,7 @@ const process$2 = async (inputStructure, inputFilenameOptions, extensions, timez
|
|
|
1459
1506
|
const filePattern = getFilePattern(features, extensions || [], logger);
|
|
1460
1507
|
logger.debug('Processing Structured Input with pattern %s from %s', filePattern, inputDirectory);
|
|
1461
1508
|
await storage.forEachFileIn(inputDirectory, async (filePath)=>{
|
|
1462
|
-
const processed = await processStructuredFile(filePath, inputDirectory, structure, shouldParseTime, callback, filePattern, dateRange, logger);
|
|
1509
|
+
const processed = await processStructuredFile(filePath, inputDirectory, structure, shouldParseTime, timezone, callback, filePattern, dateRange, logger);
|
|
1463
1510
|
if (processed) {
|
|
1464
1511
|
fileCount++;
|
|
1465
1512
|
}
|
|
@@ -1578,8 +1625,9 @@ const create$2 = (config, options)=>{
|
|
|
1578
1625
|
}
|
|
1579
1626
|
}
|
|
1580
1627
|
function sanitizeFilenameString(str) {
|
|
1581
|
-
// Replace any character that is not alphanumeric, hyphen, underscore, or dot with an underscore
|
|
1582
|
-
|
|
1628
|
+
// Replace any character that is not alphanumeric (including unicode), hyphen, underscore, or dot with an underscore
|
|
1629
|
+
// Use \p{L} for unicode letters and \p{N} for unicode numbers
|
|
1630
|
+
return str.replace(/[^\p{L}\p{N}\-_.]/gu, '_')// Replace multiple consecutive underscores with a single underscore
|
|
1583
1631
|
.replace(/_+/g, '_')// Remove leading and trailing underscores
|
|
1584
1632
|
.replace(/^_+|_+$/g, '')// Ensure the string is not empty
|
|
1585
1633
|
.replace(/^$/, 'untitled');
|
|
@@ -1609,7 +1657,7 @@ const create$2 = (config, options)=>{
|
|
|
1609
1657
|
}
|
|
1610
1658
|
return parts.join('-');
|
|
1611
1659
|
}
|
|
1612
|
-
function constructOutputDirectory(creationTime) {
|
|
1660
|
+
async function constructOutputDirectory(creationTime) {
|
|
1613
1661
|
// Throw this error to ensure that we don't success if outputDirectory or outputStructure are not set
|
|
1614
1662
|
if (!outputDirectory) {
|
|
1615
1663
|
throw new Error('Unable to Create Output: Output directory is not set');
|
|
@@ -1635,7 +1683,7 @@ const create$2 = (config, options)=>{
|
|
|
1635
1683
|
default:
|
|
1636
1684
|
outputPath = outputDirectory;
|
|
1637
1685
|
}
|
|
1638
|
-
storage.createDirectory(outputPath);
|
|
1686
|
+
await storage.createDirectory(outputPath);
|
|
1639
1687
|
return outputPath;
|
|
1640
1688
|
}
|
|
1641
1689
|
return {
|