UNPKG

@us-legal-tools/ecfr-sdk

Version:

TypeScript SDK and MCP server for the eCFR (Electronic Code of Federal Regulations) API

12 lines 15.2 kB
{ "version": 3, "sources": ["../src/api/client.ts", "../src/api/generated/endpoints.ts", "../src/index.ts"], "sourcesContent": [ "import axios, { type AxiosRequestConfig } from 'axios';\n\nexport const customInstance = <T>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<T> => {\n const source = axios.CancelToken.source();\n const promise = axios({\n ...config,\n ...options,\n cancelToken: source.token,\n }).then(({ data }) => data);\n\n // @ts-ignore\n promise.cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport default customInstance;\n", "/**\n * Generated by orval v7.10.0 🍺\n * Do not edit manually.\n * eCFR SDK\n * TypeScript SDK and Model Context Protocol server for the Electronic Code of Federal Regulations (eCFR) API\n * OpenAPI spec version: 1.0.0\n */\nimport type {\n GetApiAdminV1CorrectionsJsonParams,\n GetApiSearchV1CountParams,\n GetApiSearchV1CountsDailyParams,\n GetApiSearchV1CountsHierarchyParams,\n GetApiSearchV1CountsTitlesParams,\n GetApiSearchV1Results200,\n GetApiSearchV1ResultsParams,\n GetApiSearchV1SuggestionsParams,\n GetApiSearchV1SummaryParams,\n GetApiVersionerV1AncestryDateTitleTitleJsonParams,\n GetApiVersionerV1FullDateTitleTitleXmlParams,\n GetApiVersionerV1VersionsTitleTitleJsonParams\n} from './model';\n\nimport { customInstance } from '../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n /**\n * All top-level agencies in name order with children also in name order\n * @summary Agencies\n */\nexport const getApiAdminV1AgenciesJson = (\n \n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/admin/v1/agencies.json`, method: 'GET'\n },\n options);\n }\n \n/**\n * The Corrections service can be used to determine all corrections or can be filtered by title, effective date, or correction date.\n\n * @summary Corrections route returns all eCFR corrections.\n */\nexport const getApiAdminV1CorrectionsJson = (\n params?: GetApiAdminV1CorrectionsJsonParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/admin/v1/corrections.json`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * The Corrections service can be used to determine all corrections for the given title.\n * @summary Corrections title route returns all corrections for the supplied title.\n */\nexport const getApiAdminV1CorrectionsTitleTitleJson = (\n title: string | undefined | null,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/admin/v1/corrections/title/${title}.json`, method: 'GET'\n },\n options);\n }\n \n/**\n * @summary Search results\n */\nexport const getApiSearchV1Results = (\n params?: GetApiSearchV1ResultsParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<GetApiSearchV1Results200>(\n {url: `https://www.ecfr.gov/api/search/v1/results`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search result count\n */\nexport const getApiSearchV1Count = (\n params?: GetApiSearchV1CountParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/count`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search summary details\n */\nexport const getApiSearchV1Summary = (\n params?: GetApiSearchV1SummaryParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/summary`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search result counts by date\n */\nexport const getApiSearchV1CountsDaily = (\n params?: GetApiSearchV1CountsDailyParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/counts/daily`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search result counts by title\n */\nexport const getApiSearchV1CountsTitles = (\n params?: GetApiSearchV1CountsTitlesParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/counts/titles`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search result counts by hierarchy\n */\nexport const getApiSearchV1CountsHierarchy = (\n params?: GetApiSearchV1CountsHierarchyParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/counts/hierarchy`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * @summary Search suggestions\n */\nexport const getApiSearchV1Suggestions = (\n params?: GetApiSearchV1SuggestionsParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/search/v1/suggestions`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * The Ancestry service can be used to determine the complete ancestry to a leaf node at a specific point in time.\n### Example\nThe complete hierarchy for **2 CFR 1532.137** is\n```\nTitle 2\n Subtitle B\n Chapter XV\n Part 1532\n Subpart A\n Section 1532.137\n```\nTo retrieve this complete hierarchy you can use the ancestry endpoint and provide a Title, Part and Section (you can provide additional layers of the hierarchy) to retrieve a full ancestry.\nSee sample json responses below.\n\n * @summary Ancestors route returns all ancestors (including self) from a given level through the top title node.\n */\nexport const getApiVersionerV1AncestryDateTitleTitleJson = (\n date: string | undefined | null,\n title: string | undefined | null,\n params?: GetApiVersionerV1AncestryDateTitleTitleJsonParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/versioner/v1/ancestry/${date}/title-${title}.json`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * The title source route can be used to retrieve the source xml for a complete title or subset. The subset of xml is determined by the lowest leaf node given. For example, if you request Title 1, Chapter I, Part 1, you'll receive the XML only for Part 1 and its children.\nIf you request a section you'll receive the section XML inside its parent Part as well as relevant non-section sibling nodes (Auth, Source, etc).\nThe largest title source xml files can be dozens of megabytes.\n\n[GPO eCFR XML User guide](https://github.com/usgpo/bulk-data/blob/master/ECFR-XML-User-Guide.md)\n\n * @summary Source XML for a title or subset of a title. Requests can be for entire titles or part level and below. Downloadable XML document is returned for title requests. Processed XML is returned if part, subpart, section, or appendix is requested.\n */\nexport const getApiVersionerV1FullDateTitleTitleXml = (\n date: string | undefined | null,\n title: string | undefined | null,\n params?: GetApiVersionerV1FullDateTitleTitleXmlParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<string>(\n {url: `https://www.ecfr.gov/api/versioner/v1/full/${date}/title-${title}.xml`, method: 'GET',\n params\n },\n options);\n }\n \n/**\n * The structure JSON endpoint returns the complete structure of a title back as json. This format does not include the content of the title but does include all structure and content nodes as well as their meta data including their type, label, description, identifier and children.\n * @summary Structure JSON for a title\n */\nexport const getApiVersionerV1StructureDateTitleTitleJson = (\n date: string | undefined | null,\n title: string | undefined | null,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/versioner/v1/structure/${date}/title-${title}.json`, method: 'GET'\n },\n options);\n }\n \n/**\n * The Title service can be used to determine the status of each individual title and of the overall status of title imports and reprocessings. It returns an array of all titles containing a hash for each with the name of the title, the latest amended date, latest issue date, up-to-date date, reserved status, and if applicable, processing in progress status. The meta data returned indicates the latest issue date and whether titles are currently being reprocessed.\n * @summary Summary information about each title\n */\nexport const getApiVersionerV1TitlesJson = (\n \n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/versioner/v1/titles.json`, method: 'GET'\n },\n options);\n }\n \n/**\n * Returns the content versions meeting the specified criteria. Each content object includes its identifier, parent hierarchy, last amendment date and issue date it was last updated. Queries return content versions `on` an issue date, or before or on a specific issue date `lte` or on or after `gte` a specific issue date. The `gte` and `lte` parameters may be combined. Use of the `on` parameter precludes use of `gte` or `lte`. In the response, the `date` field is identical to `amendment_date` and is deprecated.\n<br>\nA response of `400 Bad Request` indicates that your request could not be processed. If possible the response will include a message indicating the problem.\n<br>\nA response of `503 Service Unavailable` indicates that the title is currently unavailable, typlically because it is currently being processed. The value of the `Retry-After` header suggests a number of seconds to wait before retrying the request.\n\n * @summary Returns an array of all sections and appendices inside a title.\n */\nexport const getApiVersionerV1VersionsTitleTitleJson = (\n title: string | undefined | null,\n params?: GetApiVersionerV1VersionsTitleTitleJsonParams,\n options?: SecondParameter<typeof customInstance>,) => {\n return customInstance<void>(\n {url: `https://www.ecfr.gov/api/versioner/v1/versions/title-${title}.json`, method: 'GET',\n params\n },\n options);\n }\n \nexport type GetApiAdminV1AgenciesJsonResult = NonNullable<Awaited<ReturnType<typeof getApiAdminV1AgenciesJson>>>\nexport type GetApiAdminV1CorrectionsJsonResult = NonNullable<Awaited<ReturnType<typeof getApiAdminV1CorrectionsJson>>>\nexport type GetApiAdminV1CorrectionsTitleTitleJsonResult = NonNullable<Awaited<ReturnType<typeof getApiAdminV1CorrectionsTitleTitleJson>>>\nexport type GetApiSearchV1ResultsResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1Results>>>\nexport type GetApiSearchV1CountResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1Count>>>\nexport type GetApiSearchV1SummaryResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1Summary>>>\nexport type GetApiSearchV1CountsDailyResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1CountsDaily>>>\nexport type GetApiSearchV1CountsTitlesResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1CountsTitles>>>\nexport type GetApiSearchV1CountsHierarchyResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1CountsHierarchy>>>\nexport type GetApiSearchV1SuggestionsResult = NonNullable<Awaited<ReturnType<typeof getApiSearchV1Suggestions>>>\nexport type GetApiVersionerV1AncestryDateTitleTitleJsonResult = NonNullable<Awaited<ReturnType<typeof getApiVersionerV1AncestryDateTitleTitleJson>>>\nexport type GetApiVersionerV1FullDateTitleTitleXmlResult = NonNullable<Awaited<ReturnType<typeof getApiVersionerV1FullDateTitleTitleXml>>>\nexport type GetApiVersionerV1StructureDateTitleTitleJsonResult = NonNullable<Awaited<ReturnType<typeof getApiVersionerV1StructureDateTitleTitleJson>>>\nexport type GetApiVersionerV1TitlesJsonResult = NonNullable<Awaited<ReturnType<typeof getApiVersionerV1TitlesJson>>>\nexport type GetApiVersionerV1VersionsTitleTitleJsonResult = NonNullable<Awaited<ReturnType<typeof getApiVersionerV1VersionsTitleTitleJson>>>\n", "import * as packageJson from '../package.json';\n\n// Export the configured API client\nexport * from './api/client';\n\n// Export all generated API functions\nexport * from './api/generated/endpoints';\n\n// Export package version\nexport const VERSION = packageJson.version;\n" ], "mappings": ";;;;AAAA;AAEO,IAAM,iBAAiB,CAC5B,QACA,YACe;AAAA,EACf,MAAM,SAAS,MAAM,YAAY,OAAO;AAAA,EACxC,MAAM,UAAU,MAAM;AAAA,OACjB;AAAA,OACA;AAAA,IACH,aAAa,OAAO;AAAA,EACtB,CAAC,EAAE,KAAK,GAAG,WAAW,IAAI;AAAA,EAG1B,QAAQ,SAAS,MAAM;AAAA,IACrB,OAAO,OAAO,oCAAoC;AAAA;AAAA,EAGpD,OAAO;AAAA;;ACcF,IAAM,4BAA4B,CAExC,YAAsD;AAAA,EACjD,OAAO,eACP;AAAA,IAAC,KAAK;AAAA,IAAmD,QAAQ;AAAA,EACnE,GACE,OAAO;AAAA;AAQN,IAAM,+BAA+B,CACxC,QACH,YAAsD;AAAA,EACjD,OAAO,eACP;AAAA,IAAC,KAAK;AAAA,IAAsD,QAAQ;AAAA,IAClE;AAAA,EACJ,GACE,OAAO;AAAA;AAON,IAAM,yCAAyC,CAClD,OACH,YAAsD;AAAA,EACjD,OAAO,eACP;AAAA,IAAC,KAAK,uDAAuD;AAAA,IAAc,QAAQ;AAAA,EACrF,GACE,OAAO;AAAA;AAMN,IAAM,wBAAwB,CACjC,QACH,YAAsD;AAAA,EACjD,OAAO,eACP;AAAA,IAAC,KAAK;AAAA,IAA8C,QAAQ;AAAA,IAC1D;AAAA,EACJ,GACE,OAAO;AAAA;AAMN,IAAM,sBAAsB,CAC/B,QACH,YAAsD;AAAA,EACjD,OAAO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