Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Rely on less custom config, cut out travis ci, upgrade tools and dependencies #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
env: {
es2021: true,
node: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-explicit-any': 0,
'prefer-spread': 0
}
};
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release & Publish when a new tag (e.g. v1.0.0) is pushed

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false

publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: https://registry.npmjs.org/
cache: 'npm'
- run: npm install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test the nodejs code
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run format
- run: npm run test:ci
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
coverage
node_modules
lib
.coveralls.yml
package-lock.json
.eslintcache
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

48 changes: 29 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
## 1.0.0
* fix transaction description parsing (see https://github.com/webschik/mt940-js/issues/12)
* updated development tools
* first major release :)

- fix transaction description parsing (see https://github.com/webschik/mt940-js/issues/12)
- updated development tools
- first major release :)

## 0.6.0
* **Breaking change**: [new transaction id generator](README.md#readoptions)

- **Breaking change**: [new transaction id generator](README.md#readoptions)

## 0.5.2
* fix parsing of customer and bank references

- fix parsing of customer and bank references

## 0.5.1
* fix transactions parsing

- fix transactions parsing

## 0.5.0
* parse bank and customer references in transaction info, tag :61:
* refactoring. Build the module only with Typescript, without Webpack

- parse bank and customer references in transaction info, tag :61:
- refactoring. Build the module only with Typescript, without Webpack

## 0.4.1
* removed Webpack polyfills


- removed Webpack polyfills

## 0.4.0
* added `id` property to transaction info
* added `isExpense` property to transaction info

- added `id` property to transaction info
- added `isExpense` property to transaction info

## 0.3.0
* Transaction description
* filter symbols `\r`, `\n`
* replace multiple spaces by 1 space symbol


- Transaction description
- filter symbols `\r`, `\n`
- replace multiple spaces by 1 space symbol

## 0.2.0
* added `npm-shrinkwrap.json`
* added `Transaction`, `BalanceInfo` interfaces to `.d.ts` file

- added `npm-shrinkwrap.json`
- added `Transaction`, `BalanceInfo` interfaces to `.d.ts` file

## 0.1.0
* reading of the documents according to [mt940 specification](README.md#mt940-specification)

- reading of the documents according to [mt940 specification](README.md#mt940-specification)
104 changes: 60 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# mt940-js

[![Build Status](https://travis-ci.org/webschik/mt940-js.svg?branch=master)](https://travis-ci.org/webschik/mt940-js)
[![npm](https://img.shields.io/npm/dm/mt940-js.svg)](https://www.npmjs.com/package/mt940-js)
[![npm](https://img.shields.io/npm/v/mt940-js.svg)](https://www.npmjs.com/package/mt940-js)
Expand All @@ -10,39 +11,44 @@
# [Changelog](CHANGELOG.md)

## Reading

### API

#### read(buffer, options)
* `buffer` {Buffer|ArrayBuffer} - income buffer that contains data of mt940 file.
* `options` {ReadOptions}
* returns `Promise` with list of [Statement](src/index.ts#L49).

- `buffer` {Buffer|ArrayBuffer} - income buffer that contains data of mt940 file.
- `options` {ReadOptions}
- returns `Promise` with list of [Statement](src/index.ts#L49).

##### ReadOptions
* `getTransactionId(transaction, index)` - a custom generator for transaction id. By default it's:

- `getTransactionId(transaction, index)` - a custom generator for transaction id. By default it's:

```js
/**
* @description version 0.5.x
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId (transaction, index) {
return md5(`${ date }${ transaction.description }${ amount }${ transaction.currency }`);
* @description version 0.5.x
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId(transaction, index) {
return md5(`${date}${transaction.description}${amount}${transaction.currency}`);
}


/**
* @description version 0.6.x+
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId (transaction, index) {
* @description version 0.6.x+
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId(transaction, index) {
return md5(JSON.strinfigy(transaction));
}
```

### Node.js environment
````js

```js
import * as mt940 from 'mt940-js';
import fs from 'fs';

Expand All @@ -51,29 +57,34 @@ fs.readFile('/path/to/your/mt940/file', (error, buffer) => {
//
});
});
````
```

### Browser environment

#### Reading a local file
````html
<input type="file" onchange="onFileSelected(this.files[0])"/>
````
````js

```html
<input type="file" onchange="onFileSelected(this.files[0])" />
```

```js
import * as mt940 from 'mt940-js';

function onFileSelected (file) {
function onFileSelected(file) {
const reader = new FileReader();

reader.onload = () => {
mt940.read(reader.result).then((statements) => {
// List of the Statements
});
};
reader.readAsArrayBuffer(file);
}
````
```

#### Reading a remote file
````js

```js
import * as mt940 from 'mt940-js';

fetch('/url/to/mt940/file')
Expand All @@ -83,29 +94,34 @@ fetch('/url/to/mt940/file')
// List of the Statements
});
});
````
```

## Writing

Coming soon

## Supported MT940 tags
* **:20:**
* **:21:**
* **:25:**
* **:28(C):**
* **:60(M|F):**
* **:61:**
* **:62(M|F):**
* **:64:**
* **:65:**
* **:86:**

- **:20:**
- **:21:**
- **:25:**
- **:28(C):**
- **:60(M|F):**
- **:61:**
- **:62(M|F):**
- **:64:**
- **:65:**
- **:86:**

## Related links

### JS
* [Buffer](https://nodejs.org/api/buffer.html)
* [ArrayBuffer](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)

- [Buffer](https://nodejs.org/api/buffer.html)
- [ArrayBuffer](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)

### mt940 specification
* [Societe Generale spec.](https://web.archive.org/web/20160725042101/http://www.societegenerale.rs/fileadmin/template/main/pdf/SGS%20MT940.pdf)
* [Sepa spec.](http://www.sepaforcorporates.com/swift-for-corporates/account-statement-mt940-file-format-overview/)
* [Deutsche Bank spec.](https://deutschebank.nl/nl/docs/MT94042_EN.pdf)

- [Societe Generale spec.](https://web.archive.org/web/20160725042101/http://www.societegenerale.rs/fileadmin/template/main/pdf/SGS%20MT940.pdf)
- [Sepa spec.](http://www.sepaforcorporates.com/swift-for-corporates/account-statement-mt940-file-format-overview/)
- [Deutsche Bank spec.](https://deutschebank.nl/nl/docs/MT94042_EN.pdf)
13 changes: 5 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */

module.exports = {
coverageDirectory: '__tests__/coverage',
coverageReporters: ['lcov', 'html'],
collectCoverageFrom: ['src/*.{ts,tsx}', 'src/**/*.{ts,tsx}'],
transform: {'.*': '<rootDir>/jest/preprocessor.js'},
setupFilesAfterEnv: ['<rootDir>/jest/config.js'],
testPathIgnorePatterns: ['/node_modules/', '/test/e2e/'],
testRegex: '(/test/unit/.*|\\.(test|spec))\\.(ts|tsx|js)$',
moduleFileExtensions: ['ts', 'tsx', 'js']
preset: 'ts-jest',
testEnvironment: 'node',
coverageReporters: ['json-summary', 'text', 'lcov']
};
5 changes: 0 additions & 5 deletions jest/config.js

This file was deleted.

18 changes: 0 additions & 18 deletions jest/preprocessor.js

This file was deleted.

Loading