ofx-data-extractor 1.2.0 → 1.2.1
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/config.d.ts +4 -0
- package/dist/helpers.d.ts +27 -0
- package/dist/index.d.ts +3 -0
- package/dist/main.d.ts +28 -0
- package/dist/types.d.ts +114 -0
- package/package.json +1 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { STRTTRN as STRTTRNType } from './types';
|
|
3
|
+
export declare function formatDate(date: string, format: string): string;
|
|
4
|
+
export declare function fixJsonProblems(content: string): string;
|
|
5
|
+
export declare function extractFinancialInstitutionTransactionId(fitid: string): string;
|
|
6
|
+
export declare function isDateField(field: string): boolean;
|
|
7
|
+
export declare function trim(str: string): string;
|
|
8
|
+
export declare function objectStartReplacer(param: string): string;
|
|
9
|
+
export declare function objectEndReplacer(param: string): string;
|
|
10
|
+
export declare function sanitizeCurrency(value: string): string;
|
|
11
|
+
export declare function isValidNumberToConvert(field: string, value: string): boolean;
|
|
12
|
+
export declare function getBankTransferListText(ofxContent: string): {
|
|
13
|
+
oldListText: string;
|
|
14
|
+
newListText: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function convertMetaDataToObject(stringList: string[], nativeTypes: boolean): {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export declare function getTransactionsSummary(STRTTRN: STRTTRNType[]): {
|
|
20
|
+
credit: number;
|
|
21
|
+
debit: number;
|
|
22
|
+
amountOfCredits: number;
|
|
23
|
+
amountOfDebits: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function bufferToString(data: Buffer): string;
|
|
26
|
+
export declare function fileFromPathToString(pathname: string): Promise<string>;
|
|
27
|
+
export declare function blobToString(blob: Blob): Promise<string>;
|
package/dist/index.d.ts
ADDED
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OfxConfig, OFXMetaData, OfxResponse, OfxStructure, STRTTRN } from './types';
|
|
3
|
+
export declare class Ofx {
|
|
4
|
+
private _data;
|
|
5
|
+
private _config;
|
|
6
|
+
constructor(data: string, config?: OfxConfig);
|
|
7
|
+
static fromBuffer(data: Buffer): Ofx;
|
|
8
|
+
static fromFilePath(pathname: string): Promise<Ofx>;
|
|
9
|
+
static fromBlob(blob: Blob): Promise<Ofx>;
|
|
10
|
+
config(config: OfxConfig): this;
|
|
11
|
+
getHeaders(): OFXMetaData;
|
|
12
|
+
getBankTransferList(): STRTTRN[];
|
|
13
|
+
private getPartialJsonData;
|
|
14
|
+
private sanitizeValue;
|
|
15
|
+
private sanitize;
|
|
16
|
+
private configFinancialInstitutionTransactionId;
|
|
17
|
+
private configDate;
|
|
18
|
+
getTransactionsSummary(): {
|
|
19
|
+
credit: number;
|
|
20
|
+
debit: number;
|
|
21
|
+
amountOfCredits: number;
|
|
22
|
+
amountOfDebits: number;
|
|
23
|
+
dateStart: import("./types").DateResponse;
|
|
24
|
+
dateEnd: import("./types").DateResponse;
|
|
25
|
+
};
|
|
26
|
+
getContent(): OfxStructure;
|
|
27
|
+
toJson(): OfxResponse;
|
|
28
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export type OFXMetaData = {
|
|
2
|
+
OFXHEADER: string;
|
|
3
|
+
DATA: string;
|
|
4
|
+
VERSION: string;
|
|
5
|
+
SECURITY: string;
|
|
6
|
+
ENCODING: string;
|
|
7
|
+
CHARSET: string;
|
|
8
|
+
COMPRESSION: string;
|
|
9
|
+
OLDFILEUID: string;
|
|
10
|
+
NEWFILEUID: string;
|
|
11
|
+
};
|
|
12
|
+
export type DateResponse = {
|
|
13
|
+
datetime: string | null;
|
|
14
|
+
date: string | null;
|
|
15
|
+
time: string | null;
|
|
16
|
+
offset: string | null;
|
|
17
|
+
timezone: string | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* separated - returns the separate transaction id:
|
|
21
|
+
* "date": string,
|
|
22
|
+
* "transactionCode": string,
|
|
23
|
+
* "protocol": string
|
|
24
|
+
*/
|
|
25
|
+
type ConfigFitId = 'normal' | 'separated';
|
|
26
|
+
export type ConfigDate = {
|
|
27
|
+
/**
|
|
28
|
+
* @description supported keys:
|
|
29
|
+
* yy => year -> 2 digits,
|
|
30
|
+
* yyyy or y => year,
|
|
31
|
+
* MM or M => month,
|
|
32
|
+
* dd or d => day,
|
|
33
|
+
* hh or h => hour,
|
|
34
|
+
* mm or m => minute,
|
|
35
|
+
* ss or s => second,
|
|
36
|
+
* O => offset,
|
|
37
|
+
* TZ => timezone
|
|
38
|
+
* @example format: 'y-M-d h:m:s'
|
|
39
|
+
* @returns '2022-02-21 09:00:00'
|
|
40
|
+
*/
|
|
41
|
+
formatDate?: string;
|
|
42
|
+
};
|
|
43
|
+
type MapKeys<T> = {
|
|
44
|
+
[Property in keyof T]?: string;
|
|
45
|
+
};
|
|
46
|
+
type KeysJson = MapKeys<Status | BankAccountFrom | STRTTRN | BankTransferList | LedGerBal | FINANCIAL_INSTITUTION | OfxStructure>;
|
|
47
|
+
export type OfxConfig = ConfigDate & {
|
|
48
|
+
fitId?: ConfigFitId;
|
|
49
|
+
nativeTypes?: boolean;
|
|
50
|
+
formatJson?: MapKeys<KeysJson>;
|
|
51
|
+
};
|
|
52
|
+
export type Status = {
|
|
53
|
+
CODE: string;
|
|
54
|
+
SEVERITY: string;
|
|
55
|
+
};
|
|
56
|
+
export type BankAccountFrom = {
|
|
57
|
+
BANKID: string;
|
|
58
|
+
ACCTID: string;
|
|
59
|
+
ACCTT: string;
|
|
60
|
+
};
|
|
61
|
+
type TransferType = string;
|
|
62
|
+
export type STRTTRN = {
|
|
63
|
+
TRNTYPE: TransferType;
|
|
64
|
+
DTPOSTED: DateResponse;
|
|
65
|
+
TRNAMT: string;
|
|
66
|
+
FITID: string | {
|
|
67
|
+
date: string;
|
|
68
|
+
protocol: string;
|
|
69
|
+
transactionCode: string;
|
|
70
|
+
};
|
|
71
|
+
CHECKNUM: string;
|
|
72
|
+
MEMO: string;
|
|
73
|
+
};
|
|
74
|
+
export type BankTransferList = {
|
|
75
|
+
DTSTART: DateResponse;
|
|
76
|
+
DTEND: DateResponse;
|
|
77
|
+
STRTTRN: STRTTRN[];
|
|
78
|
+
};
|
|
79
|
+
export type LedGerBal = {
|
|
80
|
+
BALAMT: string;
|
|
81
|
+
DTASOF: DateResponse;
|
|
82
|
+
};
|
|
83
|
+
export type FINANCIAL_INSTITUTION = {
|
|
84
|
+
ORG: string;
|
|
85
|
+
FID: string;
|
|
86
|
+
};
|
|
87
|
+
export type OfxStructure = {
|
|
88
|
+
OFX: {
|
|
89
|
+
SIGNONMSGSRSV1: {
|
|
90
|
+
SONRS: {
|
|
91
|
+
STATUS: Status;
|
|
92
|
+
DTSERVER: DateResponse;
|
|
93
|
+
LANGUAGE: string;
|
|
94
|
+
DTACCTUP: DateResponse;
|
|
95
|
+
FI: FINANCIAL_INSTITUTION;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
BANKMSGSRSV1: {
|
|
99
|
+
STMTTRNRS: {
|
|
100
|
+
TRNUID: number;
|
|
101
|
+
STATUS: Status;
|
|
102
|
+
STMTRS: {
|
|
103
|
+
CURDEF: string;
|
|
104
|
+
BANKACCTFROM: BankAccountFrom;
|
|
105
|
+
BANKTRANLIST: BankTransferList;
|
|
106
|
+
LEDGERBAL: LedGerBal;
|
|
107
|
+
MKTGINFO: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export type OfxResponse = OFXMetaData & OfxStructure;
|
|
114
|
+
export {};
|