export type GetApiRecordsParentNaIdParentNaIdArgs = {parentNaId: string, controlGroup?: string | undefined, page?: number | undefined, limit?: number | undefined, debug?: boolean | undefined, abbreviated?: boolean | undefined, ingestTimeStart?: string | undefined, ingestTimeEnd?: string | undefined}; export type GetApiRecordsParentNaIdParentNaIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get records which are immediate children of a specified parentNaId. * * GET /records/parentNaId/{parentNaId} */ export const getApiRecordsParentNaIdParentNaId = async (args: GetApiRecordsParentNaIdParentNaIdArgs, options?: GetApiRecordsParentNaIdParentNaIdOptions) => { const {baseUrl = "https://catalog.archives.gov/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.controlGroup != null) query.append("controlGroup", String(args.controlGroup)) if (args.page != null) query.append("page", String(args.page)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.debug != null) query.append("debug", String(args.debug)) if (args.abbreviated != null) query.append("abbreviated", String(args.abbreviated)) if (args.ingestTimeStart != null) query.append("ingestTimeStart", String(args.ingestTimeStart)) if (args.ingestTimeEnd != null) query.append("ingestTimeEnd", String(args.ingestTimeEnd)) const url = `${baseUrl.replace(/\/+$/, '')}/records/parentNaId/${encodeURIComponent(String(args.parentNaId))}${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 undefined };