diff --git a/.gitignore b/.gitignore index d288d6b..f80e3c3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ macbuild.sh deploy.ps1 # Sentry Config File .env.sentry-build-plugin + +.serverless/ \ No newline at end of file diff --git a/dev-app-update.yml b/dev-app-update.yml index bd74279..b73be57 100644 --- a/dev-app-update.yml +++ b/dev-app-update.yml @@ -1,3 +1,3 @@ provider: s3 -bucket: esdp +bucket: esdatapump region: ca-central-1 diff --git a/electron-builder.yml b/electron-builder.yml index 4edf100..9144333 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -56,5 +56,5 @@ appImage: npmRebuild: false publish: provider: s3 - bucket: esdp + bucket: esdatapump region: ca-central-1 diff --git a/serverless/package.json b/serverless/package.json new file mode 100644 index 0000000..5c27e38 --- /dev/null +++ b/serverless/package.json @@ -0,0 +1,13 @@ +{ + "name": "serverless", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "commonjs" +} diff --git a/serverless/serverless.yml b/serverless/serverless.yml new file mode 100644 index 0000000..bdc5e30 --- /dev/null +++ b/serverless/serverless.yml @@ -0,0 +1,73 @@ +service: esdp-api +app: esdp-api-app +frameworkVersion: "4" + +stages: + prod: + # Enables observability in the prod stage + observability: true + + # Sepcify parameter values to be used in the prod stage + params: + es_endpoint: https://insurtechtoolkit.com + domain: es.imex.online + beta: + # Enables observability in the prod stage + observability: false + + # Sepcify parameter values to be used in the prod stage + params: + es_endpoint: https://4284-79073.el-alt.com + domain: beta.es.imex.online + alpha: + # Enables observability in the prod stage + observability: false + # Sepcify parameter values to be used in the prod stage + params: + es_endpoint: https://4284-79287.el-alt.com + domain: alpha.es.imex.online + dev: + # Enables observability in the prod stage + observability: false + # Sepcify parameter values to be used in the prod stage + params: + es_endpoint: https://4284-79287.el-alt.com + domain: alpha.es.imex.online + +# params: +# dev: +# domain: dev.es.imex.online +# alpha: +# domain: alpha.es.imex.online +# beta: +# domain: beta.es.imex.online +# prod: +# domain: es.imex.online + +provider: + name: aws + runtime: nodejs22.x + region: ca-central-1 + domain: ${param:domain} + httpApi: # This creates a cheaper, faster "HTTP API" Gateway + cors: true # Automatically configures CORS + +functions: + # Route 1: POST /scrub + scrub: + handler: src/handlers/scrub.handler + environment: + ES_ENDPOINT: ${param:es_endpoint} + events: + - httpApi: + path: /scrub + method: post + # Route 1: POST /scrub + emsupload: + handler: src/handlers/emsupload.handler + environment: + ES_ENDPOINT: ${param:es_endpoint} + events: + - httpApi: + path: /emsupload + method: post diff --git a/serverless/src/handlers/emsupload.js b/serverless/src/handlers/emsupload.js new file mode 100644 index 0000000..e5a7bcf --- /dev/null +++ b/serverless/src/handlers/emsupload.js @@ -0,0 +1,15 @@ +// You can require shared code from the lib folder +// const { dbConnect } = require('../lib/db'); + +exports.handler = async (event) => { + // Path parameters are automatically parsed for you + const userId = event.pathParameters.id; + + return { + statusCode: 200, + body: JSON.stringify({ + message: `EMS Upload Path`, + + }) + }; +}; \ No newline at end of file diff --git a/serverless/src/handlers/scrub.js b/serverless/src/handlers/scrub.js new file mode 100644 index 0000000..a577de4 --- /dev/null +++ b/serverless/src/handlers/scrub.js @@ -0,0 +1,15 @@ +// You can require shared code from the lib folder +// const { dbConnect } = require('../lib/db'); + +exports.handler = async (event) => { + // Path parameters are automatically parsed for you + + + return { + statusCode: 200, + body: JSON.stringify({ + message: `Scrub Path`, + data: { id: 1, name: "Alice" } + }) + }; +}; \ No newline at end of file diff --git a/serverless/src/lib/db.js b/serverless/src/lib/db.js new file mode 100644 index 0000000..e69de29 diff --git a/src/main/estimate-scrubber/es-job-object.interface.ts b/src/main/estimate-scrubber/es-job-object.interface.ts index 734f23d..8787a59 100644 --- a/src/main/estimate-scrubber/es-job-object.interface.ts +++ b/src/main/estimate-scrubber/es-job-object.interface.ts @@ -188,8 +188,8 @@ export interface ESJobObject extends Omit< close_date: string | null; created_at: string; id: string; - group: string; - group_verified: boolean; + group?: string; + group_verified?: boolean; updated_at: string; v_age: number; v_type: string; diff --git a/src/main/estimate-scrubber/es-transformer.ts b/src/main/estimate-scrubber/es-transformer.ts index 3048b76..0c1d493 100644 --- a/src/main/estimate-scrubber/es-transformer.ts +++ b/src/main/estimate-scrubber/es-transformer.ts @@ -1,10 +1,14 @@ import { RawJobDataObject } from "../decoder/decoder"; import { ESJobObject } from "./es-job-object.interface"; import _ from "lodash"; - +import dayjas from "dayjs"; +import dayjs from "dayjs"; +import axios from "axios"; const sendingEntityId = "87330f61-412b-4251-baaa-d026565b23c5"; -function TransformJobForEstimateScrubber(job: RawJobDataObject): ESJobObject { +async function TransformJobForEstimateScrubber( + job: RawJobDataObject, +): Promise { //Take the job object and strip off everything we don't need. const omittedJob = _.omit(job, [ "cat_no", @@ -190,17 +194,23 @@ function TransformJobForEstimateScrubber(job: RawJobDataObject): ESJobObject { //Add the ES Objects. + const vehType: string = ( + await axios.post(`https://api.test.imex.online/es/vehicletype`, { + model: job.v_model_desc, + }) + ).data?.type; + return { //TODO: Remove hard coded values ...omittedJob, impact_1: job.area_of_damage?.impact1, impact_2: job.area_of_damage?.impact2, close_date: null, - created_at: "2025-12-11T18:09:14.085604+00:00", + created_at: dayjs().toISOString(), id: "c478593b-58a2-4bab-b7c7-2df19a257b2b", - group: "Group 10", - group_verified: false, - updated_at: "2025-12-11T18:09:14.085604+00:00", + // group: "Group 10", + // group_verified: false, + updated_at: dayjs().toISOString(), v_age: 20, //Needed? RPS calc. v_type: "PC", // need to get from API. v_makedesc: job.v_make_desc, diff --git a/src/main/estimate-scrubber/estimate-scrubber.ts b/src/main/estimate-scrubber/estimate-scrubber.ts index fbf586d..28ac2d3 100644 --- a/src/main/estimate-scrubber/estimate-scrubber.ts +++ b/src/main/estimate-scrubber/estimate-scrubber.ts @@ -47,7 +47,7 @@ async function ScrubEstimate({ //Scrub Estimate Transformer. Original schema kept to keep data in line with ImEX standards. - const transformedJob = TransformJobForEstimateScrubber(job); + const transformedJob = await TransformJobForEstimateScrubber(job); const basicAuthUser = "Imex2"; const basicAuthpassword = "Patrick"; const currentChannel = autoUpdater.channel;