Skip to content

Commit

Permalink
Merge pull request #28 from first-quality-books/fix/arbitrary-tags
Browse files Browse the repository at this point in the history
fix: support arbitrary keys in all objects
  • Loading branch information
Fabiopf02 authored Jan 24, 2025
2 parents e8782f9 + 1f52d1a commit eea1872
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/@types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type MetaData = {
COMPRESSION: string
OLDFILEUID: string
NEWFILEUID: string
[key: string]: any
}

export type DateResponse = {
Expand Down
5 changes: 5 additions & 0 deletions src/@types/ofx/banking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { AccountType, Balance, StatementTransaction, Status } from './common'

export interface BankResponse {
STMTTRNRS: StatementTransactionResponse
[key: string]: any
}

export interface StatementTransactionResponse {
TRNUID: string
STATUS: Status
STMTRS: StatementResponse
[key: string]: any
}

export interface StatementResponse {
Expand All @@ -16,17 +18,20 @@ export interface StatementResponse {
BANKTRANLIST: BankTransactionList
LEDGERBAL: Balance
AVAILBAL?: Balance
[key: string]: any
}

export type BankAccount = {
BANKID: string
ACCTID: string
ACCTTYPE: AccountType
[key: string]: any
}

export type BankTransactionList = {
DTSTART: string
DTEND: string
STMTTRN: StatementTransaction[]
STRTTRN: StatementTransaction[]
[key: string]: any
}
4 changes: 4 additions & 0 deletions src/@types/ofx/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface Status {
CODE: number | string
SEVERITY: 'INFO' | 'WARN' | 'ERROR'
MESSAGE?: string
[key: string]: any
}

export type AccountType = 'CHECKING' | 'SAVINGS' | 'CREDITLINE' | 'MONEYMRKT'
Expand All @@ -10,6 +11,7 @@ export type BankAccount = {
BANKID: string
ACCTID: string
ACCTTYPE: AccountType
[key: string]: any
}

export type TransactionType =
Expand All @@ -34,6 +36,7 @@ export type TransactionType =
export interface Balance {
BALAMT: number
DTASOF: string
[key: string]: any
}

export type StatementTransaction = {
Expand All @@ -44,4 +47,5 @@ export type StatementTransaction = {
FITID: string
CHECKNUM?: string
MEMO?: string
[key: string]: any
}
4 changes: 4 additions & 0 deletions src/@types/ofx/credit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type CreditCardTransactionResponse = {
TRNUID: string
STATUS: Status
CCSTMTRS: CreditCardStatementResponse
[key: string]: any
}

export type CreditCardStatementResponse = {
Expand All @@ -13,12 +14,15 @@ export type CreditCardStatementResponse = {
BANKTRANLIST: BankTransactionList
LEDGERBAL: Balance
AVAILBAL?: Balance
[key: string]: any
}

export type CreditCardAccount = {
ACCTID: string
[key: string]: any
}

export type CreditCardResponse = {
CCSTMTTRNRS: CreditCardTransactionResponse
[key: string]: any
}
2 changes: 2 additions & 0 deletions src/@types/ofx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ export type OFX = {
SIGNONMSGSRSV1: SignOnResponse
BANKMSGSRSV1: BankResponse
CREDITCARDMSGSRSV1: CreditCardResponse
[key: string]: any
}

export type OfxStructure = {
OFX: OFX
[key: string]: any
}

export type OfxResponse = MetaData & OfxStructure
4 changes: 4 additions & 0 deletions src/@types/ofx/signon.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
export type SignOnResponse = {
SONRS: SignOnStatus
[key: string]: any
}

export type SignOnStatus = {
STATUS: Status
DTSERVER: string
LANGUAGE: string
FI?: FinancialInstitution
[key: string]: any
}

export type Status = {
CODE: number | string
SEVERITY: 'INFO' | 'WARN' | 'ERROR'
MESSAGE?: string
[key: string]: any
}

export type FinancialInstitution = {
ORG: string
FID: string
[key: string]: any
}
4 changes: 2 additions & 2 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const ELEMENT_CLOSURE_REGEX = /<\/\w+>/g
export const ELEMENT_OPENING_REGEX = /<\w+>/g
export const ELEMENT_CLOSURE_REGEX = /<\/[\w.]+>/g
export const ELEMENT_OPENING_REGEX = /<[\w.]+>/g
export const BANK_SERVICE_START = '<BANKMSGSRSV1>'
export const BANK_SERVICE_END = '</BANKMSGSRSV1>'
export const CREDIT_CARD_SERVICE_START = '<CREDITCARDMSGSRSV1>'
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/ofx.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ exports[` 1`] = `
"SIGNONMSGSRSV1": {
"SONRS": {
"DTSERVER": "2005-08-31",
"INTU.BID": "1810",
"LANGUAGE": "ENG",
"STATUS": {
"CODE": "0",
Expand Down Expand Up @@ -470,6 +471,7 @@ exports[` 2`] = `
"SIGNONMSGSRSV1": {
"SONRS": {
"DTSERVER": "2005-08-31",
"INTU.BID": "1810",
"LANGUAGE": "ENG",
"STATUS": {
"CODE": "0",
Expand Down
1 change: 1 addition & 0 deletions tests/example.ofx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NEWFILEUID:NONE
</STATUS>
<DTSERVER>20050831165153.000[-3:BRT]</DTSERVER>
<LANGUAGE>ENG</LANGUAGE>
<INTU.BID>1810
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
Expand Down
1 change: 1 addition & 0 deletions tests/example2.ofx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</STATUS>
<DTSERVER>20050831165153.000[-3:BRT]</DTSERVER>
<LANGUAGE>ENG</LANGUAGE>
<INTU.BID>1810</INTU.BID>
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
Expand Down

0 comments on commit eea1872

Please sign in to comment.