OpenAPI Generierung verbessert
This commit is contained in:
1522
openapi.json
1522
openapi.json
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
@@ -10,9 +10,9 @@ export const createCaller = createCallerFactory({
|
|||||||
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
||||||
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
|
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
|
||||||
"objekt": await import("../src/pages/api/objekt/index.ts"),
|
"objekt": await import("../src/pages/api/objekt/index.ts"),
|
||||||
|
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
|
||||||
"user": await import("../src/pages/api/user/index.ts"),
|
"user": await import("../src/pages/api/user/index.ts"),
|
||||||
"user/self": await import("../src/pages/api/user/self.ts"),
|
"user/self": await import("../src/pages/api/user/self.ts"),
|
||||||
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
|
|
||||||
"verbrauchsausweis-wohnen/[uid]": await import("../src/pages/api/verbrauchsausweis-wohnen/[uid].ts"),
|
"verbrauchsausweis-wohnen/[uid]": await import("../src/pages/api/verbrauchsausweis-wohnen/[uid].ts"),
|
||||||
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
|
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
|
||||||
"objekt/[uid]/bilder": await import("../src/pages/api/objekt/[uid]/bilder.ts"),
|
"objekt/[uid]/bilder": await import("../src/pages/api/objekt/[uid]/bilder.ts"),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||||
import {
|
import {
|
||||||
Aufnahme,
|
Aufnahme,
|
||||||
BedarfsausweisWohnen,
|
BedarfsausweisWohnen,
|
||||||
@@ -104,3 +105,15 @@ export type OptionalNullable<T> = T extends object ? {
|
|||||||
} & {
|
} & {
|
||||||
[K in keyof PickNotNullable<T>]: OptionalNullable<T[K]>
|
[K in keyof PickNotNullable<T>]: OptionalNullable<T[K]>
|
||||||
} : T;
|
} : T;
|
||||||
|
|
||||||
|
export const UUidWithPrefix = z.string().refine((value) => {
|
||||||
|
const prefixedUUidRegex = /^([0-9a-z]+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||||
|
|
||||||
|
const match = value.match(prefixedUUidRegex)
|
||||||
|
|
||||||
|
if (match && match[1] in VALID_UUID_PREFIXES) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
@@ -4,6 +4,22 @@ export const API_ACCESS_TOKEN_COOKIE_NAME = "accessToken";
|
|||||||
export const API_REFRESH_TOKEN_COOKIE_NAME = "refreshToken";
|
export const API_REFRESH_TOKEN_COOKIE_NAME = "refreshToken";
|
||||||
export const API_UID_COOKIE_NAME = "uid";
|
export const API_UID_COOKIE_NAME = "uid";
|
||||||
|
|
||||||
|
export enum VALID_UUID_PREFIXES {
|
||||||
|
"auf" = "Aufnahme",
|
||||||
|
"obj" = "Objekt",
|
||||||
|
"vaw" = "Verbrauchsausweis Wohnen",
|
||||||
|
"vag" = "Verbrauchsausweis Gewerbe",
|
||||||
|
"baw" = "Bedarfsausweis Wohnen",
|
||||||
|
"bag" = "Bedarfsausweis Gewerbe",
|
||||||
|
"usr" = "User",
|
||||||
|
"ant" = "Anteilshaber",
|
||||||
|
"evt" = "Event",
|
||||||
|
"img" = "Bild",
|
||||||
|
"inv" = "Rechnung",
|
||||||
|
"tkt" = "Ticket",
|
||||||
|
"pln" = "Gebäude Plan",
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ein Objekt welches alle definierten Preise für unsere Basisprodukte enthält.
|
* Ein Objekt welches alle definierten Preise für unsere Basisprodukte enthält.
|
||||||
*/
|
*/
|
||||||
@@ -12,10 +28,13 @@ export const PRICES: Record<Enums.Ausweisart, [number, number, number]> = {
|
|||||||
BedarfsausweisWohnen: [135, 145, 290],
|
BedarfsausweisWohnen: [135, 145, 290],
|
||||||
VerbrauchsausweisWohnen: [65, 75, 180],
|
VerbrauchsausweisWohnen: [65, 75, 180],
|
||||||
VerbrauchsausweisGewerbe: [95, 115, 360],
|
VerbrauchsausweisGewerbe: [95, 115, 360],
|
||||||
BedarfsausweisGewerbe: [500, 0, 0]
|
BedarfsausweisGewerbe: [500, 0, 0],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SERVICES: Record<Enums.Ausweisart, Record<Enums.Service, number>> = {
|
export const SERVICES: Record<
|
||||||
|
Enums.Ausweisart,
|
||||||
|
Record<Enums.Service, number>
|
||||||
|
> = {
|
||||||
BedarfsausweisWohnen: {
|
BedarfsausweisWohnen: {
|
||||||
Qualitaetsdruck: 9,
|
Qualitaetsdruck: 9,
|
||||||
Aushang: 10,
|
Aushang: 10,
|
||||||
@@ -34,4 +53,10 @@ export const SERVICES: Record<Enums.Ausweisart, Record<Enums.Service, number>> =
|
|||||||
SameDay: 29,
|
SameDay: 29,
|
||||||
Telefonberatung: 25,
|
Telefonberatung: 25,
|
||||||
},
|
},
|
||||||
};
|
BedarfsausweisGewerbe: {
|
||||||
|
Aushang: 0,
|
||||||
|
Qualitaetsdruck: 0,
|
||||||
|
SameDay: 0,
|
||||||
|
Telefonberatung: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { decodeToken } from "#lib/auth/token.js";
|
|||||||
import { hashPassword } from "#lib/password.js";
|
import { hashPassword } from "#lib/password.js";
|
||||||
import { prisma } from "@ibcornelsen/database/server";
|
import { prisma } from "@ibcornelsen/database/server";
|
||||||
import { APIError, TypesafeAPIContextWithRequest } from "astro-typesafe-api/server";
|
import { APIError, TypesafeAPIContextWithRequest } from "astro-typesafe-api/server";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
export async function authorizationMiddleware(input: any, context: TypesafeAPIContextWithRequest<any>) {
|
export async function authorizationMiddleware(input: any, context: TypesafeAPIContextWithRequest<any>) {
|
||||||
const authorization: string | undefined = context.request.headers.get("Authorization");
|
const authorization: string | undefined = context.request.headers.get("Authorization");
|
||||||
@@ -87,3 +88,7 @@ export async function maybeAuthorizationMiddleware(input: any, ctx: TypesafeAPIC
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const authorizationHeaders = {
|
||||||
|
Authorization: z.string()
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AufnahmeClient, OptionalNullable, ZodOverlap } from "#components/Ausweis/types.js";
|
import { AufnahmeClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { AufnahmeSchema, prisma } from "@ibcornelsen/database/server";
|
import { AufnahmeSchema, prisma } from "@ibcornelsen/database/server";
|
||||||
@@ -62,7 +62,7 @@ export const GET = defineApiRoute({
|
|||||||
objekt_id: true,
|
objekt_id: true,
|
||||||
benutzer_id: true
|
benutzer_id: true
|
||||||
}).merge(z.object({
|
}).merge(z.object({
|
||||||
uid_objekt: z.string().uuid()
|
uid_objekt: UUidWithPrefix
|
||||||
}))),
|
}))),
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { UUidWithPrefix } from "#components/Ausweis/types.js"
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js"
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js"
|
||||||
import { AufnahmeSchema, ObjektSchema, prisma } from "@ibcornelsen/database/server"
|
import { AufnahmeSchema, ObjektSchema, prisma } from "@ibcornelsen/database/server"
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server"
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server"
|
||||||
@@ -11,12 +12,12 @@ export const PUT = defineApiRoute({
|
|||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
objekt_id: true,
|
objekt_id: true,
|
||||||
}).merge(z.object({
|
}).merge(z.object({
|
||||||
baujahr_klima: z.array(z.number().int().positive()).nullish()
|
baujahr_klima: z.array(z.number().int().positive()).optional()
|
||||||
})),
|
})),
|
||||||
uid_objekt: z.string().uuid()
|
uid_objekt: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid()
|
uid: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export const GET = defineApiRoute({
|
|||||||
input: z.object({
|
input: z.object({
|
||||||
refreshToken: z.string(),
|
refreshToken: z.string(),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
output: z.object({
|
output: z.object({
|
||||||
accessToken: z.string(),
|
accessToken: z.string(),
|
||||||
accessTokenExpiry: z.number(),
|
accessTokenExpiry: z.number(),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { encodeToken } from "../../../lib/auth/token.js";
|
|||||||
import { validatePassword } from "../../../lib/password.js";
|
import { validatePassword } from "../../../lib/password.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { TokenType } from "#lib/auth/types.js";
|
import { TokenType } from "#lib/auth/types.js";
|
||||||
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
|
||||||
export const GET = defineApiRoute({
|
export const GET = defineApiRoute({
|
||||||
meta: {
|
meta: {
|
||||||
@@ -18,7 +19,7 @@ export const GET = defineApiRoute({
|
|||||||
passwort: z.string().min(8).max(100),
|
passwort: z.string().min(8).max(100),
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid(),
|
uid: UUidWithPrefix,
|
||||||
accessToken: z.string(),
|
accessToken: z.string(),
|
||||||
refreshToken: z.string(),
|
refreshToken: z.string(),
|
||||||
refreshTokenBase64: z.string(),
|
refreshTokenBase64: z.string(),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { ObjektSchema, prisma } from "@ibcornelsen/database/server";
|
import { ObjektSchema, prisma } from "@ibcornelsen/database/server";
|
||||||
import { defineApiRoute } from "astro-typesafe-api/server";
|
import { defineApiRoute } from "astro-typesafe-api/server";
|
||||||
@@ -10,7 +11,7 @@ export const PUT = defineApiRoute({
|
|||||||
benutzer_id: true
|
benutzer_id: true
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid()
|
uid: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|||||||
import { TicketsSchema, prisma } from "@ibcornelsen/database/server";
|
import { TicketsSchema, prisma } from "@ibcornelsen/database/server";
|
||||||
import { defineApiRoute } from "astro-typesafe-api/server";
|
import { defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { maybeAuthorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { maybeAuthorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
|
||||||
export const PUT = defineApiRoute({
|
export const PUT = defineApiRoute({
|
||||||
meta: {
|
meta: {
|
||||||
@@ -23,7 +24,7 @@ export const PUT = defineApiRoute({
|
|||||||
updated_at: true,
|
updated_at: true,
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid(),
|
uid: UUidWithPrefix,
|
||||||
}),
|
}),
|
||||||
middleware: maybeAuthorizationMiddleware,
|
middleware: maybeAuthorizationMiddleware,
|
||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
import { hashPassword } from "#lib/password.js";
|
import { hashPassword } from "#lib/password.js";
|
||||||
import { prisma } from "@ibcornelsen/database/server";
|
import { prisma } from "@ibcornelsen/database/server";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
@@ -11,7 +12,7 @@ export const PUT = defineApiRoute({
|
|||||||
name: z.string()
|
name: z.string()
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid()
|
uid: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
async fetch(input) {
|
async fetch(input) {
|
||||||
const user = await prisma.benutzer.findUnique({
|
const user = await prisma.benutzer.findUnique({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OptionalNullable, VerbrauchsausweisWohnenClient, ZodOverlap } from "#components/Ausweis/types.js";
|
import { OptionalNullable, UUidWithPrefix, VerbrauchsausweisWohnenClient, ZodOverlap } from "#components/Ausweis/types.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { prisma, VerbrauchsausweisWohnenSchema } from "@ibcornelsen/database/server";
|
import { prisma, VerbrauchsausweisWohnenSchema } from "@ibcornelsen/database/server";
|
||||||
@@ -61,9 +61,9 @@ export const GET = defineApiRoute({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
output: ZodOverlap<OptionalNullable<VerbrauchsausweisWohnenClient>>(VerbrauchsausweisWohnenSchema.merge(z.object({
|
output: ZodOverlap<OptionalNullable<VerbrauchsausweisWohnenClient>>(VerbrauchsausweisWohnenSchema.merge(z.object({
|
||||||
uid_aufnahme: z.string().uuid(),
|
uid_aufnahme: UUidWithPrefix,
|
||||||
uid_objekt: z.string().uuid(),
|
uid_objekt: UUidWithPrefix,
|
||||||
uid_benutzer: z.string().uuid().optional()
|
uid_benutzer: UUidWithPrefix.optional()
|
||||||
})).omit({
|
})).omit({
|
||||||
id: true,
|
id: true,
|
||||||
aufnahme_id: true,
|
aufnahme_id: true,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { prisma, VerbrauchsausweisWohnenSchema } from "@ibcornelsen/database/server";
|
import { prisma, VerbrauchsausweisWohnenSchema } from "@ibcornelsen/database/server";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -21,13 +22,14 @@ export const PUT = defineApiRoute({
|
|||||||
uid: true,
|
uid: true,
|
||||||
aufnahme_id: true
|
aufnahme_id: true
|
||||||
}),
|
}),
|
||||||
uid_aufnahme: z.string().uuid()
|
uid_aufnahme: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: z.string().uuid(),
|
uid: UUidWithPrefix,
|
||||||
objekt_uid: z.string().uuid(),
|
objekt_uid: UUidWithPrefix,
|
||||||
aufnahme_uid: z.string().uuid(),
|
aufnahme_uid: UUidWithPrefix,
|
||||||
}),
|
}),
|
||||||
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
const aufnahme = await prisma.aufnahme.findUnique({
|
const aufnahme = await prisma.aufnahme.findUnique({
|
||||||
|
|||||||
Reference in New Issue
Block a user