bigbuffet-rw/packages/pl-api/lib/entities/oauth-token.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

15 lines
468 B
TypeScript

import { z } from 'zod';
/** @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#get-apioauth_tokens} */
const oauthTokenSchema = z.preprocess((token: any) => ({
...token,
valid_until: token?.valid_until?.padEnd(27, 'Z'),
}), z.object({
app_name: z.string(),
id: z.number(),
valid_until: z.string().datetime({ offset: true }),
}));
type OauthToken = z.infer<typeof oauthTokenSchema>;
export { oauthTokenSchema, type OauthToken };