Fix order locale and remake Zod def of ErrorApi

This commit is contained in:
CEC
2022-04-21 14:16:18 +02:00
parent 711832bc3a
commit bc17b86ce4
7 changed files with 95 additions and 39 deletions
+36 -6
View File
@@ -5,17 +5,47 @@ import { z } from "zod";
* All other files are automatically copied from this file on container startup / build
*/
export const isErrorApiData = z.object({
type: z.string(),
export const isErrorApiErrorData = z.object({
// @ts-ignore
type: z.literal('error'),
code: z.string(),
title: z.string(),
subtitle: z.string(),
details: z.string(),
image: z.string(),
urlToRedirect: z.optional(z.nullable(z.string())),
buttonTitle: z.optional(z.nullable(z.string())),
timeToRetry: z.optional(z.nullable(z.bigint())),
canRetryManual: z.optional(z.nullable(z.boolean())),
});
export const isErrorApiRetryData = z.object({
type: z.literal('retry'),
code: z.string(),
title: z.string(),
subtitle: z.string(),
details: z.string(),
image: z.string(),
buttonTitle: z.optional(z.nullable(z.string())),
timeToRetry: z.number(),
canRetryManual: z.boolean(),
});
export const isErrorApiRedirectData = z.object({
type: z.literal('redirect'),
urlToRedirect: z.string(),
});
export const isErrorApiUnauthorizedData = z.object({
type: z.literal('unauthorized'),
});
export const isErrorApiData = z.discriminatedUnion("type", [
isErrorApiErrorData,
isErrorApiRetryData,
isErrorApiRedirectData,
isErrorApiUnauthorizedData,
]);
export type ErrorApiErrorData = z.infer<typeof isErrorApiErrorData>;
export type ErrorApiRetryData = z.infer<typeof isErrorApiRetryData>;
export type ErrorApiRedirectData = z.infer<typeof isErrorApiRedirectData>;
export type ErrorApiUnauthorizedData = z.infer<typeof isErrorApiUnauthorizedData>;
export type ErrorApiData = z.infer<typeof isErrorApiData>;
+9 -9
View File
@@ -226,15 +226,15 @@ message ErrorMessage {
*/
message ErrorScreenMessage {
string type = 1;
string code = 2;
string title = 3;
string subtitle = 4;
string details = 5;
int32 timeToRetry = 6;
bool canRetryManual = 7;
string urlToRedirect = 8;
string buttonTitle = 9;
string image = 10;
google.protobuf.StringValue code = 2;
google.protobuf.StringValue title = 3;
google.protobuf.StringValue subtitle = 4;
google.protobuf.StringValue details = 5;
google.protobuf.Int32Value timeToRetry = 6;
google.protobuf.BoolValue canRetryManual = 7;
google.protobuf.StringValue urlToRedirect = 8;
google.protobuf.StringValue buttonTitle = 9;
google.protobuf.StringValue image = 10;
}
message ItemStateMessage {