@propriety/court-calendar 1.0.47 → 1.0.48
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/index.mjs +8 -3
- package/package.json +1 -1
- package/src/helpers/api/courtDates.ts +13 -1
package/dist/index.mjs
CHANGED
|
@@ -12661,14 +12661,19 @@ async function mu(t, e) {
|
|
|
12661
12661
|
console.log("Fetched dates:", r), e || (e = wt.SCAR);
|
|
12662
12662
|
for (const i of r.dates) {
|
|
12663
12663
|
i.NegDateID !== void 0 && i.CourtDateID == null && (i.CourtDateID = i.NegDateID), i.Date !== void 0 && i.CourtDate == null && (i.CourtDate = new Date(i.Date)), i.Time !== void 0 && i.HearingTime == null && (i.HearingTime = i.Time), i.Lifecycle || (i.Lifecycle = $t.SCHEDULED), i.Type || (i.Type = It.UNKNOWN), i.DateType || (i.DateType = e);
|
|
12664
|
-
const o = i.MultipleDates
|
|
12664
|
+
const o = i.MultipleDates;
|
|
12665
|
+
o != null && o !== null && console.warn(`Court date ${i.CourtDateID} has raw MultipleDates:`, o);
|
|
12666
|
+
const s = Array.isArray(o) ? o : typeof o == "string" ? (() => {
|
|
12665
12667
|
try {
|
|
12666
|
-
|
|
12668
|
+
let c = o;
|
|
12669
|
+
for (; typeof c == "string"; )
|
|
12670
|
+
c = JSON.parse(c);
|
|
12671
|
+
return Array.isArray(c) ? c : null;
|
|
12667
12672
|
} catch {
|
|
12668
12673
|
return null;
|
|
12669
12674
|
}
|
|
12670
12675
|
})() : null;
|
|
12671
|
-
i.MultipleDates = Array.isArray(s) ? s.map((c) => {
|
|
12676
|
+
s == null && o != null ? console.error(`Court date ${i.CourtDateID} has invalid MultipleDates format:`, o) : s != null && console.log(`Court date ${i.CourtDateID} parsed MultipleDates:`, s), i.MultipleDates = Array.isArray(s) ? s.map((c) => {
|
|
12672
12677
|
const [u, h, f] = c.split("T")[0].split("-").map(Number);
|
|
12673
12678
|
return new Date(u, h - 1, f);
|
|
12674
12679
|
}) : null;
|
package/package.json
CHANGED
|
@@ -35,17 +35,29 @@ export async function getAllDates(apiKey: string, type?: DateType): Promise<Arra
|
|
|
35
35
|
date.DateType = type;
|
|
36
36
|
}
|
|
37
37
|
const rawMD = date.MultipleDates;
|
|
38
|
+
if (rawMD != undefined && rawMD !== null) {
|
|
39
|
+
console.warn(`Court date ${date.CourtDateID} has raw MultipleDates:`, rawMD);
|
|
40
|
+
}
|
|
38
41
|
const mdArray: string[] | null = Array.isArray(rawMD)
|
|
39
42
|
? rawMD
|
|
40
43
|
: typeof rawMD === 'string'
|
|
41
44
|
? (() => {
|
|
42
45
|
try {
|
|
43
|
-
|
|
46
|
+
let parsed: unknown = rawMD;
|
|
47
|
+
while (typeof parsed === 'string') {
|
|
48
|
+
parsed = JSON.parse(parsed);
|
|
49
|
+
}
|
|
50
|
+
return Array.isArray(parsed) ? (parsed as string[]) : null;
|
|
44
51
|
} catch {
|
|
45
52
|
return null;
|
|
46
53
|
}
|
|
47
54
|
})()
|
|
48
55
|
: null;
|
|
56
|
+
if (mdArray == null && rawMD != null) {
|
|
57
|
+
console.error(`Court date ${date.CourtDateID} has invalid MultipleDates format:`, rawMD);
|
|
58
|
+
} else if (mdArray != null) {
|
|
59
|
+
console.log(`Court date ${date.CourtDateID} parsed MultipleDates:`, mdArray);
|
|
60
|
+
}
|
|
49
61
|
date.MultipleDates = Array.isArray(mdArray)
|
|
50
62
|
? mdArray.map((d: string) => {
|
|
51
63
|
const [year, month, day] = d.split('T')[0].split('-').map(Number);
|