import {z} from 'zod' export type VertrouwelijkheidaanduidingEnum = 'openbaar' | 'beperkt_openbaar' | 'intern' | 'zaakvertrouwelijk' | 'vertrouwelijk' | 'confidentieel' | 'geheim' | 'zeer_geheim'; export type IndicatieInternOfExternEnum = 'intern' | 'extern'; export type ReferentieProces = {naam: string, link?: string | undefined}; export type BronCatalogus = {url: string, domein: string, rsin: string}; export type BronZaaktype = {url: string, identificatie: string, omschrijving: string}; export type AardRelatieEnum = 'vervolg' | 'bijdrage' | 'onderwerp'; export type ZaakTypenRelatieCreate = {zaaktype: string, aardRelatie: AardRelatieEnum, toelichting?: string | undefined}; export type ZaakTypeCreate = {url: string, identificatie: string, omschrijving: string, omschrijvingGeneriek?: string | undefined, vertrouwelijkheidaanduiding: VertrouwelijkheidaanduidingEnum, doel: string, aanleiding: string, toelichting?: string | undefined, indicatieInternOfExtern: IndicatieInternOfExternEnum, handelingInitiator: string, onderwerp: string, handelingBehandelaar: string, doorlooptijd: unknown, servicenorm?: (unknown | null) | undefined, opschortingEnAanhoudingMogelijk: boolean, verlengingMogelijk: boolean, verlengingstermijn?: (unknown | null) | undefined, trefwoorden?: Array | undefined, publicatieIndicatie: boolean, publicatietekst?: string | undefined, verantwoordingsrelatie?: Array | undefined, productenOfDiensten: Array, selectielijstProcestype?: string | undefined, referentieproces: ReferentieProces, verantwoordelijke: string, zaakobjecttypen: Array, broncatalogus?: BronCatalogus | undefined, bronzaaktype?: BronZaaktype | undefined, catalogus: string, statustypen: Array, resultaattypen: Array, eigenschappen: Array, informatieobjecttypen: string, roltypen: Array, besluittypen: Array, deelzaaktypen: Array, gerelateerdeZaaktypen: Array, beginGeldigheid: string, eindeGeldigheid?: (string | null) | undefined, beginObject?: (string | null) | undefined, eindeObject?: (string | null) | undefined, versiedatum?: string | undefined, concept: boolean}; export type CreateApiZaaktypenArgs = {'Content-Type': 'application/json', body: ZaakTypeCreate}; export type CreateApiZaaktypenOptions = {baseUrl?: string | undefined, JWTClaims?: string | undefined, fetch?: typeof fetch | undefined}; export const vertrouwelijkheidaanduidingEnum = z.enum(["openbaar", "beperkt_openbaar", "intern", "zaakvertrouwelijk", "vertrouwelijk", "confidentieel", "geheim", "zeer_geheim"]); export const indicatieInternOfExternEnum = z.enum(["intern", "extern"]); export const referentieProces = z.object({naam: z.string().max(80), link: z.string().max(200).optional()}); export const bronCatalogus = z.object({url: z.string().max(200), domein: z.string().max(5), rsin: z.string().max(9)}); export const bronZaaktype = z.object({url: z.string().max(200), identificatie: z.string().max(50), omschrijving: z.string().max(80)}); export const aardRelatieEnum = z.enum(["vervolg", "bijdrage", "onderwerp"]); export const zaakTypenRelatie = z.object({zaaktype: z.string().max(200), aardRelatie: aardRelatieEnum, toelichting: z.string().max(255).optional()}); export const zaakType = z.object({url: z.string().min(1).max(1000), identificatie: z.string().max(50), omschrijving: z.string().max(80), omschrijvingGeneriek: z.string().max(80).optional(), vertrouwelijkheidaanduiding: vertrouwelijkheidaanduidingEnum, doel: z.string(), aanleiding: z.string(), toelichting: z.string().optional(), indicatieInternOfExtern: indicatieInternOfExternEnum, handelingInitiator: z.string().max(20), onderwerp: z.string().max(80), handelingBehandelaar: z.string().max(20), doorlooptijd: z.string(), servicenorm: z.string().nullable().optional(), opschortingEnAanhoudingMogelijk: z.boolean(), verlengingMogelijk: z.boolean(), verlengingstermijn: z.string().nullable().optional(), trefwoorden: z.array(z.string().max(30)).optional(), publicatieIndicatie: z.boolean(), publicatietekst: z.string().optional(), verantwoordingsrelatie: z.array(z.string().max(40)).optional(), productenOfDiensten: z.array(z.string().max(1000)), selectielijstProcestype: z.string().max(200).optional(), referentieproces: referentieProces, verantwoordelijke: z.string().max(50), zaakobjecttypen: z.array(z.string()), broncatalogus: bronCatalogus.optional(), bronzaaktype: bronZaaktype.optional(), catalogus: z.string(), statustypen: z.array(z.string()), resultaattypen: z.array(z.string()), eigenschappen: z.array(z.string()), informatieobjecttypen: z.array(z.string()), roltypen: z.array(z.string()), besluittypen: z.array(z.string()), deelzaaktypen: z.array(z.string().nullable()).optional(), gerelateerdeZaaktypen: z.array(zaakTypenRelatie), beginGeldigheid: z.string(), eindeGeldigheid: z.string().nullable().optional(), beginObject: z.string().nullable().optional(), eindeObject: z.string().nullable().optional(), versiedatum: z.string().optional(), concept: z.boolean()}); 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 }; /** * Maak een ZAAKTYPE aan. * * POST /zaaktypen */ export const createApiZaaktypen = async (args: CreateApiZaaktypenArgs, options?: CreateApiZaaktypenOptions) => { const {baseUrl = "https://virtserver.swaggerhub.com/michielverhoef/Catalogussen_API/1.3.0", fetch: fetchFn = fetch, JWTClaims} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (JWTClaims !== undefined) headers.set('authorization', `Bearer ${JWTClaims}`) const url = `${baseUrl.replace(/\/+$/, '')}/zaaktypen${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(zaakType, await res.json()) };