supported apps domain + some refactor of data types redundancy
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as v from "valibot";
|
||||
import { deviceSchema } from "@domains/device/data";
|
||||
import { supportedAppSchema } from "@domains/supported-app/data";
|
||||
|
||||
export enum LinkStatus {
|
||||
ACTIVE = "active",
|
||||
@@ -15,9 +16,8 @@ export const linkSchema = v.object({
|
||||
id: v.number(),
|
||||
token: v.string(),
|
||||
status: linkStatusSchema,
|
||||
appName: v.string(),
|
||||
appPackage: v.string(),
|
||||
linkedDeviceId: v.nullable(v.number()),
|
||||
supportedAppId: v.number(),
|
||||
expiresAt: v.nullable(v.date()),
|
||||
lastAccessedAt: v.nullable(v.date()),
|
||||
createdAt: v.date(),
|
||||
@@ -28,14 +28,14 @@ export type Link = v.InferOutput<typeof linkSchema>;
|
||||
export const linkWithDeviceSchema = v.object({
|
||||
...linkSchema.entries,
|
||||
device: v.nullable(deviceSchema),
|
||||
supportedApp: v.nullable(supportedAppSchema),
|
||||
});
|
||||
export type LinkWithDevice = v.InferOutput<typeof linkWithDeviceSchema>;
|
||||
|
||||
export const createLinkSchema = v.object({
|
||||
token: v.pipe(v.string(), v.minLength(1)),
|
||||
appName: v.pipe(v.string(), v.minLength(1)),
|
||||
appPackage: v.pipe(v.string(), v.minLength(1)),
|
||||
linkedDeviceId: v.number(),
|
||||
supportedAppId: v.number(),
|
||||
expiresAt: v.optional(v.nullable(v.date())),
|
||||
});
|
||||
export type CreateLink = v.InferOutput<typeof createLinkSchema>;
|
||||
@@ -43,9 +43,8 @@ export type CreateLink = v.InferOutput<typeof createLinkSchema>;
|
||||
export const updateLinkSchema = v.partial(
|
||||
v.object({
|
||||
status: linkStatusSchema,
|
||||
appName: v.string(),
|
||||
appPackage: v.string(),
|
||||
linkedDeviceId: v.nullable(v.number()),
|
||||
supportedAppId: v.number(),
|
||||
expiresAt: v.nullable(v.date()),
|
||||
lastAccessedAt: v.nullable(v.date()),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user