All files / lib/packages/shared-types/events temporary-extension.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43      186x         69x             171x                                       186x              
import { z } from "zod";
import { attachmentArraySchema, attachmentArraySchemaOptional } from "../attachments";
 
export const baseSchema = z.object({
  event: z.literal("temporary-extension").default("temporary-extension"),
  id: z
    .string()
    .min(1, { message: "Required" })
    .refine((id) => /^[A-Z]{2}-\d{4,5}\.R\d{2}\.TE\d{2}$/.test(id), {
      message:
        "The Temporary Extension Request Number must be in the format of SS-####.R##.TE## or SS-#####.R##.TE##",
    }),
  waiverNumber: z
    .string()
    .min(1, { message: "Required" })
    .refine((id) => /^[A-Z]{2}-\d{4,5}\.R\d{2}\.00$/.test(id), {
      message:
        "The Approved Initial or Renewal Waiver Number must be in the format of SS-####.R##.00 or SS-#####.R##.00.",
    }),
  authority: z.string(), // z.enum?
  additionalInformation: z.string().max(4000).nullable().default(null).optional(),
  attachments: z.object({
    waiverExtensionRequest: z.object({
      label: z.string().default("Waiver Extension Request"),
      files: attachmentArraySchema(),
    }),
    other: z.object({
      label: z.string().default("Other"),
      files: attachmentArraySchemaOptional(),
    }),
  }),
});
 
export type TemporaryExtensionSchema = z.infer<typeof baseSchema>;
 
export const schema = baseSchema.extend({
  actionType: z.string().default("Extend"),
  origin: z.literal("mako").default("mako"),
  submitterName: z.string(),
  submitterEmail: z.string().email(),
  timestamp: z.number(),
});