47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
|
|
import { z } from "zod/v4";
|
||
|
|
|
||
|
|
const id = z.uuid().transform((value) => value.toLowerCase());
|
||
|
|
|
||
|
|
export const LocalIdentityCommandSchema = z.discriminatedUnion("action", [
|
||
|
|
z.strictObject({
|
||
|
|
action: z.literal("create"),
|
||
|
|
assetId: id,
|
||
|
|
systemId: id,
|
||
|
|
name: z.string().trim().min(1).max(100),
|
||
|
|
}),
|
||
|
|
z.strictObject({ action: z.literal("associate"), environmentId: id, assetId: id }),
|
||
|
|
z.strictObject({ action: z.literal("retire"), environmentId: id }),
|
||
|
|
]);
|
||
|
|
|
||
|
|
export type LocalIdentityCommand = z.infer<typeof LocalIdentityCommandSchema>;
|
||
|
|
|
||
|
|
export const LocalIdentityEnvironmentSchema = z.strictObject({
|
||
|
|
id,
|
||
|
|
companyId: id,
|
||
|
|
environmentId: id,
|
||
|
|
assetId: id,
|
||
|
|
systemId: id,
|
||
|
|
identityScope: z.literal("local-device"),
|
||
|
|
startedAt: z.iso.datetime(),
|
||
|
|
startedBy: id,
|
||
|
|
endedAt: z.iso.datetime().nullable(),
|
||
|
|
endedBy: id.nullable(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type LocalIdentityEnvironmentDTO = z.infer<typeof LocalIdentityEnvironmentSchema>;
|
||
|
|
|
||
|
|
export const LocalIdentityQuerySchema = z.strictObject({
|
||
|
|
assetId: id.optional(),
|
||
|
|
environmentId: id.optional(),
|
||
|
|
includeEnded: z.enum(["true", "false"]).default("false"),
|
||
|
|
pageSize: z.coerce.number().int().min(1).max(100).default(50),
|
||
|
|
afterId: id.optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type LocalIdentityQuery = z.infer<typeof LocalIdentityQuerySchema>;
|
||
|
|
|
||
|
|
export const LocalIdentityPageSchema = z.strictObject({
|
||
|
|
environments: z.array(LocalIdentityEnvironmentSchema).max(100),
|
||
|
|
nextAfterId: id.nullable(),
|
||
|
|
});
|