@adminforth/import-export
Advanced tools
Comparing version 1.0.0 to 1.0.2
18
index.ts
@@ -100,3 +100,3 @@ import AdminForth, { AdminForthPlugin, Filters, suggestIfTypo, AdminForthFilterOperators } from "adminforth"; | ||
return { data: csv, total: data.total, ok: true }; | ||
return { data: csv, exportedCount: data.total, ok: true }; | ||
@@ -116,2 +116,17 @@ } | ||
const columns = Object.keys(data); | ||
// check column names are valid | ||
const errors: string[] = []; | ||
columns.forEach((col) => { | ||
if (!this.resourceConfig.columns.some((c) => c.name === col)) { | ||
const similar = suggestIfTypo(this.resourceConfig.columns.map((c) => c.name), col); | ||
errors.push(`Column '${col}' defined in CSV not found in resource '${this.resourceConfig.resourceId}'. ${ | ||
similar ? `If you mean '${similar}', rename it in CSV` : 'If column is in database but not in resource configuration, add it with showIn:[]'}` | ||
); | ||
} | ||
}); | ||
if (errors.length > 0) { | ||
return { ok: false, errors }; | ||
} | ||
const columnValues: any[] = Object.values(data); | ||
@@ -126,3 +141,2 @@ for (let i = 0; i < columnValues[0].length; i++) { | ||
const errors: string[] = []; | ||
let importedCount = 0; | ||
@@ -129,0 +143,0 @@ await Promise.all(rows.map(async (row) => { |
{ | ||
"name": "@adminforth/import-export", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"main": "dist/index.js", | ||
@@ -9,3 +9,4 @@ "types": "dist/index.d.ts", | ||
"build": "tsc && rsync -av --exclude 'node_modules' custom dist/ && npm version patch", | ||
"rollout": "npm publish --access public" | ||
"rollout": "npm run build && npm version patch && npm publish --access public", | ||
"prepare": "npm link adminforth" | ||
}, | ||
@@ -16,9 +17,3 @@ "keywords": [], | ||
"description": "", | ||
"devDependencies": { | ||
"@types/node": "^22.6.1", | ||
"adminforth": "file:../..", | ||
"typescript": "^5.6.2" | ||
}, | ||
"dependencies": { | ||
} | ||
"dependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27609
0
10
285