@0xtorch/csv 0.0.91 → 0.0.93
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 +32 -3
- 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 +6 -3
- package/_cjs/schemas/parser.js.map +1 -1
- package/_esm/parseRowsToActions/parse.js +33 -4
- 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 +7 -3
- 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 +211 -27
- package/_types/schemas/format.d.ts.map +1 -1
- package/_types/schemas/parser.d.ts +348 -36
- package/_types/schemas/parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/parseRowsToActions/parse.ts +49 -3
- package/parseRowsToActions/pattern.ts +3 -0
- package/schemas/parser.ts +7 -3
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Action,
|
|
3
|
+
type ActionCrossType,
|
|
4
|
+
type ActionEvidence,
|
|
5
|
+
type ActionType,
|
|
3
6
|
type CryptoCurrency,
|
|
4
7
|
type FiatCurrency,
|
|
8
|
+
actionTypes,
|
|
5
9
|
checkIfActionsIsValid,
|
|
6
10
|
stringify,
|
|
7
11
|
} from '@0xtorch/core'
|
|
@@ -10,6 +14,7 @@ import type { parserSchema } from '../schemas/parser'
|
|
|
10
14
|
import type { FormattedRow } from '../types'
|
|
11
15
|
import { getAllValue } from './allValue'
|
|
12
16
|
import { getAssetById } from './asset'
|
|
17
|
+
import { getCellValue } from './cellValue'
|
|
13
18
|
import { isMatchPattern } from './pattern'
|
|
14
19
|
import { createTransfers } from './transfer'
|
|
15
20
|
|
|
@@ -53,6 +58,18 @@ export const parseRowsToActionsByParser = ({
|
|
|
53
58
|
const source = stringify(
|
|
54
59
|
getAllValue({ schema: generator.source, rows, service, fileId }),
|
|
55
60
|
)
|
|
61
|
+
const type =
|
|
62
|
+
typeof generator.type === 'string'
|
|
63
|
+
? generator.type
|
|
64
|
+
: stringify(
|
|
65
|
+
getCellValue({
|
|
66
|
+
schema: generator.type,
|
|
67
|
+
rows,
|
|
68
|
+
}),
|
|
69
|
+
)
|
|
70
|
+
if (!isActionType(type)) {
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
56
73
|
const timestampValue = getAllValue({
|
|
57
74
|
schema: generator.timestamp,
|
|
58
75
|
rows,
|
|
@@ -63,6 +80,15 @@ export const parseRowsToActionsByParser = ({
|
|
|
63
80
|
typeof timestampValue === 'number'
|
|
64
81
|
? timestampValue
|
|
65
82
|
: new Date(stringify(timestampValue)).getTime()
|
|
83
|
+
const evidence =
|
|
84
|
+
generator.evidence === undefined
|
|
85
|
+
? 'system-rule'
|
|
86
|
+
: typeof generator.evidence === 'string'
|
|
87
|
+
? generator.evidence
|
|
88
|
+
: stringify(getCellValue({ schema: generator.evidence, rows }))
|
|
89
|
+
if (!isActionEvidence(evidence)) {
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
66
92
|
const comment =
|
|
67
93
|
generator.comment === undefined
|
|
68
94
|
? undefined
|
|
@@ -81,6 +107,15 @@ export const parseRowsToActionsByParser = ({
|
|
|
81
107
|
: stringify(
|
|
82
108
|
getAllValue({ schema: generator.crossId, rows, service, fileId }),
|
|
83
109
|
)
|
|
110
|
+
const crossType =
|
|
111
|
+
generator.crossType === undefined
|
|
112
|
+
? undefined
|
|
113
|
+
: typeof generator.crossType === 'string'
|
|
114
|
+
? generator.crossType
|
|
115
|
+
: stringify(getCellValue({ schema: generator.crossType, rows }))
|
|
116
|
+
if (crossType !== undefined && !isActionCrossType(crossType)) {
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
84
119
|
const loanId =
|
|
85
120
|
generator.loanId === undefined
|
|
86
121
|
? undefined
|
|
@@ -99,9 +134,9 @@ export const parseRowsToActionsByParser = ({
|
|
|
99
134
|
const action: Action = {
|
|
100
135
|
source,
|
|
101
136
|
order: 0,
|
|
102
|
-
type
|
|
137
|
+
type,
|
|
103
138
|
timestamp,
|
|
104
|
-
evidence
|
|
139
|
+
evidence,
|
|
105
140
|
comment,
|
|
106
141
|
app,
|
|
107
142
|
transfers: generator.transfers.flatMap((transfer) =>
|
|
@@ -116,7 +151,7 @@ export const parseRowsToActionsByParser = ({
|
|
|
116
151
|
}),
|
|
117
152
|
),
|
|
118
153
|
crossId,
|
|
119
|
-
crossType
|
|
154
|
+
crossType,
|
|
120
155
|
loanId,
|
|
121
156
|
target:
|
|
122
157
|
target === undefined || target.type !== 'Nft' ? undefined : target,
|
|
@@ -128,3 +163,14 @@ export const parseRowsToActionsByParser = ({
|
|
|
128
163
|
}
|
|
129
164
|
return actions
|
|
130
165
|
}
|
|
166
|
+
|
|
167
|
+
const isActionType = (value: string): value is ActionType =>
|
|
168
|
+
actionTypes.includes(value as ActionType)
|
|
169
|
+
|
|
170
|
+
const isActionEvidence = (value: string): value is ActionEvidence =>
|
|
171
|
+
['contract', 'system-rule', 'user-rule', 'manual-check', 'none'].includes(
|
|
172
|
+
value,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const isActionCrossType = (value: string): value is ActionCrossType =>
|
|
176
|
+
['start', 'middle', 'end'].includes(value)
|
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,14 +201,14 @@ 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(),
|
|
206
210
|
crossId: allValueSchema.optional(),
|
|
207
|
-
crossType: actionCrossTypeUnionSchema.optional(),
|
|
211
|
+
crossType: z.union([actionCrossTypeUnionSchema, cellValueSchema]).optional(),
|
|
208
212
|
loanId: allValueSchema.optional(),
|
|
209
213
|
target: assetIdSchema.optional(),
|
|
210
214
|
transfers: z.array(transferComponentSchema),
|