import {z} from 'zod' export type GetApiV1NfipCommunityLayerNoOverlapsSplitArgs = {$filter?: string | undefined, $top?: number | undefined, $skip?: number | undefined, $count?: boolean | undefined, $filename?: string | undefined, $metadata?: boolean | undefined, $gzip?: boolean | undefined, $orderby?: (Array<'id' | 'id desc' | 'communityIdNumber' | 'communityIdNumber desc' | 'stateCode' | 'stateCode desc' | 'countyCode' | 'countyCode desc' | 'censusGeoid' | 'censusGeoid desc' | 'county' | 'county desc' | 'communityName' | 'communityName desc' | 'communityNameShort' | 'communityNameShort desc' | 'censusYear' | 'censusYear desc' | 'censusPopulationEntire' | 'censusPopulationEntire desc' | 'censusHousingUnitsEntire' | 'censusHousingUnitsEntire desc' | 'landAreaEntire' | 'landAreaEntire desc' | 'censusPopulationPunched' | 'censusPopulationPunched desc' | 'censusHousingUnitsPunched' | 'censusHousingUnitsPunched desc' | 'landArea2D' | 'landArea2D desc' | 'cisType' | 'cisType desc' | 'cisSource' | 'cisSource desc' | 'geometrySource' | 'geometrySource desc' | 'alternateGeoid' | 'alternateGeoid desc' | 'alternateName' | 'alternateName desc' | 'alternateLongName' | 'alternateLongName desc' | 'layerCreationNotes' | 'layerCreationNotes desc' | 'censusClassCodes' | 'censusClassCodes desc' | 'censusFunctionalStatusCodes' | 'censusFunctionalStatusCodes desc' | 'layerTypeCode' | 'layerTypeCode desc' | 'layerGeometry' | 'layerGeometry desc'>) | undefined, $select?: (Array<'id' | 'communityIdNumber' | 'stateCode' | 'countyCode' | 'censusGeoid' | 'county' | 'communityName' | 'communityNameShort' | 'censusYear' | 'censusPopulationEntire' | 'censusHousingUnitsEntire' | 'landAreaEntire' | 'censusPopulationPunched' | 'censusHousingUnitsPunched' | 'landArea2D' | 'cisType' | 'cisSource' | 'geometrySource' | 'alternateGeoid' | 'alternateName' | 'alternateLongName' | 'layerCreationNotes' | 'censusClassCodes' | 'censusFunctionalStatusCodes' | 'layerTypeCode' | 'layerGeometry'>) | undefined, $format?: ('json' | 'jsona' | 'jsonl' | 'geojson' | 'csv' | 'parquet' | 'esrigeojson') | undefined}; export type GetApiV1NfipCommunityLayerNoOverlapsSplitOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const metadata = z.object({skip: z.number().nullable().optional(), filter: z.string().nullable().optional(), orderBy: z.string().nullable().optional(), select: z.string().nullable().optional(), rundate: z.string().nullable().optional(), top: z.number().nullable().optional(), format: z.string().nullable().optional(), metadata: z.boolean().nullable().optional(), entityname: z.string().optional(), version: z.string().optional(), url: z.string().optional(), count: z.number().nullable().optional()}); export const v1NfipCommunityLayerNoOverlapsSplit = z.object({id: z.number().optional(), communityIdNumber: z.string().nullable().optional(), stateCode: z.string().nullable().optional(), countyCode: z.string().nullable().optional(), censusGeoid: z.string().nullable().optional(), county: z.string().nullable().optional(), communityName: z.string().nullable().optional(), communityNameShort: z.string().nullable().optional(), censusYear: z.number().nullable().optional(), censusPopulationEntire: z.number().nullable().optional(), censusHousingUnitsEntire: z.number().nullable().optional(), landAreaEntire: z.number().nullable().optional(), censusPopulationPunched: z.number().nullable().optional(), censusHousingUnitsPunched: z.number().nullable().optional(), landArea2D: z.number().nullable().optional(), cisType: z.string().nullable().optional(), cisSource: z.string().nullable().optional(), geometrySource: z.string().nullable().optional(), alternateGeoid: z.string().nullable().optional(), alternateName: z.string().nullable().optional(), alternateLongName: z.string().nullable().optional(), layerCreationNotes: z.string().nullable().optional(), censusClassCodes: z.string().nullable().optional(), censusFunctionalStatusCodes: z.string().nullable().optional(), layerTypeCode: z.string().nullable().optional(), layerGeometry: z.object({}).nullable().optional()}); export const getApiV1NfipCommunityLayerNoOverlapsSplitResponse = z.object({metadata: metadata.optional(), NfipCommunityLayerNoOverlapsSplit: z.array(v1NfipCommunityLayerNoOverlapsSplit).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 }; /** * NFIP Community Layer No Overlaps Split * * GET /v1/NfipCommunityLayerNoOverlapsSplit */ export const getApiV1NfipCommunityLayerNoOverlapsSplit = async (args: GetApiV1NfipCommunityLayerNoOverlapsSplitArgs, options?: GetApiV1NfipCommunityLayerNoOverlapsSplitOptions) => { const {baseUrl = "https://www.fema.gov/api/open", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.$filter != null) query.append("$filter", String(args.$filter)) if (args.$top != null) query.append("$top", String(args.$top)) if (args.$skip != null) query.append("$skip", String(args.$skip)) if (args.$count != null) query.append("$count", String(args.$count)) if (args.$filename != null) query.append("$filename", String(args.$filename)) if (args.$metadata != null) query.append("$metadata", String(args.$metadata)) if (args.$gzip != null) query.append("$gzip", String(args.$gzip)) for (const item of args.$orderby ?? []) query.append("$orderby", String(item)) for (const item of args.$select ?? []) query.append("$select", String(item)) if (args.$format != null) query.append("$format", String(args.$format)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/NfipCommunityLayerNoOverlapsSplit${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(getApiV1NfipCommunityLayerNoOverlapsSplitResponse, await res.json()) };