@digione/node-custom-api 0.1.9-beta6 → 0.1.9-beta8
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/package.json +1 -1
- package/utils/file.d.ts +4 -3
- package/utils/file.js +8 -7
- package/utils/stream.js +3 -1
package/package.json
CHANGED
package/utils/file.d.ts
CHANGED
|
@@ -147,7 +147,7 @@ export declare class FileUtil {
|
|
|
147
147
|
hidden?: number;
|
|
148
148
|
input?: {};
|
|
149
149
|
}): Promise<any>;
|
|
150
|
-
createFileByPath(files: Array<
|
|
150
|
+
createFileByPath(files: Array<any>, slug: string, user_id: any, { parent_slug, type, name, root, upload, tags, group }?: {
|
|
151
151
|
parent_slug?: string;
|
|
152
152
|
type?: string;
|
|
153
153
|
name?: any;
|
|
@@ -171,7 +171,7 @@ export declare class FileUtil {
|
|
|
171
171
|
user_id: any;
|
|
172
172
|
organ_id: any;
|
|
173
173
|
organ_by: any;
|
|
174
|
-
sort:
|
|
174
|
+
sort: any;
|
|
175
175
|
date_added: string;
|
|
176
176
|
name: any;
|
|
177
177
|
filename: any;
|
|
@@ -181,7 +181,8 @@ export declare class FileUtil {
|
|
|
181
181
|
extension: string;
|
|
182
182
|
type: any;
|
|
183
183
|
is_hidden: any;
|
|
184
|
-
tags:
|
|
184
|
+
tags: any;
|
|
185
|
+
custom: any;
|
|
185
186
|
group: any;
|
|
186
187
|
}[]>;
|
|
187
188
|
insertFileUnique(results: Array<any>, { format, thumb, width, height }?: {
|
package/utils/file.js
CHANGED
|
@@ -470,8 +470,13 @@ class FileUtil {
|
|
|
470
470
|
let folder = yield this.createFolder(slug, { parent_id, root, name });
|
|
471
471
|
let results = [], reqs = [];
|
|
472
472
|
files.forEach((item) => {
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
let addition = {}, path = item;
|
|
474
|
+
if (typeof item == "object") {
|
|
475
|
+
addition = item;
|
|
476
|
+
path = item['path'];
|
|
477
|
+
}
|
|
478
|
+
results.push({ Location: path, Key: path });
|
|
479
|
+
reqs.push(Object.assign({ originalname: (0, helper_1.getSlug)(32), mimetype: null, size: 0, type }, addition));
|
|
475
480
|
});
|
|
476
481
|
results = yield this.formatFile(folder['id'], user_id, reqs, results, { input, tags, group });
|
|
477
482
|
return yield this.insertFileUnique(results);
|
|
@@ -577,11 +582,7 @@ class FileUtil {
|
|
|
577
582
|
let item = Object.assign(Object.assign({}, input), { folder_id,
|
|
578
583
|
user_id,
|
|
579
584
|
organ_id,
|
|
580
|
-
organ_by,
|
|
581
|
-
sort,
|
|
582
|
-
date_added, name: reqs[key].originalname || (0, helper_1.getSlug)(32), filename: reqs[key].Key || file.Key || input['filename'], path, mimetype: reqs[key].mimetype, filesize: reqs[key].size, extension: (extension ? "." + extension : ''), type: reqs[key].type || file.type || input['type'], is_hidden,
|
|
583
|
-
tags,
|
|
584
|
-
group });
|
|
585
|
+
organ_by, sort: reqs[key].sort || sort, date_added, name: reqs[key].originalname || (0, helper_1.getSlug)(32), filename: reqs[key].Key || file.Key || input['filename'], path, mimetype: reqs[key].mimetype, filesize: reqs[key].size, extension: (extension ? "." + extension : ''), type: reqs[key].type || file.type || input['type'], is_hidden, tags: reqs[key].tags || tags, custom: reqs[key].custom || input['custom'], group });
|
|
585
586
|
if (format) {
|
|
586
587
|
item = yield this.afterQueryFile(item);
|
|
587
588
|
}
|
package/utils/stream.js
CHANGED
|
@@ -474,6 +474,7 @@ class StreamUtil {
|
|
|
474
474
|
if (convert_option) {
|
|
475
475
|
let obj_value = {};
|
|
476
476
|
if (item['field_type'] == "choice") {
|
|
477
|
+
let opt_empty = false;
|
|
477
478
|
if (field_data['choice_data']) {
|
|
478
479
|
let data = [];
|
|
479
480
|
data = field_data['choice_data'].split('\n');
|
|
@@ -496,6 +497,7 @@ class StreamUtil {
|
|
|
496
497
|
data[k] = { key, value };
|
|
497
498
|
}
|
|
498
499
|
else {
|
|
500
|
+
opt_empty = true;
|
|
499
501
|
data[k] = { key: '', value };
|
|
500
502
|
}
|
|
501
503
|
}
|
|
@@ -522,7 +524,7 @@ class StreamUtil {
|
|
|
522
524
|
}
|
|
523
525
|
if (convert_value && typeof item['field_value'] != "undefined") {
|
|
524
526
|
let field_value = item['field_value'];
|
|
525
|
-
if (item['field_value'] == null)
|
|
527
|
+
if (item['field_value'] == null && opt_empty)
|
|
526
528
|
field_value = '';
|
|
527
529
|
field_data['value'] = obj_value[field_value];
|
|
528
530
|
}
|