import {z} from 'zod' export type GetApiV1InvestorEventsRecentArgs = {since?: string | undefined, until?: string | undefined, eventType?: string | undefined, market?: string | undefined, minMarketCap?: number | undefined, tickers?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1InvestorEventsRecentOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const listingNotice = z.object({status: z.string().nullable().optional(), ticker: z.string().nullable().optional(), delistedOn: z.string().nullable().optional(), successorTicker: z.string().nullable().optional()}); export const materialStatusDto = z.object({status: z.string().nullable().optional(), reason: z.string().nullable().optional(), lastAttemptAt: z.string().nullable().optional(), nextAttemptAt: z.string().nullable().optional()}); export const investorEventMaterialsDto = z.object({transcript: materialStatusDto.optional(), audio: materialStatusDto.optional(), slides: materialStatusDto.optional()}); export const recentInvestorEventDto = z.object({ticker: z.string().nullable().optional(), companyName: z.string().nullable().optional(), market: z.string().nullable().optional(), id: z.string().optional(), eventType: z.string().nullable().optional(), eventTypeName: z.string().nullable().optional(), title: z.string().nullable().optional(), callDate: z.string().optional(), callDateIsPeriodEnd: z.boolean().optional(), fiscalYear: z.number().int().nullable().optional(), fiscalQuarter: z.number().int().nullable().optional(), status: z.string().nullable().optional(), statusName: z.string().nullable().optional(), webcastUrl: z.string().nullable().optional(), transcriptDocumentId: z.string().nullable().optional(), earningsReleaseDocumentId: z.string().nullable().optional(), hasAudio: z.boolean().optional(), hasSlides: z.boolean().optional(), hasTranscript: z.boolean().optional(), materials: investorEventMaterialsDto.optional(), isTombstoned: z.boolean().nullable().optional(), presentationOnly: z.boolean().nullable().optional(), partialRecording: z.boolean().nullable().optional()}); export const pageMeta = z.object({limit: z.number().int().optional(), offset: z.number().int().optional(), count: z.number().int().optional(), hasMore: z.boolean().optional(), total: z.number().int().nullable().optional()}); export const recentInvestorEventDtoPagedResponse = z.object({listingNotice: listingNotice.optional(), data: z.array(recentInvestorEventDto).nullable().optional(), meta: pageMeta.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 }; /** * Investor events across every covered company whose transcript is on file, newest call first — the feed for a poller that posts or indexes new transcripts without naming tickers. Only events whose call date falls inside the since/until window are considered (default the last 7 days, at most 31), filtered to the listing market (default US) and, for US listings, a minimum market capitalization. A transcript can land a day or more after the call, so poll with a window wider than your interval and de-duplicate on id. * * GET /v1/investor-events/recent */ export const getApiV1InvestorEventsRecent = async (args: GetApiV1InvestorEventsRecentArgs, options?: GetApiV1InvestorEventsRecentOptions) => { 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 (args.since != null) query.append("since", String(args.since)) if (args.until != null) query.append("until", String(args.until)) if (args.eventType != null) query.append("eventType", String(args.eventType)) if (args.market != null) query.append("market", String(args.market)) if (args.minMarketCap != null) query.append("minMarketCap", String(args.minMarketCap)) if (args.tickers != null) query.append("tickers", String(args.tickers)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/investor-events/recent${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(recentInvestorEventDtoPagedResponse, await res.json()) };