Conversation
96bc0e0 to
eee8b50
Compare
ac3d1dc to
f8e7b01
Compare
93384f1 to
e778ec8
Compare
apps/backend/src/lambdas/parseTDI.ts
Outdated
| import { TDI17Record } from '../tdi-parser/tdi17/TDI17Record'; | ||
| import { TDI17Header } from '../tdi-parser/tdi17/TDI17Header'; | ||
| import { TDI17Details } from '../tdi-parser/tdi17/TDI17Details'; | ||
| import { TDI17Trailer } from '../tdi-parser/tdi17/TDI17Trailer'; | ||
| import { TDI34Record } from '../tdi-parser/tdi34/TDI34Record'; | ||
| import { TDI34Header } from '../tdi-parser/tdi34/TDI34Header'; | ||
| import { TDI34Details } from '../tdi-parser/tdi34/TDI34Details'; | ||
| import { TDI34Trailer } from '../tdi-parser/tdi34/TDI34Trailer'; | ||
| import { TDI34Enum } from './const/tdi34.const'; | ||
| import { TDI17Enum } from './const/tdi17.const'; |
There was a problem hiding this comment.
could be imported as a single module for 17 and 34 each.
apps/backend/src/lambdas/parseTDI.ts
Outdated
| appLogger.log({ event }); | ||
| appLogger.log({ context }); | ||
|
|
||
| const filetype = event?.type ?? process.env.TDI_TYPE; |
There was a problem hiding this comment.
Suggestion - This line should throw an error if the event type does not exist. Defaulting should not be an option
apps/backend/src/lambdas/parseTDI.ts
Outdated
| const outputFile = Buffer.from(JSON.stringify(output)); | ||
|
|
||
| appLogger.log(outputFile); | ||
| await s3manager.putObject( |
There was a problem hiding this comment.
I would prefer this to have it's own try catch.
apps/backend/src/lambdas/parseTDI.ts
Outdated
| const header = TDI_17 ? new TDI17Header({}) : new TDI34Header({}); | ||
| const trailer = TDI_17 ? new TDI17Trailer({}) : new TDI34Trailer({}); |
There was a problem hiding this comment.
I don't think we want to store the header and trailer for TDI files.
The transactions line items is all we want.
apps/backend/src/lambdas/parseTDI.ts
Outdated
| const record = TDI_17 ? new TDI17Record({}) : new TDI34Record({}); | ||
|
|
||
| record.details = TDI_17 ? tdi17RecordDetails : tdi34RecordDetails; | ||
| record.trailer = trailer; | ||
| record.header = header; | ||
|
|
||
| return { | ||
| header: record.header.resource, | ||
| details: record.details.map((itm: { resource: unknown }) => itm.resource), | ||
| trailer: record.trailer.resource, | ||
| }; |
There was a problem hiding this comment.
we need only the array of details.
| @@ -0,0 +1,200 @@ | |||
| import { | |||
There was a problem hiding this comment.
create folder level index files and export from them.
| @@ -0,0 +1,121 @@ | |||
| import { | |||
There was a problem hiding this comment.
We could skip the header and trailer as we don't have any use for it YET. So we can leave it here and use if we need it later.
There was a problem hiding this comment.
Okay sounds good. I thought we might want the file header as there is the file creation date. So for now I will add an index, and export only the details for 17/34?
There was a problem hiding this comment.
Yes.
The date seems to also be in each of the transaction items, so it might just be redundant.
Is the header date different or providing us any additional context? 🤔
4b06182 to
1d9b778
Compare
| # Add Local Tdi Files | ||
| # =================================== | ||
|
|
||
| put-local-tdi17: |
There was a problem hiding this comment.
the make command can also accept paths
There was a problem hiding this comment.
There was a problem hiding this comment.
|
|
||
| await uploadParsedTDI(TDI_FILE, s3manager, output, appLogger); | ||
| } catch (e) { | ||
| appLogger.error(e); |
There was a problem hiding this comment.
we should exit the handler here gracefully.
There was a problem hiding this comment.
or pass the error back to the root fn and exit there
There was a problem hiding this comment.
It is also okay to not handle it because we will see the error in the console, but more logs and structure will help debugging in the future
apps/backend/src/tdi-files/const.ts
Outdated
| return { | ||
| TYPE: fileType, | ||
| BUCKET: 'bc-pcc-data-files-local', | ||
| LOCALSTACK_PATH: `${fileType.toLowerCase()}/${fileType.toUpperCase()}.TXT`, |
There was a problem hiding this comment.
to be removed all together for providing flexible testing
apps/backend/src/tdi-files/const.ts
Outdated
| export const generateEnum =(fileType: string)=> { | ||
| return { | ||
| TYPE: fileType, | ||
| BUCKET: 'bc-pcc-data-files-local', |
There was a problem hiding this comment.
Bucket name needs to change by ENV
apps/backend/package.json
Outdated
| "parseTDI17": "NODE_ENV=local RUNTIME_ENV=local LAMBDA_ARG=TDI17 ts-node ./scripts/handler.ts", | ||
| "parseTDI34": "NODE_ENV=local RUNTIME_ENV=local LAMBDA_ARG=TDI34 ts-node ./scripts/handler.ts" |
There was a problem hiding this comment.
ts-node ./scripts/handler.ts console.log(handler.({type: "TDI34", path: "pcc-bc-xxxx-local"}))
something like this
apps/backend/scripts/handler.ts
Outdated
| @@ -0,0 +1,7 @@ | |||
| import {handler} from '../src/lambdas/parseTDI' | |||
There was a problem hiding this comment.
Proabbaly dont need this file
Makefile
Outdated
| # =================================== | ||
|
|
||
| parse-local-tdi17: | ||
| cd './apps/backend' && yarn run parseTDI17 |
There was a problem hiding this comment.
node -e 'require("./lambdas/parseTDI").handler({type: "TDI17", path: "/xasxasx/xasxas/xasxas"})'"
ea473ce to
975c833
Compare
What has changed:
Added class definitions for TDI17/TDI34 files.
Added sample files to a root directory (could not access sharepoint files from the terminal)
Added Makefile commands to parse local. Parsing requires a file path and file type, either passed in the event, or, set as env vars. Env vars are set for local dev in makefile cmd.