refactor(data): replace schema classes with readonly models
This commit is contained in:
@@ -1,39 +1,25 @@
|
||||
/**
|
||||
* PWA 事件上报请求
|
||||
*
|
||||
*
|
||||
*/
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
createSchemaModel,
|
||||
type SchemaModel,
|
||||
} from "../../schema_model";
|
||||
|
||||
import {
|
||||
booleanOrFalse,
|
||||
numberOrZero,
|
||||
stringOrEmpty,
|
||||
} from "../../nullable-defaults";
|
||||
|
||||
export const PwaEventSchema = z.object({
|
||||
deviceId: stringOrEmpty,
|
||||
deviceType: stringOrEmpty,
|
||||
timestamp: numberOrZero,
|
||||
pwaInstalled: booleanOrFalse,
|
||||
pwaSupported: booleanOrFalse,
|
||||
});
|
||||
export const PwaEventSchema = z
|
||||
.object({
|
||||
deviceId: stringOrEmpty,
|
||||
deviceType: stringOrEmpty,
|
||||
timestamp: numberOrZero,
|
||||
pwaInstalled: booleanOrFalse,
|
||||
pwaSupported: booleanOrFalse,
|
||||
})
|
||||
.readonly();
|
||||
|
||||
export type PwaEventInput = z.input<typeof PwaEventSchema>;
|
||||
export type PwaEventData = z.output<typeof PwaEventSchema>;
|
||||
|
||||
type PwaEventPublicKey =
|
||||
| "deviceId"
|
||||
| "deviceType"
|
||||
| "timestamp"
|
||||
| "pwaInstalled"
|
||||
| "pwaSupported";
|
||||
export type PwaEvent = SchemaModel<typeof PwaEventSchema, PwaEventPublicKey>;
|
||||
export const PwaEvent = createSchemaModel<
|
||||
typeof PwaEventSchema,
|
||||
PwaEventPublicKey
|
||||
>(PwaEventSchema);
|
||||
export type PwaEvent = PwaEventData;
|
||||
|
||||
Reference in New Issue
Block a user