-
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.
release: 🔖 1.0.2 Jun 6, 2024, 3:06 PM [skip ci]
## [1.0.2](v1.0.1...v1.0.2) (2024-06-06) ### Features * ✨ docket search ([b9f278c](b9f278c)) * ✨ new docket search ([e5de589](e5de589)) ### Bug Fixes * 🐛 failing tests ([365350c](365350c)) * 🐛 failing tests ([f61afa2](f61afa2)) * 🐛 fetch without body on get ([54463a9](54463a9)) * 🐛 fix build ([40ce396](40ce396))
- Loading branch information
1 parent
2f43a11
commit 03a40f7
Showing
17 changed files
with
416 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
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 @@ | ||
"use strict";var f=Object.defineProperty;var d=(a,t,e)=>t in a?f(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var i=(a,t,e)=>(d(a,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("fs"),g=require("path");class h{constructor(){i(this,"params",{});i(this,"data")}}function c(a,t="post"){return async e=>fetch(`https://elibrary.ferc.gov/eLibrarywebapi/api/${a}`,{headers:{"content-type":"application/json"},method:t,...t!=="get"?{body:JSON.stringify(e)}:{}}).then(s=>s.json())}const u={dockets:"rp24-769",subdockets:"000",filed_date_beg:"01-01-1960",filed_date_end:"06-04-2024",complete_flag:0,numHits:100,pageNumber:0};class P extends h{constructor(e){super();i(this,"defaultParams",u);i(this,"fetch",c("Docket/GetSingleDocketSheet"));this.params={...this.defaultParams,...e}}async getData(){this.data=await this.fetch(this.params)}updateParams(e){this.params={...u,...e}}async nextPage(){var r;const{numHits:e,pageNumber:s}=this.params;return(((r=this.data)==null?void 0:r.Page.totalHits)??-1)>e*(s+1)?(this.params.pageNumber++,await this.getData(),!0):!1}async prevPage(){const{pageNumber:e}=this.params;return e>0?(this.params.pageNumber--,await this.getData(),!0):!1}}const o={by:"rbFilingDate",start:"06-04-2024",end:"06-04-2024"};class y extends h{constructor(e){super();i(this,"defaultParams",o);i(this,"fetch",c(""));this.params={...this.defaultParams,...e},this.setFetch()}setFetch(){this.fetch=c(`Docket/GetATMSdocs/${this.params.by}/${this.params.start}/${this.params.end}/DocketFullNumber`,"get")}async getData(){this.data=await this.fetch({})}updateParams(e){this.params={...o,...e},this.setFetch()}}const l={searchText:"*",searchFullText:!0,searchDescription:!0,dateSearches:[],availability:null,affiliations:[],categories:[],libraries:[],accessionNumber:null,eFiling:!1,docketSearches:[{docketNumber:"P-15056-000",subDocketNumbers:[]}],resultsPerPage:100,curPage:1,classTypes:[],sortBy:"",groupBy:"NONE",idolResultID:"",allDates:!1};class D extends h{constructor(e){super();i(this,"defaultParams",l);i(this,"fetch",c("Search/AdvancedSearch"));this.params={...this.defaultParams,...e},this.params.curPage===0&&(this.params.curPage=1)}async getData(){this.data=await this.fetch(this.params)}updateParams(e){this.params={...l,...e}}async nextPage(){var r;const{resultsPerPage:e,curPage:s}=this.params;return(((r=this.data)==null?void 0:r.totalHits)??-1)>e*s?(this.params.curPage++,await this.getData(),!0):!1}async prevPage(){const{curPage:e}=this.params;return e>1?(this.params.curPage--,await this.getData(),!0):!1}}const n={path:"temp",format:"pdf",file:"temp"};async function b(a,t){const e={...n,file:a.fileidLst[0]??n.file,...t};return p(e,"File/DownloadP8File",{},a)}async function S(a,t){const e={...n,file:a,...t};return p(e,"File/DownloadPDF",{accessionNumber:a},'{serverLocation: ""}')}async function p(a,t,e,s){return fetch(`https://elibrary.ferc.gov/eLibrarywebapi/api/${t}?`+new URLSearchParams(e),{headers:{accept:"application/json, text/plain, */*","content-type":"application/json"},body:typeof s=="string"?s:JSON.stringify(s),method:"POST"}).then(r=>r.arrayBuffer()).then(r=>m.writeFileSync(g.join(a.path,`${a.file}.${a.format}`),Buffer.from(r),"binary"))}exports.DocketSearch=P;exports.GeneralSearch=D;exports.NewDocketSearch=y;exports.downloadFile=b;exports.generatePDF=S; |
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,6 @@ | ||
import { default as DocketSearch } from './search/docket'; | ||
import { default as NewDocketSearch } from './search/newDocket'; | ||
import { default as GeneralSearch } from './search/general'; | ||
import { downloadFile, generatePDF } from './util/download'; | ||
|
||
export { DocketSearch, NewDocketSearch, GeneralSearch, downloadFile, generatePDF, }; |
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,177 @@ | ||
var f = Object.defineProperty; | ||
var m = (t, e, a) => e in t ? f(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a; | ||
var i = (t, e, a) => (m(t, typeof e != "symbol" ? e + "" : e, a), a); | ||
import { writeFileSync as d } from "fs"; | ||
import { join as g } from "path"; | ||
class h { | ||
constructor() { | ||
i(this, "params", {}); | ||
i(this, "data"); | ||
} | ||
} | ||
function c(t, e = "post") { | ||
return async (a) => fetch(`https://elibrary.ferc.gov/eLibrarywebapi/api/${t}`, { | ||
headers: { | ||
"content-type": "application/json" | ||
}, | ||
method: e, | ||
...e !== "get" ? { body: JSON.stringify(a) } : {} | ||
}).then((s) => s.json()); | ||
} | ||
const u = { | ||
dockets: "rp24-769", | ||
subdockets: "000", | ||
filed_date_beg: "01-01-1960", | ||
filed_date_end: "06-04-2024", | ||
complete_flag: 0, | ||
numHits: 100, | ||
pageNumber: 0 | ||
}; | ||
class D extends h { | ||
constructor(a) { | ||
super(); | ||
i(this, "defaultParams", u); | ||
i(this, "fetch", c("Docket/GetSingleDocketSheet")); | ||
this.params = { ...this.defaultParams, ...a }; | ||
} | ||
async getData() { | ||
this.data = await this.fetch(this.params); | ||
} | ||
updateParams(a) { | ||
this.params = { ...u, ...a }; | ||
} | ||
async nextPage() { | ||
var r; | ||
const { numHits: a, pageNumber: s } = this.params; | ||
return (((r = this.data) == null ? void 0 : r.Page.totalHits) ?? -1) > a * (s + 1) ? (this.params.pageNumber++, await this.getData(), !0) : !1; | ||
} | ||
async prevPage() { | ||
const { pageNumber: a } = this.params; | ||
return a > 0 ? (this.params.pageNumber--, await this.getData(), !0) : !1; | ||
} | ||
} | ||
const o = { | ||
by: "rbFilingDate", | ||
start: "06-04-2024", | ||
end: "06-04-2024" | ||
}; | ||
class S extends h { | ||
constructor(a) { | ||
super(); | ||
i(this, "defaultParams", o); | ||
i(this, "fetch", c("")); | ||
this.params = { ...this.defaultParams, ...a }, this.setFetch(); | ||
} | ||
setFetch() { | ||
this.fetch = c( | ||
`Docket/GetATMSdocs/${this.params.by}/${this.params.start}/${this.params.end}/DocketFullNumber`, | ||
"get" | ||
); | ||
} | ||
async getData() { | ||
this.data = await this.fetch({}); | ||
} | ||
updateParams(a) { | ||
this.params = { ...o, ...a }, this.setFetch(); | ||
} | ||
} | ||
const l = { | ||
searchText: "*", | ||
searchFullText: !0, | ||
searchDescription: !0, | ||
dateSearches: [], | ||
availability: null, | ||
affiliations: [], | ||
categories: [], | ||
libraries: [], | ||
accessionNumber: null, | ||
eFiling: !1, | ||
docketSearches: [ | ||
{ | ||
docketNumber: "P-15056-000", | ||
subDocketNumbers: [] | ||
} | ||
], | ||
resultsPerPage: 100, | ||
curPage: 1, | ||
classTypes: [], | ||
sortBy: "", | ||
groupBy: "NONE", | ||
idolResultID: "", | ||
allDates: !1 | ||
}; | ||
class w extends h { | ||
constructor(a) { | ||
super(); | ||
i(this, "defaultParams", l); | ||
i(this, "fetch", c("Search/AdvancedSearch")); | ||
this.params = { ...this.defaultParams, ...a }, this.params.curPage === 0 && (this.params.curPage = 1); | ||
} | ||
async getData() { | ||
this.data = await this.fetch(this.params); | ||
} | ||
updateParams(a) { | ||
this.params = { ...l, ...a }; | ||
} | ||
async nextPage() { | ||
var r; | ||
const { resultsPerPage: a, curPage: s } = this.params; | ||
return (((r = this.data) == null ? void 0 : r.totalHits) ?? -1) > a * s ? (this.params.curPage++, await this.getData(), !0) : !1; | ||
} | ||
async prevPage() { | ||
const { curPage: a } = this.params; | ||
return a > 1 ? (this.params.curPage--, await this.getData(), !0) : !1; | ||
} | ||
} | ||
const n = { | ||
path: "temp", | ||
format: "pdf", | ||
file: "temp" | ||
}; | ||
async function F(t, e) { | ||
const a = { | ||
...n, | ||
file: t.fileidLst[0] ?? n.file, | ||
...e | ||
}; | ||
return p(a, "File/DownloadP8File", {}, t); | ||
} | ||
async function N(t, e) { | ||
const a = { | ||
...n, | ||
file: t, | ||
...e | ||
}; | ||
return p( | ||
a, | ||
"File/DownloadPDF", | ||
{ accessionNumber: t }, | ||
'{serverLocation: ""}' | ||
); | ||
} | ||
async function p(t, e, a, s) { | ||
return fetch( | ||
`https://elibrary.ferc.gov/eLibrarywebapi/api/${e}?` + new URLSearchParams(a), | ||
{ | ||
headers: { | ||
accept: "application/json, text/plain, */*", | ||
"content-type": "application/json" | ||
}, | ||
body: typeof s == "string" ? s : JSON.stringify(s), | ||
method: "POST" | ||
} | ||
).then((r) => r.arrayBuffer()).then( | ||
(r) => d( | ||
g(t.path, `${t.file}.${t.format}`), | ||
Buffer.from(r), | ||
"binary" | ||
) | ||
); | ||
} | ||
export { | ||
D as DocketSearch, | ||
w as GeneralSearch, | ||
S as NewDocketSearch, | ||
F as downloadFile, | ||
N as generatePDF | ||
}; |
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 { DocketSearchParams, DocketSearchResults } from '../types/DocketSearch'; | ||
import { Search } from './search'; | ||
|
||
export default class DocketSearch extends Search<DocketSearchParams, DocketSearchResults> { | ||
readonly defaultParams: DocketSearchParams; | ||
readonly fetch: (params: DocketSearchParams) => Promise<DocketSearchResults>; | ||
constructor(params: Partial<DocketSearchParams>); | ||
getData(): Promise<void>; | ||
updateParams(params: Partial<DocketSearchParams>): void; | ||
nextPage(): Promise<boolean>; | ||
prevPage(): Promise<boolean>; | ||
} |
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 { GeneralSearchParams, GeneralSearchResult } from '../types'; | ||
import { Search } from './search'; | ||
|
||
export default class GeneralSearch extends Search<GeneralSearchParams, GeneralSearchResult> { | ||
readonly defaultParams: GeneralSearchParams; | ||
readonly fetch: (params: GeneralSearchParams) => Promise<GeneralSearchResult>; | ||
constructor(params: Partial<GeneralSearchParams>); | ||
getData(): Promise<void>; | ||
updateParams(params: Partial<GeneralSearch>): void; | ||
nextPage(): Promise<boolean>; | ||
prevPage(): Promise<boolean>; | ||
} |
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,11 @@ | ||
import { NewDocketParams, NewDocketResults } from '../types/NewDocket'; | ||
import { Search } from './search'; | ||
|
||
export default class NewDocketSearch extends Search<NewDocketParams, NewDocketResults> { | ||
readonly defaultParams: NewDocketParams; | ||
fetch: (params: {}) => Promise<NewDocketResults>; | ||
constructor(params: Partial<NewDocketParams>); | ||
setFetch(): void; | ||
getData(): Promise<void>; | ||
updateParams(params: Partial<NewDocketParams>): void; | ||
} |
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,6 @@ | ||
export declare abstract class Search<SearchParams extends Record<string, unknown>, SearchResults extends Record<string, unknown>> { | ||
params: SearchParams; | ||
abstract defaultParams: SearchParams; | ||
data: SearchResults | undefined; | ||
abstract readonly fetch: (params: SearchParams) => Promise<SearchResults>; | ||
} |
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,46 @@ | ||
import { Categories } from './stubs'; | ||
|
||
export type DocketSearchParams = { | ||
dockets: string; | ||
subdockets: 'All' | string; | ||
filed_date_beg: string; | ||
filed_date_end: string; | ||
numHits: number; | ||
pageNumber: number; | ||
complete_flag: 0; | ||
}; | ||
export type DocketSearchResults = { | ||
Page: { | ||
totalHits: number; | ||
numHits: number; | ||
pageNumber: number; | ||
}; | ||
ErrorList: unknown[]; | ||
DataList: { | ||
DocumentsItem: { | ||
document_id: 0; | ||
category_cd: 0; | ||
DOCKET_TEXT: string; | ||
SUBDOCKET_TEXT: string; | ||
DOCKET_CODE: null; | ||
subDocketNumber: 0; | ||
accession_no: string; | ||
accession_date: string; | ||
accession_series: null; | ||
availability_code: null; | ||
category: Categories; | ||
doc_desc: string; | ||
source: null; | ||
Affiliation_Organization: string[]; | ||
fed_reg_num: null; | ||
filed_date: string; | ||
issued_date: string; | ||
fed_reg_date: string; | ||
comments_due_date: string; | ||
FEE_AMT_CUR: 0; | ||
FERC_CITE: null; | ||
}[]; | ||
AuthorsItem: []; | ||
FedCitesItem: []; | ||
}[]; | ||
}; |
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,8 @@ | ||
export type DownloadFileParams = { | ||
FileType: string; | ||
accession: string; | ||
fileid: number; | ||
FileIDAll: string; | ||
fileidLst: string[]; | ||
Islegacy: boolean; | ||
}; |
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,76 @@ | ||
import { ClassType, Affiliations, SecurityLevel, Categories, Libraries } from './stubs'; | ||
|
||
export type DocketSearch = { | ||
docketNumber: string | null; | ||
subDocketNumbers: string[] | null; | ||
}; | ||
export type DateSearch = { | ||
dateType: 'issued_date' | 'filed_date' | 'posted_date'; | ||
startDate: string; | ||
endDate: string; | ||
}; | ||
export type GeneralSearchParams = { | ||
docketSearches: DocketSearch[]; | ||
accessionNumber?: string | null; | ||
parentAccessionNumber?: string; | ||
fedRegisterCite?: string; | ||
fedCourtCaseNumber?: string; | ||
fercCite?: string; | ||
opinion?: string; | ||
orderNumber?: string; | ||
searchText: string; | ||
searchFullText: boolean; | ||
searchDescription: boolean; | ||
allDates: boolean; | ||
dateSearches: DateSearch[]; | ||
classTypes: ClassType[]; | ||
affiliations: Affiliations[]; | ||
availability: SecurityLevel[] | null; | ||
categories: Categories[]; | ||
libraries: Libraries[]; | ||
eFiling: boolean; | ||
sortBy: string; | ||
groupBy: string; | ||
/** | ||
* Number of results to return per page. | ||
* @type {number} | ||
*/ | ||
resultsPerPage: number; | ||
curPage: number; | ||
idolResultID: string; | ||
}; | ||
export type Transmittal = { | ||
fileId: string; | ||
fileType: string; | ||
fileFormat: string; | ||
fileName: string; | ||
fileDesc: string; | ||
fileSize: number; | ||
transmittalFk: null; | ||
}; | ||
export type GeneralSearchResult = { | ||
errorMessage: unknown; | ||
numHits: number; | ||
searchResultId: unknown; | ||
success: boolean; | ||
totalHits: number; | ||
searchHits: { | ||
reference: string; | ||
documentId: string; | ||
acesssionNumber: string; | ||
docketNumbers: string[]; | ||
description: string; | ||
summary: null; | ||
familyValue: 'None' | 'none' | 'child' | 'Parent'; | ||
issuedDate: string; | ||
filedDate: string; | ||
postedDate: string; | ||
category: Categories; | ||
classTypes: ClassType[]; | ||
availCode: SecurityLevel; | ||
libraries: Libraries[]; | ||
transmittals: Transmittal[]; | ||
affiliations: Affiliations[]; | ||
score: 83.35; | ||
}[]; | ||
}; |
Oops, something went wrong.