2022-04-19 16:50:21 +02:00
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WARNING! The original file is in /messages/JsonMessages.
|
|
|
|
* All other files are automatically copied from this file on container startup / build
|
|
|
|
*/
|
|
|
|
|
2022-04-21 14:16:18 +02:00
|
|
|
export const isErrorApiErrorData = z.object({
|
|
|
|
// @ts-ignore
|
2022-04-21 14:49:41 +02:00
|
|
|
type: z.literal("error"),
|
2022-04-21 14:16:18 +02:00
|
|
|
code: z.string(),
|
|
|
|
title: z.string(),
|
|
|
|
subtitle: z.string(),
|
|
|
|
details: z.string(),
|
|
|
|
image: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const isErrorApiRetryData = z.object({
|
2022-04-21 14:49:41 +02:00
|
|
|
type: z.literal("retry"),
|
2022-04-19 16:50:21 +02:00
|
|
|
code: z.string(),
|
|
|
|
title: z.string(),
|
|
|
|
subtitle: z.string(),
|
|
|
|
details: z.string(),
|
|
|
|
image: z.string(),
|
|
|
|
buttonTitle: z.optional(z.nullable(z.string())),
|
2022-04-21 14:16:18 +02:00
|
|
|
timeToRetry: z.number(),
|
|
|
|
canRetryManual: z.boolean(),
|
2022-04-19 16:50:21 +02:00
|
|
|
});
|
|
|
|
|
2022-04-21 14:16:18 +02:00
|
|
|
export const isErrorApiRedirectData = z.object({
|
2022-04-21 14:49:41 +02:00
|
|
|
type: z.literal("redirect"),
|
2022-04-21 14:16:18 +02:00
|
|
|
urlToRedirect: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const isErrorApiUnauthorizedData = z.object({
|
2022-04-21 14:49:41 +02:00
|
|
|
type: z.literal("unauthorized"),
|
2022-04-26 18:17:12 +02:00
|
|
|
code: z.string(),
|
|
|
|
title: z.string(),
|
|
|
|
subtitle: z.string(),
|
|
|
|
details: z.string(),
|
|
|
|
image: z.string(),
|
|
|
|
buttonTitle: z.optional(z.nullable(z.string())),
|
2022-04-21 14:16:18 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export const isErrorApiData = z.discriminatedUnion("type", [
|
|
|
|
isErrorApiErrorData,
|
|
|
|
isErrorApiRetryData,
|
|
|
|
isErrorApiRedirectData,
|
|
|
|
isErrorApiUnauthorizedData,
|
|
|
|
]);
|
|
|
|
|
2022-04-19 16:50:21 +02:00
|
|
|
export type ErrorApiData = z.infer<typeof isErrorApiData>;
|