Refactor serverless and initial hasura migrations.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
@@ -0,0 +1,3 @@
|
||||
table:
|
||||
name: jobs
|
||||
schema: public
|
||||
@@ -1 +1,3 @@
|
||||
- "!include public_joblines.yaml"
|
||||
- "!include public_jobs.yaml"
|
||||
- "!include public_shops.yaml"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE "public"."jobs";
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE "public"."jobs" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "shopid" uuid NOT NULL, "clm_no" text, "version" integer NOT NULL DEFAULT 1, "ciecaid" text, "ins_co_nm" text, "ded_amt" numeric, "loss_date" date NOT NULL, "loss_desc" text, "ownr_ln" text, "ownr_fn" text, "ownr_addr1" text, "ownr_addr2" text, "ownr_co_nm" text, "ownr_ea" text, "ownr_ph1" text, "ownr_ph2" text, "ownr_st" text, "ownr_zip" text, "ownr_city" text, "v_vin" text, "v_model_yr" text NOT NULL, "v_make_desc" text NOT NULL, "v_model_desc" text NOT NULL, "id_pro_nam" text, "impact_1" text NOT NULL, "impact_2" text NOT NULL, "close_date" timestamptz, "v_age" integer NOT NULL, "v_type" text NOT NULL, "supp_amt" numeric NOT NULL, "rates" jsonb[] NOT NULL, "totals" jsonb[] NOT NULL, "ro_number" text, "v_mileage" numeric, "association_switch" text, "g_ttl_amt" numeric NOT NULL, "source_system" text, "date_estimated" date, "ded_status" text, "depreciation_taxes" numeric NOT NULL, "loss_cat" text, "loss_type" text, "plate_st" text, "plate_no" text, "v_color" text, PRIMARY KEY ("id") , FOREIGN KEY ("shopid") REFERENCES "public"."shops"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("shopid", "clm_no", "version"));
|
||||
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
|
||||
RETURNS TRIGGER AS $$
|
||||
DECLARE
|
||||
_new record;
|
||||
BEGIN
|
||||
_new := NEW;
|
||||
_new."updated_at" = NOW();
|
||||
RETURN _new;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE TRIGGER "set_public_jobs_updated_at"
|
||||
BEFORE UPDATE ON "public"."jobs"
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
|
||||
COMMENT ON TRIGGER "set_public_jobs_updated_at" ON "public"."jobs"
|
||||
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."jobs" drop constraint "jobs_id_version_key";
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."jobs" add constraint "jobs_id_version_key" unique ("id", "version");
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE "public"."joblines";
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE "public"."joblines" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "jobid" uuid NOT NULL, "version" integer NOT NULL, "line_no" integer NOT NULL, "line_ind" text NOT NULL, "db_ref" text NOT NULL, "line_desc" text NOT NULL, "part_type" text NOT NULL, "glass_flag" boolean NOT NULL DEFAULT false, "oem_partno" text NOT NULL, "price_inc" boolean NOT NULL, "tax_part" boolean NOT NULL, "db_price" numeric NOT NULL, "act_price" numeric NOT NULL, "price_j" boolean NOT NULL, "cert_part" boolean NOT NULL, "part_qty" integer NOT NULL, "alt_partno" text NOT NULL, "mod_lbr_ty" text NOT NULL, "db_hrs" numeric NOT NULL, "mod_lb_hrs" numeric NOT NULL, "lbr_inc" boolean, "lbr_op" text, "lbr_hrs_j" boolean, "lbr_op_j" boolean, "lbr_amt" numeric, "misc_amt" numeric, "tran_code" text, "unq_seq" integer, "alt_part_i" boolean, "alt_co_id" text, "prt_dsmk_p" text, "prt_dsmk_m" text, "alt_partm" text, "paint_stg" text, "paint_tone" text, "lbr_tax" boolean, "misc_tax" boolean, "bett_type" text, "bett_pctg" text, "bett_amt" numeric, "bett_tax" boolean, PRIMARY KEY ("id") , FOREIGN KEY ("jobid", "version") REFERENCES "public"."jobs"("id", "version") ON UPDATE restrict ON DELETE restrict);
|
||||
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
|
||||
RETURNS TRIGGER AS $$
|
||||
DECLARE
|
||||
_new record;
|
||||
BEGIN
|
||||
_new := NEW;
|
||||
_new."updated_at" = NOW();
|
||||
RETURN _new;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE TRIGGER "set_public_joblines_updated_at"
|
||||
BEFORE UPDATE ON "public"."joblines"
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
|
||||
COMMENT ON TRIGGER "set_public_joblines_updated_at" ON "public"."joblines"
|
||||
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
1056
serverless/package-lock.json
generated
1056
serverless/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.965.0",
|
||||
"@aws-sdk/client-s3": "^3.965.0",
|
||||
"@aws-sdk/client-secrets-manager": "^3.965.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.965.0",
|
||||
"axios": "^1.13.2",
|
||||
"drizzle-orm": "^0.44.5",
|
||||
@@ -32,7 +32,6 @@
|
||||
"@types/node": "^25.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
||||
"@typescript-eslint/parser": "^8.53.0",
|
||||
"drizzle-kit": "^0.31.5",
|
||||
"esbuild": "^0.27.2",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
@@ -40,7 +39,6 @@
|
||||
"prettier": "^3.7.4",
|
||||
"serverless-esbuild": "^1.57.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"pg": "^8.16.3",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,55 +2,43 @@ service: esdp-api
|
||||
app: esdp-api-app
|
||||
frameworkVersion: '4'
|
||||
|
||||
# Common parameters shared across all stages
|
||||
custom:
|
||||
commonParams:
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
hasura_secret_arn: arn:aws:secretsmanager:ca-central-1:714144183158:secret:esdp-hasura-credentials-s81i1u-BDFgPi
|
||||
|
||||
stages:
|
||||
prod:
|
||||
# Enables observability in the prod stage
|
||||
observability: true
|
||||
|
||||
# Sepcify parameter values to be used in the prod stage
|
||||
# Stage-specific parameter values for prod
|
||||
params:
|
||||
es_endpoint: https://insurtechtoolkit.com
|
||||
domain: es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
beta:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
|
||||
# Sepcify parameter values to be used in the prod stage
|
||||
# Stage-specific parameter values for beta
|
||||
params:
|
||||
es_endpoint: https://4284-79073.el-alt.com
|
||||
domain: beta.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
alpha:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
# Sepcify parameter values to be used in the prod stage
|
||||
|
||||
# Stage-specific parameter values for alpha
|
||||
params:
|
||||
es_endpoint: https://4284-79287.el-alt.com
|
||||
domain: alpha.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
dev:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
# Sepcify parameter values to be used in the prod stage
|
||||
|
||||
# Stage-specific parameter values for dev
|
||||
params:
|
||||
es_endpoint: https://4284-79287.el-alt.com
|
||||
domain: dev.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
|
||||
# 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
|
||||
@@ -81,8 +69,8 @@ functions:
|
||||
handler: src/handlers/scrub.handler
|
||||
environment:
|
||||
ES_ENDPOINT: ${param:es_endpoint}
|
||||
ES_USER: ${param:es_user}
|
||||
ES_PASSWORD: ${param:es_password}
|
||||
ES_USER: ${self:custom.commonParams.es_user}
|
||||
ES_PASSWORD: ${self:custom.commonParams.es_password}
|
||||
events:
|
||||
- httpApi:
|
||||
path: /scrub
|
||||
|
||||
@@ -42,12 +42,7 @@ async function ScrubEstimate({
|
||||
}: {
|
||||
job: RawJobDataObject;
|
||||
}): Promise<string | undefined> {
|
||||
//These are hard coded as they are not secure values and checking happens based on other values.
|
||||
//No secret or private information is exposed.
|
||||
|
||||
//Scrub Estimate Transformer. Original schema kept to keep data in line with ImEX standards.
|
||||
|
||||
const transformedJob = await TransformJobForEstimateScrubber(job);
|
||||
const transformedJob = await TransformJobForEstimateScrubber(job); //Job should be transformed server side.
|
||||
|
||||
const currentChannel = autoUpdater.channel;
|
||||
let estimateScrubberUrl: string;
|
||||
|
||||
Reference in New Issue
Block a user