-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
publish dist to allow installing directly from repo
- Loading branch information
1 parent
b09052a
commit 2243a6f
Showing
23 changed files
with
1,328 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules | ||
/dist | ||
|
||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export declare class CongressAPI { | ||
private _congressNumber; | ||
private apiVersion; | ||
private client; | ||
private apiKey; | ||
constructor(options: APIOptions); | ||
private getApi; | ||
request(requestParams: RequestParams): Promise<any>; | ||
readonly congressNumber: number; | ||
withDefaults(params: any): any; | ||
} | ||
interface APIOptions { | ||
apiVersion?: string; | ||
congressNumber?: number; | ||
apiKey: string; | ||
} | ||
interface RequestParams { | ||
format?: 'xml' | 'json'; | ||
offset?: number; | ||
url: string; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var axios_1 = __importDefault(require("axios")); | ||
var CongressAPI = /** @class */ (function () { | ||
function CongressAPI(options) { | ||
this._congressNumber = 116; | ||
this.apiVersion = 'v1'; | ||
this.apiKey = options.apiKey; | ||
if (options.congressNumber) { | ||
this._congressNumber = options.congressNumber; | ||
} | ||
this.client = this.getApi(); | ||
} | ||
CongressAPI.prototype.getApi = function () { | ||
return axios_1.default.create({ | ||
baseURL: "https://api.propublica.org/congress/" + this.apiVersion, | ||
headers: { 'X-API-Key': this.apiKey }, | ||
}); | ||
}; | ||
CongressAPI.prototype.request = function (requestParams) { | ||
var url = requestParams.url; | ||
if (requestParams.offset) { | ||
url += "?offset=" + requestParams.offset; | ||
} | ||
return this.client.get(url + "." + requestParams.format); | ||
}; | ||
Object.defineProperty(CongressAPI.prototype, "congressNumber", { | ||
get: function () { | ||
return this._congressNumber; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
CongressAPI.prototype.withDefaults = function (params) { | ||
return __assign({ format: 'json', congressNumber: this.congressNumber }, params); | ||
}; | ||
return CongressAPI; | ||
}()); | ||
exports.CongressAPI = CongressAPI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CommitteeListResult, SingleCommitteeResult, CommitteeHearingListResult, SingleSubcommitteeResult } from './types'; | ||
import { ChamberRequestParams } from '../types'; | ||
interface CongressNumberParams extends ChamberRequestParams { | ||
congressNumber?: number; | ||
} | ||
interface CommitteeParams extends CongressNumberParams { | ||
committeeId: string; | ||
} | ||
interface SubcommitteeParams extends CommitteeParams { | ||
subcommitteeId: string; | ||
} | ||
declare module '../api' { | ||
interface CongressAPI { | ||
getAllCommittees(params: CongressNumberParams): Promise<CommitteeListResult>; | ||
getCommittee(params: CommitteeParams): Promise<SingleCommitteeResult>; | ||
getRecentHearings(params: CongressNumberParams): Promise<CommitteeHearingListResult>; | ||
getCommitteeHearings(params: CommitteeParams): Promise<CommitteeHearingListResult>; | ||
getSubcommittee(params: SubcommitteeParams): Promise<SingleSubcommitteeResult>; | ||
} | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var api_1 = require("../api"); | ||
api_1.CongressAPI.prototype.getAllCommittees = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
params = this.withDefaults(params); | ||
return [4 /*yield*/, this.request({ | ||
url: "/" + params.congressNumber + "/" + params.chamber + "/committees", | ||
format: params.format, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
api_1.CongressAPI.prototype.getCommittee = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
params = this.withDefaults(params); | ||
return [4 /*yield*/, this.request({ | ||
url: "/" + params.congressNumber + "/" + params.chamber + "/committees/" + params.committeeId, | ||
format: params.format, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
api_1.CongressAPI.prototype.getRecentHearings = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
params = this.withDefaults(params); | ||
return [4 /*yield*/, this.request({ | ||
url: "/" + params.congressNumber + "/committees/hearings", | ||
format: params.format, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
api_1.CongressAPI.prototype.getCommitteeHearings = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
params = this.withDefaults(params); | ||
return [4 /*yield*/, this.request({ | ||
url: "/" + params.congressNumber + "/" + params.chamber + "/committees/" + params.committeeId + "/hearings", | ||
format: params.format, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
api_1.CongressAPI.prototype.getSubcommittee = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
params = this.withDefaults(params); | ||
return [4 /*yield*/, this.request({ | ||
url: "/" + params.congressNumber + "/" + params.chamber + "/committees/" + params.committeeId + "/subcommittees/" + params.subcommitteeId, | ||
format: params.format, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { BaseApiResult, BasePagedResult, CapitalizedChamber, URLString } from '../types'; | ||
import { MemberId } from '../members/types'; | ||
declare type CommitteeId = string; | ||
interface BaseCommittee { | ||
id: CommitteeId; | ||
name: string; | ||
url: URLString; | ||
chair: string; | ||
chair_id: MemberId; | ||
chair_party: 'R' | 'D' | 'I'; | ||
chair_state: string; | ||
ranking_member_id: MemberId; | ||
} | ||
export interface Committee extends BaseCommittee { | ||
api_uri: URLString; | ||
chair_uri: URLString; | ||
subcommittees: BaseSubcommittee[]; | ||
} | ||
interface BaseSubcommittee { | ||
id: CommitteeId; | ||
name: string; | ||
api_uri: URLString; | ||
} | ||
interface Subcommittee { | ||
congress: string; | ||
chamber: CapitalizedChamber; | ||
num_results: number; | ||
id: CommitteeId; | ||
name: string; | ||
committee_id: CommitteeId; | ||
committee_name: string; | ||
committee_url: URLString; | ||
chair: string; | ||
chair_id: MemberId; | ||
chair_party: 'R' | 'D' | 'I'; | ||
chair_state: string; | ||
ranking_member_id: MemberId; | ||
current_members: CommitteeMember[]; | ||
} | ||
interface CommitteeMember { | ||
id: MemberId; | ||
name: string; | ||
api_uri: URLString; | ||
party: 'R' | 'D' | 'I'; | ||
side: string; | ||
rank_in_party: number; | ||
state: string; | ||
note: string; | ||
begin_date: string; | ||
} | ||
interface CommitteeHearing { | ||
chamber: CapitalizedChamber; | ||
committee: string; | ||
committee_code: string; | ||
api_uri: URLString; | ||
date: string; | ||
time: string; | ||
location: string; | ||
description: string; | ||
bill_ids: string[]; | ||
url: URLString; | ||
meeting_type: string; | ||
} | ||
export interface SingleCommittee extends BaseCommittee { | ||
congress: string; | ||
chamber: CapitalizedChamber; | ||
num_results: number; | ||
current_members: CommitteeMember[]; | ||
} | ||
export interface CommitteeListResult extends BaseApiResult { | ||
results: { | ||
congress: string; | ||
chamber: string; | ||
num_results: number; | ||
committees: Committee[]; | ||
}[]; | ||
} | ||
export interface SingleCommitteeResult extends BaseApiResult { | ||
results: SingleCommittee[]; | ||
} | ||
export interface CommitteeHearingListResult extends BaseApiResult { | ||
results: (BasePagedResult & { | ||
hearings: CommitteeHearing[]; | ||
})[]; | ||
} | ||
export interface SingleSubcommitteeResult extends BaseApiResult { | ||
results: Subcommittee[]; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ChamberRequestParams } from '../types'; | ||
import { FloorActionListResult } from './types'; | ||
interface FloorActionsDateParams extends ChamberRequestParams { | ||
date: Date; | ||
} | ||
declare module '../api' { | ||
interface CongressAPI { | ||
getRecentFloorActions(params: ChamberRequestParams): Promise<FloorActionListResult>; | ||
getFloorActionsForDate(params: FloorActionsDateParams): Promise<FloorActionListResult>; | ||
} | ||
} | ||
export {}; |
Oops, something went wrong.