ofx-data-extractor 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/common.d.ts +1 -0
- package/dist/@types/ofx/banking.d.ts +5 -0
- package/dist/@types/ofx/common.d.ts +4 -0
- package/dist/@types/ofx/credit-card.d.ts +4 -0
- package/dist/@types/ofx/index.d.ts +2 -0
- package/dist/@types/ofx/signon.d.ts +4 -0
- package/dist/esm/index.min.js +2 -2
- package/dist/umd/bundle.min.js +2 -2
- package/package.json +1 -1
package/dist/@types/common.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AccountType, Balance, StatementTransaction, Status } from './common';
|
|
2
2
|
export interface BankResponse {
|
|
3
3
|
STMTTRNRS: StatementTransactionResponse;
|
|
4
|
+
[key: string]: any;
|
|
4
5
|
}
|
|
5
6
|
export interface StatementTransactionResponse {
|
|
6
7
|
TRNUID: string;
|
|
7
8
|
STATUS: Status;
|
|
8
9
|
STMTRS: StatementResponse;
|
|
10
|
+
[key: string]: any;
|
|
9
11
|
}
|
|
10
12
|
export interface StatementResponse {
|
|
11
13
|
CURDEF: string;
|
|
@@ -13,15 +15,18 @@ export interface StatementResponse {
|
|
|
13
15
|
BANKTRANLIST: BankTransactionList;
|
|
14
16
|
LEDGERBAL: Balance;
|
|
15
17
|
AVAILBAL?: Balance;
|
|
18
|
+
[key: string]: any;
|
|
16
19
|
}
|
|
17
20
|
export type BankAccount = {
|
|
18
21
|
BANKID: string;
|
|
19
22
|
ACCTID: string;
|
|
20
23
|
ACCTTYPE: AccountType;
|
|
24
|
+
[key: string]: any;
|
|
21
25
|
};
|
|
22
26
|
export type BankTransactionList = {
|
|
23
27
|
DTSTART: string;
|
|
24
28
|
DTEND: string;
|
|
25
29
|
STMTTRN: StatementTransaction[];
|
|
26
30
|
STRTTRN: StatementTransaction[];
|
|
31
|
+
[key: string]: any;
|
|
27
32
|
};
|
|
@@ -2,17 +2,20 @@ export interface Status {
|
|
|
2
2
|
CODE: number | string;
|
|
3
3
|
SEVERITY: 'INFO' | 'WARN' | 'ERROR';
|
|
4
4
|
MESSAGE?: string;
|
|
5
|
+
[key: string]: any;
|
|
5
6
|
}
|
|
6
7
|
export type AccountType = 'CHECKING' | 'SAVINGS' | 'CREDITLINE' | 'MONEYMRKT';
|
|
7
8
|
export type BankAccount = {
|
|
8
9
|
BANKID: string;
|
|
9
10
|
ACCTID: string;
|
|
10
11
|
ACCTTYPE: AccountType;
|
|
12
|
+
[key: string]: any;
|
|
11
13
|
};
|
|
12
14
|
export type TransactionType = 'CREDIT' | 'DEBIT' | 'INT' | 'DIV' | 'FEE' | 'SRVCHG' | 'DEP' | 'ATM' | 'POS' | 'XFER' | 'CHECK' | 'PAYMENT' | 'CASH' | 'DIRECTDEP' | 'DIRECTDEBIT' | 'REPEATPMT' | 'OTHER';
|
|
13
15
|
export interface Balance {
|
|
14
16
|
BALAMT: number;
|
|
15
17
|
DTASOF: string;
|
|
18
|
+
[key: string]: any;
|
|
16
19
|
}
|
|
17
20
|
export type StatementTransaction = {
|
|
18
21
|
TRNTYPE: TransactionType;
|
|
@@ -22,4 +25,5 @@ export type StatementTransaction = {
|
|
|
22
25
|
FITID: string;
|
|
23
26
|
CHECKNUM?: string;
|
|
24
27
|
MEMO?: string;
|
|
28
|
+
[key: string]: any;
|
|
25
29
|
};
|
|
@@ -4,6 +4,7 @@ export type CreditCardTransactionResponse = {
|
|
|
4
4
|
TRNUID: string;
|
|
5
5
|
STATUS: Status;
|
|
6
6
|
CCSTMTRS: CreditCardStatementResponse;
|
|
7
|
+
[key: string]: any;
|
|
7
8
|
};
|
|
8
9
|
export type CreditCardStatementResponse = {
|
|
9
10
|
CURDEF: string;
|
|
@@ -11,10 +12,13 @@ export type CreditCardStatementResponse = {
|
|
|
11
12
|
BANKTRANLIST: BankTransactionList;
|
|
12
13
|
LEDGERBAL: Balance;
|
|
13
14
|
AVAILBAL?: Balance;
|
|
15
|
+
[key: string]: any;
|
|
14
16
|
};
|
|
15
17
|
export type CreditCardAccount = {
|
|
16
18
|
ACCTID: string;
|
|
19
|
+
[key: string]: any;
|
|
17
20
|
};
|
|
18
21
|
export type CreditCardResponse = {
|
|
19
22
|
CCSTMTTRNRS: CreditCardTransactionResponse;
|
|
23
|
+
[key: string]: any;
|
|
20
24
|
};
|
|
@@ -6,8 +6,10 @@ export type OFX = {
|
|
|
6
6
|
SIGNONMSGSRSV1: SignOnResponse;
|
|
7
7
|
BANKMSGSRSV1: BankResponse;
|
|
8
8
|
CREDITCARDMSGSRSV1: CreditCardResponse;
|
|
9
|
+
[key: string]: any;
|
|
9
10
|
};
|
|
10
11
|
export type OfxStructure = {
|
|
11
12
|
OFX: OFX;
|
|
13
|
+
[key: string]: any;
|
|
12
14
|
};
|
|
13
15
|
export type OfxResponse = MetaData & OfxStructure;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
export type SignOnResponse = {
|
|
2
2
|
SONRS: SignOnStatus;
|
|
3
|
+
[key: string]: any;
|
|
3
4
|
};
|
|
4
5
|
export type SignOnStatus = {
|
|
5
6
|
STATUS: Status;
|
|
6
7
|
DTSERVER: string;
|
|
7
8
|
LANGUAGE: string;
|
|
8
9
|
FI?: FinancialInstitution;
|
|
10
|
+
[key: string]: any;
|
|
9
11
|
};
|
|
10
12
|
export type Status = {
|
|
11
13
|
CODE: number | string;
|
|
12
14
|
SEVERITY: 'INFO' | 'WARN' | 'ERROR';
|
|
13
15
|
MESSAGE?: string;
|
|
16
|
+
[key: string]: any;
|
|
14
17
|
};
|
|
15
18
|
export type FinancialInstitution = {
|
|
16
19
|
ORG: string;
|
|
17
20
|
FID: string;
|
|
21
|
+
[key: string]: any;
|
|
18
22
|
};
|
package/dist/esm/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Ofx-data-extractor v1.4.
|
|
2
|
-
const E
|
|
1
|
+
// Ofx-data-extractor v1.4.6 Copyright (c) 2025 Fábio Pereira França
|
|
2
|
+
const E=/<\/[\w.]+>/g,N=/<[\w.]+>/g,u="<BANKMSGSRSV1>",d="</BANKMSGSRSV1>",g="<CREDITCARDMSGSRSV1>",S="</CREDITCARDMSGSRSV1>",R="<STMTTRN>",T="</STMTTRN>",x="_#_",M=new RegExp(x,"g"),b=[u,R,g],L=[d,S,T];function _(e){const t=e.slice(0,4),n=e.slice(4,6),r=e.slice(6,8),s=e.slice(8,10),a=e.slice(10,12),i=e.slice(12,14);return{yyyy:t,yy:t.slice(2),y:t,MM:n,M:n,dd:r,d:r,hh:s,h:s,mm:a,m:a,ss:i,s:i}}function k(e,t){const n=_(e);let r=t;for(const[s,a]of Object.entries(n))r=r.replace(s,a);return r}var l;(function(e){e.BANK="BANK",e.CREDIT_CARD="CREDIT_CARD"})(l||(l={}));const G=["debit","fee","srvchg","atm","pos","check","payment","directdebit","cash","repeatpmt"],F=e=>e.includes(u)?l.BANK:l.CREDIT_CARD;function K(e){if(String(e.TRNAMT).startsWith("-"))return!0;const t=String(e.TRNTYPE).toLocaleLowerCase();return t==="1"||G.includes(t)}function f(e){const t=e.replace(/(\\)/g,"\\\\").replace(E,n=>A(n,!0)).replace(N,n=>w(n,!0)).replace(/(},})/g,"}}").replace(/(}")/g,'},"').replace(/(]")/g,'],"').replace(/(},])/g,"}]").replace(/(,})/g,"}").replace(/,\s*}/g,"}").replace(/(,",)/,",").replace(M,'\\"').slice(0,-1);return t.endsWith(",")?t.slice(0,-1):t}const J=e=>JSON.stringify({date:e.slice(0,12),transactionCode:e.slice(12,19),protocol:e.slice(19)}),P=e=>e.startsWith("DT"),D=e=>e.trim();function w(e,t=!1){return b.includes(e)&&!t?e:e.replace(/[<]/g,`
|
|
3
3
|
"`).replace(/[>]/g,'":{')}function A(e,t=!1){return L.includes(e)&&!t?`
|
|
4
4
|
${e}`:`},
|
|
5
5
|
`}function X({fitId:e,fitValue:t}){return e==="separated"?J(t):`"${t}",`}function $(e){return e.search(",")>e.search(".")?e.replace(/[.]/g,"").replace(/[,]/g,"."):e.replace(/[,]/g,"")}function V({dateString:e,formatDate:t="y-M-d"}){return k(e,t)}function W(e){let t=e.value.replace(/[{]/g,"").replace(/(},)/g,"").replace(/["]/g,x);const n=e.field.replace(/['"]/g,"");return n.endsWith("AMT")&&(t=$(t)),P(n)&&(t=V({dateString:t,formatDate:e.formatDate})),n==="FITID"?X({fitId:e.fitId,fitValue:t}):e.nativeTypes&&B(n,t)?`${Number(t)},`:`"${t}",`}function z(e,t){let n=e;return e.match(/{(\w|\W)+/)&&(n=n.replace(/({(\w|\W)+)$/,r=>W({field:n.slice(0,n.indexOf(":")),value:r,...t}))),n}function B(e,t){return e.endsWith("ID")||e.endsWith("NUM")?!1:!isNaN(Number(t))}function y(e){const t=e.indexOf(R),n=e.lastIndexOf(T)+T.length,r=e.substring(t,n),s=new RegExp(R,"g"),a=new RegExp(T,"g"),i=`"STRTTRN":[${r.replace(s,"{").replace(a,"},")}]`;return{oldListText:e,newListText:e.replace(r,i)}}function m(e){if(!(e.indexOf(u)>0))return{newBankStatementTransactions:null,oldBankStatementTransactions:null};const n=y(e.substring(e.indexOf(u),e.indexOf(d)+d.length));return{newBankStatementTransactions:n.newListText,oldBankStatementTransactions:n.oldListText}}function h(e){if(!(e.indexOf(g)>0))return{newCreditCardStatementTransactions:null,oldCreditCardStatementTransactions:null};const n=e.substring(e.indexOf(g),e.indexOf(S)+S.length),r=y(n);return{newCreditCardStatementTransactions:r.newListText,oldCreditCardStatementTransactions:r.oldListText}}function j(e){const t=[];for(const n of e)t.push(...n.replace("<?xml"," ").replace("<?OFX"," ").replace("?>"," ").split(" ").filter(Boolean).map(D).map(r=>r.replace("=",":").replace(/["]/g,"")));return t}function H(e,t){const n={};e.join("").search("<?")>-1&&(e=j(e));for(const r of e){const[s,a]=r.split(":"),i=s.replace(`
|
package/dist/umd/bundle.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Ofx-data-extractor v1.4.
|
|
2
|
-
(function(c,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis<"u"?globalThis:c||self,u(c.ofx={}))})(this,function(c){"use strict";const u
|
|
1
|
+
// Ofx-data-extractor v1.4.6 Copyright (c) 2025 Fábio Pereira França
|
|
2
|
+
(function(c,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis<"u"?globalThis:c||self,u(c.ofx={}))})(this,function(c){"use strict";const u=/<\/[\w.]+>/g,N=/<[\w.]+>/g,f="<BANKMSGSRSV1>",R="</BANKMSGSRSV1>",m="<CREDITCARDMSGSRSV1>",C="</CREDITCARDMSGSRSV1>",h="<STMTTRN>",d="</STMTTRN>",x="_#_",_=new RegExp(x,"g"),k=[f,h,m],G=[R,C,d];function F(e){const t=e.slice(0,4),n=e.slice(4,6),r=e.slice(6,8),s=e.slice(8,10),a=e.slice(10,12),i=e.slice(12,14);return{yyyy:t,yy:t.slice(2),y:t,MM:n,M:n,dd:r,d:r,hh:s,h:s,mm:a,m:a,ss:i,s:i}}function D(e,t){const n=F(e);let r=t;for(const[s,a]of Object.entries(n))r=r.replace(s,a);return r}var l;(function(e){e.BANK="BANK",e.CREDIT_CARD="CREDIT_CARD"})(l||(l={}));const J=["debit","fee","srvchg","atm","pos","check","payment","directdebit","cash","repeatpmt"],K=e=>e.includes(f)?l.BANK:l.CREDIT_CARD;function P(e){if(String(e.TRNAMT).startsWith("-"))return!0;const t=String(e.TRNTYPE).toLocaleLowerCase();return t==="1"||J.includes(t)}function g(e){const t=e.replace(/(\\)/g,"\\\\").replace(u,n=>y(n,!0)).replace(N,n=>A(n,!0)).replace(/(},})/g,"}}").replace(/(}")/g,'},"').replace(/(]")/g,'],"').replace(/(},])/g,"}]").replace(/(,})/g,"}").replace(/,\s*}/g,"}").replace(/(,",)/,",").replace(_,'\\"').slice(0,-1);return t.endsWith(",")?t.slice(0,-1):t}const X=e=>JSON.stringify({date:e.slice(0,12),transactionCode:e.slice(12,19),protocol:e.slice(19)}),$=e=>e.startsWith("DT"),w=e=>e.trim();function A(e,t=!1){return k.includes(e)&&!t?e:e.replace(/[<]/g,`
|
|
3
3
|
"`).replace(/[>]/g,'":{')}function y(e,t=!1){return G.includes(e)&&!t?`
|
|
4
4
|
${e}`:`},
|
|
5
5
|
`}function V({fitId:e,fitValue:t}){return e==="separated"?X(t):`"${t}",`}function W(e){return e.search(",")>e.search(".")?e.replace(/[.]/g,"").replace(/[,]/g,"."):e.replace(/[,]/g,"")}function j({dateString:e,formatDate:t="y-M-d"}){return D(e,t)}function z(e){let t=e.value.replace(/[{]/g,"").replace(/(},)/g,"").replace(/["]/g,x);const n=e.field.replace(/['"]/g,"");return n.endsWith("AMT")&&(t=W(t)),$(n)&&(t=j({dateString:t,formatDate:e.formatDate})),n==="FITID"?V({fitId:e.fitId,fitValue:t}):e.nativeTypes&&B(n,t)?`${Number(t)},`:`"${t}",`}function H(e,t){let n=e;return e.match(/{(\w|\W)+/)&&(n=n.replace(/({(\w|\W)+)$/,r=>z({field:n.slice(0,n.indexOf(":")),value:r,...t}))),n}function B(e,t){return e.endsWith("ID")||e.endsWith("NUM")?!1:!isNaN(Number(t))}function O(e){const t=e.indexOf(h),n=e.lastIndexOf(d)+d.length,r=e.substring(t,n),s=new RegExp(h,"g"),a=new RegExp(d,"g"),i=`"STRTTRN":[${r.replace(s,"{").replace(a,"},")}]`;return{oldListText:e,newListText:e.replace(r,i)}}function b(e){if(!(e.indexOf(f)>0))return{newBankStatementTransactions:null,oldBankStatementTransactions:null};const n=O(e.substring(e.indexOf(f),e.indexOf(R)+R.length));return{newBankStatementTransactions:n.newListText,oldBankStatementTransactions:n.oldListText}}function M(e){if(!(e.indexOf(m)>0))return{newCreditCardStatementTransactions:null,oldCreditCardStatementTransactions:null};const n=e.substring(e.indexOf(m),e.indexOf(C)+C.length),r=O(n);return{newCreditCardStatementTransactions:r.newListText,oldCreditCardStatementTransactions:r.oldListText}}function U(e){const t=[];for(const n of e)t.push(...n.replace("<?xml"," ").replace("<?OFX"," ").replace("?>"," ").split(" ").filter(Boolean).map(w).map(r=>r.replace("=",":").replace(/["]/g,"")));return t}function v(e,t){const n={};e.join("").search("<?")>-1&&(e=U(e));for(const r of e){const[s,a]=r.split(":"),i=s.replace(`
|