@0xtorch/csv 0.0.58 → 0.0.60

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 (37) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/formatCsvRows.js +14 -0
  3. package/_cjs/formatCsvRows.js.map +1 -1
  4. package/_cjs/parseRowsToActions/parse.js +1 -1
  5. package/_cjs/parseRowsToActions/parse.js.map +1 -1
  6. package/_cjs/schemas/formatter.js +2 -0
  7. package/_cjs/schemas/formatter.js.map +1 -1
  8. package/_cjs/schemas/formatterTypes.js +11 -1
  9. package/_cjs/schemas/formatterTypes.js.map +1 -1
  10. package/_cjs/schemas/parser.js +1 -0
  11. package/_cjs/schemas/parser.js.map +1 -1
  12. package/_esm/formatCsvRows.js +15 -1
  13. package/_esm/formatCsvRows.js.map +1 -1
  14. package/_esm/parseRowsToActions/parse.js +1 -1
  15. package/_esm/parseRowsToActions/parse.js.map +1 -1
  16. package/_esm/schemas/formatter.js +2 -0
  17. package/_esm/schemas/formatter.js.map +1 -1
  18. package/_esm/schemas/formatterTypes.js +10 -0
  19. package/_esm/schemas/formatterTypes.js.map +1 -1
  20. package/_esm/schemas/parser.js +2 -1
  21. package/_esm/schemas/parser.js.map +1 -1
  22. package/_types/formatCsvRows.d.ts.map +1 -1
  23. package/_types/schemas/format.d.ts +12 -3
  24. package/_types/schemas/format.d.ts.map +1 -1
  25. package/_types/schemas/formatter.d.ts +2 -2
  26. package/_types/schemas/formatter.d.ts.map +1 -1
  27. package/_types/schemas/formatterTypes.d.ts +3 -1
  28. package/_types/schemas/formatterTypes.d.ts.map +1 -1
  29. package/_types/schemas/parser.d.ts +12 -0
  30. package/_types/schemas/parser.d.ts.map +1 -1
  31. package/formatCsvRows.ts +16 -0
  32. package/package.json +2 -2
  33. package/parseRowsToActions/parse.ts +1 -1
  34. package/schemas/formatter.ts +2 -0
  35. package/schemas/formatterTypes.ts +12 -0
  36. package/schemas/parser.ts +2 -0
  37. package/tests/.DS_Store +0 -0
package/formatCsvRows.ts CHANGED
@@ -7,6 +7,8 @@ import {
7
7
  iso8601JpTextSchema,
8
8
  iso8601TextSchema,
9
9
  stringTextSchema,
10
+ unixtimeMsSchema,
11
+ unixtimeSchema,
10
12
  } from './schemas/formatterTypes'
11
13
  import type { FormattedRow, Formatter, FormatterValue } from './types'
12
14
 
@@ -72,6 +74,20 @@ export const formatCsvRow = (row: RawRow, formatter: Formatter): FormattedRow =>
72
74
  }
73
75
  return [column, parsed.data]
74
76
  }
77
+ case 'unixtime': {
78
+ const parsed = unixtimeSchema.safeParse(value)
79
+ if (!parsed.success) {
80
+ break
81
+ }
82
+ return [column, parsed.data]
83
+ }
84
+ case 'unixtime-ms': {
85
+ const parsed = unixtimeMsSchema.safeParse(value)
86
+ if (!parsed.success) {
87
+ break
88
+ }
89
+ return [column, parsed.data]
90
+ }
75
91
  case 'iso8601': {
76
92
  const parsed = iso8601TextSchema.safeParse(value)
77
93
  if (!parsed.success) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/csv",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "Cryptorch CSV extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@0xtorch/big-decimal": "^0.0.13",
38
- "@0xtorch/core": "^0.0.60",
38
+ "@0xtorch/core": "^0.0.61",
39
39
  "encoding-japanese": "^2.1.0",
40
40
  "papaparse": "^5.4.1",
41
41
  "xlsx": "^0.18.5",
@@ -85,7 +85,7 @@ export const parseRowsToActionsByParser = ({
85
85
  order: 0,
86
86
  type: generator.type,
87
87
  timestamp,
88
- evidence: 'system-rule',
88
+ evidence: generator.evidence ?? 'system-rule',
89
89
  comment,
90
90
  app,
91
91
  transfers: generator.transfers.flatMap((transfer) =>
@@ -6,6 +6,8 @@ export const formatterValueTypeSchema = z.union([
6
6
  z.literal('big-decimal'),
7
7
  z.literal('big-decimal-positive'),
8
8
  z.literal('big-decimal-negative'),
9
+ z.literal('unixtime'),
10
+ z.literal('unixtime-ms'),
9
11
  z.literal('iso8601'),
10
12
  z.literal('iso8601-jp'),
11
13
  z.literal('datetime-jp'),
@@ -20,6 +20,16 @@ export const bigDecimalNegativeTextSchema = z
20
20
  .regex(/^(" *)?-[\d,]+(\.\d+)?([eE][-+]?\d+)?( *")?$/)
21
21
  .transform((v) => createBigDecimal(v.replaceAll('"', '').trim()))
22
22
 
23
+ export const unixtimeSchema = z
24
+ .string()
25
+ .regex(/^\d{10}$/)
26
+ .transform(Number)
27
+
28
+ export const unixtimeMsSchema = z
29
+ .string()
30
+ .regex(/^\d{13}$/)
31
+ .transform(Number)
32
+
23
33
  export const iso8601TextSchema = z
24
34
  .string()
25
35
  .regex(/^[\d:\. ]*\d{2,4}(\-|\/)?\d{1,2}(\-|\/)?\d{1,2}T?[\d:\. ]*Z?$/)
@@ -67,6 +77,8 @@ export const formatterValueSchema = z.union([
67
77
  bigDecimalTextSchema,
68
78
  bigDecimalPositiveTextSchema,
69
79
  bigDecimalNegativeTextSchema,
80
+ unixtimeSchema,
81
+ unixtimeMsSchema,
70
82
  iso8601TextSchema,
71
83
  iso8601JpTextSchema,
72
84
  datetimeJpTextSchema,
package/schemas/parser.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  actionCrossTypeUnionSchema,
3
+ actionEvidenceUnionSchema,
3
4
  actionTypeUnionSchema,
4
5
  } from '@0xtorch/core'
5
6
  import { z } from 'zod'
@@ -193,6 +194,7 @@ export const transferComponentSchema = z.object({
193
194
  const generatorSchema = z.object({
194
195
  type: actionTypeUnionSchema,
195
196
  source: allValueSchema,
197
+ evidence: actionEvidenceUnionSchema.optional(),
196
198
  timestamp: cellValueSchema,
197
199
  comment: allValueSchema.optional(),
198
200
  app: allValueSchema.optional(),
Binary file