@0xtorch/csv 0.0.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.
Files changed (147) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/formatCsvRows.js +67 -0
  3. package/_cjs/formatCsvRows.js.map +1 -0
  4. package/_cjs/index.js +12 -0
  5. package/_cjs/index.js.map +1 -0
  6. package/_cjs/package.json +1 -0
  7. package/_cjs/parseCsvFileToAccountActions.js +26 -0
  8. package/_cjs/parseCsvFileToAccountActions.js.map +1 -0
  9. package/_cjs/parseCsvFileToText.js +15 -0
  10. package/_cjs/parseCsvFileToText.js.map +1 -0
  11. package/_cjs/parseCsvRowToNormalAction/asset.js +62 -0
  12. package/_cjs/parseCsvRowToNormalAction/asset.js.map +1 -0
  13. package/_cjs/parseCsvRowToNormalAction/condition.js +32 -0
  14. package/_cjs/parseCsvRowToNormalAction/condition.js.map +1 -0
  15. package/_cjs/parseCsvRowToNormalAction/index.js +6 -0
  16. package/_cjs/parseCsvRowToNormalAction/index.js.map +1 -0
  17. package/_cjs/parseCsvRowToNormalAction/nft.js +15 -0
  18. package/_cjs/parseCsvRowToNormalAction/nft.js.map +1 -0
  19. package/_cjs/parseCsvRowToNormalAction/parseCsvRowToNormalAction.js +83 -0
  20. package/_cjs/parseCsvRowToNormalAction/parseCsvRowToNormalAction.js.map +1 -0
  21. package/_cjs/parseCsvRowToNormalAction/text.js +31 -0
  22. package/_cjs/parseCsvRowToNormalAction/text.js.map +1 -0
  23. package/_cjs/parseCsvRowToNormalAction/timestamp.js +12 -0
  24. package/_cjs/parseCsvRowToNormalAction/timestamp.js.map +1 -0
  25. package/_cjs/parseCsvRowToNormalAction/transfer.js +29 -0
  26. package/_cjs/parseCsvRowToNormalAction/transfer.js.map +1 -0
  27. package/_cjs/parseCsvRowsToAccountActions.js +49 -0
  28. package/_cjs/parseCsvRowsToAccountActions.js.map +1 -0
  29. package/_cjs/parseCsvText.js +15 -0
  30. package/_cjs/parseCsvText.js.map +1 -0
  31. package/_cjs/schemas/formatter.js +15 -0
  32. package/_cjs/schemas/formatter.js.map +1 -0
  33. package/_cjs/schemas/formatterTypes.js +37 -0
  34. package/_cjs/schemas/formatterTypes.js.map +1 -0
  35. package/_cjs/schemas/index.js +6 -0
  36. package/_cjs/schemas/index.js.map +1 -0
  37. package/_cjs/schemas/parser.js +80 -0
  38. package/_cjs/schemas/parser.js.map +1 -0
  39. package/_cjs/schemas/schemas.js +14 -0
  40. package/_cjs/schemas/schemas.js.map +1 -0
  41. package/_cjs/types.js +3 -0
  42. package/_cjs/types.js.map +1 -0
  43. package/_esm/formatCsvRows.js +67 -0
  44. package/_esm/formatCsvRows.js.map +1 -0
  45. package/_esm/index.js +5 -0
  46. package/_esm/index.js.map +1 -0
  47. package/_esm/package.json +1 -0
  48. package/_esm/parseCsvFileToAccountActions.js +22 -0
  49. package/_esm/parseCsvFileToAccountActions.js.map +1 -0
  50. package/_esm/parseCsvFileToText.js +11 -0
  51. package/_esm/parseCsvFileToText.js.map +1 -0
  52. package/_esm/parseCsvRowToNormalAction/asset.js +58 -0
  53. package/_esm/parseCsvRowToNormalAction/asset.js.map +1 -0
  54. package/_esm/parseCsvRowToNormalAction/condition.js +28 -0
  55. package/_esm/parseCsvRowToNormalAction/condition.js.map +1 -0
  56. package/_esm/parseCsvRowToNormalAction/index.js +2 -0
  57. package/_esm/parseCsvRowToNormalAction/index.js.map +1 -0
  58. package/_esm/parseCsvRowToNormalAction/nft.js +11 -0
  59. package/_esm/parseCsvRowToNormalAction/nft.js.map +1 -0
  60. package/_esm/parseCsvRowToNormalAction/parseCsvRowToNormalAction.js +81 -0
  61. package/_esm/parseCsvRowToNormalAction/parseCsvRowToNormalAction.js.map +1 -0
  62. package/_esm/parseCsvRowToNormalAction/text.js +27 -0
  63. package/_esm/parseCsvRowToNormalAction/text.js.map +1 -0
  64. package/_esm/parseCsvRowToNormalAction/timestamp.js +8 -0
  65. package/_esm/parseCsvRowToNormalAction/timestamp.js.map +1 -0
  66. package/_esm/parseCsvRowToNormalAction/transfer.js +25 -0
  67. package/_esm/parseCsvRowToNormalAction/transfer.js.map +1 -0
  68. package/_esm/parseCsvRowsToAccountActions.js +47 -0
  69. package/_esm/parseCsvRowsToAccountActions.js.map +1 -0
  70. package/_esm/parseCsvText.js +11 -0
  71. package/_esm/parseCsvText.js.map +1 -0
  72. package/_esm/schemas/formatter.js +12 -0
  73. package/_esm/schemas/formatter.js.map +1 -0
  74. package/_esm/schemas/formatterTypes.js +35 -0
  75. package/_esm/schemas/formatterTypes.js.map +1 -0
  76. package/_esm/schemas/index.js +2 -0
  77. package/_esm/schemas/index.js.map +1 -0
  78. package/_esm/schemas/parser.js +100 -0
  79. package/_esm/schemas/parser.js.map +1 -0
  80. package/_esm/schemas/schemas.js +11 -0
  81. package/_esm/schemas/schemas.js.map +1 -0
  82. package/_esm/types.js +2 -0
  83. package/_esm/types.js.map +1 -0
  84. package/_types/formatCsvRows.d.ts +11 -0
  85. package/_types/formatCsvRows.d.ts.map +1 -0
  86. package/_types/index.d.ts +6 -0
  87. package/_types/index.d.ts.map +1 -0
  88. package/_types/parseCsvFileToAccountActions.d.ts +12 -0
  89. package/_types/parseCsvFileToAccountActions.d.ts.map +1 -0
  90. package/_types/parseCsvFileToText.d.ts +2 -0
  91. package/_types/parseCsvFileToText.d.ts.map +1 -0
  92. package/_types/parseCsvRowToNormalAction/asset.d.ts +17 -0
  93. package/_types/parseCsvRowToNormalAction/asset.d.ts.map +1 -0
  94. package/_types/parseCsvRowToNormalAction/condition.d.ts +10 -0
  95. package/_types/parseCsvRowToNormalAction/condition.d.ts.map +1 -0
  96. package/_types/parseCsvRowToNormalAction/index.d.ts +2 -0
  97. package/_types/parseCsvRowToNormalAction/index.d.ts.map +1 -0
  98. package/_types/parseCsvRowToNormalAction/nft.d.ts +12 -0
  99. package/_types/parseCsvRowToNormalAction/nft.d.ts.map +1 -0
  100. package/_types/parseCsvRowToNormalAction/parseCsvRowToNormalAction.d.ts +20 -0
  101. package/_types/parseCsvRowToNormalAction/parseCsvRowToNormalAction.d.ts.map +1 -0
  102. package/_types/parseCsvRowToNormalAction/text.d.ts +11 -0
  103. package/_types/parseCsvRowToNormalAction/text.d.ts.map +1 -0
  104. package/_types/parseCsvRowToNormalAction/timestamp.d.ts +8 -0
  105. package/_types/parseCsvRowToNormalAction/timestamp.d.ts.map +1 -0
  106. package/_types/parseCsvRowToNormalAction/transfer.d.ts +18 -0
  107. package/_types/parseCsvRowToNormalAction/transfer.d.ts.map +1 -0
  108. package/_types/parseCsvRowsToAccountActions.d.ts +16 -0
  109. package/_types/parseCsvRowsToAccountActions.d.ts.map +1 -0
  110. package/_types/parseCsvText.d.ts +4 -0
  111. package/_types/parseCsvText.d.ts.map +1 -0
  112. package/_types/schemas/formatter.d.ts +4 -0
  113. package/_types/schemas/formatter.d.ts.map +1 -0
  114. package/_types/schemas/formatterTypes.d.ts +10 -0
  115. package/_types/schemas/formatterTypes.d.ts.map +1 -0
  116. package/_types/schemas/index.d.ts +2 -0
  117. package/_types/schemas/index.d.ts.map +1 -0
  118. package/_types/schemas/parser.d.ts +1505 -0
  119. package/_types/schemas/parser.d.ts.map +1 -0
  120. package/_types/schemas/schemas.d.ts +806 -0
  121. package/_types/schemas/schemas.d.ts.map +1 -0
  122. package/_types/types.d.ts +13 -0
  123. package/_types/types.d.ts.map +1 -0
  124. package/formatCsvRows.ts +97 -0
  125. package/index.ts +5 -0
  126. package/package.json +50 -0
  127. package/parseCsvFileToAccountActions.ts +40 -0
  128. package/parseCsvFileToText.ts +11 -0
  129. package/parseCsvRowToNormalAction/asset.ts +92 -0
  130. package/parseCsvRowToNormalAction/condition.ts +39 -0
  131. package/parseCsvRowToNormalAction/index.ts +1 -0
  132. package/parseCsvRowToNormalAction/nft.ts +27 -0
  133. package/parseCsvRowToNormalAction/parseCsvRowToNormalAction.ts +146 -0
  134. package/parseCsvRowToNormalAction/text.ts +37 -0
  135. package/parseCsvRowToNormalAction/timestamp.ts +19 -0
  136. package/parseCsvRowToNormalAction/transfer.ts +55 -0
  137. package/parseCsvRowsToAccountActions.ts +67 -0
  138. package/parseCsvText.ts +14 -0
  139. package/schemas/formatter.ts +13 -0
  140. package/schemas/formatterTypes.ts +44 -0
  141. package/schemas/index.ts +1 -0
  142. package/schemas/parser.ts +110 -0
  143. package/schemas/schemas.ts +11 -0
  144. package/tests/assets.ts +28 -0
  145. package/tests/coincheck-standard.csv +17 -0
  146. package/tests/coincheck.ts +137 -0
  147. package/types.ts +17 -0
package/.DS_Store ADDED
Binary file
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatCsvRows = void 0;
4
+ const formatterTypes_1 = require("./schemas/formatterTypes");
5
+ const formatCsvRows = ({ rows, formatter, }) => rows.map((row) => formatCsvRow(row, formatter));
6
+ exports.formatCsvRows = formatCsvRows;
7
+ const formatCsvRow = (row, formatter) => Object.fromEntries(Object.entries(formatter).map(([column, schemaTypes]) => {
8
+ if (!(column in row)) {
9
+ throw new Error(`The column '${column}' does not exist in the CSV`);
10
+ }
11
+ const value = row[column];
12
+ for (const schemaType of schemaTypes) {
13
+ switch (schemaType) {
14
+ case 'blank': {
15
+ const parsed = formatterTypes_1.blankTextSchema.safeParse(value);
16
+ if (!parsed.success) {
17
+ break;
18
+ }
19
+ return [column, parsed.data];
20
+ }
21
+ case 'string': {
22
+ const parsed = formatterTypes_1.stringTextSchema.safeParse(value);
23
+ if (!parsed.success) {
24
+ break;
25
+ }
26
+ return [column, parsed.data];
27
+ }
28
+ case 'big-decimal': {
29
+ const parsed = formatterTypes_1.bigDecimalTextSchema.safeParse(value);
30
+ if (!parsed.success) {
31
+ break;
32
+ }
33
+ return [column, parsed.data];
34
+ }
35
+ case 'big-decimal-negative': {
36
+ const parsed = formatterTypes_1.bigDecimalNegativeTextSchema.safeParse(value);
37
+ if (!parsed.success) {
38
+ break;
39
+ }
40
+ return [column, parsed.data];
41
+ }
42
+ case 'big-decimal-positive': {
43
+ const parsed = formatterTypes_1.bigDecimalPositiveTextSchema.safeParse(value);
44
+ if (!parsed.success) {
45
+ break;
46
+ }
47
+ return [column, parsed.data];
48
+ }
49
+ case 'iso8601': {
50
+ const parsed = formatterTypes_1.iso8601TextSchema.safeParse(value);
51
+ if (!parsed.success) {
52
+ break;
53
+ }
54
+ return [column, parsed.data];
55
+ }
56
+ case 'datetime-jp': {
57
+ const parsed = formatterTypes_1.datetimeJpTextSchema.safeParse(value);
58
+ if (!parsed.success) {
59
+ break;
60
+ }
61
+ return [column, parsed.data];
62
+ }
63
+ }
64
+ }
65
+ throw new Error(`The column "${column}"'s value "${value}" does not match schema: [${schemaTypes.join(',')}]`);
66
+ }));
67
+ //# sourceMappingURL=formatCsvRows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatCsvRows.js","sourceRoot":"","sources":["../formatCsvRows.ts"],"names":[],"mappings":";;;AAAA,6DAQiC;AAY1B,MAAM,aAAa,GAAG,CAAC,EAC5B,IAAI,EACJ,SAAS,GACe,EAA2B,EAAE,CACrD,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;AAJpC,QAAA,aAAa,iBAIuB;AAEjD,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,SAAoB,EAAgB,EAAE,CACvE,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAC3B,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,EAA4B,EAAE;IAElD,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,eAAe,MAAM,6BAA6B,CAAC,CAAA;IACrE,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzB,KAAK,MAAM,UAAU,IAAI,WAAW,E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ACP,CAAC;gBACD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;YACD,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,MAAM,GAAG,kCAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;gBACjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAK;gBACP,CAAC;gBACD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;YACD,KAAK,aAAa,CAAC,CAAC,CAAC;gBACnB,MAAM,MAAM,GAAG,qCAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;gBACpD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAK;gBACP,CAAC;gBACD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAGD,MAAM,IAAI,KAAK,CACb,eAAe,MAAM,cAAc,KAAK,6BAA6B,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAC9F,CAAA;AACH,CAAC,CACF,CACF,CAAA"}
package/_cjs/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.csvFormatSchema = exports.parseCsvText = exports.parseCsvFileToText = exports.parseCsvFileToAccountActions = void 0;
4
+ var parseCsvFileToAccountActions_1 = require("./parseCsvFileToAccountActions");
5
+ Object.defineProperty(exports, "parseCsvFileToAccountActions", { enumerable: true, get: function () { return parseCsvFileToAccountActions_1.parseCsvFileToAccountActions; } });
6
+ var parseCsvFileToText_1 = require("./parseCsvFileToText");
7
+ Object.defineProperty(exports, "parseCsvFileToText", { enumerable: true, get: function () { return parseCsvFileToText_1.parseCsvFileToText; } });
8
+ var parseCsvText_1 = require("./parseCsvText");
9
+ Object.defineProperty(exports, "parseCsvText", { enumerable: true, get: function () { return parseCsvText_1.parseCsvText; } });
10
+ var schemas_1 = require("./schemas");
11
+ Object.defineProperty(exports, "csvFormatSchema", { enumerable: true, get: function () { return schemas_1.csvFormatSchema; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,+EAA6E;AAApE,4IAAA,4BAA4B,OAAA;AACrC,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAC3B,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AACrB,qCAA2C;AAAlC,0GAAA,eAAe,OAAA"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvFileToAccountActions = void 0;
4
+ const formatCsvRows_1 = require("./formatCsvRows");
5
+ const parseCsvFileToText_1 = require("./parseCsvFileToText");
6
+ const parseCsvRowsToAccountActions_1 = require("./parseCsvRowsToAccountActions");
7
+ const parseCsvText_1 = require("./parseCsvText");
8
+ const parseCsvFileToAccountActions = async ({ file, format: { service, formatter, parsers, symbolAssetMap }, accountId, cryptoCurrencies, fiatCurrencies, }) => {
9
+ const text = await (0, parseCsvFileToText_1.parseCsvFileToText)(file);
10
+ const rows = (0, formatCsvRows_1.formatCsvRows)({
11
+ rows: (0, parseCsvText_1.parseCsvText)(text),
12
+ formatter,
13
+ });
14
+ const actions = (0, parseCsvRowsToAccountActions_1.parseCsvRowsToAccountActions)({
15
+ rows,
16
+ service,
17
+ parsers,
18
+ symbolAssetMap,
19
+ accountId,
20
+ cryptoCurrencies,
21
+ fiatCurrencies,
22
+ });
23
+ return actions;
24
+ };
25
+ exports.parseCsvFileToAccountActions = parseCsvFileToAccountActions;
26
+ //# sourceMappingURL=parseCsvFileToAccountActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCsvFileToAccountActions.js","sourceRoot":"","sources":["../parseCsvFileToAccountActions.ts"],"names":[],"mappings":";;;AACA,mDAA+C;AAC/C,6DAAyD;AACzD,iFAA6E;AAC7E,iDAA6C;AAWtC,MAAM,4BAA4B,GAAG,KAAK,EAAE,EACjD,IAAI,EACJ,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,EACvD,SAAS,EACT,gBAAgB,EAChB,cAAc,GACyB,EAEvC,EAAE;IACF,MAAM,IAAI,GAAG,MAAM,IAAA,uCAAkB,EAAC,IAAI,CAAC,CAAA;IAC3C,MAAM,IAAI,GAAG,IAAA,6BAAa,EAAC;QACzB,IAAI,EAAE,IAAA,2BAAY,EAAC,IAAI,CAAC;QACxB,SAAS;KACV,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,IAAA,2DAA4B,EAAC;QAC3C,IAAI;QACJ,OAAO;QACP,OAAO;QACP,cAAc;QACd,SAAS;QACT,gBAAgB;QAChB,cAAc;KACf,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAxBY,QAAA,4BAA4B,gCAwBxC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvFileToText = void 0;
4
+ const encoding_japanese_1 = require("encoding-japanese");
5
+ const parseCsvFileToText = async (file) => {
6
+ const buffers = await file.arrayBuffer();
7
+ const codes = new Uint8Array(buffers);
8
+ const unicodeString = (0, encoding_japanese_1.convert)(codes, {
9
+ to: 'UNICODE',
10
+ type: 'string',
11
+ });
12
+ return unicodeString;
13
+ };
14
+ exports.parseCsvFileToText = parseCsvFileToText;
15
+ //# sourceMappingURL=parseCsvFileToText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCsvFileToText.js","sourceRoot":"","sources":["../parseCsvFileToText.ts"],"names":[],"mappings":";;;AAAA,yDAA2C;AAEpC,MAAM,kBAAkB,GAAG,KAAK,EAAE,IAAU,EAAmB,EAAE;IACtE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;IACxC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;IACrC,MAAM,aAAa,GAAG,IAAA,2BAAO,EAAC,KAAK,EAAE;QACnC,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,QAAQ;KACf,CAAC,CAAA;IACF,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AARY,QAAA,kBAAkB,sBAQ9B"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAssetByComponent = void 0;
4
+ const nft_1 = require("./nft");
5
+ const createAssetByComponent = ({ row, service, symbolAssetMap, component, cryptoCurrencies, fiatCurrencies, }) => {
6
+ switch (component.type) {
7
+ case 'custom': {
8
+ switch (component.assetType) {
9
+ case 'CryptoCurrency': {
10
+ const asset = cryptoCurrencies.find((cryptoCurrency) => cryptoCurrency.id === component.assetId);
11
+ if (asset === undefined) {
12
+ throw new Error(`asset not found: ${component.assetId}`);
13
+ }
14
+ return asset;
15
+ }
16
+ case 'FiatCurrency': {
17
+ const asset = fiatCurrencies.find((fiatCurrency) => fiatCurrency.id === component.assetId);
18
+ if (asset === undefined) {
19
+ throw new Error(`asset not found: ${component.assetId}`);
20
+ }
21
+ return asset;
22
+ }
23
+ case 'Nft': {
24
+ return {
25
+ type: 'Nft',
26
+ id: component.assetId,
27
+ };
28
+ }
29
+ }
30
+ throw new Error('Not reachable');
31
+ }
32
+ case 'column': {
33
+ const symbol = row[component.column];
34
+ if (typeof symbol !== 'string') {
35
+ throw new TypeError(`symbol needs to be string but got ${typeof symbol}`);
36
+ }
37
+ if (symbolAssetMap !== undefined && symbol in symbolAssetMap) {
38
+ const assetId = symbolAssetMap[symbol];
39
+ const asset = cryptoCurrencies.find((cryptoCurrency) => cryptoCurrency.id === assetId);
40
+ if (asset !== undefined) {
41
+ return asset;
42
+ }
43
+ throw new Error(`asset not found: ${assetId}`);
44
+ }
45
+ const upperSymbol = symbol.toUpperCase();
46
+ const fiat = fiatCurrencies.find((fiatCurrency) => fiatCurrency.symbol.toUpperCase() === upperSymbol);
47
+ if (fiat !== undefined) {
48
+ return fiat;
49
+ }
50
+ const crypto = cryptoCurrencies.find((cryptoCurrency) => cryptoCurrency.symbol.toUpperCase() === upperSymbol);
51
+ if (crypto !== undefined) {
52
+ return crypto;
53
+ }
54
+ throw new Error(`asset not found: ${symbol}`);
55
+ }
56
+ case 'nft': {
57
+ return (0, nft_1.createNftByNftComponent)({ row, service, component });
58
+ }
59
+ }
60
+ };
61
+ exports.createAssetByComponent = createAssetByComponent;
62
+ //# sourceMappingURL=asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/asset.ts"],"names":[],"mappings":";;;AAIA,+BAA+C;AAWxC,MAAM,sBAAsB,GAAG,CAAC,EACrC,GAAG,EACH,OAAO,EACP,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GACmB,EAAuC,EAAE;IAC1E,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,QAAQ,SAAS,CAAC,SAAS,EAAE,CAAC;gBAC5B,KAAK,gBAAgB,CAAC,CAAC,CAAC;oBACtB,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,KAAK,SAAS,CAAC,OAAO,CAC5D,CAAA;oBACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBACxB,MAAM,IAAI,KAAK,CAAC,oBAAoB,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;oBAC1D,CAAC;oBACD,OAAO,KAAK,CAAA;gBACd,CAAC;gBACD,KAAK,cAAc,CAAC,CAAC,CAAC;oBACpB,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,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,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,WAAW,CACpE,CAAA;YACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YAED,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAClC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,WAAW,CACxE,CAAA;YACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAA;YACf,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAA;QAC/C,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,OAAO,IAAA,6BAAuB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AA5EY,QAAA,sBAAsB,0BA4ElC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchCondition = void 0;
4
+ const matchCondition = ({ row, component, }) => {
5
+ const { column, pattern } = component;
6
+ const value = row[column];
7
+ if (typeof pattern === 'string' || typeof pattern === 'number') {
8
+ return value === pattern;
9
+ }
10
+ switch (pattern.type) {
11
+ case 'defined': {
12
+ return value !== undefined;
13
+ }
14
+ case 'undefined': {
15
+ return value === undefined;
16
+ }
17
+ case 'in': {
18
+ if (value === undefined || typeof value === 'object') {
19
+ return false;
20
+ }
21
+ return pattern.values.includes(value);
22
+ }
23
+ case 'not-in': {
24
+ if (value === undefined || typeof value === 'object') {
25
+ return false;
26
+ }
27
+ return !pattern.values.includes(value);
28
+ }
29
+ }
30
+ };
31
+ exports.matchCondition = matchCondition;
32
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/condition.ts"],"names":[],"mappings":";;;AASO,MAAM,cAAc,GAAG,CAAC,EAC7B,GAAG,EACH,SAAS,GACgB,EAAW,EAAE;IACtC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;IACrC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;IACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC/D,OAAO,KAAK,KAAK,OAAO,CAAA;IAC1B,CAAC;IACD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,KAAK,KAAK,SAAS,CAAA;QAC5B,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,KAAK,KAAK,SAAS,CAAA;QAC5B,CAAC;QACD,KAAK,IAAI,CAAC,CAAC,CAAC;YACV,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrD,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrD,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AA7BY,QAAA,cAAc,kBA6B1B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvRowToNormalAction = void 0;
4
+ var parseCsvRowToNormalAction_1 = require("./parseCsvRowToNormalAction");
5
+ Object.defineProperty(exports, "parseCsvRowToNormalAction", { enumerable: true, get: function () { return parseCsvRowToNormalAction_1.parseCsvRowToNormalAction; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/index.ts"],"names":[],"mappings":";;;AAAA,yEAAuE;AAA9D,sIAAA,yBAAyB,OAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNftByNftComponent = void 0;
4
+ const text_1 = require("./text");
5
+ const createNftByNftComponent = ({ row, service, component, }) => {
6
+ const id = component.id
7
+ .map((idComponent) => (0, text_1.createTextByComponent)({ row, service, component: idComponent }))
8
+ .join('');
9
+ return {
10
+ type: 'Nft',
11
+ id,
12
+ };
13
+ };
14
+ exports.createNftByNftComponent = createNftByNftComponent;
15
+ //# sourceMappingURL=nft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nft.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/nft.ts"],"names":[],"mappings":";;;AAIA,iCAA8C;AAQvC,MAAM,uBAAuB,GAAG,CAAC,EACtC,GAAG,EACH,OAAO,EACP,SAAS,GACyB,EAAO,EAAE;IAC3C,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE;SACpB,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACnB,IAAA,4BAAqB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAChE;SACA,IAAI,CAAC,EAAE,CAAC,CAAA;IACX,OAAO;QACL,IAAI,EAAE,KAAK;QACX,EAAE;KACH,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,uBAAuB,2BAcnC"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvRowToNormalAction = void 0;
4
+ const core_1 = require("@0xtorch/core");
5
+ const condition_1 = require("./condition");
6
+ const nft_1 = require("./nft");
7
+ const text_1 = require("./text");
8
+ const timestamp_1 = require("./timestamp");
9
+ const transfer_1 = require("./transfer");
10
+ const parseCsvRowToNormalAction = ({ row, service, parsers, symbolAssetMap, accountId, cryptoCurrencies, fiatCurrencies, }) => {
11
+ for (const parser of parsers) {
12
+ try {
13
+ const action = parseCsvRowToNormalActionByParser({
14
+ row,
15
+ service,
16
+ parser,
17
+ symbolAssetMap,
18
+ accountId,
19
+ cryptoCurrencies,
20
+ fiatCurrencies,
21
+ });
22
+ if (action !== undefined) {
23
+ return action;
24
+ }
25
+ }
26
+ catch (error) {
27
+ console.debug(error);
28
+ continue;
29
+ }
30
+ }
31
+ return undefined;
32
+ };
33
+ exports.parseCsvRowToNormalAction = parseCsvRowToNormalAction;
34
+ const parseCsvRowToNormalActionByParser = ({ row, service, parser, symbolAssetMap, accountId, cryptoCurrencies, fiatCurrencies, }) => {
35
+ for (const condition of parser.conditions) {
36
+ if (!(0, condition_1.matchCondition)({ row, component: condition })) {
37
+ return undefined;
38
+ }
39
+ }
40
+ const baseAction = {
41
+ action: parser.action,
42
+ evidence: 'system-rule',
43
+ timestamp: (0, timestamp_1.createTimestampByRow)({ row, column: parser.timestamp }),
44
+ comment: parser.comment === undefined
45
+ ? undefined
46
+ : parser.comment
47
+ .map((component) => (0, text_1.createTextByComponent)({ row, service, component }))
48
+ .join(''),
49
+ app: undefined,
50
+ transfers: parser.transfers.map((component) => (0, transfer_1.createTransferByComponent)({
51
+ row,
52
+ service,
53
+ symbolAssetMap,
54
+ component,
55
+ accountId,
56
+ cryptoCurrencies,
57
+ fiatCurrencies,
58
+ })),
59
+ crossId: parser.crossId === undefined
60
+ ? undefined
61
+ : parser.crossId
62
+ .map((component) => (0, text_1.createTextByComponent)({ row, service, component }))
63
+ .join(''),
64
+ crossType: parser.crossType,
65
+ loanId: parser.loanId === undefined
66
+ ? undefined
67
+ : parser.loanId
68
+ .map((component) => (0, text_1.createTextByComponent)({ row, service, component }))
69
+ .join(''),
70
+ target: parser.target === undefined
71
+ ? undefined
72
+ : (0, nft_1.createNftByNftComponent)({ row, service, component: parser.target }),
73
+ };
74
+ const action = (0, core_1.parseBaseNormalActionToNormalAction)(baseAction);
75
+ const source = parser.source
76
+ .map((component) => (0, text_1.createTextByComponent)({ row, service, component }))
77
+ .join('');
78
+ return {
79
+ action,
80
+ source,
81
+ };
82
+ };
83
+ //# sourceMappingURL=parseCsvRowToNormalAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCsvRowToNormalAction.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/parseCsvRowToNormalAction.ts"],"names":[],"mappings":";;;AAMA,wCAAmE;AAEnE,2CAA4C;AAC5C,+BAA+C;AAC/C,iCAA8C;AAC9C,2CAAkD;AAClD,yCAAsD;AAmB/C,MAAM,yBAAyB,GAAG,CAAC,EACxC,GAAG,EACH,OAAO,EACP,OAAO,EACP,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GACsB,EAAwC,EAAE;IAC9E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,iCAAiC,CAAC;gBAC/C,GAAG;gBACH,OAAO;gBACP,MAAM;gBACN,cAAc;gBACd,SAAS;gBACT,gBAAgB;gBAChB,cAAc;aACf,CAAC,CAAA;YACF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAA;YACf,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACpB,SAAQ;QACV,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AA9BY,QAAA,yBAAyB,6BA8BrC;AAYD,MAAM,iCAAiC,GAAG,CAAC,EACzC,GAAG,EACH,OAAO,EACP,MAAM,EACN,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GAC8B,EA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ACzB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM,CAAC,MAAM;iBACV,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACjB,IAAA,4BAAqB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CACnD;iBACA,IAAI,CAAC,EAAE,CAAC;QACjB,MAAM,EACJ,MAAM,CAAC,MAAM,KAAK,SAAS;YACzB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAA,6BAAuB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;KAC1E,CAAA;IAED,MAAM,MAAM,GAAG,IAAA,0CAAmC,EAAC,UAAU,CAAC,CAAA;IAC9D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM;SACzB,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,4BAAqB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;SACtE,IAAI,CAAC,EAAE,CAAC,CAAA;IAEX,OAAO;QACL,MAAM;QACN,MAAM;KACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTextByComponent = void 0;
4
+ const big_decimal_1 = require("@0xtorch/big-decimal");
5
+ const createTextByComponent = ({ row, service, component, }) => {
6
+ if (typeof component === 'string') {
7
+ return component;
8
+ }
9
+ switch (component.type) {
10
+ case 'service': {
11
+ return service;
12
+ }
13
+ case 'column': {
14
+ const value = row[component.column];
15
+ if (value === undefined) {
16
+ return '';
17
+ }
18
+ else if (typeof value === 'string') {
19
+ return value;
20
+ }
21
+ else if (typeof value === 'number') {
22
+ return value.toString();
23
+ }
24
+ else {
25
+ return (0, big_decimal_1.toStringBigDecimal)(value);
26
+ }
27
+ }
28
+ }
29
+ };
30
+ exports.createTextByComponent = createTextByComponent;
31
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/text.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AAWlD,MAAM,qBAAqB,GAAG,CAAC,EACpC,GAAG,EACH,OAAO,EACP,SAAS,GACuB,EAAU,EAAE;IAC5C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,EAAE,CAAA;YACX,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAA;YACd,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;YACzB,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAA,gCAAkB,EAAC,KAAK,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,qBAAqB,yBAyBjC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTimestampByRow = void 0;
4
+ const createTimestampByRow = ({ row, column, }) => {
5
+ const timestamp = row[column];
6
+ if (typeof timestamp !== 'number') {
7
+ throw new TypeError(`timestamp needs to be number but got ${typeof timestamp}`);
8
+ }
9
+ return timestamp;
10
+ };
11
+ exports.createTimestampByRow = createTimestampByRow;
12
+ //# sourceMappingURL=timestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/timestamp.ts"],"names":[],"mappings":";;;AAOO,MAAM,oBAAoB,GAAG,CAAC,EACnC,GAAG,EACH,MAAM,GACyB,EAAU,EAAE;IAC3C,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CACjB,wCAAwC,OAAO,SAAS,EAAE,CAC3D,CAAA;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAXY,QAAA,oBAAoB,wBAWhC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransferByComponent = void 0;
4
+ const big_decimal_1 = require("@0xtorch/big-decimal");
5
+ const asset_1 = require("./asset");
6
+ const createTransferByComponent = ({ row, service, symbolAssetMap, component, accountId, cryptoCurrencies, fiatCurrencies, }) => {
7
+ const { direction, asset: assetComponent, amount: amountComponent, } = component;
8
+ const amount = row[amountComponent];
9
+ if (typeof amount !== 'object') {
10
+ throw new TypeError(`amount needs to be BigDecimal but got ${typeof amount}`);
11
+ }
12
+ return {
13
+ from: direction === 'in' ? undefined : accountId,
14
+ to: direction === 'in' ? accountId : undefined,
15
+ asset: (0, asset_1.createAssetByComponent)({
16
+ row,
17
+ service,
18
+ symbolAssetMap,
19
+ component: assetComponent,
20
+ cryptoCurrencies,
21
+ fiatCurrencies,
22
+ }),
23
+ amount: (0, big_decimal_1.absoluteValue)(amount),
24
+ price: undefined,
25
+ direction,
26
+ };
27
+ };
28
+ exports.createTransferByComponent = createTransferByComponent;
29
+ //# sourceMappingURL=transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../parseCsvRowToNormalAction/transfer.ts"],"names":[],"mappings":";;;AAAA,sDAAoD;AAKpD,mCAAgD;AAYzC,MAAM,yBAAyB,GAAG,CAAC,EACxC,GAAG,EACH,OAAO,EACP,cAAc,EACd,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,cAAc,GACsB,EAAY,EAAE;IAClD,MAAM,EACJ,SAAS,EACT,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,eAAe,GACxB,GAAG,SAAS,CAAA;IAEb,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,CAAA;IACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CACjB,yCAAyC,OAAO,MAAM,EAAE,CACzD,CAAA;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAChD,EAAE,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC9C,KAAK,EAAE,IAAA,8BAAsB,EAAC;YAC5B,GAAG;YACH,OAAO;YACP,cAAc;YACd,SAAS,EAAE,cAAc;YACzB,gBAAgB;YAChB,cAAc;SACf,CAAC;QACF,MAAM,EAAE,IAAA,2BAAa,EAAC,MAAM,CAAC;QAC7B,KAAK,EAAE,SAAS;QAChB,SAAS;KACV,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,yBAAyB,6BAqCrC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvRowsToAccountActions = void 0;
4
+ const big_decimal_1 = require("@0xtorch/big-decimal");
5
+ const core_1 = require("@0xtorch/core");
6
+ const parseCsvRowToNormalAction_1 = require("./parseCsvRowToNormalAction");
7
+ const parseCsvRowsToAccountActions = ({ rows, service, parsers, symbolAssetMap, accountId, cryptoCurrencies, fiatCurrencies, }) => {
8
+ const sortedCryptoCurrencies = cryptoCurrencies.toSorted((a, b) => {
9
+ if (a.market.marketCapUsd === undefined) {
10
+ return -1;
11
+ }
12
+ if (b.market.marketCapUsd === undefined) {
13
+ return 1;
14
+ }
15
+ return (0, big_decimal_1.greaterThan)(a.market.marketCapUsd, b.market.marketCapUsd) ? -1 : 1;
16
+ });
17
+ const actions = rows.flatMap((row) => {
18
+ const result = (0, parseCsvRowToNormalAction_1.parseCsvRowToNormalAction)({
19
+ row,
20
+ service,
21
+ parsers,
22
+ symbolAssetMap,
23
+ accountId,
24
+ cryptoCurrencies: sortedCryptoCurrencies,
25
+ fiatCurrencies,
26
+ });
27
+ if (result === undefined) {
28
+ return [];
29
+ }
30
+ const { action, source } = result;
31
+ return (0, core_1.parseNormalActionToAccountActions)({
32
+ action,
33
+ accountIds: new Set([accountId]),
34
+ source,
35
+ });
36
+ });
37
+ const mut_sources = [];
38
+ const mut_actions = [];
39
+ for (const action of actions) {
40
+ mut_actions.push({
41
+ ...action,
42
+ order: mut_sources.filter((source) => source === action.source).length,
43
+ });
44
+ mut_sources.push(action.source);
45
+ }
46
+ return mut_actions;
47
+ };
48
+ exports.parseCsvRowsToAccountActions = parseCsvRowsToAccountActions;
49
+ //# sourceMappingURL=parseCsvRowsToAccountActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCsvRowsToAccountActions.js","sourceRoot":"","sources":["../parseCsvRowsToAccountActions.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,wCAAiE;AACjE,2EAAuE;AAahE,MAAM,4BAA4B,GAAG,CAAC,EAC3C,IAAI,EACJ,OAAO,EACP,OAAO,EACP,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GACyB,EAA4B,EAAE;IAErE,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAChE,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,CAAC,CAAC,CAAA;QACX,CAAC;QACD,IAAI,CA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,gCAkDxC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvText = void 0;
4
+ const papaparse_1 = require("papaparse");
5
+ const zod_1 = require("zod");
6
+ const schema = zod_1.z.record(zod_1.z.string());
7
+ const parseCsvText = (text) => {
8
+ const result = (0, papaparse_1.parse)(text, {
9
+ header: true,
10
+ skipEmptyLines: true,
11
+ });
12
+ return result.data.map((row) => schema.parse(row));
13
+ };
14
+ exports.parseCsvText = parseCsvText;
15
+ //# sourceMappingURL=parseCsvText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCsvText.js","sourceRoot":"","sources":["../parseCsvText.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AACjC,6BAAuB;AAEvB,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAA;AAE5B,MAAM,YAAY,GAAG,CAC1B,IAAY,EAC0B,EAAE;IACxC,MAAM,MAAM,GAAG,IAAA,iBAAK,EAAC,IAAI,EAAE;QACzB,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE,IAAI;KACrB,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AACpD,CAAC,CAAA;AARY,QAAA,YAAY,gBAQxB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatterSchema = exports.formatterValueTypeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.formatterValueTypeSchema = zod_1.z.union([
6
+ zod_1.z.literal('blank'),
7
+ zod_1.z.literal('string'),
8
+ zod_1.z.literal('big-decimal'),
9
+ zod_1.z.literal('big-decimal-positive'),
10
+ zod_1.z.literal('big-decimal-negative'),
11
+ zod_1.z.literal('iso8601'),
12
+ zod_1.z.literal('datetime-jp'),
13
+ ]);
14
+ exports.formatterSchema = zod_1.z.record(zod_1.z.array(exports.formatterValueTypeSchema));
15
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../schemas/formatter.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,wBAAwB,GAAG,OAAC,CAAC,KAAK,CAAC;IAC9C,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAClB,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACnB,OAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IACxB,OAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;IACjC,OAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;IACjC,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IACpB,OAAC,CAAC,OAAO,CAAC,aAAa,CAAC;CACzB,CAAC,CAAA;AAEW,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,gCAAwB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatterValueSchema = exports.datetimeJpTextSchema = exports.iso8601TextSchema = exports.bigDecimalNegativeTextSchema = exports.bigDecimalPositiveTextSchema = exports.bigDecimalTextSchema = exports.stringTextSchema = exports.blankTextSchema = void 0;
4
+ const big_decimal_1 = require("@0xtorch/big-decimal");
5
+ const zod_1 = require("zod");
6
+ exports.blankTextSchema = zod_1.z.literal('').transform(() => undefined);
7
+ exports.stringTextSchema = zod_1.z.string();
8
+ exports.bigDecimalTextSchema = zod_1.z
9
+ .string()
10
+ .regex(/^-?\d+(\.\d+)?$/)
11
+ .transform((v) => (0, big_decimal_1.createBigDecimal)(v));
12
+ exports.bigDecimalPositiveTextSchema = zod_1.z
13
+ .string()
14
+ .regex(/^\d+(\.\d+)?$/)
15
+ .transform((v) => (0, big_decimal_1.createBigDecimal)(v));
16
+ exports.bigDecimalNegativeTextSchema = zod_1.z
17
+ .string()
18
+ .regex(/^-\d+(\.\d+)?$/)
19
+ .transform((v) => (0, big_decimal_1.createBigDecimal)(v));
20
+ exports.iso8601TextSchema = zod_1.z
21
+ .string()
22
+ .regex(/^\d{4}-?\d\d-?\d\d(?:(T|( ))\d\d(?::?\d\d(?::?\d\d(?:\.\d+)?)?)?( )?(?:Z|[+-]\d\d:?\d\d)?)?$/)
23
+ .transform((v) => new Date(v).getTime());
24
+ exports.datetimeJpTextSchema = zod_1.z
25
+ .string()
26
+ .regex(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/)
27
+ .transform((v) => new Date(`${v}+09:00`).getTime());
28
+ exports.formatterValueSchema = zod_1.z.union([
29
+ exports.blankTextSchema,
30
+ exports.stringTextSchema,
31
+ exports.bigDecimalTextSchema,
32
+ exports.bigDecimalPositiveTextSchema,
33
+ exports.bigDecimalNegativeTextSchema,
34
+ exports.iso8601TextSchema,
35
+ exports.datetimeJpTextSchema,
36
+ ]);
37
+ //# sourceMappingURL=formatterTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatterTypes.js","sourceRoot":"","sources":["../../schemas/formatterTypes.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AACvD,6BAAuB;AAEV,QAAA,eAAe,GAAG,OAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAE1D,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAA;AAE7B,QAAA,oBAAoB,GAAG,OAAC;KAClC,MAAM,EAAE;KACR,KAAK,CAAC,iBAAiB,CAAC;KACxB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,CAAC,CAAC,CAAC,CAAA;AAE3B,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,EAAE;KACR,KAAK,CAAC,eAAe,CAAC;KACtB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,CAAC,CAAC,CAAC,CAAA;AAE3B,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,EAAE;KACR,KAAK,CAAC,gBAAgB,CAAC;KACvB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,CAAC,CAAC,CAAC,CAAA;AAE3B,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,EAAE;KACR,KAAK,CACJ,8FAA8F,CAC/F;KACA,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAG7B,QAAA,oBAAoB,GAAG,OAAC;KAClC,MAAM,EAAE;KACR,KAAK,CAAC,yCAAyC,CAAC;KAChD,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAExC,QAAA,oBAAoB,GAAG,OAAC,CAAC,KAAK,CAAC;IAC1C,uBAAe;IACf,wBAAgB;IAChB,4BAAoB;IACpB,oCAA4B;IAC5B,oCAA4B;IAC5B,yBAAiB;IACjB,4BAAoB;CACrB,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.csvFormatSchema = void 0;
4
+ var schemas_1 = require("./schemas");
5
+ Object.defineProperty(exports, "csvFormatSchema", { enumerable: true, get: function () { return schemas_1.csvFormatSchema; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../schemas/index.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAAlC,0GAAA,eAAe,OAAA"}