@intelligo.ai/object-to-schema
Advanced tools
Comparing version 2.3.5 to 2.3.6
@@ -14,4 +14,5 @@ declare function fromTracerDate(tracerDate: number): string | undefined; | ||
declare function joinObjectKeysToString(value: any, options: any): string; | ||
declare function convertFastCaseData(fastCaseDate: string): Promise<Date | undefined>; | ||
declare function convertClearData(clearDate: string): Date | null | undefined; | ||
declare function convertFastCaseDate(fastCaseDate: string): Promise<Date | undefined>; | ||
declare function convertClearDate(clearDate: string): Date | undefined; | ||
declare function convertSteeleDate(steeleDate: string): Date | undefined; | ||
export declare const strategies: { | ||
@@ -38,4 +39,5 @@ predefinedTransformations: { | ||
convertStringToDate: (str: string) => Date | null; | ||
convertFastCaseData: typeof convertFastCaseData; | ||
convertClearData: typeof convertClearData; | ||
convertFastCaseDate: typeof convertFastCaseDate; | ||
convertClearDate: typeof convertClearDate; | ||
convertSteeleDate: typeof convertSteeleDate; | ||
}; | ||
@@ -42,0 +44,0 @@ }; |
@@ -324,3 +324,3 @@ "use strict"; | ||
} | ||
function convertFastCaseData(fastCaseDate) { | ||
function convertFastCaseDate(fastCaseDate) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -351,3 +351,10 @@ var jsDate, match, milliseconds, offset, date, offsetHours, offsetMinutes, offsetMilliseconds, normalizedDate; | ||
} | ||
function convertClearData(clearDate) { | ||
function parseClearDate(clearDate) { | ||
var cleanedInput = clearDate.replace(/^(ca\.?|around|approximately)\s*/i, '').trim(); | ||
if (String(cleanedInput).length === 4) { | ||
return new Date(Number(clearDate), 0, 1); | ||
} | ||
return chrono.parseDate(clearDate); | ||
} | ||
function convertClearDate(clearDate) { | ||
if (!clearDate) { | ||
@@ -359,12 +366,39 @@ return; | ||
if (dates.length === 1) { | ||
return chrono.parseDate(dates[0]); | ||
return parseClearDate(dates[0]); | ||
} | ||
var _a = __read(dates | ||
.map(function (date) { return date.trim(); }) | ||
.map(function (date) { return chrono.parseDate(date); }) | ||
.map(function (date) { return parseClearDate(date); }) | ||
.sort(function (a, b) { return a.getTime() - b.getTime(); }), 1), earlyDate = _a[0]; | ||
return earlyDate; | ||
} | ||
return chrono.parseDate(clearDate); | ||
return parseClearDate(clearDate); | ||
} | ||
function parseSteeleDate(steeleDate) { | ||
if (/^\d{2}\.\d{2}\.\d{4}$/.test(steeleDate)) { | ||
var _a = __read(steeleDate.split('.'), 3), day = _a[0], month = _a[1], year = _a[2]; | ||
return new Date("".concat(year, "-").concat(month, "-").concat(day)); | ||
} | ||
if (/^\d{4}-\d{2}$/.test(steeleDate)) { | ||
return new Date("".concat(steeleDate, "-01")); | ||
} | ||
return new Date("".concat(steeleDate, "-01-01")); | ||
} | ||
function convertSteeleDate(steeleDate) { | ||
if (!steeleDate) { | ||
return; | ||
} | ||
if (steeleDate.includes(';')) { | ||
var dates = steeleDate.split(';'); | ||
if (dates.length === 1) { | ||
return parseSteeleDate(steeleDate[0]); | ||
} | ||
var _a = __read(dates | ||
.map(function (date) { return date.trim(); }) | ||
.map(function (date) { return parseSteeleDate(date); }) | ||
.sort(function (a, b) { return a.getTime() - b.getTime(); }), 1), earlyDate = _a[0]; | ||
return earlyDate; | ||
} | ||
return parseSteeleDate(steeleDate); | ||
} | ||
exports.strategies = { | ||
@@ -391,6 +425,7 @@ predefinedTransformations: { | ||
convertStringToDate: function (str) { return chrono.parseDate(str); }, | ||
convertFastCaseData: convertFastCaseData, | ||
convertClearData: convertClearData | ||
convertFastCaseDate: convertFastCaseDate, | ||
convertClearDate: convertClearDate, | ||
convertSteeleDate: convertSteeleDate | ||
} | ||
}; | ||
//# sourceMappingURL=predefinedTransformations.js.map |
@@ -0,0 +0,0 @@ module.exports = { |
{ | ||
"name": "@intelligo.ai/object-to-schema", | ||
"version": "2.3.5", | ||
"version": "2.3.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,0 +0,0 @@ # object-to-schema-mapper |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
373825
64
7074
1