@usa-open-data-connectors/usa-sources 0.1.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/README.md +339 -0
- package/dist/blsSeries.d.ts +73 -0
- package/dist/blsSeries.d.ts.map +1 -0
- package/dist/blsSeries.js +173 -0
- package/dist/blsSeries.js.map +1 -0
- package/dist/cdcCountyObesity.d.ts +116 -0
- package/dist/cdcCountyObesity.d.ts.map +1 -0
- package/dist/cdcCountyObesity.js +180 -0
- package/dist/cdcCountyObesity.js.map +1 -0
- package/dist/cfpbConsumerComplaints.d.ts +152 -0
- package/dist/cfpbConsumerComplaints.d.ts.map +1 -0
- package/dist/cfpbConsumerComplaints.js +273 -0
- package/dist/cfpbConsumerComplaints.js.map +1 -0
- package/dist/cpscProductRecalls.d.ts +146 -0
- package/dist/cpscProductRecalls.d.ts.map +1 -0
- package/dist/cpscProductRecalls.js +298 -0
- package/dist/cpscProductRecalls.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/femaDisasterDeclarations.d.ts +123 -0
- package/dist/femaDisasterDeclarations.d.ts.map +1 -0
- package/dist/femaDisasterDeclarations.js +214 -0
- package/dist/femaDisasterDeclarations.js.map +1 -0
- package/dist/fixtures.d.ts +5 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +11 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/nceiAnnualTemperature.d.ts +92 -0
- package/dist/nceiAnnualTemperature.d.ts.map +1 -0
- package/dist/nceiAnnualTemperature.js +158 -0
- package/dist/nceiAnnualTemperature.js.map +1 -0
- package/dist/noaaSeaLevel.d.ts +144 -0
- package/dist/noaaSeaLevel.d.ts.map +1 -0
- package/dist/noaaSeaLevel.js +252 -0
- package/dist/noaaSeaLevel.js.map +1 -0
- package/dist/openFdaFoodRecalls.d.ts +154 -0
- package/dist/openFdaFoodRecalls.d.ts.map +1 -0
- package/dist/openFdaFoodRecalls.js +293 -0
- package/dist/openFdaFoodRecalls.js.map +1 -0
- package/dist/registry.d.ts +28 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +79 -0
- package/dist/registry.js.map +1 -0
- package/dist/treasuryAvgInterestRate.d.ts +107 -0
- package/dist/treasuryAvgInterestRate.d.ts.map +1 -0
- package/dist/treasuryAvgInterestRate.js +191 -0
- package/dist/treasuryAvgInterestRate.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/usgsEarthquakes.d.ts +108 -0
- package/dist/usgsEarthquakes.d.ts.map +1 -0
- package/dist/usgsEarthquakes.js +199 -0
- package/dist/usgsEarthquakes.js.map +1 -0
- package/dist/usgsPeakStreamflow.d.ts +116 -0
- package/dist/usgsPeakStreamflow.d.ts.map +1 -0
- package/dist/usgsPeakStreamflow.js +211 -0
- package/dist/usgsPeakStreamflow.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UsSourceApiError, UsSourceParseError } from './errors.js';
|
|
3
|
+
import { readFixtureJson } from './fixtures.js';
|
|
4
|
+
/** Base URL for the SaferProducts.gov recall service. */
|
|
5
|
+
export const CPSC_RECALL_API_BASE = 'https://www.saferproducts.gov/RestWebServices/Recall';
|
|
6
|
+
/**
|
|
7
|
+
* First calendar year the adapter reads.
|
|
8
|
+
*
|
|
9
|
+
* The service holds recalls from the 1970s, but a story that leans on recent
|
|
10
|
+
* years does not need a fifty-year fetch: every request costs a year of
|
|
11
|
+
* data, and the counts before 2014 are thin enough that the year-to-year
|
|
12
|
+
* shape is noise.
|
|
13
|
+
*/
|
|
14
|
+
export const CPSC_RECALL_FIRST_YEAR = 2014;
|
|
15
|
+
/**
|
|
16
|
+
* Recall id the service uses for an error row.
|
|
17
|
+
*
|
|
18
|
+
* A failed query does not answer with an HTTP error. It answers 200 with a
|
|
19
|
+
* single row whose id is 0 and whose title begins "Error retrieving Recalls",
|
|
20
|
+
* which is why the parser checks the row rather than the status code.
|
|
21
|
+
*/
|
|
22
|
+
export const CPSC_ERROR_RECALL_ID = 0;
|
|
23
|
+
/** Start of the first row the agency sends in the error case. */
|
|
24
|
+
const CPSC_ERROR_TITLE_PREFIX = 'Error retrieving Recalls';
|
|
25
|
+
/** Committed snapshot, so a build works when the SaferProducts host is unreachable. */
|
|
26
|
+
const CPSC_RECALL_FIXTURE_FILENAME = 'cpsc-product-recalls-2026-10-02.json';
|
|
27
|
+
/** Shape of the agency's recall date, e.g. "2025-12-18T00:00:00". */
|
|
28
|
+
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}/;
|
|
29
|
+
// Every field arrives as PascalCase. A row the agency could not complete
|
|
30
|
+
// arrives with the field null, and the nested arrays arrive as [].
|
|
31
|
+
const CPSC_ROW_SCHEMA = z.object({
|
|
32
|
+
RecallID: z.number().optional(),
|
|
33
|
+
RecallNumber: z.string().nullable().optional(),
|
|
34
|
+
RecallDate: z.string().nullable().optional(),
|
|
35
|
+
Title: z.string().nullable().optional(),
|
|
36
|
+
Products: z
|
|
37
|
+
.array(z.object({ Name: z.string().nullable().optional() }))
|
|
38
|
+
.nullable()
|
|
39
|
+
.optional(),
|
|
40
|
+
RemedyOptions: z
|
|
41
|
+
.array(z.object({ Option: z.string().nullable().optional() }))
|
|
42
|
+
.nullable()
|
|
43
|
+
.optional(),
|
|
44
|
+
ManufacturerCountries: z
|
|
45
|
+
.array(z.object({ Country: z.string().nullable().optional() }))
|
|
46
|
+
.nullable()
|
|
47
|
+
.optional(),
|
|
48
|
+
});
|
|
49
|
+
const CPSC_PAYLOAD_SCHEMA = z.array(CPSC_ROW_SCHEMA);
|
|
50
|
+
// The committed snapshot holds the folded counts rather than the year of raw
|
|
51
|
+
// rows they came from, because the raw years run to roughly a megabyte each
|
|
52
|
+
// and a build only needs the counts.
|
|
53
|
+
const CPSC_SNAPSHOT_SCHEMA = z.object({
|
|
54
|
+
exportedAt: z.string(),
|
|
55
|
+
firstYear: z.number(),
|
|
56
|
+
newestYear: z.number(),
|
|
57
|
+
newestRecallDate: z.string(),
|
|
58
|
+
totalRecalls: z.number(),
|
|
59
|
+
years: z.array(z.object({ year: z.number(), recallCount: z.number() })).min(1),
|
|
60
|
+
remedyOptions: z.array(z.object({ option: z.string(), recallCount: z.number() })),
|
|
61
|
+
manufacturerCountries: z.array(z.object({ country: z.string(), recallCount: z.number() })),
|
|
62
|
+
});
|
|
63
|
+
/** Pulls one named field out of a nested list, dropping blank entries. */
|
|
64
|
+
function valuesFrom(rows, key) {
|
|
65
|
+
return (rows ?? []).flatMap((row) => {
|
|
66
|
+
const value = row[key];
|
|
67
|
+
return value === null || value === undefined ? [] : [value];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Builds the request URL for one calendar year of recalls.
|
|
72
|
+
*
|
|
73
|
+
* The service refuses a range wider than a year with a body reading
|
|
74
|
+
* "The underlying provider failed on Open", so a caller reads one year per
|
|
75
|
+
* request. The endpoint is keyless.
|
|
76
|
+
*
|
|
77
|
+
* @param year - the calendar year to read
|
|
78
|
+
* @returns the full request URL
|
|
79
|
+
*/
|
|
80
|
+
export function buildCpscRecallUrl(year) {
|
|
81
|
+
const params = new URLSearchParams({
|
|
82
|
+
format: 'json',
|
|
83
|
+
RecallDateStart: `${year}-01-01`,
|
|
84
|
+
RecallDateEnd: `${year}-12-31`,
|
|
85
|
+
});
|
|
86
|
+
return `${CPSC_RECALL_API_BASE}?${params.toString()}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parses one year's response into the recalls dated inside that year.
|
|
90
|
+
*
|
|
91
|
+
* A failed query answers 200 with a single error row, which stops the parse
|
|
92
|
+
* rather than counting as a recall. A row dated outside the year asked for is
|
|
93
|
+
* dropped, so a response that ignored the date filter cannot widen the year.
|
|
94
|
+
* A row with no recall number or no readable date is a changed shape and also
|
|
95
|
+
* stops the parse.
|
|
96
|
+
*
|
|
97
|
+
* @param payload - the JSON body from the recall service
|
|
98
|
+
* @param year - the calendar year the request asked for
|
|
99
|
+
* @returns the recalls dated inside that year, in the order the agency sent them
|
|
100
|
+
*/
|
|
101
|
+
export function parseCpscRecallPayload(payload, year) {
|
|
102
|
+
const parsed = CPSC_PAYLOAD_SCHEMA.safeParse(payload);
|
|
103
|
+
if (!parsed.success) {
|
|
104
|
+
throw new UsSourceParseError('cpsc-product-recalls', parsed.error.message);
|
|
105
|
+
}
|
|
106
|
+
const yearPrefix = `${year}-`;
|
|
107
|
+
const recalls = [];
|
|
108
|
+
for (const row of parsed.data) {
|
|
109
|
+
if (row.RecallID === CPSC_ERROR_RECALL_ID ||
|
|
110
|
+
(row.Title?.startsWith(CPSC_ERROR_TITLE_PREFIX) ?? false)) {
|
|
111
|
+
throw new UsSourceApiError('cpsc-product-recalls', row.Title ?? 'The recall service returned an error row');
|
|
112
|
+
}
|
|
113
|
+
if (row.RecallDate === null || row.RecallDate === undefined) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (!ISO_DATE_PATTERN.test(row.RecallDate)) {
|
|
117
|
+
throw new UsSourceParseError('cpsc-product-recalls', `Unreadable recall date: ${row.RecallDate}`);
|
|
118
|
+
}
|
|
119
|
+
if (!row.RecallDate.startsWith(yearPrefix)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (row.RecallNumber === null ||
|
|
123
|
+
row.RecallNumber === undefined ||
|
|
124
|
+
row.RecallNumber.trim() === '') {
|
|
125
|
+
throw new UsSourceParseError('cpsc-product-recalls', `Recall dated ${row.RecallDate} carries no number`);
|
|
126
|
+
}
|
|
127
|
+
recalls.push({
|
|
128
|
+
recallNumber: row.RecallNumber,
|
|
129
|
+
recallDate: row.RecallDate.slice(0, 10),
|
|
130
|
+
title: row.Title ?? '',
|
|
131
|
+
productNames: valuesFrom(row.Products, 'Name'),
|
|
132
|
+
remedyOptions: valuesFrom(row.RemedyOptions, 'Option'),
|
|
133
|
+
manufacturerCountries: valuesFrom(row.ManufacturerCountries, 'Country'),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return recalls;
|
|
137
|
+
}
|
|
138
|
+
/** Counts how often each value appears, in the order the values were seen. */
|
|
139
|
+
function countValues(values) {
|
|
140
|
+
const counts = new Map();
|
|
141
|
+
for (const value of values) {
|
|
142
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
143
|
+
}
|
|
144
|
+
return counts;
|
|
145
|
+
}
|
|
146
|
+
/** Turns a counted map into a list, most first, ties broken by name. */
|
|
147
|
+
function sortCounts(counts, build) {
|
|
148
|
+
return [...counts.entries()]
|
|
149
|
+
.sort(([leftName, leftCount], [rightName, rightCount]) => leftCount === rightCount ? leftName.localeCompare(rightName) : rightCount - leftCount)
|
|
150
|
+
.map(([name, count]) => build(name, count));
|
|
151
|
+
}
|
|
152
|
+
/** Picks the year with the most, or fewest, recalls. Ties go to the earlier year. */
|
|
153
|
+
function extremeYear(years, direction) {
|
|
154
|
+
const first = years[0];
|
|
155
|
+
if (first === undefined) {
|
|
156
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'No years to summarise');
|
|
157
|
+
}
|
|
158
|
+
return years.reduce((best, year) => {
|
|
159
|
+
if (direction === 'most') {
|
|
160
|
+
return year.recallCount > best.recallCount ? year : best;
|
|
161
|
+
}
|
|
162
|
+
return year.recallCount < best.recallCount ? year : best;
|
|
163
|
+
}, first);
|
|
164
|
+
}
|
|
165
|
+
/** Folds year rows and counted fields into the series a story reads. */
|
|
166
|
+
function assembleCpscRecallSeries(input) {
|
|
167
|
+
const yearTotal = input.years.reduce((sum, year) => sum + year.recallCount, 0);
|
|
168
|
+
if (yearTotal !== input.totalRecalls) {
|
|
169
|
+
throw new UsSourceParseError('cpsc-product-recalls', `Year counts add to ${yearTotal}, not the file total of ${input.totalRecalls}`);
|
|
170
|
+
}
|
|
171
|
+
const completeYears = input.years.filter((year) => year.year !== input.newestYear);
|
|
172
|
+
if (completeYears.length === 0) {
|
|
173
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'No complete year to compare against');
|
|
174
|
+
}
|
|
175
|
+
const first = input.years[0];
|
|
176
|
+
const newest = input.years[input.years.length - 1];
|
|
177
|
+
if (first === undefined || newest === undefined || first.year !== input.firstYear) {
|
|
178
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'The year rows do not cover the window asked for');
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
firstYear: input.firstYear,
|
|
182
|
+
newestYear: input.newestYear,
|
|
183
|
+
newestRecallDate: input.newestRecallDate,
|
|
184
|
+
totalRecalls: input.totalRecalls,
|
|
185
|
+
years: input.years,
|
|
186
|
+
completeYearCount: completeYears.length,
|
|
187
|
+
busiestCompleteYear: extremeYear(completeYears, 'most'),
|
|
188
|
+
quietestCompleteYear: extremeYear(completeYears, 'fewest'),
|
|
189
|
+
remedyOptions: input.remedyOptions,
|
|
190
|
+
manufacturerCountries: input.manufacturerCountries,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Folds one window of recalls into the counts, the busiest and quietest
|
|
195
|
+
* complete years, and the remedy and country tallies.
|
|
196
|
+
*
|
|
197
|
+
* The newest year in the window is the year the agency is still filling, so
|
|
198
|
+
* the busiest and quietest years are picked from the years before it.
|
|
199
|
+
*
|
|
200
|
+
* @param recalls - the recalls read across the window
|
|
201
|
+
* @param window - the first and newest year the fetch covered
|
|
202
|
+
* @returns the counts and the named years
|
|
203
|
+
*/
|
|
204
|
+
export function buildCpscProductRecallSeries(recalls, window) {
|
|
205
|
+
if (window.newestYear <= window.firstYear) {
|
|
206
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'The window needs at least two years');
|
|
207
|
+
}
|
|
208
|
+
if (recalls.length === 0) {
|
|
209
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'No recalls to summarise');
|
|
210
|
+
}
|
|
211
|
+
const years = [];
|
|
212
|
+
for (let year = window.firstYear; year <= window.newestYear; year += 1) {
|
|
213
|
+
years.push({ year, recallCount: 0 });
|
|
214
|
+
}
|
|
215
|
+
for (const recall of recalls) {
|
|
216
|
+
const row = years.find((candidate) => candidate.year === Number(recall.recallDate.slice(0, 4)));
|
|
217
|
+
if (row === undefined) {
|
|
218
|
+
throw new UsSourceParseError('cpsc-product-recalls', `Recall dated ${recall.recallDate} falls outside the window`);
|
|
219
|
+
}
|
|
220
|
+
row.recallCount += 1;
|
|
221
|
+
}
|
|
222
|
+
const dates = recalls.map((recall) => recall.recallDate).sort();
|
|
223
|
+
const newestRecallDate = dates[dates.length - 1];
|
|
224
|
+
if (newestRecallDate === undefined) {
|
|
225
|
+
throw new UsSourceParseError('cpsc-product-recalls', 'No recall date to summarise');
|
|
226
|
+
}
|
|
227
|
+
return assembleCpscRecallSeries({
|
|
228
|
+
firstYear: window.firstYear,
|
|
229
|
+
newestYear: window.newestYear,
|
|
230
|
+
newestRecallDate,
|
|
231
|
+
totalRecalls: recalls.length,
|
|
232
|
+
years,
|
|
233
|
+
remedyOptions: sortCounts(countValues(recalls.flatMap((recall) => recall.remedyOptions)), (option, recallCount) => ({ option, recallCount })),
|
|
234
|
+
manufacturerCountries: sortCounts(countValues(recalls.flatMap((recall) => recall.manufacturerCountries)), (country, recallCount) => ({ country, recallCount })),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Parses the folded counts a snapshot holds into the story shape.
|
|
239
|
+
*
|
|
240
|
+
* A snapshot is written by the daily loop and keeps the counts, not the year
|
|
241
|
+
* of raw rows they came from. The year counts must add to the file total, so
|
|
242
|
+
* a snapshot from a half-finished fetch cannot be read as a smaller file.
|
|
243
|
+
*
|
|
244
|
+
* @param payload - the JSON body of a committed snapshot
|
|
245
|
+
* @returns the counts and the named years
|
|
246
|
+
*/
|
|
247
|
+
export function parseCpscRecallSnapshot(payload) {
|
|
248
|
+
const parsed = CPSC_SNAPSHOT_SCHEMA.safeParse(payload);
|
|
249
|
+
if (!parsed.success) {
|
|
250
|
+
throw new UsSourceParseError('cpsc-product-recalls', parsed.error.message);
|
|
251
|
+
}
|
|
252
|
+
return assembleCpscRecallSeries({
|
|
253
|
+
firstYear: parsed.data.firstYear,
|
|
254
|
+
newestYear: parsed.data.newestYear,
|
|
255
|
+
newestRecallDate: parsed.data.newestRecallDate,
|
|
256
|
+
totalRecalls: parsed.data.totalRecalls,
|
|
257
|
+
years: parsed.data.years,
|
|
258
|
+
remedyOptions: parsed.data.remedyOptions,
|
|
259
|
+
manufacturerCountries: parsed.data.manufacturerCountries,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Reads the recall file one calendar year at a time.
|
|
264
|
+
*
|
|
265
|
+
* The window runs from 2014 to the current year, so a build makes one
|
|
266
|
+
* request per year and reads about thirteen. Each request carries a whole
|
|
267
|
+
* year as JSON: 2025 is 420 rows in about 1.3 MB. A failed query answers
|
|
268
|
+
* 200 with an error row, which the parser turns into a thrown error.
|
|
269
|
+
*
|
|
270
|
+
* @param options - an optional window and fetch stub
|
|
271
|
+
* @returns the counts and the named years
|
|
272
|
+
*/
|
|
273
|
+
export async function fetchCpscProductRecalls(options) {
|
|
274
|
+
const fetchImpl = options?.fetchImpl ?? globalThis.fetch;
|
|
275
|
+
const firstYear = options?.firstYear ?? CPSC_RECALL_FIRST_YEAR;
|
|
276
|
+
const newestYear = options?.newestYear ?? new Date().getFullYear();
|
|
277
|
+
const recalls = [];
|
|
278
|
+
for (let year = firstYear; year <= newestYear; year += 1) {
|
|
279
|
+
const url = buildCpscRecallUrl(year);
|
|
280
|
+
const response = await fetchImpl(url);
|
|
281
|
+
if (!response.ok) {
|
|
282
|
+
throw new UsSourceApiError('cpsc-product-recalls', `HTTP ${response.status} reading the ${year} recall file`);
|
|
283
|
+
}
|
|
284
|
+
recalls.push(...parseCpscRecallPayload(await response.json(), year));
|
|
285
|
+
}
|
|
286
|
+
return buildCpscProductRecallSeries(recalls, { firstYear, newestYear });
|
|
287
|
+
}
|
|
288
|
+
/** US Consumer Product Safety Commission product recalls, keyless. */
|
|
289
|
+
export const cpscProductRecallsAdapter = {
|
|
290
|
+
id: 'cpsc-product-recalls',
|
|
291
|
+
name: 'CPSC product recalls',
|
|
292
|
+
auth: 'none',
|
|
293
|
+
description: 'Every consumer product recall the Consumer Product Safety Commission has published, one row per recall, with the remedy offered and the countries that made the product.',
|
|
294
|
+
fetchLive: async (options) => fetchCpscProductRecalls(options?.fetchImpl === undefined ? {} : { fetchImpl: options.fetchImpl }),
|
|
295
|
+
parse: (payload) => parseCpscRecallSnapshot(payload),
|
|
296
|
+
loadFixture: () => parseCpscRecallSnapshot(readFixtureJson(CPSC_RECALL_FIXTURE_FILENAME)),
|
|
297
|
+
};
|
|
298
|
+
//# sourceMappingURL=cpscProductRecalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cpscProductRecalls.js","sourceRoot":"","sources":["../src/cpscProductRecalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAoEhD,yDAAyD;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,sDAAsD,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,iEAAiE;AACjE,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAE3D,uFAAuF;AACvF,M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B;IAC1B,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,MAAM;IACZ,WAAW,EACT,0KAA0K;IAC5K,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAC3B,uBAAuB,CACrB,OAAO,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CACzE;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC;IACpD,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;CAC1F,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Base error for any US data source client in this package. */
|
|
2
|
+
export declare class UsSourceError extends Error {
|
|
3
|
+
constructor(message: string, options?: ErrorOptions);
|
|
4
|
+
}
|
|
5
|
+
/** The remote API rejected the request (HTTP error or bad payload). */
|
|
6
|
+
export declare class UsSourceApiError extends UsSourceError {
|
|
7
|
+
readonly source: string;
|
|
8
|
+
constructor(source: string, message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
/** The remote payload did not match the expected shape. */
|
|
11
|
+
export declare class UsSourceParseError extends UsSourceError {
|
|
12
|
+
readonly source: string;
|
|
13
|
+
constructor(source: string, message: string, options?: ErrorOptions);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED,uEAAuE;AACvE,qBAAa,gBAAiB,SAAQ,aAAa;aAE/B,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EAC9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,2DAA2D;AAC3D,qBAAa,kBAAmB,SAAQ,aAAa;aAEjC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EAC9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Base error for any US data source client in this package. */
|
|
2
|
+
export class UsSourceError extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = 'UsSourceError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** The remote API rejected the request (HTTP error or bad payload). */
|
|
9
|
+
export class UsSourceApiError extends UsSourceError {
|
|
10
|
+
source;
|
|
11
|
+
constructor(source, message, options) {
|
|
12
|
+
super(`${source}: ${message}`, options);
|
|
13
|
+
this.source = source;
|
|
14
|
+
this.name = 'UsSourceApiError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** The remote payload did not match the expected shape. */
|
|
18
|
+
export class UsSourceParseError extends UsSourceError {
|
|
19
|
+
source;
|
|
20
|
+
constructor(source, message, options) {
|
|
21
|
+
super(`${source}: ${message}`, options);
|
|
22
|
+
this.source = source;
|
|
23
|
+
this.name = 'UsSourceParseError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAE/B;IADlB,YACkB,MAAc,EAC9B,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,GAAG,MAAM,KAAK,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAJxB,WAAM,GAAN,MAAM,CAAQ;QAK9B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,2DAA2D;AAC3D,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IAEjC;IADlB,YACkB,MAAc,EAC9B,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,GAAG,MAAM,KAAK,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAJxB,WAAM,GAAN,MAAM,CAAQ;QAK9B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { UsDataAdapter } from './types.js';
|
|
2
|
+
/** One disaster declaration in the OpenFEMA file. */
|
|
3
|
+
export interface FemaDeclaration {
|
|
4
|
+
/** The agency's own identifier for the declaration, e.g. 5672. */
|
|
5
|
+
disasterNumber: number;
|
|
6
|
+
/** The date the declaration was signed, e.g. "2026-09-15T00:00:00.000Z". */
|
|
7
|
+
declarationDate: string;
|
|
8
|
+
/** Calendar year the declaration is dated to. */
|
|
9
|
+
year: number;
|
|
10
|
+
/**
|
|
11
|
+
* The program the declaration was made under: Major Disaster, Emergency,
|
|
12
|
+
* Fire Management, or Fire Suppression.
|
|
13
|
+
*/
|
|
14
|
+
declarationType: string;
|
|
15
|
+
/** The hazard behind the declaration, e.g. "Fire" or "Severe Storm". */
|
|
16
|
+
incidentType: string;
|
|
17
|
+
/** Two-letter state or territory code the declaration names. */
|
|
18
|
+
stateCode: string;
|
|
19
|
+
/** State or territory name that goes with the code. */
|
|
20
|
+
stateName: string;
|
|
21
|
+
}
|
|
22
|
+
/** One calendar year of declarations, with the fire share split out. */
|
|
23
|
+
export interface FemaDeclarationYear {
|
|
24
|
+
year: number;
|
|
25
|
+
total: number;
|
|
26
|
+
fire: number;
|
|
27
|
+
}
|
|
28
|
+
/** One value of a counted field, with how many declarations carry it. */
|
|
29
|
+
export interface FemaDeclarationCount {
|
|
30
|
+
name: string;
|
|
31
|
+
count: number;
|
|
32
|
+
}
|
|
33
|
+
/** The whole declaration file, folded into the shape a story reads. */
|
|
34
|
+
export interface FemaDeclarationCatalogue {
|
|
35
|
+
/** Every declaration in the file, oldest first. */
|
|
36
|
+
declarations: FemaDeclaration[];
|
|
37
|
+
declarationCount: number;
|
|
38
|
+
firstYear: number;
|
|
39
|
+
newestYear: number;
|
|
40
|
+
/** One entry per calendar year in the file, oldest first. */
|
|
41
|
+
years: FemaDeclarationYear[];
|
|
42
|
+
busiestYear: FemaDeclarationYear;
|
|
43
|
+
/** Declarations whose incident type is fire. */
|
|
44
|
+
fireCount: number;
|
|
45
|
+
firstFireYear: number;
|
|
46
|
+
/** Incident types, most declarations first. */
|
|
47
|
+
incidentTypes: FemaDeclarationCount[];
|
|
48
|
+
/** Declaration programs, most declarations first. */
|
|
49
|
+
declarationTypes: FemaDeclarationCount[];
|
|
50
|
+
/** States and territories, most declarations first. */
|
|
51
|
+
topStates: FemaDeclarationCount[];
|
|
52
|
+
}
|
|
53
|
+
/** Base URL for the OpenFEMA API. */
|
|
54
|
+
export declare const FEMA_OPEN_DATA_API_BASE = "https://www.fema.gov/api/open/v1";
|
|
55
|
+
/** Dataset path for the web disaster declarations file. */
|
|
56
|
+
export declare const FEMA_DECLARATION_PATH = "/FemaWebDisasterDeclarations";
|
|
57
|
+
/**
|
|
58
|
+
* Row cap for one request.
|
|
59
|
+
*
|
|
60
|
+
* The file carries a little over five thousand declarations from 1953 on,
|
|
61
|
+
* so one request covers it and the adapter never pages. A file that outgrows
|
|
62
|
+
* the cap is caught by the parser rather than silently truncated.
|
|
63
|
+
*/
|
|
64
|
+
export declare const FEMA_DECLARATION_ROW_LIMIT = 10000;
|
|
65
|
+
/**
|
|
66
|
+
* Incident type the file uses for wildfire declarations.
|
|
67
|
+
*
|
|
68
|
+
* Fires arrive under several declaration programs (Fire Management, Fire
|
|
69
|
+
* Suppression, and occasionally Major Disaster), so the incident type is what
|
|
70
|
+
* the adapter counts rather than the program.
|
|
71
|
+
*/
|
|
72
|
+
export declare const FEMA_FIRE_INCIDENT_TYPE = "Fire";
|
|
73
|
+
/**
|
|
74
|
+
* Builds the request URL for the whole declaration file.
|
|
75
|
+
*
|
|
76
|
+
* The endpoint is keyless. The row cap is high enough that one request
|
|
77
|
+
* covers the file, and the inline count lets the parser tell a complete
|
|
78
|
+
* response from a truncated one.
|
|
79
|
+
*
|
|
80
|
+
* @param options - an optional row cap
|
|
81
|
+
* @returns the full request URL
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildFemaDeclarationUrl(options?: {
|
|
84
|
+
rowLimit?: number;
|
|
85
|
+
}): string;
|
|
86
|
+
/**
|
|
87
|
+
* Parses one response into the declarations it carries.
|
|
88
|
+
*
|
|
89
|
+
* A row without the fields the story reads stops the parse, so a changed
|
|
90
|
+
* response shape cannot quietly produce a half-empty file. A response whose
|
|
91
|
+
* row count falls short of the agency's own count means the file has outgrown
|
|
92
|
+
* the request and is also refused, rather than truncated.
|
|
93
|
+
*
|
|
94
|
+
* @param payload - the JSON body from the OpenFEMA API
|
|
95
|
+
* @returns the declarations, in the order the agency sent them
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseFemaDeclarationPayload(payload: unknown): FemaDeclaration[];
|
|
98
|
+
/**
|
|
99
|
+
* Folds the parsed file into the per-year and per-value counts a story reads.
|
|
100
|
+
*
|
|
101
|
+
* The years run from the oldest declaration in the file to the newest, and
|
|
102
|
+
* the newest one is a partial year whenever the current year is still open.
|
|
103
|
+
*
|
|
104
|
+
* @param declarations - the parsed declarations, in any order
|
|
105
|
+
* @returns the per-year counts, the busiest year, and the value counts
|
|
106
|
+
*/
|
|
107
|
+
export declare function buildFemaDeclarationCatalogue(declarations: FemaDeclaration[]): FemaDeclarationCatalogue;
|
|
108
|
+
/**
|
|
109
|
+
* Reads the OpenFEMA disaster declaration file.
|
|
110
|
+
*
|
|
111
|
+
* One keyless request covers the whole file, from the 1953 declarations to
|
|
112
|
+
* the newest one the agency has published.
|
|
113
|
+
*
|
|
114
|
+
* @param options - an optional row cap and fetch stub
|
|
115
|
+
* @returns the declarations and the counts the story reads
|
|
116
|
+
*/
|
|
117
|
+
export declare function fetchFemaDeclarations(options?: {
|
|
118
|
+
rowLimit?: number;
|
|
119
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
120
|
+
}): Promise<FemaDeclarationCatalogue>;
|
|
121
|
+
/** FEMA disaster declarations, keyless. */
|
|
122
|
+
export declare const femaDisasterDeclarationsAdapter: UsDataAdapter<FemaDeclarationCatalogue>;
|
|
123
|
+
//# sourceMappingURL=femaDisasterDeclarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"femaDisasterDeclarations.d.ts","sourceRoot":"","sources":["../src/femaDisasterDeclarations.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wEAAwE;AACxE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC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