@0xtorch/csv 0.0.75 → 0.0.77

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 (112) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/parseCsvFileToActions.js +2 -1
  3. package/_cjs/parseCsvFileToActions.js.map +1 -1
  4. package/_cjs/parseRowsToActions/allValue.js +9 -1
  5. package/_cjs/parseRowsToActions/allValue.js.map +1 -1
  6. package/_cjs/parseRowsToActions/asset.js +7 -4
  7. package/_cjs/parseRowsToActions/asset.js.map +1 -1
  8. package/_cjs/parseRowsToActions/index.js +4 -1
  9. package/_cjs/parseRowsToActions/index.js.map +1 -1
  10. package/_cjs/parseRowsToActions/joinValue.js +10 -3
  11. package/_cjs/parseRowsToActions/joinValue.js.map +1 -1
  12. package/_cjs/parseRowsToActions/matchValue.js +2 -2
  13. package/_cjs/parseRowsToActions/matchValue.js.map +1 -1
  14. package/_cjs/parseRowsToActions/mathValue.js +17 -6
  15. package/_cjs/parseRowsToActions/mathValue.js.map +1 -1
  16. package/_cjs/parseRowsToActions/parse.js +9 -6
  17. package/_cjs/parseRowsToActions/parse.js.map +1 -1
  18. package/_cjs/parseRowsToActions/simpleValue.js +4 -1
  19. package/_cjs/parseRowsToActions/simpleValue.js.map +1 -1
  20. package/_cjs/parseRowsToActions/sliceValue.js +7 -3
  21. package/_cjs/parseRowsToActions/sliceValue.js.map +1 -1
  22. package/_cjs/parseRowsToActions/splitValue.js +2 -2
  23. package/_cjs/parseRowsToActions/splitValue.js.map +1 -1
  24. package/_cjs/parseRowsToActions/transfer.js +12 -8
  25. package/_cjs/parseRowsToActions/transfer.js.map +1 -1
  26. package/_cjs/schemas/parser.js +5 -1
  27. package/_cjs/schemas/parser.js.map +1 -1
  28. package/_cjs/streamCsvToActions.js +4 -1
  29. package/_cjs/streamCsvToActions.js.map +1 -1
  30. package/_esm/parseCsvFileToActions.js +2 -1
  31. package/_esm/parseCsvFileToActions.js.map +1 -1
  32. package/_esm/parseRowsToActions/allValue.js +9 -1
  33. package/_esm/parseRowsToActions/allValue.js.map +1 -1
  34. package/_esm/parseRowsToActions/asset.js +7 -4
  35. package/_esm/parseRowsToActions/asset.js.map +1 -1
  36. package/_esm/parseRowsToActions/index.js +4 -1
  37. package/_esm/parseRowsToActions/index.js.map +1 -1
  38. package/_esm/parseRowsToActions/joinValue.js +10 -3
  39. package/_esm/parseRowsToActions/joinValue.js.map +1 -1
  40. package/_esm/parseRowsToActions/matchValue.js +2 -2
  41. package/_esm/parseRowsToActions/matchValue.js.map +1 -1
  42. package/_esm/parseRowsToActions/mathValue.js +17 -6
  43. package/_esm/parseRowsToActions/mathValue.js.map +1 -1
  44. package/_esm/parseRowsToActions/parse.js +9 -6
  45. package/_esm/parseRowsToActions/parse.js.map +1 -1
  46. package/_esm/parseRowsToActions/simpleValue.js +4 -1
  47. package/_esm/parseRowsToActions/simpleValue.js.map +1 -1
  48. package/_esm/parseRowsToActions/sliceValue.js +7 -3
  49. package/_esm/parseRowsToActions/sliceValue.js.map +1 -1
  50. package/_esm/parseRowsToActions/splitValue.js +2 -2
  51. package/_esm/parseRowsToActions/splitValue.js.map +1 -1
  52. package/_esm/parseRowsToActions/transfer.js +12 -8
  53. package/_esm/parseRowsToActions/transfer.js.map +1 -1
  54. package/_esm/schemas/parser.js +4 -0
  55. package/_esm/schemas/parser.js.map +1 -1
  56. package/_esm/streamCsvToActions.js +4 -1
  57. package/_esm/streamCsvToActions.js.map +1 -1
  58. package/_types/detectFileEncoding.d.ts.map +1 -1
  59. package/_types/formatCsvRows.d.ts.map +1 -1
  60. package/_types/getCsvRowCount.d.ts.map +1 -1
  61. package/_types/hasValidHeaderRow.d.ts.map +1 -1
  62. package/_types/parseCsvFileToActions.d.ts +2 -1
  63. package/_types/parseCsvFileToActions.d.ts.map +1 -1
  64. package/_types/parseCsvFileToText.d.ts.map +1 -1
  65. package/_types/parseCsvText.d.ts.map +1 -1
  66. package/_types/parseExcelToCsvTextFiles.d.ts.map +1 -1
  67. package/_types/parseRowsToActions/allValue.d.ts +2 -1
  68. package/_types/parseRowsToActions/allValue.d.ts.map +1 -1
  69. package/_types/parseRowsToActions/asset.d.ts +6 -3
  70. package/_types/parseRowsToActions/asset.d.ts.map +1 -1
  71. package/_types/parseRowsToActions/cellValue.d.ts.map +1 -1
  72. package/_types/parseRowsToActions/index.d.ts +3 -1
  73. package/_types/parseRowsToActions/index.d.ts.map +1 -1
  74. package/_types/parseRowsToActions/joinValue.d.ts +2 -1
  75. package/_types/parseRowsToActions/joinValue.d.ts.map +1 -1
  76. package/_types/parseRowsToActions/key.d.ts.map +1 -1
  77. package/_types/parseRowsToActions/matchValue.d.ts +2 -1
  78. package/_types/parseRowsToActions/matchValue.d.ts.map +1 -1
  79. package/_types/parseRowsToActions/mathValue.d.ts +2 -1
  80. package/_types/parseRowsToActions/mathValue.d.ts.map +1 -1
  81. package/_types/parseRowsToActions/parse.d.ts +2 -1
  82. package/_types/parseRowsToActions/parse.d.ts.map +1 -1
  83. package/_types/parseRowsToActions/pattern.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/package.json +2 -2
  99. package/parseCsvFileToActions.ts +3 -0
  100. package/parseRowsToActions/allValue.ts +10 -0
  101. package/parseRowsToActions/asset.ts +10 -1
  102. package/parseRowsToActions/index.ts +6 -0
  103. package/parseRowsToActions/joinValue.ts +14 -1
  104. package/parseRowsToActions/matchValue.ts +3 -1
  105. package/parseRowsToActions/mathValue.ts +20 -3
  106. package/parseRowsToActions/parse.ts +18 -5
  107. package/parseRowsToActions/simpleValue.ts +5 -0
  108. package/parseRowsToActions/sliceValue.ts +9 -1
  109. package/parseRowsToActions/splitValue.ts +3 -1
  110. package/parseRowsToActions/transfer.ts +15 -5
  111. package/schemas/parser.ts +5 -0
  112. package/streamCsvToActions.ts +5 -0
@@ -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,CA0OtE,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,GAAU,uEAStC,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,CA6OtE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/csv",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
4
4
  "description": "Cryptorch CSV extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -39,7 +39,7 @@
39
39
  "encoding-japanese": "^2.1.0",
40
40
  "papaparse": "^5.4.1",
41
41
  "xlsx": "^0.18.5",
42
- "zod": "^3.23.8"
42
+ "zod": "3.23.8"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/encoding-japanese": "^2.0.5",
@@ -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') {
@@ -24,6 +24,7 @@ export const createTransfers = ({
24
24
  schema,
25
25
  rows,
26
26
  service,
27
+ fileId,
27
28
  symbolAssetMap,
28
29
  cryptoes,
29
30
  fiats,
@@ -31,6 +32,7 @@ export const createTransfers = ({
31
32
  schema: z.infer<typeof transferComponentSchema>
32
33
  rows: readonly FormattedRow[]
33
34
  service: string
35
+ fileId: string
34
36
  symbolAssetMap?: { readonly [symbol: string]: string }
35
37
  cryptoes: readonly CryptoCurrency[]
36
38
  fiats: readonly FiatCurrency[]
@@ -40,6 +42,7 @@ export const createTransfers = ({
40
42
  schema,
41
43
  rows,
42
44
  service,
45
+ fileId,
43
46
  symbolAssetMap,
44
47
  cryptoes,
45
48
  fiats,
@@ -59,6 +62,7 @@ export const createTransfers = ({
59
62
  schema,
60
63
  rows: [targetRow],
61
64
  service,
65
+ fileId,
62
66
  symbolAssetMap,
63
67
  cryptoes,
64
68
  fiats,
@@ -95,6 +99,7 @@ const createSingleTransfer = ({
95
99
  schema,
96
100
  rows,
97
101
  service,
102
+ fileId,
98
103
  symbolAssetMap,
99
104
  cryptoes,
100
105
  fiats,
@@ -102,6 +107,7 @@ const createSingleTransfer = ({
102
107
  schema: z.infer<typeof transferComponentSchema>
103
108
  rows: readonly FormattedRow[]
104
109
  service: string
110
+ fileId: string
105
111
  symbolAssetMap?: { readonly [symbol: string]: string }
106
112
  cryptoes: readonly CryptoCurrency[]
107
113
  fiats: readonly FiatCurrency[]
@@ -109,15 +115,15 @@ const createSingleTransfer = ({
109
115
  const from =
110
116
  schema.from === undefined
111
117
  ? undefined
112
- : stringify(getAllValue({ schema: schema.from, rows, service }))
118
+ : stringify(getAllValue({ schema: schema.from, rows, service, fileId }))
113
119
  const to =
114
120
  schema.to === undefined
115
121
  ? undefined
116
- : stringify(getAllValue({ schema: schema.to, rows, service }))
122
+ : stringify(getAllValue({ schema: schema.to, rows, service, fileId }))
117
123
  const priceValue =
118
124
  schema.price === undefined
119
125
  ? undefined
120
- : getAllValue({ schema: schema.price, rows, service })
126
+ : getAllValue({ schema: schema.price, rows, service, fileId })
121
127
  let price: BigDecimal | undefined
122
128
  if (typeof priceValue === 'string') {
123
129
  if (priceValue.length === 0) {
@@ -140,6 +146,7 @@ const createSingleTransfer = ({
140
146
  schema: schema.asset,
141
147
  rows,
142
148
  service,
149
+ fileId,
143
150
  symbolAssetMap,
144
151
  cryptoes,
145
152
  fiats,
@@ -149,6 +156,7 @@ const createSingleTransfer = ({
149
156
  schema: schema.amount,
150
157
  rows,
151
158
  service,
159
+ fileId,
152
160
  }),
153
161
  ),
154
162
  price,
@@ -159,15 +167,17 @@ const createAmount = ({
159
167
  schema,
160
168
  rows,
161
169
  service,
170
+ fileId,
162
171
  }: {
163
172
  schema: z.infer<typeof amountSchema>
164
173
  rows: readonly FormattedRow[]
165
174
  service: string
175
+ fileId: string
166
176
  }): BigDecimal => {
167
177
  switch (schema.type) {
168
178
  case 'decimal': {
169
179
  const baseValue = stringify(
170
- getAllValue({ schema: schema.value, rows, service }),
180
+ getAllValue({ schema: schema.value, rows, service, fileId }),
171
181
  )
172
182
  let value: bigint
173
183
  if (baseValue === stringify(undefined)) {
@@ -183,7 +193,7 @@ const createAmount = ({
183
193
  }
184
194
  }
185
195
  case 'text': {
186
- const value = getAllValue({ schema: schema.value, rows, service })
196
+ const value = getAllValue({ schema: schema.value, rows, service, fileId })
187
197
  if (value === undefined) {
188
198
  return createBigDecimal(0n)
189
199
  }