184 lines
6.5 KiB
TypeScript
184 lines
6.5 KiB
TypeScript
import * as v from "valibot";
|
|
|
|
export const dateLikeSchema = v.union([v.date(), v.string()]);
|
|
export type DateLike = v.InferOutput<typeof dateLikeSchema>;
|
|
|
|
export const mobileDeviceSchema = v.object({
|
|
id: v.pipe(v.number(), v.integer()),
|
|
externalDeviceId: v.string(),
|
|
name: v.string(),
|
|
manufacturer: v.string(),
|
|
model: v.string(),
|
|
androidVersion: v.string(),
|
|
ownerUserId: v.string(),
|
|
lastPingAt: v.nullable(v.date()),
|
|
createdAt: v.date(),
|
|
updatedAt: v.date(),
|
|
});
|
|
export type MobileDevice = v.InferOutput<typeof mobileDeviceSchema>;
|
|
export type MobileDevices = MobileDevice[];
|
|
|
|
export const registerMobileDeviceSchema = v.object({
|
|
externalDeviceId: v.string(),
|
|
name: v.string(),
|
|
manufacturer: v.string(),
|
|
model: v.string(),
|
|
androidVersion: v.string(),
|
|
});
|
|
export type RegisterMobileDevice = v.InferOutput<typeof registerMobileDeviceSchema>;
|
|
|
|
export const pingMobileDeviceSchema = v.object({
|
|
pingAt: v.optional(dateLikeSchema),
|
|
});
|
|
export type PingMobileDevice = v.InferOutput<typeof pingMobileDeviceSchema>;
|
|
|
|
export const mobileSMSSchema = v.object({
|
|
id: v.pipe(v.number(), v.integer()),
|
|
deviceId: v.pipe(v.number(), v.integer()),
|
|
externalMessageId: v.optional(v.nullable(v.string())),
|
|
sender: v.string(),
|
|
recipient: v.optional(v.nullable(v.string())),
|
|
body: v.string(),
|
|
sentAt: v.date(),
|
|
receivedAt: v.optional(v.nullable(v.date())),
|
|
dedupHash: v.string(),
|
|
rawPayload: v.optional(v.nullable(v.record(v.string(), v.any()))),
|
|
createdAt: v.date(),
|
|
updatedAt: v.date(),
|
|
});
|
|
export type MobileSMS = v.InferOutput<typeof mobileSMSSchema>;
|
|
export type MobileSMSList = MobileSMS[];
|
|
|
|
export const mobileSMSInputSchema = v.object({
|
|
externalMessageId: v.optional(v.nullable(v.string())),
|
|
sender: v.string(),
|
|
recipient: v.optional(v.nullable(v.string())),
|
|
body: v.string(),
|
|
sentAt: dateLikeSchema,
|
|
receivedAt: v.optional(v.nullable(dateLikeSchema)),
|
|
dedupHash: v.optional(v.string()),
|
|
rawPayload: v.optional(v.record(v.string(), v.any())),
|
|
});
|
|
export type MobileSMSInput = v.InferOutput<typeof mobileSMSInputSchema>;
|
|
|
|
export const syncMobileSMSSchema = v.object({
|
|
messages: v.array(mobileSMSInputSchema),
|
|
});
|
|
export type SyncMobileSMS = v.InferOutput<typeof syncMobileSMSSchema>;
|
|
|
|
export const mobileMediaAssetSchema = v.object({
|
|
id: v.pipe(v.number(), v.integer()),
|
|
deviceId: v.pipe(v.number(), v.integer()),
|
|
externalMediaId: v.optional(v.nullable(v.string())),
|
|
fileId: v.string(),
|
|
r2Url: v.optional(v.nullable(v.string())),
|
|
mimeType: v.string(),
|
|
filename: v.optional(v.nullable(v.string())),
|
|
capturedAt: v.optional(v.nullable(v.date())),
|
|
sizeBytes: v.optional(v.nullable(v.number())),
|
|
hash: v.optional(v.nullable(v.string())),
|
|
metadata: v.optional(v.nullable(v.record(v.string(), v.any()))),
|
|
createdAt: v.date(),
|
|
updatedAt: v.date(),
|
|
});
|
|
export type MobileMediaAsset = v.InferOutput<typeof mobileMediaAssetSchema>;
|
|
export type MobileMediaAssets = MobileMediaAsset[];
|
|
|
|
export const mobileMediaAssetInputSchema = v.object({
|
|
externalMediaId: v.optional(v.nullable(v.string())),
|
|
fileId: v.string(),
|
|
mimeType: v.string(),
|
|
filename: v.optional(v.nullable(v.string())),
|
|
capturedAt: v.optional(v.nullable(dateLikeSchema)),
|
|
sizeBytes: v.optional(v.nullable(v.number())),
|
|
hash: v.optional(v.nullable(v.string())),
|
|
metadata: v.optional(v.record(v.string(), v.any())),
|
|
});
|
|
export type MobileMediaAssetInput = v.InferOutput<typeof mobileMediaAssetInputSchema>;
|
|
|
|
export const syncMobileMediaSchema = v.object({
|
|
assets: v.array(mobileMediaAssetInputSchema),
|
|
});
|
|
export type SyncMobileMedia = v.InferOutput<typeof syncMobileMediaSchema>;
|
|
|
|
export const mobilePaginationSchema = v.object({
|
|
page: v.pipe(v.number(), v.integer()),
|
|
pageSize: v.pipe(v.number(), v.integer()),
|
|
sortBy: v.optional(v.string()),
|
|
sortOrder: v.optional(v.picklist(["asc", "desc"])),
|
|
});
|
|
export type MobilePagination = v.InferOutput<typeof mobilePaginationSchema>;
|
|
|
|
export const listMobileDevicesFiltersSchema = v.object({
|
|
ownerUserId: v.string(),
|
|
search: v.optional(v.string()),
|
|
});
|
|
export type ListMobileDevicesFilters = v.InferOutput<
|
|
typeof listMobileDevicesFiltersSchema
|
|
>;
|
|
|
|
export const listMobileDeviceSMSFiltersSchema = v.object({
|
|
deviceId: v.pipe(v.number(), v.integer()),
|
|
search: v.optional(v.string()),
|
|
});
|
|
export type ListMobileDeviceSMSFilters = v.InferOutput<
|
|
typeof listMobileDeviceSMSFiltersSchema
|
|
>;
|
|
|
|
export const listMobileDeviceMediaFiltersSchema = v.object({
|
|
deviceId: v.pipe(v.number(), v.integer()),
|
|
mimeType: v.optional(v.string()),
|
|
search: v.optional(v.string()),
|
|
});
|
|
export type ListMobileDeviceMediaFilters = v.InferOutput<
|
|
typeof listMobileDeviceMediaFiltersSchema
|
|
>;
|
|
|
|
export const paginatedMobileDevicesSchema = v.object({
|
|
data: v.array(mobileDeviceSchema),
|
|
total: v.pipe(v.number(), v.integer()),
|
|
page: v.pipe(v.number(), v.integer()),
|
|
pageSize: v.pipe(v.number(), v.integer()),
|
|
totalPages: v.pipe(v.number(), v.integer()),
|
|
});
|
|
export type PaginatedMobileDevices = v.InferOutput<
|
|
typeof paginatedMobileDevicesSchema
|
|
>;
|
|
|
|
export const paginatedMobileSMSSchema = v.object({
|
|
data: v.array(mobileSMSSchema),
|
|
total: v.pipe(v.number(), v.integer()),
|
|
page: v.pipe(v.number(), v.integer()),
|
|
pageSize: v.pipe(v.number(), v.integer()),
|
|
totalPages: v.pipe(v.number(), v.integer()),
|
|
});
|
|
export type PaginatedMobileSMS = v.InferOutput<typeof paginatedMobileSMSSchema>;
|
|
|
|
export const paginatedMobileMediaSchema = v.object({
|
|
data: v.array(mobileMediaAssetSchema),
|
|
total: v.pipe(v.number(), v.integer()),
|
|
page: v.pipe(v.number(), v.integer()),
|
|
pageSize: v.pipe(v.number(), v.integer()),
|
|
totalPages: v.pipe(v.number(), v.integer()),
|
|
});
|
|
export type PaginatedMobileMedia = v.InferOutput<typeof paginatedMobileMediaSchema>;
|
|
|
|
export const mobileDeviceDetailSchema = v.object({
|
|
device: mobileDeviceSchema,
|
|
smsCount: v.pipe(v.number(), v.integer()),
|
|
mediaCount: v.pipe(v.number(), v.integer()),
|
|
});
|
|
export type MobileDeviceDetail = v.InferOutput<typeof mobileDeviceDetailSchema>;
|
|
|
|
export const deleteDeviceSchema = v.object({
|
|
deviceId: v.pipe(v.number(), v.integer()),
|
|
ownerUserId: v.string(),
|
|
});
|
|
export type DeleteDevice = v.InferOutput<typeof deleteDeviceSchema>;
|
|
|
|
export const deleteMediaAssetSchema = v.object({
|
|
mediaAssetId: v.pipe(v.number(), v.integer()),
|
|
ownerUserId: v.string(),
|
|
});
|
|
export type DeleteMediaAsset = v.InferOutput<typeof deleteMediaAssetSchema>;
|