refactor(data): replace schema classes with readonly models

This commit is contained in:
2026-07-17 13:21:40 +08:00
parent 3437312167
commit ae97366a4a
103 changed files with 1220 additions and 2117 deletions
+11 -25
View File
@@ -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;