sec-edgar-toolkit
Version:
Open source toolkit to facilitate working with the SEC EDGAR database
123 lines • 3.95 kB
TypeScript
/**
* Synchronous wrapper utilities for TypeScript async APIs
*
* Note: This provides synchronous versions of async methods for compatibility
* with legacy codebases. Async/await is strongly recommended for new code.
*
* The synchronous implementation uses a promise-based approach that waits
* for async operations to complete before returning.
*/
import { Company } from '../edgar';
import { EdgarClientConfig } from '../types';
/**
* Note about synchronous implementation:
*
* True synchronous execution of async code in JavaScript/TypeScript is challenging
* without blocking the event loop. This implementation provides a synchronous-style
* API but still requires the underlying async operations to complete.
*
* For true synchronous behavior in Node.js, consider using:
* - child_process.execSync with a separate script
* - Native addons
* - Worker threads with SharedArrayBuffer
*
* For most use cases, we recommend using the async API with async/await.
*/
/**
* Synchronous-style wrapper for SEC EDGAR API client
*
* IMPORTANT: This is a compatibility layer that provides a synchronous-style API.
* The methods still return Promises internally but can be used with .then() chaining
* or in environments that support top-level await.
*
* For true synchronous behavior, you must await the results:
* ```typescript
* const client = new SyncEdgarClient(config);
* const company = await client.companies.lookup("AAPL");
* ```
*
* Or use .then() chaining:
* ```typescript
* client.companies.lookup("AAPL").then(company => {
* // Use company here
* });
* ```
*/
export declare class SyncEdgarClient {
private client;
constructor(config: EdgarClientConfig);
/**
* Company operations with synchronous-style API
*/
get companies(): {
/**
* Look up a company synchronously
* Note: Still returns a Promise, use with await or .then()
*/
lookup: (identifier: string | number) => Promise<Company | null>;
/**
* Search companies synchronously
*/
search: (query: string, limit?: number) => Promise<Company[]>;
/**
* Batch lookup companies
*/
batchLookup: (identifiers: Array<string | number>) => Promise<(Company | null)[]>;
};
/**
* Filing operations with synchronous-style API
*/
get filings(): {
/**
* Get filings for a company
*/
getFilings: (company: Company | string | number, options?: {
formTypes?: string[];
since?: string;
until?: string;
limit?: number;
}) => Promise<import("../edgar").Filing[]>;
};
/**
* Facts operations with synchronous-style API
*/
get facts(): {
/**
* Get facts for a company
*/
getFacts: (company: Company | string | number, options?: {
concept?: string;
taxonomy?: string;
units?: string;
period?: string;
}) => Promise<Record<string, any>[]>;
};
}
/**
* Create a synchronous-style Edgar client
*
* @example
* ```typescript
* // With top-level await (Node.js 14.8+, or transpiled)
* const client = createSyncClient({ userAgent: "MyApp/1.0" });
* const company = await client.companies.lookup("AAPL");
*
* // With .then() chaining
* client.companies.lookup("AAPL").then(company => {
* console.log(company?.name);
* });
*
* // In async function
* async function getCompanyData() {
* const client = createSyncClient({ userAgent: "MyApp/1.0" });
* const company = await client.companies.lookup("AAPL");
* const filings = await client.filings.getFilings(company, {
* formTypes: ["10-K"],
* limit: 5
* });
* return { company, filings };
* }
* ```
*/
export declare function createSyncClient(config: EdgarClientConfig): SyncEdgarClient;
//# sourceMappingURL=sync-wrapper.d.ts.map