csv-to-pg 3.10.3 → 3.10.5
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 +20 -20
- package/esm/parse.js +33 -0
- package/package.json +2 -2
- package/parse.js +33 -0
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# csv-to-pg
|
|
2
2
|
|
|
3
3
|
<p align="center" width="100%">
|
|
4
|
-
<img height="250" src="https://raw.githubusercontent.com/
|
|
4
|
+
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center" width="100%">
|
|
8
|
-
<a href="https://github.com/
|
|
9
|
-
<img height="20" src="https://github.com/
|
|
8
|
+
<a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
|
|
9
|
+
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://github.com/
|
|
12
|
-
<a href="https://www.npmjs.com/package/csv-to-pg"><img height="20" src="https://img.shields.io/github/package-json/v/
|
|
11
|
+
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/csv-to-pg"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Fcsv-to-pg%2Fpackage.json"/></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
Create PostgreSQL statements from CSV files
|
|
@@ -64,9 +64,9 @@ csv2pg ./config.yaml
|
|
|
64
64
|
|
|
65
65
|
### 🧪 Testing
|
|
66
66
|
|
|
67
|
-
* [launchql/pgsql-test](https://github.com/
|
|
68
|
-
* [launchql/graphile-test](https://github.com/
|
|
69
|
-
* [launchql/pg-query-context](https://github.com/
|
|
67
|
+
* [launchql/pgsql-test](https://github.com/constructive-io/constructive/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
68
|
+
* [launchql/graphile-test](https://github.com/constructive-io/constructive/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
69
|
+
* [launchql/pg-query-context](https://github.com/constructive-io/constructive/tree/main/packages/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
|
|
70
70
|
|
|
71
71
|
### 🧠 Parsing & AST
|
|
72
72
|
|
|
@@ -79,24 +79,24 @@ csv2pg ./config.yaml
|
|
|
79
79
|
|
|
80
80
|
### 🚀 API & Dev Tools
|
|
81
81
|
|
|
82
|
-
* [launchql/server](https://github.com/
|
|
83
|
-
* [launchql/explorer](https://github.com/
|
|
82
|
+
* [launchql/server](https://github.com/constructive-io/constructive/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
|
|
83
|
+
* [launchql/explorer](https://github.com/constructive-io/constructive/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
|
|
84
84
|
|
|
85
85
|
### 🔁 Streaming & Uploads
|
|
86
86
|
|
|
87
|
-
* [launchql/s3-streamer](https://github.com/
|
|
88
|
-
* [launchql/etag-hash](https://github.com/
|
|
89
|
-
* [launchql/etag-stream](https://github.com/
|
|
90
|
-
* [launchql/uuid-hash](https://github.com/
|
|
91
|
-
* [launchql/uuid-stream](https://github.com/
|
|
92
|
-
* [launchql/upload-names](https://github.com/
|
|
87
|
+
* [launchql/s3-streamer](https://github.com/constructive-io/constructive/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
|
|
88
|
+
* [launchql/etag-hash](https://github.com/constructive-io/constructive/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
89
|
+
* [launchql/etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
90
|
+
* [launchql/uuid-hash](https://github.com/constructive-io/constructive/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
91
|
+
* [launchql/uuid-stream](https://github.com/constructive-io/constructive/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
92
|
+
* [launchql/upload-names](https://github.com/constructive-io/constructive/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
|
|
93
93
|
|
|
94
94
|
### 🧰 CLI & Codegen
|
|
95
95
|
|
|
96
|
-
* [@launchql/cli](https://github.com/
|
|
97
|
-
* [
|
|
98
|
-
* [@launchql/query-builder](https://github.com/
|
|
99
|
-
* [@launchql/query](https://github.com/
|
|
96
|
+
* [@launchql/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
|
|
97
|
+
* [constructive-io/constructive-gen](https://github.com/constructive-io/constructive/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
|
|
98
|
+
* [@launchql/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
|
|
99
|
+
* [@launchql/query](https://github.com/constructive-io/constructive/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
|
|
100
100
|
|
|
101
101
|
## Disclaimer
|
|
102
102
|
|
package/esm/parse.js
CHANGED
|
@@ -407,6 +407,39 @@ const getCoercionFunc = (type, from, opts, fieldName) => {
|
|
|
407
407
|
});
|
|
408
408
|
return wrapValue(val, opts);
|
|
409
409
|
};
|
|
410
|
+
case 'jsonb[]':
|
|
411
|
+
return (record) => {
|
|
412
|
+
const rawValue = record[from[0]];
|
|
413
|
+
if (isNullToken(rawValue)) {
|
|
414
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is empty or null');
|
|
415
|
+
}
|
|
416
|
+
if (Array.isArray(rawValue)) {
|
|
417
|
+
if (rawValue.length === 0) {
|
|
418
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'array is empty');
|
|
419
|
+
}
|
|
420
|
+
const elements = rawValue.map(el => JSON.stringify(el));
|
|
421
|
+
const arrayLiteral = psqlArray(elements);
|
|
422
|
+
if (isEmpty(arrayLiteral)) {
|
|
423
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'failed to format array');
|
|
424
|
+
}
|
|
425
|
+
const val = nodes.aConst({
|
|
426
|
+
sval: ast.string({ sval: String(arrayLiteral) })
|
|
427
|
+
});
|
|
428
|
+
return wrapValue(val, opts);
|
|
429
|
+
}
|
|
430
|
+
// If it's a string, try to parse as JSON array
|
|
431
|
+
if (typeof rawValue === 'string') {
|
|
432
|
+
const parsed = parseJson(cleanseEmptyStrings(rawValue));
|
|
433
|
+
if (isEmpty(parsed)) {
|
|
434
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is empty or null');
|
|
435
|
+
}
|
|
436
|
+
const val = nodes.aConst({
|
|
437
|
+
sval: ast.string({ sval: String(parsed) })
|
|
438
|
+
});
|
|
439
|
+
return wrapValue(val, opts);
|
|
440
|
+
}
|
|
441
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is not an array');
|
|
442
|
+
};
|
|
410
443
|
default:
|
|
411
444
|
return (record) => {
|
|
412
445
|
const rawValue = record[from[0]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "csv-to-pg",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.5",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "csv to pg statements",
|
|
6
6
|
"main": "index.js",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"js-yaml": "^4.1.0",
|
|
51
51
|
"pgsql-deparser": "^17.18.1"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3b3735292589a49601f40645ea7880f584a23b77"
|
|
54
54
|
}
|
package/parse.js
CHANGED
|
@@ -416,6 +416,39 @@ const getCoercionFunc = (type, from, opts, fieldName) => {
|
|
|
416
416
|
});
|
|
417
417
|
return (0, utils_2.wrapValue)(val, opts);
|
|
418
418
|
};
|
|
419
|
+
case 'jsonb[]':
|
|
420
|
+
return (record) => {
|
|
421
|
+
const rawValue = record[from[0]];
|
|
422
|
+
if (isNullToken(rawValue)) {
|
|
423
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is empty or null');
|
|
424
|
+
}
|
|
425
|
+
if (Array.isArray(rawValue)) {
|
|
426
|
+
if (rawValue.length === 0) {
|
|
427
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'array is empty');
|
|
428
|
+
}
|
|
429
|
+
const elements = rawValue.map(el => JSON.stringify(el));
|
|
430
|
+
const arrayLiteral = psqlArray(elements);
|
|
431
|
+
if (isEmpty(arrayLiteral)) {
|
|
432
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'failed to format array');
|
|
433
|
+
}
|
|
434
|
+
const val = utils_1.nodes.aConst({
|
|
435
|
+
sval: utils_1.ast.string({ sval: String(arrayLiteral) })
|
|
436
|
+
});
|
|
437
|
+
return (0, utils_2.wrapValue)(val, opts);
|
|
438
|
+
}
|
|
439
|
+
// If it's a string, try to parse as JSON array
|
|
440
|
+
if (typeof rawValue === 'string') {
|
|
441
|
+
const parsed = parseJson(cleanseEmptyStrings(rawValue));
|
|
442
|
+
if (isEmpty(parsed)) {
|
|
443
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is empty or null');
|
|
444
|
+
}
|
|
445
|
+
const val = utils_1.nodes.aConst({
|
|
446
|
+
sval: utils_1.ast.string({ sval: String(parsed) })
|
|
447
|
+
});
|
|
448
|
+
return (0, utils_2.wrapValue)(val, opts);
|
|
449
|
+
}
|
|
450
|
+
return makeNullOrThrow(fieldName, rawValue, type, required, 'value is not an array');
|
|
451
|
+
};
|
|
419
452
|
default:
|
|
420
453
|
return (record) => {
|
|
421
454
|
const rawValue = record[from[0]];
|