@0xtorch/csv 0.0.91 → 0.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/_cjs/parseRowsToActions/parse.js +22 -2
- package/_cjs/parseRowsToActions/parse.js.map +1 -1
- package/_cjs/parseRowsToActions/pattern.js +3 -0
- package/_cjs/parseRowsToActions/pattern.js.map +1 -1
- package/_cjs/schemas/parser.js +5 -2
- package/_cjs/schemas/parser.js.map +1 -1
- package/_esm/parseRowsToActions/parse.js +23 -3
- package/_esm/parseRowsToActions/parse.js.map +1 -1
- package/_esm/parseRowsToActions/pattern.js +3 -0
- package/_esm/parseRowsToActions/pattern.js.map +1 -1
- package/_esm/schemas/parser.js +6 -2
- package/_esm/schemas/parser.js.map +1 -1
- package/_types/parseRowsToActions/parse.d.ts.map +1 -1
- package/_types/parseRowsToActions/pattern.d.ts.map +1 -1
- package/_types/schemas/format.d.ts +158 -18
- package/_types/schemas/format.d.ts.map +1 -1
- package/_types/schemas/parser.d.ts +272 -24
- package/_types/schemas/parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/parseRowsToActions/parse.ts +35 -2
- package/parseRowsToActions/pattern.ts +3 -0
- package/schemas/parser.ts +6 -2
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Action,
|
|
3
|
+
type ActionEvidence,
|
|
4
|
+
type ActionType,
|
|
3
5
|
type CryptoCurrency,
|
|
4
6
|
type FiatCurrency,
|
|
7
|
+
actionTypes,
|
|
5
8
|
checkIfActionsIsValid,
|
|
6
9
|
stringify,
|
|
7
10
|
} from '@0xtorch/core'
|
|
@@ -10,6 +13,7 @@ import type { parserSchema } from '../schemas/parser'
|
|
|
10
13
|
import type { FormattedRow } from '../types'
|
|
11
14
|
import { getAllValue } from './allValue'
|
|
12
15
|
import { getAssetById } from './asset'
|
|
16
|
+
import { getCellValue } from './cellValue'
|
|
13
17
|
import { isMatchPattern } from './pattern'
|
|
14
18
|
import { createTransfers } from './transfer'
|
|
15
19
|
|
|
@@ -53,6 +57,18 @@ export const parseRowsToActionsByParser = ({
|
|
|
53
57
|
const source = stringify(
|
|
54
58
|
getAllValue({ schema: generator.source, rows, service, fileId }),
|
|
55
59
|
)
|
|
60
|
+
const type =
|
|
61
|
+
typeof generator.type === 'string'
|
|
62
|
+
? generator.type
|
|
63
|
+
: stringify(
|
|
64
|
+
getCellValue({
|
|
65
|
+
schema: generator.type,
|
|
66
|
+
rows,
|
|
67
|
+
}),
|
|
68
|
+
)
|
|
69
|
+
if (!isActionType(type)) {
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
56
72
|
const timestampValue = getAllValue({
|
|
57
73
|
schema: generator.timestamp,
|
|
58
74
|
rows,
|
|
@@ -63,6 +79,15 @@ export const parseRowsToActionsByParser = ({
|
|
|
63
79
|
typeof timestampValue === 'number'
|
|
64
80
|
? timestampValue
|
|
65
81
|
: new Date(stringify(timestampValue)).getTime()
|
|
82
|
+
const evidence =
|
|
83
|
+
generator.evidence === undefined
|
|
84
|
+
? 'system-rule'
|
|
85
|
+
: typeof generator.evidence === 'string'
|
|
86
|
+
? generator.evidence
|
|
87
|
+
: stringify(getCellValue({ schema: generator.evidence, rows }))
|
|
88
|
+
if (!isActionEvidence(evidence)) {
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
66
91
|
const comment =
|
|
67
92
|
generator.comment === undefined
|
|
68
93
|
? undefined
|
|
@@ -99,9 +124,9 @@ export const parseRowsToActionsByParser = ({
|
|
|
99
124
|
const action: Action = {
|
|
100
125
|
source,
|
|
101
126
|
order: 0,
|
|
102
|
-
type
|
|
127
|
+
type,
|
|
103
128
|
timestamp,
|
|
104
|
-
evidence
|
|
129
|
+
evidence,
|
|
105
130
|
comment,
|
|
106
131
|
app,
|
|
107
132
|
transfers: generator.transfers.flatMap((transfer) =>
|
|
@@ -128,3 +153,11 @@ export const parseRowsToActionsByParser = ({
|
|
|
128
153
|
}
|
|
129
154
|
return actions
|
|
130
155
|
}
|
|
156
|
+
|
|
157
|
+
const isActionType = (value: string): value is ActionType =>
|
|
158
|
+
actionTypes.includes(value as ActionType)
|
|
159
|
+
|
|
160
|
+
const isActionEvidence = (value: string): value is ActionEvidence =>
|
|
161
|
+
['contract', 'system-rule', 'user-rule', 'manual-check', 'none'].includes(
|
|
162
|
+
value,
|
|
163
|
+
)
|
package/schemas/parser.ts
CHANGED
|
@@ -145,6 +145,10 @@ export const patternSchema = z.union([
|
|
|
145
145
|
z.object({
|
|
146
146
|
type: z.literal('nonnegative'),
|
|
147
147
|
}),
|
|
148
|
+
// zero
|
|
149
|
+
z.object({
|
|
150
|
+
type: z.literal('zero'),
|
|
151
|
+
}),
|
|
148
152
|
])
|
|
149
153
|
|
|
150
154
|
export const conditionSchema = z.object({
|
|
@@ -197,9 +201,9 @@ export const transferComponentSchema = z.object({
|
|
|
197
201
|
})
|
|
198
202
|
|
|
199
203
|
const generatorSchema = z.object({
|
|
200
|
-
type: actionTypeUnionSchema,
|
|
204
|
+
type: z.union([actionTypeUnionSchema, cellValueSchema]),
|
|
201
205
|
source: allValueSchema,
|
|
202
|
-
evidence: actionEvidenceUnionSchema.optional(),
|
|
206
|
+
evidence: z.union([actionEvidenceUnionSchema, cellValueSchema]).optional(),
|
|
203
207
|
timestamp: allValueSchema,
|
|
204
208
|
comment: allValueSchema.optional(),
|
|
205
209
|
app: allValueSchema.optional(),
|