import {z} from 'zod' export type GetApiV1StocksTickerAtmProgramsArgs = {ticker: string}; export type GetApiV1StocksTickerAtmProgramsOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const atmProgramDto = z.object({announcedDate: z.string().nullable().optional(), announcedDatePrecision: z.string().nullable().optional(), lastAmendedDate: z.string().nullable().optional(), lastAmendedDatePrecision: z.string().nullable().optional(), capacity: z.number().nullable().optional(), capacityShares: z.number().nullable().optional(), currency: z.string().nullable().optional(), expiresDate: z.string().nullable().optional(), soldAmount: z.number().nullable().optional(), soldAsOf: z.string().nullable().optional(), soldShares: z.number().nullable().optional(), soldSharesAsOf: z.string().nullable().optional(), remainingAmount: z.number().nullable().optional(), remainingAsOf: z.string().nullable().optional(), remainingShares: z.number().nullable().optional(), remainingSharesAsOf: z.string().nullable().optional(), lastObservedFiledDate: z.string().optional(), latestForm: z.string().nullable().optional(), latestFilingUrl: z.string().nullable().optional(), isFullyUtilized: z.boolean().optional(), isExpired: z.boolean().optional()}); export const atmProgramsResponse = z.object({ticker: z.string().nullable().optional(), companyName: z.string().nullable().optional(), programs: z.array(atmProgramDto).nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * A company's at-the-market (ATM) equity offering programs: original agreement date and stated precision, latest amendment, money and/or share capacity, cumulative sold and remaining figures with their own as-of dates, expiry, derived utilization/expiry flags, and source filings. Bare table figures are normalized only from an exact grounded filing scale header. Figures come from verified extractions of the company's own 10-K/10-Q/8-K filings scanned over roughly the last 13 months (ATM programs have no tagged XBRL equivalent) — an empty list means no program was captured there, NOT proof the company runs no ATM program. * * GET /v1/stocks/{ticker}/atm-programs */ export const getApiV1StocksTickerAtmPrograms = async (args: GetApiV1StocksTickerAtmProgramsArgs, options?: GetApiV1StocksTickerAtmProgramsOptions) => { const {baseUrl = "https://api.equibles.com", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/stocks/${encodeURIComponent(String(args.ticker))}/atm-programs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(atmProgramsResponse, await res.json()) };