jtcsv 2.2.8 → 3.1.0
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/README.md +204 -115
- package/bin/jtcsv.ts +2612 -0
- package/browser.d.ts +142 -0
- package/dist/benchmark.js +446 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/bin/jtcsv.js +1940 -0
- package/dist/bin/jtcsv.js.map +1 -0
- package/dist/csv-to-json.js +1262 -0
- package/dist/csv-to-json.js.map +1 -0
- package/dist/errors.js +291 -0
- package/dist/errors.js.map +1 -0
- package/dist/eslint.config.js +147 -0
- package/dist/eslint.config.js.map +1 -0
- package/dist/index-core.js +95 -0
- package/dist/index-core.js.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/json-save.js +229 -0
- package/dist/json-save.js.map +1 -0
- package/dist/json-to-csv.js +576 -0
- package/dist/json-to-csv.js.map +1 -0
- package/dist/jtcsv-core.cjs.js +1736 -0
- package/dist/jtcsv-core.cjs.js.map +1 -0
- package/dist/jtcsv-core.esm.js +1708 -0
- package/dist/jtcsv-core.esm.js.map +1 -0
- package/dist/jtcsv-core.umd.js +1742 -0
- package/dist/jtcsv-core.umd.js.map +1 -0
- package/dist/jtcsv-full.cjs.js +2241 -0
- package/dist/jtcsv-full.cjs.js.map +1 -0
- package/dist/jtcsv-full.esm.js +2209 -0
- package/dist/jtcsv-full.esm.js.map +1 -0
- package/dist/jtcsv-full.umd.js +2247 -0
- package/dist/jtcsv-full.umd.js.map +1 -0
- package/dist/jtcsv-workers.esm.js +768 -0
- package/dist/jtcsv-workers.esm.js.map +1 -0
- package/dist/jtcsv-workers.umd.js +782 -0
- package/dist/jtcsv-workers.umd.js.map +1 -0
- package/dist/jtcsv.cjs.js +1996 -2048
- package/dist/jtcsv.cjs.js.map +1 -1
- package/dist/jtcsv.esm.js +1992 -2048
- package/dist/jtcsv.esm.js.map +1 -1
- package/dist/jtcsv.umd.js +2157 -2209
- package/dist/jtcsv.umd.js.map +1 -1
- package/dist/plugins/express-middleware/index.js +350 -0
- package/dist/plugins/express-middleware/index.js.map +1 -0
- package/dist/plugins/fastify-plugin/index.js +315 -0
- package/dist/plugins/fastify-plugin/index.js.map +1 -0
- package/dist/plugins/hono/index.js +111 -0
- package/dist/plugins/hono/index.js.map +1 -0
- package/dist/plugins/nestjs/index.js +112 -0
- package/dist/plugins/nestjs/index.js.map +1 -0
- package/dist/plugins/nuxt/index.js +53 -0
- package/dist/plugins/nuxt/index.js.map +1 -0
- package/dist/plugins/remix/index.js +133 -0
- package/dist/plugins/remix/index.js.map +1 -0
- package/dist/plugins/sveltekit/index.js +155 -0
- package/dist/plugins/sveltekit/index.js.map +1 -0
- package/dist/plugins/trpc/index.js +136 -0
- package/dist/plugins/trpc/index.js.map +1 -0
- package/dist/run-demo.js +49 -0
- package/dist/run-demo.js.map +1 -0
- package/dist/src/browser/browser-functions.js +193 -0
- package/dist/src/browser/browser-functions.js.map +1 -0
- package/dist/src/browser/core.js +123 -0
- package/dist/src/browser/core.js.map +1 -0
- package/dist/src/browser/csv-to-json-browser.js +353 -0
- package/dist/src/browser/csv-to-json-browser.js.map +1 -0
- package/dist/src/browser/errors-browser.js +219 -0
- package/dist/src/browser/errors-browser.js.map +1 -0
- package/dist/src/browser/extensions/plugins.js +106 -0
- package/dist/src/browser/extensions/plugins.js.map +1 -0
- package/dist/src/browser/extensions/workers.js +66 -0
- package/dist/src/browser/extensions/workers.js.map +1 -0
- package/dist/src/browser/index.js +140 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/browser/json-to-csv-browser.js +225 -0
- package/dist/src/browser/json-to-csv-browser.js.map +1 -0
- package/dist/src/browser/streams.js +340 -0
- package/dist/src/browser/streams.js.map +1 -0
- package/dist/src/browser/workers/csv-parser.worker.js +264 -0
- package/dist/src/browser/workers/csv-parser.worker.js.map +1 -0
- package/dist/src/browser/workers/worker-pool.js +338 -0
- package/dist/src/browser/workers/worker-pool.js.map +1 -0
- package/dist/src/core/delimiter-cache.js +196 -0
- package/dist/src/core/delimiter-cache.js.map +1 -0
- package/dist/src/core/node-optimizations.js +279 -0
- package/dist/src/core/node-optimizations.js.map +1 -0
- package/dist/src/core/plugin-system.js +399 -0
- package/dist/src/core/plugin-system.js.map +1 -0
- package/dist/src/core/transform-hooks.js +348 -0
- package/dist/src/core/transform-hooks.js.map +1 -0
- package/dist/src/engines/fast-path-engine-new.js +262 -0
- package/dist/src/engines/fast-path-engine-new.js.map +1 -0
- package/dist/src/engines/fast-path-engine.js +671 -0
- package/dist/src/engines/fast-path-engine.js.map +1 -0
- package/dist/src/errors.js +18 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/formats/ndjson-parser.js +332 -0
- package/dist/src/formats/ndjson-parser.js.map +1 -0
- package/dist/src/formats/tsv-parser.js +230 -0
- package/dist/src/formats/tsv-parser.js.map +1 -0
- package/dist/src/index-with-plugins.js +259 -0
- package/dist/src/index-with-plugins.js.map +1 -0
- package/dist/src/types/index.js +3 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/bom-utils.js +267 -0
- package/dist/src/utils/bom-utils.js.map +1 -0
- package/dist/src/utils/encoding-support.js +77 -0
- package/dist/src/utils/encoding-support.js.map +1 -0
- package/dist/src/utils/schema-validator.js +609 -0
- package/dist/src/utils/schema-validator.js.map +1 -0
- package/dist/src/utils/transform-loader.js +281 -0
- package/dist/src/utils/transform-loader.js.map +1 -0
- package/dist/src/utils/validators.js +40 -0
- package/dist/src/utils/validators.js.map +1 -0
- package/dist/src/utils/zod-adapter.js +144 -0
- package/dist/src/utils/zod-adapter.js.map +1 -0
- package/dist/src/web-server/index.js +648 -0
- package/dist/src/web-server/index.js.map +1 -0
- package/dist/src/workers/csv-multithreaded.js +211 -0
- package/dist/src/workers/csv-multithreaded.js.map +1 -0
- package/dist/src/workers/csv-parser.worker.js +179 -0
- package/dist/src/workers/csv-parser.worker.js.map +1 -0
- package/dist/src/workers/worker-pool.js +228 -0
- package/dist/src/workers/worker-pool.js.map +1 -0
- package/dist/stream-csv-to-json.js +665 -0
- package/dist/stream-csv-to-json.js.map +1 -0
- package/dist/stream-json-to-csv.js +389 -0
- package/dist/stream-json-to-csv.js.map +1 -0
- package/examples/advanced/conditional-transformations.ts +446 -0
- package/examples/advanced/csv-parser.worker.ts +89 -0
- package/examples/advanced/nested-objects-example.ts +306 -0
- package/examples/advanced/performance-optimization.ts +504 -0
- package/examples/advanced/run-demo-server.ts +116 -0
- package/examples/advanced/web-worker-usage.html +874 -0
- package/examples/async-multithreaded-example.ts +335 -0
- package/examples/cli-advanced-usage.md +290 -0
- package/examples/{cli-batch-processing.js → cli-batch-processing.ts} +38 -38
- package/examples/{cli-tool.js → cli-tool.ts} +5 -8
- package/examples/{error-handling.js → error-handling.ts} +356 -324
- package/examples/{express-api.js → express-api.ts} +161 -164
- package/examples/{large-dataset-example.js → large-dataset-example.ts} +201 -182
- package/examples/{ndjson-processing.js → ndjson-processing.ts} +456 -434
- package/examples/{plugin-excel-exporter.js → plugin-excel-exporter.ts} +6 -7
- package/examples/react-integration.tsx +637 -0
- package/examples/{schema-validation.js → schema-validation.ts} +2 -2
- package/examples/simple-usage.ts +194 -0
- package/examples/{streaming-example.js → streaming-example.ts} +12 -12
- package/index.d.ts +187 -18
- package/package.json +75 -81
- package/plugins.d.ts +37 -0
- package/schema.d.ts +103 -0
- package/src/browser/browser-functions.ts +402 -0
- package/src/browser/core.ts +152 -0
- package/src/browser/csv-to-json-browser.d.ts +3 -0
- package/src/browser/csv-to-json-browser.ts +494 -0
- package/src/browser/{errors-browser.js → errors-browser.ts} +305 -197
- package/src/browser/extensions/plugins.ts +93 -0
- package/src/browser/extensions/workers.ts +39 -0
- package/src/browser/globals.d.ts +5 -0
- package/src/browser/index.ts +192 -0
- package/src/browser/json-to-csv-browser.d.ts +3 -0
- package/src/browser/json-to-csv-browser.ts +338 -0
- package/src/browser/streams.ts +403 -0
- package/src/browser/workers/{csv-parser.worker.js → csv-parser.worker.ts} +3 -3
- package/src/browser/workers/{worker-pool.js → worker-pool.ts} +51 -30
- package/src/core/delimiter-cache.ts +320 -0
- package/src/core/{node-optimizations.js → node-optimizations.ts} +448 -407
- package/src/core/plugin-system.ts +588 -0
- package/src/core/transform-hooks.ts +566 -0
- package/src/engines/{fast-path-engine-new.js → fast-path-engine-new.ts} +11 -2
- package/src/engines/{fast-path-engine.js → fast-path-engine.ts} +79 -53
- package/src/errors.ts +1 -0
- package/src/formats/{ndjson-parser.js → ndjson-parser.ts} +24 -16
- package/src/formats/{tsv-parser.js → tsv-parser.ts} +18 -17
- package/src/{index-with-plugins.js → index-with-plugins.ts} +381 -357
- package/src/types/index.ts +275 -0
- package/src/utils/bom-utils.ts +373 -0
- package/src/utils/encoding-support.ts +155 -0
- package/src/utils/{schema-validator.js → schema-validator.ts} +814 -589
- package/src/utils/transform-loader.ts +389 -0
- package/src/utils/validators.ts +35 -0
- package/src/utils/zod-adapter.ts +280 -0
- package/src/web-server/{index.js → index.ts} +19 -19
- package/src/workers/csv-multithreaded.ts +310 -0
- package/src/workers/csv-parser.worker.ts +227 -0
- package/src/workers/worker-pool.ts +409 -0
- package/bin/jtcsv.js +0 -2462
- package/csv-to-json.js +0 -688
- package/errors.js +0 -208
- package/examples/simple-usage.js +0 -282
- package/index.js +0 -68
- package/json-save.js +0 -254
- package/json-to-csv.js +0 -526
- package/plugins/README.md +0 -91
- package/plugins/express-middleware/README.md +0 -64
- package/plugins/express-middleware/example.js +0 -136
- package/plugins/express-middleware/index.d.ts +0 -114
- package/plugins/express-middleware/index.js +0 -360
- package/plugins/express-middleware/package.json +0 -52
- package/plugins/fastify-plugin/index.js +0 -406
- package/plugins/fastify-plugin/package.json +0 -55
- package/plugins/hono/README.md +0 -28
- package/plugins/hono/index.d.ts +0 -12
- package/plugins/hono/index.js +0 -36
- package/plugins/hono/package.json +0 -35
- package/plugins/nestjs/README.md +0 -35
- package/plugins/nestjs/index.d.ts +0 -25
- package/plugins/nestjs/index.js +0 -77
- package/plugins/nestjs/package.json +0 -37
- package/plugins/nextjs-api/README.md +0 -57
- package/plugins/nextjs-api/examples/ConverterComponent.jsx +0 -386
- package/plugins/nextjs-api/examples/api-convert.js +0 -69
- package/plugins/nextjs-api/index.js +0 -387
- package/plugins/nextjs-api/package.json +0 -63
- package/plugins/nextjs-api/route.js +0 -371
- package/plugins/nuxt/README.md +0 -24
- package/plugins/nuxt/index.js +0 -21
- package/plugins/nuxt/package.json +0 -35
- package/plugins/nuxt/runtime/composables/useJtcsv.js +0 -6
- package/plugins/nuxt/runtime/plugin.js +0 -6
- package/plugins/remix/README.md +0 -26
- package/plugins/remix/index.d.ts +0 -16
- package/plugins/remix/index.js +0 -62
- package/plugins/remix/package.json +0 -35
- package/plugins/sveltekit/README.md +0 -28
- package/plugins/sveltekit/index.d.ts +0 -17
- package/plugins/sveltekit/index.js +0 -54
- package/plugins/sveltekit/package.json +0 -33
- package/plugins/trpc/README.md +0 -25
- package/plugins/trpc/index.d.ts +0 -7
- package/plugins/trpc/index.js +0 -32
- package/plugins/trpc/package.json +0 -34
- package/src/browser/browser-functions.js +0 -219
- package/src/browser/csv-to-json-browser.js +0 -700
- package/src/browser/index.js +0 -113
- package/src/browser/json-to-csv-browser.js +0 -309
- package/src/browser/streams.js +0 -393
- package/src/core/delimiter-cache.js +0 -186
- package/src/core/plugin-system.js +0 -476
- package/src/core/transform-hooks.js +0 -350
- package/src/errors.js +0 -26
- package/src/utils/transform-loader.js +0 -205
- package/stream-csv-to-json.js +0 -542
- package/stream-json-to-csv.js +0 -464
- /package/examples/{web-workers-advanced.js → web-workers-advanced.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,86 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jtcsv",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Complete JSON<->CSV and CSV<->JSON converter for Node.js and Browser with streaming, security, Web Workers, TypeScript support, and optional ecosystem (zero-deps core)",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/jtcsv.umd.js",
|
|
7
7
|
"module": "dist/jtcsv.esm.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"jtcsv": "bin/jtcsv.js"
|
|
10
|
+
"jtcsv": "dist/bin/jtcsv.js"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"require": "./index.js",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
15
|
"import": "./dist/jtcsv.esm.js",
|
|
16
16
|
"browser": "./dist/jtcsv.umd.js",
|
|
17
|
-
"default": "./index.js"
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./browser": {
|
|
20
|
+
"types": "./browser.d.ts",
|
|
20
21
|
"require": "./dist/jtcsv.cjs.js",
|
|
21
22
|
"import": "./dist/jtcsv.esm.js",
|
|
22
23
|
"browser": "./dist/jtcsv.umd.js",
|
|
23
24
|
"default": "./dist/jtcsv.esm.js"
|
|
24
25
|
},
|
|
25
26
|
"./plugins": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"types": "./plugins.d.ts",
|
|
28
|
+
"require": "./dist/src/index-with-plugins.js",
|
|
29
|
+
"import": "./dist/src/index-with-plugins.js",
|
|
30
|
+
"default": "./dist/src/index-with-plugins.js"
|
|
29
31
|
},
|
|
30
|
-
"./
|
|
31
|
-
"require": "./
|
|
32
|
-
"import": "./
|
|
33
|
-
"default": "./
|
|
32
|
+
"./cli": {
|
|
33
|
+
"require": "./dist/bin/jtcsv.js",
|
|
34
|
+
"import": "./dist/bin/jtcsv.js",
|
|
35
|
+
"default": "./dist/bin/jtcsv.js"
|
|
34
36
|
},
|
|
35
|
-
"./
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"./nextjs": {
|
|
41
|
-
"require": "./plugins/nextjs-api/index.js",
|
|
42
|
-
"import": "./plugins/nextjs-api/index.js",
|
|
43
|
-
"default": "./plugins/nextjs-api/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./nextjs/route": {
|
|
46
|
-
"require": "./plugins/nextjs-api/route.js",
|
|
47
|
-
"import": "./plugins/nextjs-api/route.js",
|
|
48
|
-
"default": "./plugins/nextjs-api/route.js"
|
|
49
|
-
},
|
|
50
|
-
"./nestjs": {
|
|
51
|
-
"require": "./plugins/nestjs/index.js",
|
|
52
|
-
"import": "./plugins/nestjs/index.js",
|
|
53
|
-
"default": "./plugins/nestjs/index.js"
|
|
54
|
-
},
|
|
55
|
-
"./remix": {
|
|
56
|
-
"require": "./plugins/remix/index.js",
|
|
57
|
-
"import": "./plugins/remix/index.js",
|
|
58
|
-
"default": "./plugins/remix/index.js"
|
|
59
|
-
},
|
|
60
|
-
"./nuxt": {
|
|
61
|
-
"require": "./plugins/nuxt/index.js",
|
|
62
|
-
"import": "./plugins/nuxt/index.js",
|
|
63
|
-
"default": "./plugins/nuxt/index.js"
|
|
64
|
-
},
|
|
65
|
-
"./sveltekit": {
|
|
66
|
-
"require": "./plugins/sveltekit/index.js",
|
|
67
|
-
"import": "./plugins/sveltekit/index.js",
|
|
68
|
-
"default": "./plugins/sveltekit/index.js"
|
|
69
|
-
},
|
|
70
|
-
"./hono": {
|
|
71
|
-
"require": "./plugins/hono/index.js",
|
|
72
|
-
"import": "./plugins/hono/index.js",
|
|
73
|
-
"default": "./plugins/hono/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./trpc": {
|
|
76
|
-
"require": "./plugins/trpc/index.js",
|
|
77
|
-
"import": "./plugins/trpc/index.js",
|
|
78
|
-
"default": "./plugins/trpc/index.js"
|
|
37
|
+
"./schema": {
|
|
38
|
+
"types": "./schema.d.ts",
|
|
39
|
+
"require": "./dist/src/utils/schema-validator.js",
|
|
40
|
+
"import": "./dist/src/utils/schema-validator.js",
|
|
41
|
+
"default": "./dist/src/utils/schema-validator.js"
|
|
79
42
|
}
|
|
80
43
|
},
|
|
81
44
|
"scripts": {
|
|
82
45
|
"test": "jest",
|
|
83
|
-
"test:
|
|
46
|
+
"test:unit": "jest --testPathIgnorePatterns=\"(__tests__/benchmark-suite.test.js|__tests__/load-tests.test.js|__tests__/soak-memory.test.js|__tests__/security-fuzzing.test.js|__tests__/memory-profiling.test.js)\"",
|
|
47
|
+
"test:coverage": "node scripts/run-coverage.js --target=ts --scope=full --strict=0",
|
|
48
|
+
"test:coverage:entry": "node scripts/run-coverage.js --target=ts --scope=entry --strict=1",
|
|
49
|
+
"test:coverage:ts": "node scripts/run-coverage.js --target=ts --scope=full --strict=0",
|
|
84
50
|
"test:watch": "jest --watch",
|
|
85
51
|
"test:browser": "jest --testEnvironment=jsdom",
|
|
86
52
|
"test:plugins": "jest __tests__/plugin-system.test.js",
|
|
@@ -89,39 +55,55 @@
|
|
|
89
55
|
"test:performance": "jest __tests__/*.test.js --testNamePattern=\"Производительность|производительность\"",
|
|
90
56
|
"test:benchmark": "jest __tests__/benchmark-suite.test.js --testTimeout=60000",
|
|
91
57
|
"test:load": "jest __tests__/load-tests.test.js --testTimeout=300000",
|
|
92
|
-
"test:load:large": "LOAD_TEST_SIZE=large jest __tests__/load-tests.test.js --testTimeout=300000",
|
|
58
|
+
"test:load:large": "cross-env LOAD_TEST_SIZE=large jest __tests__/load-tests.test.js --testTimeout=300000",
|
|
93
59
|
"test:security": "jest __tests__/security-fuzzing.test.js --testTimeout=60000",
|
|
94
60
|
"test:memory": "node --expose-gc node_modules/jest/bin/jest __tests__/memory-profiling.test.js --testTimeout=120000",
|
|
95
61
|
"test:express": "cd plugins/express-middleware && npm test",
|
|
96
62
|
"test:fastify": "cd plugins/fastify-plugin && npm test",
|
|
97
63
|
"test:nextjs": "cd plugins/nextjs-api && npm test",
|
|
98
|
-
"lint": "eslint index.
|
|
64
|
+
"lint": "eslint index.ts json-to-csv.ts csv-to-json.ts errors.ts stream-json-to-csv.ts stream-csv-to-json.ts json-save.ts",
|
|
99
65
|
"lint:all": "eslint .",
|
|
100
66
|
"lint:plugins": "eslint plugins/",
|
|
101
67
|
"security-check": "npm audit",
|
|
102
|
-
"prepublishOnly": "npm test && npm run build && eslint index.
|
|
68
|
+
"prepublishOnly": "npm test && npm run build && eslint index.ts json-to-csv.ts csv-to-json.ts errors.ts stream-json-to-csv.ts stream-csv-to-json.ts json-save.ts",
|
|
103
69
|
"tui": "node packages/jtcsv-tui/bin/jtcsv-tui.js",
|
|
104
|
-
"cli": "node bin/jtcsv.js",
|
|
105
|
-
"build": "rollup -c rollup.config.mjs",
|
|
70
|
+
"cli": "node dist/bin/jtcsv.js",
|
|
71
|
+
"build": "npm run tsc:build && rollup -c rollup.config.mjs",
|
|
106
72
|
"build:watch": "rollup -c rollup.config.mjs -w",
|
|
107
|
-
"build:prod": "NODE_ENV=production rollup -c rollup.config.mjs",
|
|
108
|
-
"dev": "NODE_ENV=development rollup -c rollup.config.mjs -w",
|
|
109
|
-
"
|
|
73
|
+
"build:prod": "npm run tsc:build && cross-env NODE_ENV=production rollup -c rollup.config.mjs",
|
|
74
|
+
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.mjs -w",
|
|
75
|
+
"verify:browser": "node scripts/verify-browser-build.js",
|
|
76
|
+
"demo": "npm run build && node dist/run-demo.js",
|
|
110
77
|
"demo:web": "cd demo && npm run dev",
|
|
111
78
|
"demo:serve": "cd demo && npm run serve",
|
|
112
79
|
"demo:plugins": "node examples/plugin-excel-exporter.js",
|
|
113
80
|
"demo:express": "cd plugins/express-middleware && node example.js",
|
|
114
81
|
"size": "size-limit",
|
|
115
82
|
"size:why": "size-limit --why",
|
|
116
|
-
"benchmark": "node benchmark.js",
|
|
117
|
-
"benchmark:fastpath": "node benchmark.js --fastpath",
|
|
118
|
-
"profile:perf": "node scripts/profile-performance.js",
|
|
83
|
+
"benchmark": "npm run build && node dist/benchmark.js",
|
|
84
|
+
"benchmark:fastpath": "npm run build && node dist/benchmark.js --fastpath",
|
|
85
|
+
"profile:perf": "npm run build && node dist/scripts/profile-performance.js",
|
|
119
86
|
"example:plugins": "node examples/plugin-excel-exporter.js",
|
|
120
87
|
"example:express": "cd plugins/express-middleware && node example.js",
|
|
121
88
|
"plugins:build": "npm run build && cd plugins/express-middleware && npm run build && cd ../fastify-plugin && npm run build && cd ../nextjs-api && npm run build",
|
|
122
89
|
"docs": "typedoc",
|
|
123
90
|
"docs:watch": "typedoc --watch",
|
|
124
|
-
"docs:serve": "typedoc && npx serve docs/api"
|
|
91
|
+
"docs:serve": "typedoc && npx serve docs/api",
|
|
92
|
+
"tsc": "tsc",
|
|
93
|
+
"tsc:dev": "tsc --project tsconfig.dev.json",
|
|
94
|
+
"tsc:build": "tsc --project tsconfig.build.json",
|
|
95
|
+
"tsc:watch": "tsc --project tsconfig.dev.json --watch",
|
|
96
|
+
"tsc:check": "tsc --noEmit",
|
|
97
|
+
"tsc:check-strict": "tsc --noEmit --strict",
|
|
98
|
+
"tsc:types": "tsc --project tsconfig.types.json",
|
|
99
|
+
"test:ts": "jest --config jest.config.ts.js",
|
|
100
|
+
"test:ts:coverage": "jest --config jest.config.ts.js --coverage",
|
|
101
|
+
"test:ts:watch": "jest --config jest.config.ts.js --watch",
|
|
102
|
+
"test:types": "npm run tsc:build && node scripts/run-type-tests.js",
|
|
103
|
+
"build:ts": "npm run build",
|
|
104
|
+
"build:ts:watch": "npm run tsc:watch & npm run build:watch",
|
|
105
|
+
"lint:ts": "eslint --ext .ts,.tsx .",
|
|
106
|
+
"lint:ts:fix": "eslint --ext .ts,.tsx --fix ."
|
|
125
107
|
},
|
|
126
108
|
"keywords": [
|
|
127
109
|
"json",
|
|
@@ -186,44 +168,56 @@
|
|
|
186
168
|
"node": ">=12.0.0"
|
|
187
169
|
},
|
|
188
170
|
"files": [
|
|
189
|
-
"index.js",
|
|
190
|
-
"json-to-csv.js",
|
|
191
|
-
"csv-to-json.js",
|
|
192
|
-
"errors.js",
|
|
193
|
-
"stream-json-to-csv.js",
|
|
194
|
-
"stream-csv-to-json.js",
|
|
195
|
-
"json-save.js",
|
|
196
171
|
"index.d.ts",
|
|
172
|
+
"browser.d.ts",
|
|
173
|
+
"plugins.d.ts",
|
|
174
|
+
"schema.d.ts",
|
|
197
175
|
"bin/",
|
|
198
176
|
"dist/",
|
|
199
177
|
"src/",
|
|
200
|
-
"examples/"
|
|
201
|
-
"plugins/"
|
|
178
|
+
"examples/"
|
|
202
179
|
],
|
|
203
|
-
"dependencies": {},
|
|
204
180
|
"optionalDependencies": {
|
|
205
181
|
"glob": "^11.0.0"
|
|
206
182
|
},
|
|
207
183
|
"devDependencies": {
|
|
208
184
|
"@babel/core": "^7.26.0",
|
|
185
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
|
|
186
|
+
"@babel/plugin-proposal-optional-chaining": "7.21.0",
|
|
187
|
+
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
188
|
+
"@babel/plugin-syntax-jsx": "7.28.6",
|
|
209
189
|
"@babel/preset-env": "^7.26.0",
|
|
190
|
+
"@babel/preset-react": "7.28.5",
|
|
210
191
|
"@eslint/js": "^9.18.0",
|
|
211
192
|
"@rollup/plugin-babel": "^6.0.4",
|
|
212
193
|
"@rollup/plugin-commonjs": "^28.0.0",
|
|
213
194
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
214
195
|
"@rollup/plugin-terser": "^0.4.4",
|
|
196
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
215
197
|
"@size-limit/preset-small-lib": "^11.1.0",
|
|
198
|
+
"@types/express": "5.0.6",
|
|
199
|
+
"@types/jest": "^29.5.14",
|
|
200
|
+
"@types/node": "^22.10.6",
|
|
216
201
|
"blessed": "^0.1.81",
|
|
217
|
-
"blessed-contrib": "
|
|
202
|
+
"blessed-contrib": "4.11.0",
|
|
203
|
+
"cross-env": "7.0.3",
|
|
218
204
|
"eslint": "^9.18.0",
|
|
205
|
+
"express": "5.2.1",
|
|
219
206
|
"globals": "^15.14.0",
|
|
220
207
|
"jest": "^29.7.0",
|
|
221
208
|
"jest-environment-jsdom": "^29.7.0",
|
|
222
209
|
"rollup": "^4.30.0",
|
|
223
210
|
"size-limit": "^11.1.0",
|
|
224
|
-
"
|
|
211
|
+
"supertest": "7.2.2",
|
|
212
|
+
"ts-jest": "^29.2.5",
|
|
213
|
+
"ts-node": "^10.9.2",
|
|
214
|
+
"tsd": "0.33.0",
|
|
215
|
+
"tslib": "^2.8.1",
|
|
216
|
+
"typedoc": "^0.27.0",
|
|
217
|
+
"typescript": "^5.7.3"
|
|
225
218
|
},
|
|
226
219
|
"type": "commonjs",
|
|
220
|
+
"sideEffects": false,
|
|
227
221
|
"size-limit": [
|
|
228
222
|
{
|
|
229
223
|
"path": "dist/jtcsv.umd.js",
|
package/plugins.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CsvToJsonOptions, JsonToCsvOptions, SaveAsCsvOptions } from './index';
|
|
2
|
+
|
|
3
|
+
export interface JtcsvWithPluginsOptions {
|
|
4
|
+
enableFastPath?: boolean;
|
|
5
|
+
enablePlugins?: boolean;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PluginHookContext {
|
|
10
|
+
operation: string;
|
|
11
|
+
options?: any;
|
|
12
|
+
metadata?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class JtcsvWithPlugins {
|
|
16
|
+
constructor(options?: JtcsvWithPluginsOptions);
|
|
17
|
+
csvToJson(csv: string, options?: CsvToJsonOptions): Promise<any[]>;
|
|
18
|
+
csvToJsonIterator(csv: string, options?: CsvToJsonOptions): AsyncGenerator<any, void, unknown>;
|
|
19
|
+
jsonToCsv(json: any[], options?: JsonToCsvOptions): Promise<string>;
|
|
20
|
+
saveAsCsv(data: any[], filePath: string, options?: SaveAsCsvOptions): Promise<void>;
|
|
21
|
+
readCsvAsJson(filePath: string, options?: CsvToJsonOptions): Promise<any[]>;
|
|
22
|
+
parseNdjson(input: string | ReadableStream, options?: any): Promise<any[]>;
|
|
23
|
+
toNdjson(data: any[], options?: any): string;
|
|
24
|
+
fromNdjson(input: string, options?: any): any[];
|
|
25
|
+
use(name: string, plugin: any): void;
|
|
26
|
+
getStats(): any;
|
|
27
|
+
configure(newOptions: JtcsvWithPluginsOptions): this;
|
|
28
|
+
static create(options?: JtcsvWithPluginsOptions): JtcsvWithPlugins;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class PluginManager {}
|
|
32
|
+
export class FastPathEngine {}
|
|
33
|
+
export class NdjsonParser {}
|
|
34
|
+
|
|
35
|
+
export const create: typeof JtcsvWithPlugins.create;
|
|
36
|
+
|
|
37
|
+
export default JtcsvWithPlugins;
|
package/schema.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export interface SchemaRule {
|
|
2
|
+
type?: string | string[];
|
|
3
|
+
required?: boolean;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
pattern?: string | RegExp;
|
|
7
|
+
enum?: any[];
|
|
8
|
+
minLength?: number;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
minimum?: number;
|
|
11
|
+
maximum?: number;
|
|
12
|
+
exclusiveMinimum?: number;
|
|
13
|
+
exclusiveMaximum?: number;
|
|
14
|
+
multipleOf?: number;
|
|
15
|
+
minItems?: number;
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
uniqueItems?: boolean;
|
|
18
|
+
items?: SchemaRule;
|
|
19
|
+
properties?: Record<string, SchemaRule>;
|
|
20
|
+
format?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Schema extends Record<string, any> {
|
|
24
|
+
properties?: Record<string, SchemaRule>;
|
|
25
|
+
required?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ValidationErrorItem {
|
|
29
|
+
row: number;
|
|
30
|
+
type: string;
|
|
31
|
+
field: string;
|
|
32
|
+
message: string;
|
|
33
|
+
value?: any;
|
|
34
|
+
expected?: any;
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
pattern?: string;
|
|
38
|
+
allowed?: any[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ValidationResult {
|
|
42
|
+
valid: boolean;
|
|
43
|
+
errors: ValidationErrorItem[];
|
|
44
|
+
warnings: any[];
|
|
45
|
+
summary: {
|
|
46
|
+
totalRows: number;
|
|
47
|
+
validRows: number;
|
|
48
|
+
errorCount: number;
|
|
49
|
+
warningCount: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ApplySchemaValidationResult {
|
|
54
|
+
valid: boolean;
|
|
55
|
+
errors: Array<{ row: number; message: string; data: any }>;
|
|
56
|
+
data: any[];
|
|
57
|
+
summary: {
|
|
58
|
+
totalRows: number;
|
|
59
|
+
validRows: number;
|
|
60
|
+
errorCount: number;
|
|
61
|
+
errorRate: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface Validator {
|
|
66
|
+
validate(data: any[], options?: { stopOnFirstError?: boolean; transform?: boolean }): ValidationResult;
|
|
67
|
+
schema?(schema: any): void;
|
|
68
|
+
field?(field: string, rule: any): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function loadSchema(schemaPathOrJson: string): Schema;
|
|
72
|
+
export function loadSchemaAsync(schemaPathOrJson: string): Promise<Schema>;
|
|
73
|
+
export function createValidationHook(
|
|
74
|
+
schema: string | Schema
|
|
75
|
+
): (row: any, index: number, context: any) => any;
|
|
76
|
+
export function createAsyncValidationHook(
|
|
77
|
+
schema: string | Schema
|
|
78
|
+
): (row: any, index: number, context: any) => Promise<unknown>;
|
|
79
|
+
export function applySchemaValidation(
|
|
80
|
+
data: any[],
|
|
81
|
+
schema: string | Schema
|
|
82
|
+
): ApplySchemaValidationResult;
|
|
83
|
+
export function applySchemaValidationAsync(
|
|
84
|
+
data: any[],
|
|
85
|
+
schema: string | Schema
|
|
86
|
+
): Promise<ApplySchemaValidationResult>;
|
|
87
|
+
export function createValidationHooks(schema: Schema): any;
|
|
88
|
+
export function checkType(value: any, rule: SchemaRule): boolean;
|
|
89
|
+
export function createSchemaValidators(schema: Schema): Record<string, any>;
|
|
90
|
+
|
|
91
|
+
declare const schemaValidator: {
|
|
92
|
+
loadSchema: typeof loadSchema;
|
|
93
|
+
loadSchemaAsync: typeof loadSchemaAsync;
|
|
94
|
+
createValidationHook: typeof createValidationHook;
|
|
95
|
+
createAsyncValidationHook: typeof createAsyncValidationHook;
|
|
96
|
+
applySchemaValidation: typeof applySchemaValidation;
|
|
97
|
+
applySchemaValidationAsync: typeof applySchemaValidationAsync;
|
|
98
|
+
createValidationHooks: typeof createValidationHooks;
|
|
99
|
+
checkType: typeof checkType;
|
|
100
|
+
createSchemaValidators: typeof createSchemaValidators;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default schemaValidator;
|