Skip to content

Commit

Permalink
release: 🔖 1.0.2 Jun 6, 2024, 3:06 PM [skip ci]
Browse files Browse the repository at this point in the history
## [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
semantic-release-bot committed Jun 6, 2024
1 parent 2f43a11 commit 03a40f7
Show file tree
Hide file tree
Showing 17 changed files with 416 additions and 1 deletion.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [1.0.2](https://github.com/4very/ferc-elibrary-api/compare/v1.0.1...v1.0.2) (2024-06-06)


### Features

* :sparkles: docket search ([b9f278c](https://github.com/4very/ferc-elibrary-api/commit/b9f278c867ac06b61133b69c01046800ebd11cb7))
* :sparkles: new docket search ([e5de589](https://github.com/4very/ferc-elibrary-api/commit/e5de58913885f400d7cee02ed97b46d05afffec5))


### Bug Fixes

* :bug: failing tests ([365350c](https://github.com/4very/ferc-elibrary-api/commit/365350c4a23e47259bf81907ebaf344fa63594f7))
* :bug: failing tests ([f61afa2](https://github.com/4very/ferc-elibrary-api/commit/f61afa277417ab5bc40a0615ee42654c56a24884))
* :bug: fetch without body on get ([54463a9](https://github.com/4very/ferc-elibrary-api/commit/54463a91370b32a1aafad464ef305da1f1f2a572))
* :bug: fix build ([40ce396](https://github.com/4very/ferc-elibrary-api/commit/40ce396e0a72209f9e6bc4322b5977ab90614280))

## [1.0.1](https://github.com/4very/ferc-elibrary-api/compare/v1.0.0...v1.0.1) (2024-05-14)


Expand Down
1 change: 1 addition & 0 deletions dist/index.cjs
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;
6 changes: 6 additions & 0 deletions dist/index.d.ts
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, };
177 changes: 177 additions & 0 deletions dist/index.js
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
};
12 changes: 12 additions & 0 deletions dist/search/docket.d.ts
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>;
}
12 changes: 12 additions & 0 deletions dist/search/general.d.ts
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>;
}
11 changes: 11 additions & 0 deletions dist/search/newDocket.d.ts
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;
}
6 changes: 6 additions & 0 deletions dist/search/search.d.ts
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>;
}
46 changes: 46 additions & 0 deletions dist/types/DocketSearch.d.ts
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: [];
}[];
};
8 changes: 8 additions & 0 deletions dist/types/DownloadFile.d.ts
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;
};
76 changes: 76 additions & 0 deletions dist/types/GeneralSearch.d.ts
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;
}[];
};
Loading

0 comments on commit 03a40f7

Please sign in to comment.