ofx-data-extractor 1.2.0 → 1.2.2

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.
@@ -0,0 +1,4 @@
1
+ export declare const ELEMENT_CLOSURE_REGEX: RegExp;
2
+ export declare const ELEMENT_OPENING_REGEX: RegExp;
3
+ export declare const START_TEXT_BANK_TRANSFER = "<STMTTRN>";
4
+ export declare const END_TEXT_BANK_TRANSFER = "</STMTTRN>";
@@ -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>;
@@ -0,0 +1,3 @@
1
+ export { Ofx } from './main';
2
+ export { formatDate, fixJsonProblems, blobToString, bufferToString, fileFromPathToString, } from './helpers';
3
+ export type { OfxResponse, OFXMetaData, OfxStructure, BankTransferList, } from './types';
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
+ }
@@ -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 {};
package/package.json CHANGED
@@ -1,18 +1,29 @@
1
1
  {
2
2
  "name": "ofx-data-extractor",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "keywords": [
5
5
  "ofx",
6
6
  "financial",
7
7
  "ofx-js",
8
8
  "ofx-ts",
9
+ "ofx to json",
10
+ "export ofx",
11
+ "ofx json",
12
+ "ofx manipulation",
9
13
  "banking",
10
14
  "parser",
11
15
  "data-extraction",
16
+ "extract ofx",
12
17
  "typescript",
13
18
  "utility",
14
19
  "ofx-file",
15
- "data-formatting"
20
+ "data-formatting",
21
+ "ofx node",
22
+ "ofx js",
23
+ "ofx ts",
24
+ "ofx extractor",
25
+ "ofx browser",
26
+ "open financial exchange"
16
27
  ],
17
28
  "author": "Fábio Pereira França",
18
29
  "repository": {
@@ -22,7 +33,7 @@
22
33
  "bugs": {
23
34
  "url": "https://github.com/Fabiopf02/ofx-ts/issues"
24
35
  },
25
- "license": "ISC",
36
+ "license": "MIT",
26
37
  "description": "",
27
38
  "main": "dist/index.js",
28
39
  "module": "dist/index.mjs",