@usa-open-data-connectors/usa-sources 0.1.4 → 0.1.7
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 +137 -4
- package/dist/callookCallsigns.d.ts +119 -0
- package/dist/callookCallsigns.d.ts.map +1 -0
- package/dist/callookCallsigns.js +264 -0
- package/dist/callookCallsigns.js.map +1 -0
- package/dist/collegeScorecardInstitutions.d.ts +133 -0
- package/dist/collegeScorecardInstitutions.d.ts.map +1 -0
- package/dist/collegeScorecardInstitutions.js +339 -0
- package/dist/collegeScorecardInstitutions.js.map +1 -0
- package/dist/http.d.ts +5 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +33 -25
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/ncbiPubmedSearch.d.ts +4 -0
- package/dist/ncbiPubmedSearch.d.ts.map +1 -1
- package/dist/ncbiPubmedSearch.js +9 -1
- package/dist/ncbiPubmedSearch.js.map +1 -1
- package/dist/nextBusTransitVehicles.d.ts +102 -0
- package/dist/nextBusTransitVehicles.d.ts.map +1 -0
- package/dist/nextBusTransitVehicles.js +171 -0
- package/dist/nextBusTransitVehicles.js.map +1 -0
- package/dist/publicDataHubHospital.d.ts +116 -0
- package/dist/publicDataHubHospital.d.ts.map +1 -0
- package/dist/publicDataHubHospital.js +175 -0
- package/dist/publicDataHubHospital.js.map +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -0
- package/dist/registry.js.map +1 -1
- package/dist/secEdgarFilings.d.ts.map +1 -1
- package/dist/secEdgarFilings.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { UsDataAdapter } from './types.js';
|
|
2
|
+
/** Adapter id for the College Scorecard institution-level download. */
|
|
3
|
+
export declare const COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID = "college-scorecard-institutions";
|
|
4
|
+
/** The dated, keyless institution-level archive published by College Scorecard. */
|
|
5
|
+
export declare const COLLEGE_SCORECARD_INSTITUTION_ARCHIVE_URL = "https://ed-public-download.scorecard.network/downloads/Most-Recent-Cohorts-Institution_10152026.zip";
|
|
6
|
+
/** The data release the pinned archive represents, as YYYY-MM-DD. */
|
|
7
|
+
export declare const COLLEGE_SCORECARD_DATA_RELEASE_DATE = "2026-10-15";
|
|
8
|
+
/**
|
|
9
|
+
* The archive is 24 MB, and the CSV inside it is 102 MB.
|
|
10
|
+
*
|
|
11
|
+
* The shared 30 second timeout is tuned for small JSON answers, so this
|
|
12
|
+
* adapter allows two minutes for the download and inflation.
|
|
13
|
+
*/
|
|
14
|
+
export declare const COLLEGE_SCORECARD_FETCH_TIMEOUT_MS = 120000;
|
|
15
|
+
/** The kind of institution the federal government recorded. */
|
|
16
|
+
export type CollegeScorecardControl = 'public' | 'private-nonprofit' | 'private-for-profit' | 'unknown';
|
|
17
|
+
/** One institution and the outcome fields a story can use. */
|
|
18
|
+
export interface CollegeScorecardInstitution {
|
|
19
|
+
/** IPEDS unit id, the federal identifier for the institution. */
|
|
20
|
+
unitId: number;
|
|
21
|
+
/** Department of Education OPEID, or an empty string when the file has none. */
|
|
22
|
+
opeId: string;
|
|
23
|
+
/** Institution name as it appears in the federal file. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** City and state from the institution address. */
|
|
26
|
+
city: string;
|
|
27
|
+
/** Two-letter state abbreviation, or an empty string when the file has none. */
|
|
28
|
+
stateAbbr: string;
|
|
29
|
+
/** Public institution website, or null when the file has none. */
|
|
30
|
+
institutionUrl: string | null;
|
|
31
|
+
/** Public, private nonprofit, private for-profit, or unknown. */
|
|
32
|
+
control: CollegeScorecardControl;
|
|
33
|
+
/** Undergraduate enrollment, or null when suppressed. */
|
|
34
|
+
undergraduateEnrollment: number | null;
|
|
35
|
+
/** Admission rate as a fraction from 0 to 1, or null when unavailable. */
|
|
36
|
+
admissionRate: number | null;
|
|
37
|
+
/** In-state tuition and fees in dollars, or null when unavailable. */
|
|
38
|
+
inStateTuition: number | null;
|
|
39
|
+
/** Out-of-state tuition and fees in dollars, or null when unavailable. */
|
|
40
|
+
outStateTuition: number | null;
|
|
41
|
+
/** Median federal student debt at graduation in dollars, or null. */
|
|
42
|
+
medianDebt: number | null;
|
|
43
|
+
/** Six-year completion rate as a fraction, or null when unavailable. */
|
|
44
|
+
completionRate: number | null;
|
|
45
|
+
/** First-year retention rate as a fraction, or null when unavailable. */
|
|
46
|
+
retentionRate: number | null;
|
|
47
|
+
/**
|
|
48
|
+
* Median earnings of graduates working and not enrolled ten years after
|
|
49
|
+
* entry, in dollars, or null when unavailable.
|
|
50
|
+
*/
|
|
51
|
+
medianEarnings10Years: number | null;
|
|
52
|
+
}
|
|
53
|
+
/** One state's institutions, folded into the numbers a chart needs. */
|
|
54
|
+
export interface CollegeScorecardStateSummary {
|
|
55
|
+
/** Two-letter state abbreviation. */
|
|
56
|
+
stateAbbr: string;
|
|
57
|
+
/** Institutions in the state, whether or not they report outcomes. */
|
|
58
|
+
institutionCount: number;
|
|
59
|
+
/** Institutions with a reported ten-year median earnings figure. */
|
|
60
|
+
earningsReportedCount: number;
|
|
61
|
+
/** Median of the reported institution medians, in dollars, or null. */
|
|
62
|
+
medianEarnings10Years: number | null;
|
|
63
|
+
/** Median of the reported institution median debt figures, in dollars, or null. */
|
|
64
|
+
medianDebt: number | null;
|
|
65
|
+
/** Median of the reported institution completion rates, or null. */
|
|
66
|
+
medianCompletionRate: number | null;
|
|
67
|
+
/** Public institutions in the state. */
|
|
68
|
+
publicInstitutionCount: number;
|
|
69
|
+
/** Private nonprofit institutions in the state. */
|
|
70
|
+
privateNonprofitInstitutionCount: number;
|
|
71
|
+
/** Private for-profit institutions in the state. */
|
|
72
|
+
privateForProfitInstitutionCount: number;
|
|
73
|
+
}
|
|
74
|
+
/** The institution file folded for a story. */
|
|
75
|
+
export interface CollegeScorecardSnapshot {
|
|
76
|
+
/** The College Scorecard release the pinned archive represents. */
|
|
77
|
+
dataReleaseDate: string;
|
|
78
|
+
/** One row per institution in the file. */
|
|
79
|
+
institutions: CollegeScorecardInstitution[];
|
|
80
|
+
institutionCount: number;
|
|
81
|
+
/** Number of states and territories with at least one institution. */
|
|
82
|
+
stateCount: number;
|
|
83
|
+
/** Institutions with a reported ten-year median earnings figure. */
|
|
84
|
+
earningsReportedCount: number;
|
|
85
|
+
/** States and territories, alphabetical by abbreviation. */
|
|
86
|
+
stateSummaries: CollegeScorecardStateSummary[];
|
|
87
|
+
/** Median of every reported institution median, in dollars, or null. */
|
|
88
|
+
nationalMedianEarnings10Years: number | null;
|
|
89
|
+
/** Median of every reported institution median debt, in dollars, or null. */
|
|
90
|
+
nationalMedianDebt: number | null;
|
|
91
|
+
/** Median of every reported institution completion rate, or null. */
|
|
92
|
+
nationalMedianCompletionRate: number | null;
|
|
93
|
+
/** State with the highest median of institution earnings, or null. */
|
|
94
|
+
highestEarningState: CollegeScorecardStateSummary | null;
|
|
95
|
+
/** State with the lowest median of institution earnings, or null. */
|
|
96
|
+
lowestEarningState: CollegeScorecardStateSummary | null;
|
|
97
|
+
/** Institution with the highest ten-year median earnings, or null. */
|
|
98
|
+
highestEarningInstitution: CollegeScorecardInstitution | null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Parses the institution-level CSV into one row per institution and its state
|
|
102
|
+
* summaries.
|
|
103
|
+
*
|
|
104
|
+
* The federal file is very wide and uses "NA" and "PS" for figures it did not
|
|
105
|
+
* publish. Those become null rather than zero, so a chart never turns a
|
|
106
|
+
* suppressed value into an invented one.
|
|
107
|
+
*
|
|
108
|
+
* @param csv - the CSV text from the institution archive
|
|
109
|
+
* @returns every institution, plus the state and national summaries
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseCollegeScorecardCsv(csv: string): CollegeScorecardSnapshot;
|
|
112
|
+
/**
|
|
113
|
+
* Reads the institution archive, which is a zip containing one wide CSV.
|
|
114
|
+
*
|
|
115
|
+
* The live download is a zip. A committed fixture and a hand-copied sample are
|
|
116
|
+
* plain CSV, so the parser accepts both shapes.
|
|
117
|
+
*
|
|
118
|
+
* @param payload - the zip bytes, an ArrayBuffer, or CSV text
|
|
119
|
+
* @returns every institution, plus the state and national summaries
|
|
120
|
+
*/
|
|
121
|
+
export declare function parseCollegeScorecardArchive(payload: unknown): CollegeScorecardSnapshot;
|
|
122
|
+
/**
|
|
123
|
+
* Downloads and parses the keyless College Scorecard institution archive.
|
|
124
|
+
*
|
|
125
|
+
* @param options - an optional fetch stub
|
|
126
|
+
* @returns every institution, plus the state and national summaries
|
|
127
|
+
*/
|
|
128
|
+
export declare function fetchCollegeScorecardInstitutions(options?: {
|
|
129
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
130
|
+
}): Promise<CollegeScorecardSnapshot>;
|
|
131
|
+
/** College Scorecard institution-level outcomes, keyless bulk download. */
|
|
132
|
+
export declare const collegeScorecardInstitutionsAdapter: UsDataAdapter<CollegeScorecardSnapshot>;
|
|
133
|
+
//# sourceMappingURL=collegeScorecardInstitutions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collegeScorecardInstitutions.d.ts","sourceRoot":"","sources":["../src/collegeScorecardInstitutions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,uEAAuE;AACvE,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AAExF,mFAAmF;AACnF,eAAO,MAAM,yCAAyC,wGACiD,CAAC;AAExG,qEAAqE;AACrE,eAAO,MAAM,mCAAmC,eAAe,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,SAAU,CAAC;AAK1D,+DAA+D;AAC/D,MAAM,MAAM,uBAAuB,GACjC,QAAQ,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,SAAS,CAAC;AAEpE,8DAA8D;AAC9D,MAAM,WAAW,2BAA2B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romU8, unzipSync } from 'fflate';
|
|
2
|
+
import { UsSourceParseError } from './errors.js';
|
|
3
|
+
import { readFixtureText } from './fixtures.js';
|
|
4
|
+
import { httpGet } from './http.js';
|
|
5
|
+
/** Adapter id for the College Scorecard institution-level download. */
|
|
6
|
+
export const COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID = 'college-scorecard-institutions';
|
|
7
|
+
/** The dated, keyless institution-level archive published by College Scorecard. */
|
|
8
|
+
export const COLLEGE_SCORECARD_INSTITUTION_ARCHIVE_URL = 'https://ed-public-download.scorecard.network/downloads/Most-Recent-Cohorts-Institution_10152026.zip';
|
|
9
|
+
/** The data release the pinned archive represents, as YYYY-MM-DD. */
|
|
10
|
+
export const COLLEGE_SCORECARD_DATA_RELEASE_DATE = '2026-10-15';
|
|
11
|
+
/**
|
|
12
|
+
* The archive is 24 MB, and the CSV inside it is 102 MB.
|
|
13
|
+
*
|
|
14
|
+
* The shared 30 second timeout is tuned for small JSON answers, so this
|
|
15
|
+
* adapter allows two minutes for the download and inflation.
|
|
16
|
+
*/
|
|
17
|
+
export const COLLEGE_SCORECARD_FETCH_TIMEOUT_MS = 120_000;
|
|
18
|
+
/** Committed sample of real rows, so a build works when the archive is unreachable. */
|
|
19
|
+
const COLLEGE_SCORECARD_FIXTURE_FILENAME = 'college-scorecard-institutions-2026-10-15-sampled.csv';
|
|
20
|
+
/** Column names the adapter reads from the wide institution CSV. */
|
|
21
|
+
const REQUIRED_COLUMNS = [
|
|
22
|
+
'UNITID',
|
|
23
|
+
'OPEID',
|
|
24
|
+
'INSTNM',
|
|
25
|
+
'CITY',
|
|
26
|
+
'STABBR',
|
|
27
|
+
'INSTURL',
|
|
28
|
+
'CONTROL',
|
|
29
|
+
'UGDS',
|
|
30
|
+
'ADM_RATE',
|
|
31
|
+
'TUITIONFEE_IN',
|
|
32
|
+
'TUITIONFEE_OUT',
|
|
33
|
+
'DEBT_MDN',
|
|
34
|
+
'C150_4',
|
|
35
|
+
'RET_FT4',
|
|
36
|
+
'MD_EARN_WNE_P10',
|
|
37
|
+
];
|
|
38
|
+
/** Values the federal file uses for a number it did not publish. */
|
|
39
|
+
const MISSING_VALUES = new Set(['', 'NA', 'PS', 'PRIVACYSUPPRESSED', 'NULL']);
|
|
40
|
+
/** The control codes the federal file uses for public and private institutions. */
|
|
41
|
+
const CONTROL_LABELS = {
|
|
42
|
+
'1': 'public',
|
|
43
|
+
'2': 'private-nonprofit',
|
|
44
|
+
'3': 'private-for-profit',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Splits one CSV line into fields, following the quoting rule the federal file
|
|
48
|
+
* uses: a field wrapped in double quotes may contain commas, and two double
|
|
49
|
+
* quotes inside it mean one literal double quote.
|
|
50
|
+
*/
|
|
51
|
+
function splitCsvLine(line) {
|
|
52
|
+
const fields = [];
|
|
53
|
+
let field = '';
|
|
54
|
+
let inQuotes = false;
|
|
55
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
56
|
+
const character = line[index];
|
|
57
|
+
if (inQuotes) {
|
|
58
|
+
if (character === '"') {
|
|
59
|
+
if (line[index + 1] === '"') {
|
|
60
|
+
field += '"';
|
|
61
|
+
index += 1;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
inQuotes = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (character !== undefined) {
|
|
68
|
+
field += character;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (character === '"') {
|
|
72
|
+
inQuotes = true;
|
|
73
|
+
}
|
|
74
|
+
else if (character === ',') {
|
|
75
|
+
fields.push(field);
|
|
76
|
+
field = '';
|
|
77
|
+
}
|
|
78
|
+
else if (character !== undefined && character !== '\r') {
|
|
79
|
+
field += character;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (inQuotes) {
|
|
83
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'A quoted field in the institution file did not close');
|
|
84
|
+
}
|
|
85
|
+
fields.push(field);
|
|
86
|
+
return fields;
|
|
87
|
+
}
|
|
88
|
+
/** Reads a text field, turning the federal missing markers into an empty string. */
|
|
89
|
+
function readText(value) {
|
|
90
|
+
const text = value?.trim() ?? '';
|
|
91
|
+
return MISSING_VALUES.has(text.toUpperCase()) ? '' : text;
|
|
92
|
+
}
|
|
93
|
+
/** Reads a numeric field, turning suppressed values into null. */
|
|
94
|
+
function readNumber(value, column) {
|
|
95
|
+
const text = readText(value);
|
|
96
|
+
if (text === '') {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const number = Number(text);
|
|
100
|
+
if (!Number.isFinite(number)) {
|
|
101
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, `Unreadable ${column} value in the institution file: ${text}`);
|
|
102
|
+
}
|
|
103
|
+
return number;
|
|
104
|
+
}
|
|
105
|
+
/** Maps the federal control code to its plain-language label. */
|
|
106
|
+
function readControl(value) {
|
|
107
|
+
return CONTROL_LABELS[readText(value)] ?? 'unknown';
|
|
108
|
+
}
|
|
109
|
+
/** Returns the median of the values, or null when there are none. */
|
|
110
|
+
function median(values) {
|
|
111
|
+
if (values.length === 0) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
115
|
+
const middle = Math.floor(sorted.length / 2);
|
|
116
|
+
if (sorted.length % 2 === 1) {
|
|
117
|
+
return sorted[middle] ?? null;
|
|
118
|
+
}
|
|
119
|
+
const left = sorted[middle - 1];
|
|
120
|
+
const right = sorted[middle];
|
|
121
|
+
return left === undefined || right === undefined ? null : (left + right) / 2;
|
|
122
|
+
}
|
|
123
|
+
/** Builds one state's summary from the institutions in it. */
|
|
124
|
+
function buildStateSummary(stateAbbr, institutions) {
|
|
125
|
+
const earnings = institutions
|
|
126
|
+
.map((institution) => institution.medianEarnings10Years)
|
|
127
|
+
.filter((value) => value !== null);
|
|
128
|
+
const debt = institutions
|
|
129
|
+
.map((institution) => institution.medianDebt)
|
|
130
|
+
.filter((value) => value !== null);
|
|
131
|
+
const completion = institutions
|
|
132
|
+
.map((institution) => institution.completionRate)
|
|
133
|
+
.filter((value) => value !== null);
|
|
134
|
+
return {
|
|
135
|
+
stateAbbr,
|
|
136
|
+
institutionCount: institutions.length,
|
|
137
|
+
earningsReportedCount: earnings.length,
|
|
138
|
+
medianEarnings10Years: median(earnings),
|
|
139
|
+
medianDebt: median(debt),
|
|
140
|
+
medianCompletionRate: median(completion),
|
|
141
|
+
publicInstitutionCount: institutions.filter((institution) => institution.control === 'public')
|
|
142
|
+
.length,
|
|
143
|
+
privateNonprofitInstitutionCount: institutions.filter((institution) => institution.control === 'private-nonprofit').length,
|
|
144
|
+
privateForProfitInstitutionCount: institutions.filter((institution) => institution.control === 'private-for-profit').length,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Picks the institution with the highest reported earnings, ties to the earlier row. */
|
|
148
|
+
function findHighestEarningInstitution(institutions) {
|
|
149
|
+
let best = null;
|
|
150
|
+
for (const institution of institutions) {
|
|
151
|
+
if (institution.medianEarnings10Years === null) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (best === null ||
|
|
155
|
+
(best.medianEarnings10Years !== null &&
|
|
156
|
+
institution.medianEarnings10Years > best.medianEarnings10Years)) {
|
|
157
|
+
best = institution;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return best;
|
|
161
|
+
}
|
|
162
|
+
/** Picks the state with the highest or lowest median earnings, ties alphabetically. */
|
|
163
|
+
function findStateByEarnings(summaries, direction) {
|
|
164
|
+
const reported = summaries.filter((summary) => summary.medianEarnings10Years !== null);
|
|
165
|
+
if (reported.length === 0) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return reported.reduce((best, summary) => {
|
|
169
|
+
if (summary.medianEarnings10Years === best.medianEarnings10Years) {
|
|
170
|
+
return summary.stateAbbr < best.stateAbbr ? summary : best;
|
|
171
|
+
}
|
|
172
|
+
const higher = summary.medianEarnings10Years > best.medianEarnings10Years;
|
|
173
|
+
return (direction === 'highest' ? higher : !higher) ? summary : best;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Parses the institution-level CSV into one row per institution and its state
|
|
178
|
+
* summaries.
|
|
179
|
+
*
|
|
180
|
+
* The federal file is very wide and uses "NA" and "PS" for figures it did not
|
|
181
|
+
* publish. Those become null rather than zero, so a chart never turns a
|
|
182
|
+
* suppressed value into an invented one.
|
|
183
|
+
*
|
|
184
|
+
* @param csv - the CSV text from the institution archive
|
|
185
|
+
* @returns every institution, plus the state and national summaries
|
|
186
|
+
*/
|
|
187
|
+
export function parseCollegeScorecardCsv(csv) {
|
|
188
|
+
const lines = csv
|
|
189
|
+
.replace(/^\ufeff/, '')
|
|
190
|
+
.split('\n')
|
|
191
|
+
.map((line) => line.trimEnd())
|
|
192
|
+
.filter((line) => line.trim() !== '');
|
|
193
|
+
const headerLine = lines[0];
|
|
194
|
+
if (headerLine === undefined) {
|
|
195
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'The institution file was empty');
|
|
196
|
+
}
|
|
197
|
+
const header = splitCsvLine(headerLine);
|
|
198
|
+
const columnIndexes = new Map();
|
|
199
|
+
for (const column of REQUIRED_COLUMNS) {
|
|
200
|
+
const index = header.indexOf(column);
|
|
201
|
+
if (index === -1) {
|
|
202
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, `The institution file is missing the ${column} column`);
|
|
203
|
+
}
|
|
204
|
+
columnIndexes.set(column, index);
|
|
205
|
+
}
|
|
206
|
+
const column = (row, name) => {
|
|
207
|
+
const index = columnIndexes.get(name);
|
|
208
|
+
return index === undefined ? undefined : row[index];
|
|
209
|
+
};
|
|
210
|
+
const institutions = [];
|
|
211
|
+
for (const line of lines.slice(1)) {
|
|
212
|
+
const row = splitCsvLine(line);
|
|
213
|
+
if (row.length !== header.length) {
|
|
214
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, `A row in the institution file had ${row.length} fields, expected ${header.length}`);
|
|
215
|
+
}
|
|
216
|
+
const unitId = readNumber(column(row, 'UNITID'), 'UNITID');
|
|
217
|
+
const name = readText(column(row, 'INSTNM'));
|
|
218
|
+
if (unitId === null || name === '') {
|
|
219
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'An institution row arrived without its unit id or name');
|
|
220
|
+
}
|
|
221
|
+
institutions.push({
|
|
222
|
+
unitId,
|
|
223
|
+
opeId: readText(column(row, 'OPEID')),
|
|
224
|
+
name,
|
|
225
|
+
city: readText(column(row, 'CITY')),
|
|
226
|
+
stateAbbr: readText(column(row, 'STABBR')),
|
|
227
|
+
institutionUrl: readText(column(row, 'INSTURL')) || null,
|
|
228
|
+
control: readControl(column(row, 'CONTROL')),
|
|
229
|
+
undergraduateEnrollment: readNumber(column(row, 'UGDS'), 'UGDS'),
|
|
230
|
+
admissionRate: readNumber(column(row, 'ADM_RATE'), 'ADM_RATE'),
|
|
231
|
+
inStateTuition: readNumber(column(row, 'TUITIONFEE_IN'), 'TUITIONFEE_IN'),
|
|
232
|
+
outStateTuition: readNumber(column(row, 'TUITIONFEE_OUT'), 'TUITIONFEE_OUT'),
|
|
233
|
+
medianDebt: readNumber(column(row, 'DEBT_MDN'), 'DEBT_MDN'),
|
|
234
|
+
completionRate: readNumber(column(row, 'C150_4'), 'C150_4'),
|
|
235
|
+
retentionRate: readNumber(column(row, 'RET_FT4'), 'RET_FT4'),
|
|
236
|
+
medianEarnings10Years: readNumber(column(row, 'MD_EARN_WNE_P10'), 'MD_EARN_WNE_P10'),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (institutions.length === 0) {
|
|
240
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'The institution file had a header but no rows');
|
|
241
|
+
}
|
|
242
|
+
const byState = new Map();
|
|
243
|
+
for (const institution of institutions) {
|
|
244
|
+
if (institution.stateAbbr === '') {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const rows = byState.get(institution.stateAbbr) ?? [];
|
|
248
|
+
rows.push(institution);
|
|
249
|
+
byState.set(institution.stateAbbr, rows);
|
|
250
|
+
}
|
|
251
|
+
const stateSummaries = [...byState.entries()]
|
|
252
|
+
.map(([stateAbbr, rows]) => buildStateSummary(stateAbbr, rows))
|
|
253
|
+
.sort((left, right) => left.stateAbbr.localeCompare(right.stateAbbr));
|
|
254
|
+
const earnings = institutions
|
|
255
|
+
.map((institution) => institution.medianEarnings10Years)
|
|
256
|
+
.filter((value) => value !== null);
|
|
257
|
+
const debt = institutions
|
|
258
|
+
.map((institution) => institution.medianDebt)
|
|
259
|
+
.filter((value) => value !== null);
|
|
260
|
+
const completion = institutions
|
|
261
|
+
.map((institution) => institution.completionRate)
|
|
262
|
+
.filter((value) => value !== null);
|
|
263
|
+
return {
|
|
264
|
+
dataReleaseDate: COLLEGE_SCORECARD_DATA_RELEASE_DATE,
|
|
265
|
+
institutions,
|
|
266
|
+
institutionCount: institutions.length,
|
|
267
|
+
stateCount: stateSummaries.length,
|
|
268
|
+
earningsReportedCount: earnings.length,
|
|
269
|
+
stateSummaries,
|
|
270
|
+
nationalMedianEarnings10Years: median(earnings),
|
|
271
|
+
nationalMedianDebt: median(debt),
|
|
272
|
+
nationalMedianCompletionRate: median(completion),
|
|
273
|
+
highestEarningState: findStateByEarnings(stateSummaries, 'highest'),
|
|
274
|
+
lowestEarningState: findStateByEarnings(stateSummaries, 'lowest'),
|
|
275
|
+
highestEarningInstitution: findHighestEarningInstitution(institutions),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Reads the institution archive, which is a zip containing one wide CSV.
|
|
280
|
+
*
|
|
281
|
+
* The live download is a zip. A committed fixture and a hand-copied sample are
|
|
282
|
+
* plain CSV, so the parser accepts both shapes.
|
|
283
|
+
*
|
|
284
|
+
* @param payload - the zip bytes, an ArrayBuffer, or CSV text
|
|
285
|
+
* @returns every institution, plus the state and national summaries
|
|
286
|
+
*/
|
|
287
|
+
export function parseCollegeScorecardArchive(payload) {
|
|
288
|
+
if (typeof payload === 'string') {
|
|
289
|
+
return parseCollegeScorecardCsv(payload);
|
|
290
|
+
}
|
|
291
|
+
let bytes;
|
|
292
|
+
if (payload instanceof ArrayBuffer) {
|
|
293
|
+
bytes = new Uint8Array(payload);
|
|
294
|
+
}
|
|
295
|
+
else if (payload instanceof Uint8Array) {
|
|
296
|
+
bytes = payload;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'The institution archive must be zip bytes or CSV text');
|
|
300
|
+
}
|
|
301
|
+
if (bytes[0] !== 0x50 || bytes[1] !== 0x4b) {
|
|
302
|
+
return parseCollegeScorecardCsv(new TextDecoder().decode(bytes));
|
|
303
|
+
}
|
|
304
|
+
let files;
|
|
305
|
+
try {
|
|
306
|
+
files = unzipSync(bytes);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'The institution archive was not a readable zip', { cause: error });
|
|
310
|
+
}
|
|
311
|
+
const csvName = Object.keys(files).find((name) => name.endsWith('.csv') && !name.startsWith('__MACOSX/'));
|
|
312
|
+
const csvBytes = csvName === undefined ? undefined : files[csvName];
|
|
313
|
+
if (csvBytes === undefined) {
|
|
314
|
+
throw new UsSourceParseError(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, 'The institution archive contained no CSV');
|
|
315
|
+
}
|
|
316
|
+
return parseCollegeScorecardCsv(strFromU8(csvBytes));
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Downloads and parses the keyless College Scorecard institution archive.
|
|
320
|
+
*
|
|
321
|
+
* @param options - an optional fetch stub
|
|
322
|
+
* @returns every institution, plus the state and national summaries
|
|
323
|
+
*/
|
|
324
|
+
export async function fetchCollegeScorecardInstitutions(options) {
|
|
325
|
+
const fetchImpl = options?.fetchImpl ?? globalThis.fetch;
|
|
326
|
+
const response = await httpGet(COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, COLLEGE_SCORECARD_INSTITUTION_ARCHIVE_URL, { fetchImpl, timeoutMs: COLLEGE_SCORECARD_FETCH_TIMEOUT_MS });
|
|
327
|
+
return parseCollegeScorecardArchive(await response.arrayBuffer());
|
|
328
|
+
}
|
|
329
|
+
/** College Scorecard institution-level outcomes, keyless bulk download. */
|
|
330
|
+
export const collegeScorecardInstitutionsAdapter = {
|
|
331
|
+
id: COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID,
|
|
332
|
+
name: 'College Scorecard institutions',
|
|
333
|
+
auth: 'none',
|
|
334
|
+
description: 'Institution-level College Scorecard outcomes for US colleges: enrollment, cost, completion, debt, and earnings ten years after entry, from the Department of Education bulk download.',
|
|
335
|
+
fetchLive: async (options) => fetchCollegeScorecardInstitutions(options?.fetchImpl === undefined ? {} : { fetchImpl: options.fetchImpl }),
|
|
336
|
+
parse: (payload) => parseCollegeScorecardArchive(payload),
|
|
337
|
+
loadFixture: () => parseCollegeScorecardCsv(readFixtureText(COLLEGE_SCORECARD_FIXTURE_FILENAME)),
|
|
338
|
+
};
|
|
339
|
+
//# sourceMappingURL=collegeScorecardInstitutions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collegeScorecardInstitutions.js","sourceRoot":"","sources":["../src/collegeScorecardInstitutions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM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ides {@link DEFAULT_TIMEOUT_MS}. */
|
|
20
20
|
timeoutMs?: number | undefined;
|
|
21
|
+
/** How many times a retryable failure is attempted again. Defaults to 0. */
|
|
22
|
+
retries?: number | undefined;
|
|
23
|
+
/** Base delay between retry attempts, doubled each time. Defaults to 1000ms. */
|
|
24
|
+
retryDelayMs?: number | undefined;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* Issues a GET through the shared HTTP layer.
|
|
24
28
|
*
|
|
25
29
|
* Every adapter goes through here so that three things happen the same way
|
|
26
|
-
* for all
|
|
30
|
+
* for all registered sources: a `user-agent` identifies the client, a timeout aborts
|
|
27
31
|
* a request that hangs, and a failure carries whether retrying is worthwhile.
|
|
28
32
|
*
|
|
29
33
|
* @param source - Source name used in the error message, e.g. "bls".
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,mDAAmD,CAAC;AAE3E,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAQzC,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;IAChD,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,mDAAmD,CAAC;AAE3E,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAQzC,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;IAChD,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,QAAQ,CAAC,CAsCnB"}
|
package/dist/http.js
CHANGED
|
@@ -42,7 +42,7 @@ function buildRequestHeaders(extra) {
|
|
|
42
42
|
* Issues a GET through the shared HTTP layer.
|
|
43
43
|
*
|
|
44
44
|
* Every adapter goes through here so that three things happen the same way
|
|
45
|
-
* for all
|
|
45
|
+
* for all registered sources: a `user-agent` identifies the client, a timeout aborts
|
|
46
46
|
* a request that hangs, and a failure carries whether retrying is worthwhile.
|
|
47
47
|
*
|
|
48
48
|
* @param source - Source name used in the error message, e.g. "bls".
|
|
@@ -54,32 +54,40 @@ function buildRequestHeaders(extra) {
|
|
|
54
54
|
export async function httpGet(source, url, options = {}) {
|
|
55
55
|
const doFetch = options.fetchImpl ?? globalThis.fetch;
|
|
56
56
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (controller.signal.aborted) {
|
|
68
|
-
throw new UsSourceApiError(source, `request timed out after ${timeoutMs}ms`, {
|
|
69
|
-
retryable: true,
|
|
57
|
+
const retries = options.retries ?? 0;
|
|
58
|
+
const retryDelayMs = options.retryDelayMs ?? 1000;
|
|
59
|
+
for (let attempt = 0;; attempt += 1) {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
62
|
+
let response;
|
|
63
|
+
try {
|
|
64
|
+
response = await doFetch(url, {
|
|
65
|
+
headers: buildRequestHeaders(options.headers),
|
|
66
|
+
signal: controller.signal,
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (controller.signal.aborted) {
|
|
71
|
+
throw new UsSourceApiError(source, `request timed out after ${timeoutMs}ms`, {
|
|
72
|
+
retryable: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
throw new UsSourceApiError(source, `request failed: ${String(error)}`, { retryable: true });
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
}
|
|
80
|
+
if (response.ok) {
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
const retryable = response.status === HTTP_TOO_MANY_REQUESTS || response.status >= HTTP_INTERNAL_SERVER_ERROR;
|
|
84
|
+
if (!retryable || attempt >= retries) {
|
|
85
|
+
throw new UsSourceApiError(source, `HTTP ${response.status}`, {
|
|
86
|
+
status: response.status,
|
|
87
|
+
retryable,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs * 2 ** attempt));
|
|
82
91
|
}
|
|
83
|
-
return response;
|
|
84
92
|
}
|
|
85
93
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,gDAAgD,CAAC;AAE3E,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,gFAAgF;AAChF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,mFAAmF;AACnF,MAAM,0BAA0B,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,gDAAgD,CAAC;AAE3E,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,gFAAgF;AAChF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,mFAAmF;AACnF,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAgBvC;;;;;;;;;;GAUG;AACH,SAAS,mBAAmB,CAAC,KAAyC;IACpE,MAAM,OAAO,GAA2B,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IACrE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,YAAY,EAAE,CAAC;YACxC,OAAO,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KA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AAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,SAAS,GACb,QAAQ,CAAC,MAAM,KAAK,sBAAsB,IAAI,QAAQ,CAAC,MAAM,IAAI,0BAA0B,CAAC;QAC9F,IAAI,CAAC,SAAS,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YACrC,MAAM,IAAI,gBAAgB,CAAC,MAAM,EAAE,QAAQ,QAAQ,CAAC,MAAM,EAAE,EAAE;gBAC5D,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export { buildNoaaSeaLevelSeries, buildNoaaSeaLevelUrl, fetchNoaaSeaLevel, noaaS
|
|
|
24
24
|
export type { NoaaSeaLevelMonth, NoaaSeaLevelPayload, NoaaSeaLevelQuery, NoaaSeaLevelSeries, NoaaSeaLevelStation, NoaaSeaLevelYear, } from './noaaSeaLevel.js';
|
|
25
25
|
/** The uniform adapter registry and probe helpers. */
|
|
26
26
|
export { US_DATA_SOURCES, getUsDataSource, probeAllUsDataSources, probeUsDataSource, } from './registry.js';
|
|
27
|
+
/** NextBus live transit vehicle positions (keyless). */
|
|
28
|
+
export { buildNextBusVehicleUrl, fetchNextBusVehicles, nextBusTransitVehiclesAdapter, NEXTBUS_PORTLAND_STREETCAR_AGENCY_TAG, NEXTBUS_PORTLAND_STREETCAR_QUERY, NEXTBUS_PORTLAND_STREETCAR_ROUTE_TAG, NEXTBUS_TRANSIT_VEHICLES_SOURCE_ID, NEXTBUS_XML_FEED_BASE, parseNextBusVehiclePayload, } from './nextBusTransitVehicles.js';
|
|
29
|
+
/** NextBus transit vehicle types. */
|
|
30
|
+
export type { NextBusVehicle, NextBusVehicleQuery, NextBusVehicleSnapshot, } from './nextBusTransitVehicles.js';
|
|
27
31
|
/** US Treasury average interest rate on the debt outstanding (keyless). */
|
|
28
32
|
export { buildTreasuryAvgInterestRateSeries, buildTreasuryAvgInterestRateUrl, fetchTreasuryAvgInterestRates, parseTreasuryAvgInterestRatePayload, treasuryAvgInterestRateAdapter, TREASURY_AVG_INTEREST_RATE_FIRST_YEAR, TREASURY_AVG_INTEREST_RATE_PATH, TREASURY_AVG_INTEREST_RATE_ROW_LIMIT, TREASURY_AVG_INTEREST_RATE_SECURITY_DESCRIPTION, TREASURY_AVG_INTEREST_RATE_SECURITY_TYPE, TREASURY_FISCAL_DATA_API_BASE, } from './treasuryAvgInterestRate.js';
|
|
29
33
|
/** Treasury interest rate types. */
|
|
@@ -100,6 +104,18 @@ export type { BtsCatalogueCategoryCount, BtsCatalogueEntry, BtsTransportationCat
|
|
|
100
104
|
export { buildEstimateTaxUrl, ESTIMATETAX_API_BASE, ESTIMATETAX_CALCULATE_PATH, ESTIMATETAX_DEFAULT_CITY, ESTIMATETAX_DEFAULT_INCOME, ESTIMATETAX_DEFAULT_QUERY, ESTIMATETAX_DEFAULT_STATE, ESTIMATETAX_FILING_STATUSES, ESTIMATETAX_INCOME_TAX_SOURCE_ID, estimatetaxIncomeTaxAdapter, fetchEstimateTaxCalculation, parseEstimateTaxCalculation, } from './estimatetaxIncomeTax.js';
|
|
101
105
|
/** EstimateTax income tax types. */
|
|
102
106
|
export type { EstimateTaxBracket, EstimateTaxCalculation, EstimateTaxFederal, EstimateTaxFilingStatus, EstimateTaxInput, EstimateTaxLocal, EstimateTaxQuery, EstimateTaxSource, EstimateTaxSources, EstimateTaxState, EstimateTaxTotals, } from './estimatetaxIncomeTax.js';
|
|
107
|
+
/** Callook.info US amateur radio callsign lookup (keyless). */
|
|
108
|
+
export { buildCallookCallsignDirectory, buildCallookCallsignUrl, CALLOOK_API_BASE, CALLOOK_CALLSIGNS_SOURCE_ID, CALLOOK_DISTRICT_CALLSIGNS, callookCallsignsAdapter, fetchCallookCallsigns, parseCallookCallsignsPayload, } from './callookCallsigns.js';
|
|
109
|
+
/** Callook.info callsign types. */
|
|
110
|
+
export type { CallookCallsign, CallookCallsignDirectory, CallookLabelCount, CallookLookupStatus, } from './callookCallsigns.js';
|
|
111
|
+
/** College Scorecard institution-level outcomes (keyless bulk download). */
|
|
112
|
+
export { COLLEGE_SCORECARD_DATA_RELEASE_DATE, COLLEGE_SCORECARD_FETCH_TIMEOUT_MS, COLLEGE_SCORECARD_INSTITUTION_ARCHIVE_URL, COLLEGE_SCORECARD_INSTITUTION_SOURCE_ID, collegeScorecardInstitutionsAdapter, fetchCollegeScorecardInstitutions, parseCollegeScorecardArchive, parseCollegeScorecardCsv, } from './collegeScorecardInstitutions.js';
|
|
113
|
+
/** College Scorecard institution types. */
|
|
114
|
+
export type { CollegeScorecardControl, CollegeScorecardInstitution, CollegeScorecardSnapshot, CollegeScorecardStateSummary, } from './collegeScorecardInstitutions.js';
|
|
115
|
+
/** PublicDataHub Medicare hospital quality records (keyless). */
|
|
116
|
+
export { buildPublicDataHubHospitalUrl, fetchPublicDataHubHospital, getPublicDataHubMeasure, parsePublicDataHubHospitalPayload, PUBLICDATAHUB_API_BASE, PUBLICDATAHUB_DEFAULT_HOSPITAL_SLUG, PUBLICDATAHUB_HOSPITAL_SOURCE_ID, publicDataHubHospitalAdapter, } from './publicDataHubHospital.js';
|
|
117
|
+
/** PublicDataHub hospital quality types. */
|
|
118
|
+
export type { PublicDataHubHospital, PublicDataHubHospitalAddress, PublicDataHubHospitalQuality, PublicDataHubMeasure, PublicDataHubProvenance, } from './publicDataHubHospital.js';
|
|
103
119
|
/** Shared adapter contract types. */
|
|
104
120
|
export type { UsDataAdapter, UsFetchOptions, UsSourceAuth, UsSourceProbe } from './types.js';
|
|
105
121
|
/** API key normalization shared by adapters, the API, and the CLI. */
|