All files / lib/packages/shared-types/opensearch/main index.ts

100% Statements 11/11
100% Branches 0/0
66.66% Functions 2/3
100% Lines 7/7

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164                                                                                                                                                                                                                                              284x                                     284x                             2x   2x 2x       284x 2x    
import { z } from "zod";
 
import { SeaTool } from "../../events";
import { ItemResult as Changelog } from "../changelog";
import { AggQuery, Filterable as FIL, Hit, QueryState, Response as Res } from "./../_";
import {
  appK,
  capitatedAmendment,
  capitatedInitial,
  capitatedRenewal,
  changedDate,
  contractingAmendment,
  contractingInitial,
  contractingRenewal,
  legacyPackageView,
  newChipDetailsSubmission,
  newChipSubmission,
  newMedicaidSubmission,
  respondToRai,
  seatool,
  temporaryExtension,
  toggleWithdrawRai,
  uploadSubsequentDocuments,
  withdrawPackage,
  withdrawRai,
} from "./transforms";
import {
  legacyAmendmentWaiver,
  legacyAppk,
  legacyChipSpa,
  legacyIniitalWaiver,
  legacyMedicaidSpa,
  legacyRenewalWaiver,
  legacyTemporaryExtension,
} from "./transforms/legacy-transforms";
 
export type AppkDocument = z.infer<appK.Schema>;
export type CapitatedAmendmentDocument = z.infer<capitatedAmendment.Schema>;
export type CapitatedInitialDocument = z.infer<capitatedInitial.Schema>;
export type CapitatedRenewalDocument = z.infer<capitatedRenewal.Schema>;
export type ChangedDateDocument = z.infer<changedDate.Schema>;
export type ContractingAmendmentDocument = z.infer<contractingAmendment.Schema>;
export type ContractingInitialDocument = z.infer<contractingInitial.Schema>;
export type ContractingRenewalDocument = z.infer<contractingAmendment.Schema>;
export type LegacyPackageViewDocument = z.infer<legacyPackageView.Schema>;
export type NewChipSubmissionDocument = z.infer<newChipSubmission.Schema>;
export type newChipDetailsSubmissionDocument = z.infer<newChipDetailsSubmission.Schema>;
export type NewMedicaidSubmissionDocument = z.infer<newMedicaidSubmission.Schema>;
export type RespondToRaiDocument = z.infer<respondToRai.Schema>;
export type SeatoolDocument = z.infer<seatool.Schema>;
export type TemporaryExtensionDocument = z.infer<temporaryExtension.Schema>;
export type ToggleWithdrawRaiDocument = z.infer<toggleWithdrawRai.Schema>;
export type UploadSubsequentDocuments = z.infer<uploadSubsequentDocuments.Schema>;
export type WithdrawPackageDocument = z.infer<withdrawPackage.Schema>;
export type WithdrawRaiDocument = z.infer<withdrawRai.Schema>;
 
export type LegacyMedicaidSpaDocument = z.infer<legacyMedicaidSpa.Schema>;
export type LegacyChipSpaDocument = z.infer<legacyChipSpa.Schema>;
export type LegacyInitialWaiverDocument = z.infer<legacyIniitalWaiver.Schema>;
export type LegacyRenewalWaiverDocument = z.infer<legacyRenewalWaiver.Schema>;
export type LegacyAmendmentWaiverDocument = z.infer<legacyAmendmentWaiver.Schema>;
export type LegacyAppkDocument = z.infer<legacyAppk.Schema>;
export type LegacyTemporaryExtensionDocument = z.infer<legacyTemporaryExtension.Schema>;
 
export type Document = AppkDocument &
  CapitatedAmendmentDocument &
  CapitatedInitialDocument &
  CapitatedRenewalDocument &
  ChangedDateDocument &
  ContractingAmendmentDocument &
  ContractingInitialDocument &
  ContractingRenewalDocument &
  NewChipSubmissionDocument &
  newChipDetailsSubmissionDocument &
  NewMedicaidSubmissionDocument &
  RespondToRaiDocument &
  SeatoolDocument &
  SeaTool &
  TemporaryExtensionDocument &
  ToggleWithdrawRaiDocument &
  UploadSubsequentDocuments &
  WithdrawPackageDocument &
  WithdrawRaiDocument & {
    makoChangedDate: string;
    changelog?: Changelog[];
    appkChildren?: Omit<ItemResult, "found">[];
    deleted?: boolean;
    adminChangeType?: string;
    changeMade?: string;
    idToBeUpdated?: string;
    mockEvent?: string;
    withdrawEmailSent?: boolean;
    fullName?: string;
    attachments?: {
      [key: string]: {
        label: string;
        files: {
          filename: string;
          key: string;
          title?: string;
          uploadDate: number;
          bucket?: string;
        }[];
      };
    };
  };
 
export type Response = Res<Document>;
export type ItemResult = Hit<Document> & {
  found: boolean;
};
 
export type Field = keyof Document | `${keyof Document}.keyword`;
export type Filterable = FIL<Field>;
export type State = QueryState<Field>;
export type Aggs = AggQuery<Field>;
 
export * from "./transforms";
 
export const transforms = {
  "app-k": appK,
  "capitated-amendment": capitatedAmendment,
  "capitated-initial": capitatedInitial,
  "capitated-renewal": capitatedRenewal,
  "contracting-amendment": contractingAmendment,
  "contracting-initial": contractingInitial,
  "contracting-renewal": contractingRenewal,
  "new-chip-submission": newChipSubmission,
  "new-chip-details-submission": newChipDetailsSubmission,
  "new-medicaid-submission": newMedicaidSubmission,
  "respond-to-rai": respondToRai,
  "temporary-extension": temporaryExtension,
  "toggle-withdraw-rai": toggleWithdrawRai,
  "upload-subsequent-documents": uploadSubsequentDocuments,
  "withdraw-package": withdrawPackage,
  "withdraw-rai": withdrawRai,
};
 
export const legacyTransforms = {
  medicaidspa: legacyMedicaidSpa,
  chipspa: legacyChipSpa,
  waivernew: legacyIniitalWaiver,
  waiverrenewal: legacyRenewalWaiver,
  waiveramendment: legacyAmendmentWaiver,
  waiverappk: legacyAppk,
  waiverextensionb: legacyTemporaryExtension,
  waiverextensionc: legacyTemporaryExtension,
  waiverextension: legacyTemporaryExtension,
};
 
export class SkippableValidationError<TMetadata = unknown> extends Error {
  constructor(
    message: string,
    public metadata?: TMetadata,
  ) {
    super(message);
    this.name = "SkippableValidationError";
  }
}
 
export const isSkippableError = (error: unknown): error is SkippableValidationError => {
  return error instanceof SkippableValidationError;
};