UNPKG

propublica-nonprofit-explorer-sdk

Version:
153 lines 3.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchResponseSchema = exports.SearchRequestSchema = void 0; exports.validateSearchResponse = validateSearchResponse; exports.validateSearchRequest = validateSearchRequest; const zod_1 = require("zod"); const constants_1 = require("../constants"); exports.SearchRequestSchema = zod_1.z.object({ /** * Search query */ q: zod_1.z.string().optional(), /** * Zero-indexed page number */ page: zod_1.z.number().optional(), /** * ISO 3166-2 state code * * @see {@link https://en.wikipedia.org/wiki/ISO_3166-2|ISO 3166-2} */ 'state[id]': zod_1.z.enum(constants_1.STATE).optional(), /** * National Taxonomy of Exempt Entities (NTEE) ID * * @see {@link NTEE} */ 'ntee[id]': zod_1.z.enum(constants_1.NTEE).optional(), /** * Tax code subsection */ 'c_code[id]': zod_1.z.enum(constants_1.C_CODE).optional(), }); const SearchOrganizationSchema = zod_1.z.object({ /** * Employee Identification Number */ ein: zod_1.z.number(), /** * EIN version with dashes and leading zeroes */ strein: zod_1.z.string(), /** * Organization name */ name: zod_1.z.string(), /** * Organization subname */ sub_name: zod_1.z.string().nullable(), /** * Organization city */ city: zod_1.z.string(), /** * Organization state code */ state: zod_1.z.string(), /** * Organization NTEE code (value) */ ntee_code: zod_1.z.string().nullable(), /** * Organization raw NTEE code */ raw_ntee_code: zod_1.z.string().nullable(), /** * Organization tax code subsection (value) */ subseccd: zod_1.z.number(), /** * Whether the organization has a tax code subsection */ has_subseccd: zod_1.z.boolean(), /** * Whether the organization has filings */ have_filings: zod_1.z.boolean().nullable(), /** * Whether the organization has extracts */ have_extracts: zod_1.z.boolean().nullable(), /** * Whether the organization has PDFs */ have_pdfs: zod_1.z.boolean().nullable(), /** * Score * * Note: This is not defined in the API documentation */ score: zod_1.z.number(), }); exports.SearchResponseSchema = zod_1.z.object({ /** * Total number of results */ total_results: zod_1.z.number(), /** * Total number of pages (one-indexed) */ num_pages: zod_1.z.number(), /** * Current page (zero-indexed) */ cur_page: zod_1.z.number(), /** * Results per page */ per_page: zod_1.z.number(), /** * Page offset */ page_offset: zod_1.z.number(), /** * Search query */ search_query: zod_1.z.string().nullable(), /** * Selected state (code) */ selected_state: zod_1.z.string().nullable(), /** * Selected NTEE ID (value) */ selected_ntee: zod_1.z.string().nullable(), /** * Selected tax code subsection * * The documentation says this should return an integer, but it actually * returns a string. */ selected_code: zod_1.z.string().nullable(), /** * Data source */ data_source: zod_1.z.string(), /** * API version */ api_version: zod_1.z.number(), /** * Organizations */ organizations: zod_1.z.array(SearchOrganizationSchema), }); function validateSearchResponse(response) { return exports.SearchResponseSchema.parse(response); } function validateSearchRequest(request) { return exports.SearchRequestSchema.parse(request); } //# sourceMappingURL=search.js.map