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 | 8x 8x 8x 6x 2x 8x 2x 2x 2x 2x 2x 2x 1x 2x 2x 1x 1x 1x 1x 1x 8x 54x | import { errors as OpensearchErrors } from "@opensearch-project/opensearch"; import * as os from "libs/opensearch-lib"; import { getOsNamespace } from "libs/utils"; export type ErrorResponse = { statusCode: number; body: { message?: string; }; }; interface ParseKafkaEvent { id: string; event?: string; authority?: string; } export interface ProcessEmailConfig { emailAddressLookupSecretName: string; applicationEndpointUrl: string; osDomain: string; indexNamespace?: string; region: string; DLQ_URL: string; userPoolId: string; configurationSetName: string; isDev: boolean; } export const handleOpensearchError = (error: unknown): ErrorResponse => { console.error({ error }); if (error instanceof OpensearchErrors.ResponseError) { return { statusCode: error.statusCode || error.meta?.statusCode || 500, body: { message: error.body || error.meta?.body, }, }; } return { statusCode: 500, body: { message: "Internal server error" }, }; }; export const calculate90dayExpiration = async ( parsedRecord: ParseKafkaEvent, config: ProcessEmailConfig, ) => { const item = await os.getItem(config.osDomain, getOsNamespace("main"), parsedRecord.id); const submissionDate = item?._source.submissionDate || ""; const raiRequestedDate = item?._source.raiRequestedDate || ""; const submissionMS = new Date(submissionDate).getTime(); const raiMS = new Date(raiRequestedDate).getTime(); if (!submissionDate || !raiRequestedDate) { console.error("error parsing os record"); } const now = Date.now(); if (raiRequestedDate && submissionDate) { // length of time from when the RAI was requested until now const pausedDuration = now - raiMS; // 90 days in milliseconds const ninetyDays = 90 * 24 * 60 * 60 * 1000; const ninetyDayExpirationClock = submissionMS + ninetyDays + pausedDuration; return ninetyDayExpirationClock; } return undefined; }; export const isChipSpaRespondRAIEvent = (parsedRecord: ParseKafkaEvent) => { return parsedRecord?.event == "respond-to-rai" && parsedRecord?.authority == "CHIP SPA"; }; |