import {z} from 'zod' export type StringFieldFilter = {eq?: string | undefined, contains?: string | undefined, ocontains?: string | undefined, oeq?: string | undefined, neq?: string | undefined}; export type GetApiV3PortalsPortalIdApplicationsApplicationIdDevelopersArgs = {'page[size]'?: number | undefined, 'page[number]'?: number | undefined, sort?: string | undefined, filter?: ({id?: StringFieldFilter | undefined}) | undefined}; export type GetApiV3PortalsPortalIdApplicationsApplicationIdDevelopersOptions = {baseUrl?: string | undefined, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const pageMeta = z.object({number: z.number(), size: z.number(), total: z.number()}); export const paginatedMeta = z.object({page: pageMeta}); export const applicationDeveloperDetailed = z.object({id: z.string(), email: z.string().max(250).optional(), full_name: z.string().max(250).optional()}); export const listApplicationDevelopersResponse = z.object({meta: paginatedMeta, data: z.array(applicationDeveloperDetailed)}); 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 }; /** * List Developers by Application * * GET /v3/portals/{portalId}/applications/{applicationId}/developers * * Also accepts auth: systemAccountAccessToken, konnectAccessToken, serviceAccessToken */ export const getApiV3PortalsPortalIdApplicationsApplicationIdDevelopers = async (args: GetApiV3PortalsPortalIdApplicationsApplicationIdDevelopersArgs, options?: GetApiV3PortalsPortalIdApplicationsApplicationIdDevelopersOptions) => { const {baseUrl = "https://global.api.konghq.com", fetch: fetchFn = fetch, personalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['page[size]'] != null) query.append("page[size]", String(args['page[size]'])) if (args['page[number]'] != null) query.append("page[number]", String(args['page[number]'])) if (args.sort != null) query.append("sort", String(args.sort)) if (args.filter != null) query.append("filter", JSON.stringify(args.filter)) if (personalAccessToken !== undefined) headers.set('authorization', `Bearer ${personalAccessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/portals/${encodeURIComponent(String(args.portalId))}/applications/${encodeURIComponent(String(args.applicationId))}/developers${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(listApplicationDevelopersResponse, await res.json()) };