@0xtorch/csv 0.0.74 → 0.0.76

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 (118) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/getCsvRowCount.js +1 -0
  3. package/_cjs/getCsvRowCount.js.map +1 -1
  4. package/_cjs/hasValidHeaderRow.js +7 -7
  5. package/_cjs/hasValidHeaderRow.js.map +1 -1
  6. package/_cjs/parseCsvFileToActions.js +2 -1
  7. package/_cjs/parseCsvFileToActions.js.map +1 -1
  8. package/_cjs/parseRowsToActions/allValue.js +9 -1
  9. package/_cjs/parseRowsToActions/allValue.js.map +1 -1
  10. package/_cjs/parseRowsToActions/asset.js +7 -4
  11. package/_cjs/parseRowsToActions/asset.js.map +1 -1
  12. package/_cjs/parseRowsToActions/index.js +4 -1
  13. package/_cjs/parseRowsToActions/index.js.map +1 -1
  14. package/_cjs/parseRowsToActions/joinValue.js +10 -3
  15. package/_cjs/parseRowsToActions/joinValue.js.map +1 -1
  16. package/_cjs/parseRowsToActions/matchValue.js +2 -2
  17. package/_cjs/parseRowsToActions/matchValue.js.map +1 -1
  18. package/_cjs/parseRowsToActions/mathValue.js +17 -6
  19. package/_cjs/parseRowsToActions/mathValue.js.map +1 -1
  20. package/_cjs/parseRowsToActions/parse.js +9 -6
  21. package/_cjs/parseRowsToActions/parse.js.map +1 -1
  22. package/_cjs/parseRowsToActions/simpleValue.js +4 -1
  23. package/_cjs/parseRowsToActions/simpleValue.js.map +1 -1
  24. package/_cjs/parseRowsToActions/sliceValue.js +7 -3
  25. package/_cjs/parseRowsToActions/sliceValue.js.map +1 -1
  26. package/_cjs/parseRowsToActions/splitValue.js +2 -2
  27. package/_cjs/parseRowsToActions/splitValue.js.map +1 -1
  28. package/_cjs/parseRowsToActions/transfer.js +12 -8
  29. package/_cjs/parseRowsToActions/transfer.js.map +1 -1
  30. package/_cjs/schemas/parser.js +5 -1
  31. package/_cjs/schemas/parser.js.map +1 -1
  32. package/_cjs/streamCsvToActions.js +5 -1
  33. package/_cjs/streamCsvToActions.js.map +1 -1
  34. package/_esm/getCsvRowCount.js +1 -0
  35. package/_esm/getCsvRowCount.js.map +1 -1
  36. package/_esm/hasValidHeaderRow.js +7 -7
  37. package/_esm/hasValidHeaderRow.js.map +1 -1
  38. package/_esm/parseCsvFileToActions.js +2 -1
  39. package/_esm/parseCsvFileToActions.js.map +1 -1
  40. package/_esm/parseRowsToActions/allValue.js +9 -1
  41. package/_esm/parseRowsToActions/allValue.js.map +1 -1
  42. package/_esm/parseRowsToActions/asset.js +7 -4
  43. package/_esm/parseRowsToActions/asset.js.map +1 -1
  44. package/_esm/parseRowsToActions/index.js +4 -1
  45. package/_esm/parseRowsToActions/index.js.map +1 -1
  46. package/_esm/parseRowsToActions/joinValue.js +10 -3
  47. package/_esm/parseRowsToActions/joinValue.js.map +1 -1
  48. package/_esm/parseRowsToActions/matchValue.js +2 -2
  49. package/_esm/parseRowsToActions/matchValue.js.map +1 -1
  50. package/_esm/parseRowsToActions/mathValue.js +17 -6
  51. package/_esm/parseRowsToActions/mathValue.js.map +1 -1
  52. package/_esm/parseRowsToActions/parse.js +9 -6
  53. package/_esm/parseRowsToActions/parse.js.map +1 -1
  54. package/_esm/parseRowsToActions/simpleValue.js +4 -1
  55. package/_esm/parseRowsToActions/simpleValue.js.map +1 -1
  56. package/_esm/parseRowsToActions/sliceValue.js +7 -3
  57. package/_esm/parseRowsToActions/sliceValue.js.map +1 -1
  58. package/_esm/parseRowsToActions/splitValue.js +2 -2
  59. package/_esm/parseRowsToActions/splitValue.js.map +1 -1
  60. package/_esm/parseRowsToActions/transfer.js +12 -8
  61. package/_esm/parseRowsToActions/transfer.js.map +1 -1
  62. package/_esm/schemas/parser.js +4 -0
  63. package/_esm/schemas/parser.js.map +1 -1
  64. package/_esm/streamCsvToActions.js +5 -1
  65. package/_esm/streamCsvToActions.js.map +1 -1
  66. package/_types/getCsvRowCount.d.ts.map +1 -1
  67. package/_types/hasValidHeaderRow.d.ts.map +1 -1
  68. package/_types/parseCsvFileToActions.d.ts +2 -1
  69. package/_types/parseCsvFileToActions.d.ts.map +1 -1
  70. package/_types/parseRowsToActions/allValue.d.ts +2 -1
  71. package/_types/parseRowsToActions/allValue.d.ts.map +1 -1
  72. package/_types/parseRowsToActions/asset.d.ts +6 -3
  73. package/_types/parseRowsToActions/asset.d.ts.map +1 -1
  74. package/_types/parseRowsToActions/index.d.ts +3 -1
  75. package/_types/parseRowsToActions/index.d.ts.map +1 -1
  76. package/_types/parseRowsToActions/joinValue.d.ts +2 -1
  77. package/_types/parseRowsToActions/joinValue.d.ts.map +1 -1
  78. package/_types/parseRowsToActions/matchValue.d.ts +2 -1
  79. package/_types/parseRowsToActions/matchValue.d.ts.map +1 -1
  80. package/_types/parseRowsToActions/mathValue.d.ts +2 -1
  81. package/_types/parseRowsToActions/mathValue.d.ts.map +1 -1
  82. package/_types/parseRowsToActions/parse.d.ts +2 -1
  83. package/_types/parseRowsToActions/parse.d.ts.map +1 -1
  84. package/_types/parseRowsToActions/simpleValue.d.ts +2 -1
  85. package/_types/parseRowsToActions/simpleValue.d.ts.map +1 -1
  86. package/_types/parseRowsToActions/sliceValue.d.ts +2 -1
  87. package/_types/parseRowsToActions/sliceValue.d.ts.map +1 -1
  88. package/_types/parseRowsToActions/splitValue.d.ts +2 -1
  89. package/_types/parseRowsToActions/splitValue.d.ts.map +1 -1
  90. package/_types/parseRowsToActions/transfer.d.ts +2 -1
  91. package/_types/parseRowsToActions/transfer.d.ts.map +1 -1
  92. package/_types/schemas/format.d.ts +9360 -0
  93. package/_types/schemas/format.d.ts.map +1 -1
  94. package/_types/schemas/parser.d.ts +21287 -0
  95. package/_types/schemas/parser.d.ts.map +1 -1
  96. package/_types/streamCsvToActions.d.ts +2 -1
  97. package/_types/streamCsvToActions.d.ts.map +1 -1
  98. package/getCsvRowCount.ts +1 -0
  99. package/hasValidHeaderRow.ts +10 -7
  100. package/package.json +1 -1
  101. package/parseCsvFileToActions.ts +3 -0
  102. package/parseRowsToActions/allValue.ts +10 -0
  103. package/parseRowsToActions/asset.ts +10 -1
  104. package/parseRowsToActions/index.ts +6 -0
  105. package/parseRowsToActions/joinValue.ts +14 -1
  106. package/parseRowsToActions/matchValue.ts +3 -1
  107. package/parseRowsToActions/mathValue.ts +20 -3
  108. package/parseRowsToActions/parse.ts +18 -5
  109. package/parseRowsToActions/simpleValue.ts +5 -0
  110. package/parseRowsToActions/sliceValue.ts +9 -1
  111. package/parseRowsToActions/splitValue.ts +3 -1
  112. package/parseRowsToActions/transfer.ts +15 -5
  113. package/schemas/parser.ts +5 -0
  114. package/streamCsvToActions.ts +6 -0
  115. package/tests/.DS_Store +0 -0
  116. package/tests/okx-trade-jst-backup.csv +0 -18
  117. package/tests/okx-trade-jst.csv +0 -3
  118. package/tests/okx.ts +0 -275
@@ -1,6 +1,7 @@
1
1
  import type { Action, CryptoCurrency, FiatCurrency } from '@0xtorch/core';
2
2
  import type { CsvFormat } from './types';
3
3
  type StreamCsvToActionsParameters = {
4
+ fileId: string;
4
5
  file: File | string;
5
6
  encoding: string;
6
7
  format: CsvFormat;
@@ -17,6 +18,6 @@ type StreamCsvToActionsReturnTypes = {
17
18
  headerRow?: string[];
18
19
  ignoreRows: string[][];
19
20
  };
20
- export declare const streamCsvToActions: ({ file, encoding, format, cryptoes, fiats, save, chunkSize, }: StreamCsvToActionsParameters) => Promise<StreamCsvToActionsReturnTypes>;
21
+ export declare const streamCsvToActions: ({ fileId, file, encoding, format, cryptoes, fiats, save, chunkSize, }: StreamCsvToActionsParameters) => Promise<StreamCsvToActionsReturnTypes>;
21
22
  export {};
22
23
  //# sourceMappingURL=streamCsvToActions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"streamCsvToActions.d.ts","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKzE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAA;AAEtD,KAAK,4BAA4B,GAAG;IAClC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,kEAQ5B,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,CAyOtE,CAAA"}
1
+ {"version":3,"file":"streamCsvToActions.d.ts","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKzE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAA;AAEtD,KAAK,4BAA4B,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,IAAI,GAAG,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,0EAS5B,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,CA6OtE,CAAA"}
package/getCsvRowCount.ts CHANGED
@@ -14,6 +14,7 @@ export const getCsvRowCount = async ({
14
14
  parse(file, {
15
15
  header: false,
16
16
  skipEmptyLines: true,
17
+ newline: '\n',
17
18
  complete: () => {
18
19
  resolve()
19
20
  },
@@ -24,6 +24,7 @@ export const hasValidHeaderRow = async ({
24
24
  parse(file, {
25
25
  header: false,
26
26
  skipEmptyLines: true,
27
+ newline: '\n',
27
28
  encoding,
28
29
  complete: () => {
29
30
  resolve()
@@ -42,24 +43,26 @@ export const hasValidHeaderRow = async ({
42
43
  return
43
44
  }
44
45
 
46
+ const cells = result.data.map((v) =>
47
+ typeof v === 'string'
48
+ ? v.replaceAll('\r', '').replaceAll('\u{65279}', '').trim()
49
+ : v,
50
+ )
51
+
45
52
  if (headerStartColumnRegExps !== undefined) {
46
53
  for (const [index, column] of headerStartColumnRegExps.entries()) {
47
- const cell = result.data[index]
54
+ const cell = cells[index]
48
55
  if (typeof cell !== 'string') {
49
56
  return
50
57
  }
51
- const value = cell
52
- .replaceAll('\r', '')
53
- .replaceAll('\u{65279}', '')
54
- .trim()
55
- if (!column.test(value)) {
58
+ if (!column.test(cell)) {
56
59
  return
57
60
  }
58
61
  }
59
62
  }
60
63
 
61
64
  for (const key of Object.keys(format.formatter)) {
62
- if (!result.data.includes(key)) {
65
+ if (!cells.includes(key)) {
63
66
  parser.abort()
64
67
  return
65
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/csv",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "Cryptorch CSV extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -12,6 +12,7 @@ import { parseRowsToActions } from './parseRowsToActions'
12
12
  import type { CsvFormat } from './types'
13
13
 
14
14
  type ParseCsvFileToActionsParameters = {
15
+ fileId: string
15
16
  file: File
16
17
  format: CsvFormat
17
18
  cryptoes: readonly CryptoCurrency[]
@@ -27,6 +28,7 @@ type ParseCsvFileToActionsReturnTypes = {
27
28
  }
28
29
 
29
30
  export const parseCsvFileToActions = async ({
31
+ fileId,
30
32
  file,
31
33
  format: { service, formatter, parser, symbolAssetMap },
32
34
  cryptoes,
@@ -45,6 +47,7 @@ export const parseCsvFileToActions = async ({
45
47
  parser,
46
48
  symbolAssetMap,
47
49
  service,
50
+ fileId,
48
51
  cryptoes,
49
52
  fiats,
50
53
  errorLogger,
@@ -12,10 +12,12 @@ export const getAllValue = ({
12
12
  schema,
13
13
  rows,
14
14
  service,
15
+ fileId,
15
16
  }: {
16
17
  schema: z.infer<typeof allValueSchema>
17
18
  rows: readonly FormattedRow[]
18
19
  service: string
20
+ fileId: string
19
21
  }) => {
20
22
  if (typeof schema === 'string') {
21
23
  return schema
@@ -27,11 +29,15 @@ export const getAllValue = ({
27
29
  rows,
28
30
  })
29
31
  }
32
+ case 'file-id': {
33
+ return fileId
34
+ }
30
35
  case 'join': {
31
36
  return getJoinValue({
32
37
  schema,
33
38
  rows,
34
39
  service,
40
+ fileId,
35
41
  })
36
42
  }
37
43
  case 'match': {
@@ -39,6 +45,7 @@ export const getAllValue = ({
39
45
  schema,
40
46
  rows,
41
47
  service,
48
+ fileId,
42
49
  })
43
50
  }
44
51
  case 'math': {
@@ -46,6 +53,7 @@ export const getAllValue = ({
46
53
  schema,
47
54
  rows,
48
55
  service,
56
+ fileId,
49
57
  })
50
58
  }
51
59
  case 'service': {
@@ -56,6 +64,7 @@ export const getAllValue = ({
56
64
  schema,
57
65
  rows,
58
66
  service,
67
+ fileId,
59
68
  })
60
69
  }
61
70
  case 'split': {
@@ -63,6 +72,7 @@ export const getAllValue = ({
63
72
  schema,
64
73
  rows,
65
74
  service,
75
+ fileId,
66
76
  })
67
77
  }
68
78
  }
@@ -17,6 +17,7 @@ export const getAsset = ({
17
17
  schema,
18
18
  rows,
19
19
  service,
20
+ fileId,
20
21
  symbolAssetMap,
21
22
  cryptoes,
22
23
  fiats,
@@ -24,19 +25,21 @@ export const getAsset = ({
24
25
  schema: z.infer<typeof assetSchema>
25
26
  rows: readonly FormattedRow[]
26
27
  service: string
28
+ fileId: string
27
29
  symbolAssetMap?: { readonly [symbol: string]: string }
28
30
  cryptoes: readonly CryptoCurrency[]
29
31
  fiats: readonly FiatCurrency[]
30
32
  }): CryptoCurrency | FiatCurrency | Nft => {
31
33
  switch (schema.type) {
32
34
  case 'id': {
33
- return getAssetById({ schema, rows, service })
35
+ return getAssetById({ schema, rows, service, fileId })
34
36
  }
35
37
  case 'symbol': {
36
38
  return getAssetBySymbol({
37
39
  schema,
38
40
  rows,
39
41
  service,
42
+ fileId,
40
43
  symbolAssetMap,
41
44
  cryptoes,
42
45
  fiats,
@@ -49,16 +52,19 @@ export const getAssetById = ({
49
52
  schema,
50
53
  rows,
51
54
  service,
55
+ fileId,
52
56
  }: {
53
57
  schema: z.infer<typeof assetIdSchema>
54
58
  rows: readonly FormattedRow[]
55
59
  service: string
60
+ fileId: string
56
61
  }): CryptoCurrency | FiatCurrency | Nft => {
57
62
  const value = stringify(
58
63
  getAllValue({
59
64
  schema: schema.value,
60
65
  rows,
61
66
  service,
67
+ fileId,
62
68
  }),
63
69
  )
64
70
  const [type, id] = value.split(schema.splitter)
@@ -69,6 +75,7 @@ export const getAssetBySymbol = ({
69
75
  schema,
70
76
  rows,
71
77
  service,
78
+ fileId,
72
79
  symbolAssetMap,
73
80
  cryptoes,
74
81
  fiats,
@@ -76,6 +83,7 @@ export const getAssetBySymbol = ({
76
83
  schema: z.infer<typeof assetSymbolSchema>
77
84
  rows: readonly FormattedRow[]
78
85
  service: string
86
+ fileId: string
79
87
  symbolAssetMap?: { readonly [symbol: string]: string }
80
88
  cryptoes: readonly CryptoCurrency[]
81
89
  fiats: readonly FiatCurrency[]
@@ -85,6 +93,7 @@ export const getAssetBySymbol = ({
85
93
  schema: schema.value,
86
94
  rows,
87
95
  service,
96
+ fileId,
88
97
  }),
89
98
  ).toUpperCase()
90
99
  if (symbolAssetMap !== undefined && value in symbolAssetMap) {
@@ -10,6 +10,7 @@ type ParseRowsToActionsParameters = {
10
10
  parser: z.infer<typeof parsersWithKeySchema>
11
11
  symbolAssetMap?: { readonly [symbol: string]: string }
12
12
  service: string
13
+ fileId: string
13
14
  cryptoes: readonly CryptoCurrency[]
14
15
  fiats: readonly FiatCurrency[]
15
16
  errorLogger?: (error: unknown) => void
@@ -25,6 +26,7 @@ export const parseRowsToActions = ({
25
26
  parser,
26
27
  symbolAssetMap,
27
28
  service,
29
+ fileId,
28
30
  cryptoes,
29
31
  fiats,
30
32
  errorLogger,
@@ -41,6 +43,7 @@ export const parseRowsToActions = ({
41
43
  parsers: parser.parsers,
42
44
  symbolAssetMap,
43
45
  service,
46
+ fileId,
44
47
  cryptoes,
45
48
  fiats,
46
49
  errorLogger,
@@ -64,6 +67,7 @@ export const parseRowsToActions = ({
64
67
  parsers: parser.parsers,
65
68
  symbolAssetMap,
66
69
  service,
70
+ fileId,
67
71
  cryptoes,
68
72
  fiats,
69
73
  })
@@ -83,6 +87,7 @@ export const parseRowsToActions = ({
83
87
  parsers: parser.parsers,
84
88
  symbolAssetMap,
85
89
  service,
90
+ fileId,
86
91
  cryptoes,
87
92
  fiats,
88
93
  })
@@ -106,6 +111,7 @@ type ParseTargetRowsToActionsParameters = {
106
111
  parsers: readonly z.infer<typeof parserSchema>[]
107
112
  symbolAssetMap?: { readonly [symbol: string]: string }
108
113
  service: string
114
+ fileId: string
109
115
  cryptoes: readonly CryptoCurrency[]
110
116
  fiats: readonly FiatCurrency[]
111
117
  errorLogger?: (error: unknown) => void
@@ -12,13 +12,17 @@ export const getJoinValue = ({
12
12
  schema,
13
13
  rows,
14
14
  service,
15
+ fileId,
15
16
  }: {
16
17
  schema: z.infer<typeof joinValueSchema>
17
18
  rows: readonly FormattedRow[]
18
19
  service: string
20
+ fileId: string
19
21
  }) => {
20
22
  return schema.values
21
- .map((value) => stringify(getValue({ schema: value, rows, service })))
23
+ .map((value) =>
24
+ stringify(getValue({ schema: value, rows, service, fileId })),
25
+ )
22
26
  .join('')
23
27
  }
24
28
 
@@ -26,10 +30,12 @@ const getValue = ({
26
30
  schema,
27
31
  rows,
28
32
  service,
33
+ fileId,
29
34
  }: {
30
35
  schema: z.infer<typeof joinValueSchema>['values'][0]
31
36
  rows: readonly FormattedRow[]
32
37
  service: string
38
+ fileId: string
33
39
  }) => {
34
40
  if (typeof schema === 'string') {
35
41
  return schema
@@ -41,11 +47,15 @@ const getValue = ({
41
47
  rows,
42
48
  })
43
49
  }
50
+ case 'file-id': {
51
+ return fileId
52
+ }
44
53
  case 'match': {
45
54
  return getMatchValue({
46
55
  schema,
47
56
  rows,
48
57
  service,
58
+ fileId,
49
59
  })
50
60
  }
51
61
  case 'math': {
@@ -53,6 +63,7 @@ const getValue = ({
53
63
  schema,
54
64
  rows,
55
65
  service,
66
+ fileId,
56
67
  })
57
68
  }
58
69
  case 'service': {
@@ -63,6 +74,7 @@ const getValue = ({
63
74
  schema,
64
75
  rows,
65
76
  service,
77
+ fileId,
66
78
  })
67
79
  }
68
80
  case 'split': {
@@ -70,6 +82,7 @@ const getValue = ({
70
82
  schema,
71
83
  rows,
72
84
  service,
85
+ fileId,
73
86
  })
74
87
  }
75
88
  }
@@ -8,11 +8,13 @@ export const getMatchValue = ({
8
8
  schema,
9
9
  rows,
10
10
  service,
11
+ fileId,
11
12
  }: {
12
13
  schema: z.infer<typeof matchValueSchema>
13
14
  rows: readonly FormattedRow[]
14
15
  service: string
16
+ fileId: string
15
17
  }) => {
16
- const value = getSimpleValue({ schema: schema.value, rows, service })
18
+ const value = getSimpleValue({ schema: schema.value, rows, service, fileId })
17
19
  return stringify(value).match(new RegExp(schema.pattern))?.[schema.index]
18
20
  }
@@ -18,13 +18,20 @@ export const getMathValue = ({
18
18
  schema,
19
19
  rows,
20
20
  service,
21
+ fileId,
21
22
  }: {
22
23
  schema: z.infer<typeof mathValueSchema>
23
24
  rows: readonly FormattedRow[]
24
25
  service: string
26
+ fileId: string
25
27
  }) => {
26
28
  const firstValue = schema.values[0]
27
- let current = getBigDecimalValue({ schema: firstValue, rows, service })
29
+ let current = getBigDecimalValue({
30
+ schema: firstValue,
31
+ rows,
32
+ service,
33
+ fileId,
34
+ })
28
35
  let operator: '+' | '-' | '*' | '/' | undefined
29
36
  let args: BigDecimal[] = []
30
37
  for (const value of schema.values.slice(1)) {
@@ -60,7 +67,7 @@ export const getMathValue = ({
60
67
  operator = '/'
61
68
  continue
62
69
  }
63
- args.push(getBigDecimalValue({ schema: value, rows, service }))
70
+ args.push(getBigDecimalValue({ schema: value, rows, service, fileId }))
64
71
  }
65
72
  if (operator !== undefined) {
66
73
  current = calculate(operator, current, args)
@@ -72,12 +79,14 @@ const getBigDecimalValue = ({
72
79
  schema,
73
80
  rows,
74
81
  service,
82
+ fileId,
75
83
  }: {
76
84
  schema: z.infer<typeof mathValueSchema>['values'][0]
77
85
  rows: readonly FormattedRow[]
78
86
  service: string
87
+ fileId: string
79
88
  }): BigDecimal => {
80
- const value = getValue({ schema, rows, service })
89
+ const value = getValue({ schema, rows, service, fileId })
81
90
  if (value === undefined) {
82
91
  return createBigDecimal(0n)
83
92
  }
@@ -91,10 +100,12 @@ const getValue = ({
91
100
  schema,
92
101
  rows,
93
102
  service,
103
+ fileId,
94
104
  }: {
95
105
  schema: z.infer<typeof mathValueSchema>['values'][0]
96
106
  rows: readonly FormattedRow[]
97
107
  service: string
108
+ fileId: string
98
109
  }) => {
99
110
  if (typeof schema === 'string') {
100
111
  return schema
@@ -106,11 +117,15 @@ const getValue = ({
106
117
  rows,
107
118
  })
108
119
  }
120
+ case 'file-id': {
121
+ return fileId
122
+ }
109
123
  case 'match': {
110
124
  return getMatchValue({
111
125
  schema,
112
126
  rows,
113
127
  service,
128
+ fileId,
114
129
  })
115
130
  }
116
131
  case 'service': {
@@ -121,6 +136,7 @@ const getValue = ({
121
136
  schema,
122
137
  rows,
123
138
  service,
139
+ fileId,
124
140
  })
125
141
  }
126
142
  case 'split': {
@@ -128,6 +144,7 @@ const getValue = ({
128
144
  schema,
129
145
  rows,
130
146
  service,
147
+ fileId,
131
148
  })
132
149
  }
133
150
  }
@@ -19,6 +19,7 @@ type ParseRowsToActionsByParserParameters = {
19
19
  parser: z.infer<typeof parserSchema>
20
20
  symbolAssetMap?: { readonly [symbol: string]: string }
21
21
  service: string
22
+ fileId: string
22
23
  cryptoes: readonly CryptoCurrency[]
23
24
  fiats: readonly FiatCurrency[]
24
25
  }
@@ -28,6 +29,7 @@ export const parseRowsToActionsByParser = ({
28
29
  parser,
29
30
  symbolAssetMap,
30
31
  service,
32
+ fileId,
31
33
  cryptoes,
32
34
  fiats,
33
35
  }: ParseRowsToActionsByParserParameters): readonly Action[] | undefined => {
@@ -37,6 +39,7 @@ export const parseRowsToActionsByParser = ({
37
39
  schema: condition.value,
38
40
  rows,
39
41
  service,
42
+ fileId,
40
43
  })
41
44
  if (
42
45
  !isMatchPattern({ value: stringify(value), pattern: condition.pattern })
@@ -49,7 +52,7 @@ export const parseRowsToActionsByParser = ({
49
52
  const actions: Action[] = []
50
53
  for (const generator of parser.generators) {
51
54
  const source = stringify(
52
- getAllValue({ schema: generator.source, rows, service }),
55
+ getAllValue({ schema: generator.source, rows, service, fileId }),
53
56
  )
54
57
  const timestampValue = getCellValue({ schema: generator.timestamp, rows })
55
58
  const timestamp =
@@ -59,19 +62,27 @@ export const parseRowsToActionsByParser = ({
59
62
  const comment =
60
63
  generator.comment === undefined
61
64
  ? undefined
62
- : stringify(getAllValue({ schema: generator.comment, rows, service }))
65
+ : stringify(
66
+ getAllValue({ schema: generator.comment, rows, service, fileId }),
67
+ )
63
68
  const app =
64
69
  generator.app === undefined
65
70
  ? undefined
66
- : stringify(getAllValue({ schema: generator.app, rows, service }))
71
+ : stringify(
72
+ getAllValue({ schema: generator.app, rows, service, fileId }),
73
+ )
67
74
  const crossId =
68
75
  generator.crossId === undefined
69
76
  ? undefined
70
- : stringify(getAllValue({ schema: generator.crossId, rows, service }))
77
+ : stringify(
78
+ getAllValue({ schema: generator.crossId, rows, service, fileId }),
79
+ )
71
80
  const loanId =
72
81
  generator.loanId === undefined
73
82
  ? undefined
74
- : stringify(getAllValue({ schema: generator.loanId, rows, service }))
83
+ : stringify(
84
+ getAllValue({ schema: generator.loanId, rows, service, fileId }),
85
+ )
75
86
  const target =
76
87
  generator.target === undefined
77
88
  ? undefined
@@ -79,6 +90,7 @@ export const parseRowsToActionsByParser = ({
79
90
  schema: generator.target,
80
91
  rows,
81
92
  service,
93
+ fileId,
82
94
  })
83
95
  const action: Action = {
84
96
  source,
@@ -93,6 +105,7 @@ export const parseRowsToActionsByParser = ({
93
105
  schema: transfer,
94
106
  rows,
95
107
  service,
108
+ fileId,
96
109
  symbolAssetMap,
97
110
  cryptoes,
98
111
  fiats,
@@ -7,10 +7,12 @@ export const getSimpleValue = ({
7
7
  schema,
8
8
  rows,
9
9
  service,
10
+ fileId,
10
11
  }: {
11
12
  schema: z.infer<typeof simpleValueSchema>
12
13
  rows: readonly FormattedRow[]
13
14
  service: string
15
+ fileId: string
14
16
  }) => {
15
17
  if (typeof schema === 'string') {
16
18
  return schema
@@ -22,6 +24,9 @@ export const getSimpleValue = ({
22
24
  rows,
23
25
  })
24
26
  }
27
+ case 'file-id': {
28
+ return fileId
29
+ }
25
30
  case 'service': {
26
31
  return service
27
32
  }
@@ -9,12 +9,14 @@ export const getSliceValue = ({
9
9
  schema,
10
10
  rows,
11
11
  service,
12
+ fileId,
12
13
  }: {
13
14
  schema: z.infer<typeof sliceValueSchema>
14
15
  rows: readonly FormattedRow[]
15
16
  service: string
17
+ fileId: string
16
18
  }) => {
17
- const value = getValue({ schema, rows, service })
19
+ const value = getValue({ schema, rows, service, fileId })
18
20
  return stringify(value).slice(schema.start, schema.end)
19
21
  }
20
22
 
@@ -22,10 +24,12 @@ const getValue = ({
22
24
  schema,
23
25
  rows,
24
26
  service,
27
+ fileId,
25
28
  }: {
26
29
  schema: z.infer<typeof sliceValueSchema>
27
30
  rows: readonly FormattedRow[]
28
31
  service: string
32
+ fileId: string
29
33
  }) => {
30
34
  if (typeof schema.value === 'string') {
31
35
  return schema.value
@@ -37,6 +41,9 @@ const getValue = ({
37
41
  rows,
38
42
  })
39
43
  }
44
+ case 'file-id': {
45
+ return fileId
46
+ }
40
47
  case 'service': {
41
48
  return service
42
49
  }
@@ -45,6 +52,7 @@ const getValue = ({
45
52
  schema: schema.value,
46
53
  rows,
47
54
  service,
55
+ fileId,
48
56
  })
49
57
  }
50
58
  }
@@ -9,12 +9,14 @@ export const getSplitValue = ({
9
9
  schema,
10
10
  rows,
11
11
  service,
12
+ fileId,
12
13
  }: {
13
14
  schema: z.infer<typeof splitValueSchema>
14
15
  rows: readonly FormattedRow[]
15
16
  service: string
17
+ fileId: string
16
18
  }) => {
17
- const value = getSimpleValue({ schema: schema.value, rows, service })
19
+ const value = getSimpleValue({ schema: schema.value, rows, service, fileId })
18
20
  const stringifyValue = stringify(value)
19
21
 
20
22
  if (typeof schema.splitter === 'string') {