@tasenor/common-plugins 1.11.58 → 1.11.60
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-ci.log +2 -2
- package/dist/CoinbaseImport/backend/CoinbaseHandler.js +22 -9
- package/dist/CoinbaseImport/backend/CoinbaseHandler.js.map +1 -1
- package/dist/CoinbaseImport/backend/index.js +1 -1
- package/package.json +6 -6
- package/src/CoinbaseImport/backend/CoinbaseHandler.ts +23 -9
- package/src/CoinbaseImport/backend/index.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-ci.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @tasenor/common-plugins@1.11.
|
|
2
|
+
> @tasenor/common-plugins@1.11.59 ci /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
|
|
3
3
|
> pnpm run lint
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @tasenor/common-plugins@1.11.
|
|
6
|
+
> @tasenor/common-plugins@1.11.59 lint /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
|
|
7
7
|
> eslint 'src/**/*.{ts,tsx}' 'data/**/*.mjs'
|
|
8
8
|
|
|
@@ -35,36 +35,49 @@ export class CoinbaseHandler extends TransactionImportHandler {
|
|
|
35
35
|
if (file.firstLineMatch(/"You can use this transaction report/)) {
|
|
36
36
|
return 2;
|
|
37
37
|
}
|
|
38
|
+
if (file.firstLineMatch(/^$/) && file.secondLineMatch(/^Transactions$/)) {
|
|
39
|
+
return 3;
|
|
40
|
+
}
|
|
38
41
|
return 0;
|
|
39
42
|
}
|
|
40
43
|
async init(files) {
|
|
41
|
-
if (this.version ===
|
|
44
|
+
if (this.version === 1) {
|
|
45
|
+
return files;
|
|
46
|
+
}
|
|
47
|
+
if (this.version === 2 || this.version === 3) {
|
|
42
48
|
// Clean up trash from the beginning.
|
|
43
49
|
for (const file of files) {
|
|
44
50
|
const data = file.decode();
|
|
45
|
-
const lines = data.split('\n').splice(7);
|
|
51
|
+
const lines = data.split('\n').splice(this.version === 2 ? 7 : 3);
|
|
46
52
|
if (!/^Timestamp,Transaction Type,Asset,Quantity Transacted,Spot Price Currency,Spot Price at Transaction,Subtotal,Total/.test(lines[0])) {
|
|
47
53
|
throw new Error('Coinbase parser is not able to understand the format.');
|
|
48
54
|
}
|
|
49
55
|
file.set(lines.join('\n'));
|
|
50
56
|
}
|
|
57
|
+
return files;
|
|
51
58
|
}
|
|
52
|
-
|
|
59
|
+
throw new Error(`Coinbase import handler does not implement init() for version ${this.version}.`);
|
|
53
60
|
}
|
|
54
61
|
segmentId(line) {
|
|
55
|
-
if (this.version === 2) {
|
|
62
|
+
if (this.version === 2 || this.version === 3) {
|
|
56
63
|
return super.segmentId(line);
|
|
57
64
|
}
|
|
58
|
-
if (
|
|
59
|
-
|
|
65
|
+
if (this.version === 1) {
|
|
66
|
+
if (['deposit', 'withdrawal'].includes(line.columns.type)) {
|
|
67
|
+
return line.columns['transfer id'];
|
|
68
|
+
}
|
|
69
|
+
return line.columns['trade id'];
|
|
60
70
|
}
|
|
61
|
-
|
|
71
|
+
throw new Error(`Coinbase import handler does not implement segmentId() for version ${this.version}.`);
|
|
62
72
|
}
|
|
63
73
|
time(line) {
|
|
64
|
-
if (this.version === 2) {
|
|
74
|
+
if (this.version === 2 || this.version === 3) {
|
|
65
75
|
return line.columns.Timestamp ? new Date(line.columns.Timestamp) : undefined;
|
|
66
76
|
}
|
|
67
|
-
|
|
77
|
+
if (this.version === 1) {
|
|
78
|
+
return line.columns.time ? new Date(line.columns.time) : undefined;
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`Coinbase import handler does not implement time() for version ${this.version}.`);
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
83
|
//# sourceMappingURL=CoinbaseHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"C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OAAO,CAAC,IAAI,CAAC,EAAE;gBACzD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;aACnC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SAChC;QACD,MAAM,IAAI,KAAK,CAAC,sEAAsE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;IACxG,CAAC;IAED,IAAI,CAAC,IAAkB;QACrB,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE;YAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;SAC7E;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;SACnE;QACD,MAAM,IAAI,KAAK,CAAC,iEAAiE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;IACnG,CAAC;CACF"}
|
|
@@ -5,7 +5,7 @@ class CoinbaseImportPlugin extends ImportPlugin {
|
|
|
5
5
|
super(new CoinbaseHandler());
|
|
6
6
|
this.code = 'CoinbaseImport';
|
|
7
7
|
this.title = 'Import for Coinbase';
|
|
8
|
-
this.version = '1.0.
|
|
8
|
+
this.version = '1.0.22';
|
|
9
9
|
this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 6.99h3V14h2V6.99h3L9 3zM14 10v7.01h-3L15 21l4-3.99h-3V10z"/></svg>';
|
|
10
10
|
this.releaseDate = '2022-10-24';
|
|
11
11
|
this.use = 'backend';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tasenor/common-plugins",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.60",
|
|
4
4
|
"description": "Shared common plugins of Tasenor project",
|
|
5
5
|
"repository": "git@github.com:dataplugoy/tasenor-bookkeeper.git",
|
|
6
6
|
"author": "Tommi Ronkainen <tommi.ronkainen@gmail.com>",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"dayjs": "1.10.8",
|
|
14
14
|
"sprintf-js": "^1.1.2",
|
|
15
15
|
"tsx": "^4.7.0",
|
|
16
|
-
"@tasenor/common
|
|
17
|
-
"@tasenor/common-
|
|
18
|
-
"@tasenor/common": "1.11.
|
|
16
|
+
"@tasenor/common": "1.11.60",
|
|
17
|
+
"@tasenor/common-node": "1.11.60",
|
|
18
|
+
"@tasenor/common-ui": "1.11.60"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@mui/icons-material": "^5.14.1",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"react-i18next": "^14.0.5",
|
|
32
32
|
"react-router-dom": "^6.14.1",
|
|
33
33
|
"typescript": "^5.1.6",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"eslint-config-tasenor": "0.0.0",
|
|
35
|
+
"@tasenor/config": "1.11.60"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@mui/icons-material": "^5.14.1",
|
|
@@ -40,39 +40,53 @@ export class CoinbaseHandler extends TransactionImportHandler {
|
|
|
40
40
|
if (file.firstLineMatch(/"You can use this transaction report/)) {
|
|
41
41
|
return 2
|
|
42
42
|
}
|
|
43
|
+
if (file.firstLineMatch(/^$/) && file.secondLineMatch(/^Transactions$/)) {
|
|
44
|
+
return 3
|
|
45
|
+
}
|
|
43
46
|
|
|
44
47
|
return 0
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
async init(files: ProcessFile[]): Promise<ProcessFile[]> {
|
|
48
|
-
if (this.version ===
|
|
51
|
+
if (this.version === 1) {
|
|
52
|
+
return files
|
|
53
|
+
}
|
|
54
|
+
if (this.version === 2 || this.version === 3) {
|
|
49
55
|
// Clean up trash from the beginning.
|
|
50
56
|
for (const file of files) {
|
|
51
57
|
const data = file.decode()
|
|
52
|
-
const lines = data.split('\n').splice(7)
|
|
58
|
+
const lines = data.split('\n').splice(this.version === 2 ? 7 : 3)
|
|
53
59
|
if (!/^Timestamp,Transaction Type,Asset,Quantity Transacted,Spot Price Currency,Spot Price at Transaction,Subtotal,Total/.test(lines[0])) {
|
|
54
60
|
throw new Error('Coinbase parser is not able to understand the format.')
|
|
55
61
|
}
|
|
56
62
|
file.set(lines.join('\n'))
|
|
57
63
|
}
|
|
64
|
+
return files
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
|
|
67
|
+
throw new Error(`Coinbase import handler does not implement init() for version ${this.version}.`)
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
segmentId(line: TextFileLine): SegmentId | typeof NO_SEGMENT {
|
|
63
|
-
if (this.version === 2) {
|
|
71
|
+
if (this.version === 2 || this.version === 3) {
|
|
64
72
|
return super.segmentId(line)
|
|
65
73
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
74
|
+
if (this.version === 1) {
|
|
75
|
+
if (['deposit', 'withdrawal'].includes(line.columns.type)) {
|
|
76
|
+
return line.columns['transfer id']
|
|
77
|
+
}
|
|
78
|
+
return line.columns['trade id']
|
|
68
79
|
}
|
|
69
|
-
|
|
80
|
+
throw new Error(`Coinbase import handler does not implement segmentId() for version ${this.version}.`)
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
time(line: TextFileLine): Date | undefined {
|
|
73
|
-
if (this.version === 2) {
|
|
84
|
+
if (this.version === 2 || this.version === 3) {
|
|
74
85
|
return line.columns.Timestamp ? new Date(line.columns.Timestamp) : undefined
|
|
75
86
|
}
|
|
76
|
-
|
|
87
|
+
if (this.version === 1) {
|
|
88
|
+
return line.columns.time ? new Date(line.columns.time) : undefined
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`Coinbase import handler does not implement time() for version ${this.version}.`)
|
|
77
91
|
}
|
|
78
92
|
}
|
|
@@ -9,7 +9,7 @@ class CoinbaseImportPlugin extends ImportPlugin {
|
|
|
9
9
|
|
|
10
10
|
this.code = 'CoinbaseImport' as PluginCode
|
|
11
11
|
this.title = 'Import for Coinbase'
|
|
12
|
-
this.version = '1.0.
|
|
12
|
+
this.version = '1.0.22' as Version
|
|
13
13
|
this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 6.99h3V14h2V6.99h3L9 3zM14 10v7.01h-3L15 21l4-3.99h-3V10z"/></svg>'
|
|
14
14
|
this.releaseDate = '2022-10-24'
|
|
15
15
|
this.use = 'backend'
|