@budibase/server 2.5.10-alpha.0 → 2.5.10-alpha.1
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/dist/api/controllers/row/internal.js +5 -2
- package/dist/api/controllers/row/utils.js +2 -2
- package/dist/api/controllers/table/index.js +2 -2
- package/dist/api/controllers/view/exporters.js +3 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/csv.js +33 -0
- package/dist/utilities/schema.js +5 -1
- package/package.json +8 -8
- package/src/api/controllers/row/internal.ts +4 -1
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/table/index.ts +2 -2
- package/src/api/controllers/view/exporters.ts +3 -1
- package/src/utilities/csv.ts +22 -0
- package/src/utilities/schema.ts +8 -0
- package/src/utilities/tests/csv.spec.ts +33 -0
|
@@ -63,7 +63,7 @@ const backend_core_1 = require("@budibase/backend-core");
|
|
|
63
63
|
const staticFormula_1 = require("./staticFormula");
|
|
64
64
|
const exporters_1 = require("../view/exporters");
|
|
65
65
|
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
66
|
-
const
|
|
66
|
+
const utils_3 = require("./utils");
|
|
67
67
|
const CALCULATION_TYPES = {
|
|
68
68
|
SUM: "sum",
|
|
69
69
|
COUNT: "count",
|
|
@@ -398,6 +398,9 @@ function exportRows(ctx) {
|
|
|
398
398
|
const table = yield db.get(ctx.params.tableId);
|
|
399
399
|
const rowIds = ctx.request.body.rows;
|
|
400
400
|
let format = ctx.query.format;
|
|
401
|
+
if (typeof format !== "string") {
|
|
402
|
+
ctx.throw(400, "Format parameter is not valid");
|
|
403
|
+
}
|
|
401
404
|
const { columns, query } = ctx.request.body;
|
|
402
405
|
let result;
|
|
403
406
|
if (rowIds) {
|
|
@@ -425,7 +428,7 @@ function exportRows(ctx) {
|
|
|
425
428
|
else {
|
|
426
429
|
rows = result;
|
|
427
430
|
}
|
|
428
|
-
let exportRows = cleanExportRows(rows, schema, format, columns);
|
|
431
|
+
let exportRows = (0, utils_3.cleanExportRows)(rows, schema, format, columns);
|
|
429
432
|
if (format === exporters_1.Format.CSV) {
|
|
430
433
|
ctx.attachment("export.csv");
|
|
431
434
|
return (0, fileSystem_1.apiFileReturn)((0, exporters_1.csv)(Object.keys(rows[0]), exportRows));
|
|
@@ -164,8 +164,8 @@ function cleanExportRows(rows, schema, format, columns) {
|
|
|
164
164
|
});
|
|
165
165
|
delete schema[column];
|
|
166
166
|
});
|
|
167
|
-
// Intended to avoid 'undefined' in export
|
|
168
167
|
if (format === exporters_1.Format.CSV) {
|
|
168
|
+
// Intended to append empty values in export
|
|
169
169
|
const schemaKeys = Object.keys(schema);
|
|
170
170
|
for (let key of schemaKeys) {
|
|
171
171
|
if ((columns === null || columns === void 0 ? void 0 : columns.length) && columns.indexOf(key) > 0) {
|
|
@@ -173,7 +173,7 @@ function cleanExportRows(rows, schema, format, columns) {
|
|
|
173
173
|
}
|
|
174
174
|
for (let row of cleanRows) {
|
|
175
175
|
if (row[key] == null) {
|
|
176
|
-
row[key] =
|
|
176
|
+
row[key] = undefined;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -43,7 +43,7 @@ const utils_1 = require("../../../integrations/utils");
|
|
|
43
43
|
const utils_2 = require("../../../db/utils");
|
|
44
44
|
const backend_core_1 = require("@budibase/backend-core");
|
|
45
45
|
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
46
|
-
const
|
|
46
|
+
const csv_1 = require("../../../utilities/csv");
|
|
47
47
|
function pickApi({ tableId, table }) {
|
|
48
48
|
if (table && !tableId) {
|
|
49
49
|
tableId = table._id;
|
|
@@ -136,7 +136,7 @@ exports.bulkImport = bulkImport;
|
|
|
136
136
|
function csvToJson(ctx) {
|
|
137
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
138
|
const { csvString } = ctx.request.body;
|
|
139
|
-
const result = yield (0,
|
|
139
|
+
const result = yield (0, csv_1.jsonFromCsvString)(csvString);
|
|
140
140
|
ctx.status = 200;
|
|
141
141
|
ctx.body = result;
|
|
142
142
|
});
|