@nocobase/plugin-action-export 1.2.12-alpha → 1.3.0-alpha.20240710084543
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 +2 -2
- package/dist/client/ExportActionInitializer.d.ts +0 -10
- package/dist/client/ExportDesigner.d.ts +0 -10
- package/dist/client/ExportPluginProvider.d.ts +0 -10
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.js +0 -23
- package/dist/client/locale/index.d.ts +0 -10
- package/dist/client/schemaSettings.d.ts +0 -10
- package/dist/client/useExportAction.d.ts +0 -11
- package/dist/client/useFields.d.ts +0 -9
- package/dist/client/useShared.d.ts +0 -79
- package/dist/externalVersion.js +0 -24
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -4
- package/dist/locale/zh-CN.json +0 -4
- package/dist/node_modules/xlsx/LICENSE +0 -201
- package/dist/node_modules/xlsx/bin/xlsx.njs +0 -310
- package/dist/node_modules/xlsx/bower.json +0 -22
- package/dist/node_modules/xlsx/dist/cpexcel.d.ts +0 -39
- package/dist/node_modules/xlsx/dist/cpexcel.js +0 -1506
- package/dist/node_modules/xlsx/dist/shim.min.js +0 -2
- package/dist/node_modules/xlsx/dist/xlsx.core.min.js +0 -17
- package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +0 -27961
- package/dist/node_modules/xlsx/dist/xlsx.full.min.js +0 -24
- package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +0 -10
- package/dist/node_modules/xlsx/dist/xlsx.zahl.js +0 -4
- package/dist/node_modules/xlsx/dist/zahl.d.ts +0 -4
- package/dist/node_modules/xlsx/package.json +0 -1
- package/dist/node_modules/xlsx/types/index.d.ts +0 -1033
- package/dist/node_modules/xlsx/xlsx.js +0 -7
- package/dist/node_modules/xlsx/xlsxworker.js +0 -14
- package/dist/server/actions/export-xlsx.d.ts +0 -10
- package/dist/server/actions/export-xlsx.js +0 -89
- package/dist/server/actions/index.d.ts +0 -9
- package/dist/server/actions/index.js +0 -30
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +0 -76
- package/dist/server/migrations/20240425220631-change-locale-module.d.ts +0 -14
- package/dist/server/migrations/20240425220631-change-locale-module.js +0 -51
- package/dist/server/utils/deep-get.d.ts +0 -9
- package/dist/server/utils/deep-get.js +0 -58
- package/dist/server/xlsx-exporter.d.ts +0 -45
- package/dist/server/xlsx-exporter.js +0 -168
- package/dist/swagger/index.json +0 -21
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
|
2
|
-
importScripts('dist/shim.min.js');
|
|
3
|
-
/* uncomment the next line for encoding support */
|
|
4
|
-
importScripts('dist/cpexcel.js');
|
|
5
|
-
importScripts('xlsx.js');
|
|
6
|
-
postMessage({t:"ready"});
|
|
7
|
-
|
|
8
|
-
onmessage = function (evt) {
|
|
9
|
-
var v;
|
|
10
|
-
try {
|
|
11
|
-
v = XLSX.read(evt.data.d, {type: evt.data.b, codepage: evt.data.c});
|
|
12
|
-
postMessage({t:"xlsx", d:JSON.stringify(v)});
|
|
13
|
-
} catch(e) { postMessage({t:"e",d:e.stack||e}); }
|
|
14
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Context, Next } from '@nocobase/actions';
|
|
10
|
-
export declare function exportXlsx(ctx: Context, next: Next): Promise<void>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var export_xlsx_exports = {};
|
|
38
|
-
__export(export_xlsx_exports, {
|
|
39
|
-
exportXlsx: () => exportXlsx
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(export_xlsx_exports);
|
|
42
|
-
var import_xlsx_exporter = __toESM(require("../xlsx-exporter"));
|
|
43
|
-
var import_xlsx = __toESM(require("xlsx"));
|
|
44
|
-
var import_async_mutex = require("async-mutex");
|
|
45
|
-
const mutex = new import_async_mutex.Mutex();
|
|
46
|
-
async function exportXlsxAction(ctx, next) {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
const { title, filter, sort, fields, except } = ctx.action.params;
|
|
49
|
-
let columns = ((_a = ctx.action.params.values) == null ? void 0 : _a.columns) || ((_b = ctx.action.params) == null ? void 0 : _b.columns);
|
|
50
|
-
if (typeof columns === "string") {
|
|
51
|
-
columns = JSON.parse(columns);
|
|
52
|
-
}
|
|
53
|
-
const repository = ctx.getCurrentRepository();
|
|
54
|
-
const dataSource = ctx.dataSource;
|
|
55
|
-
const collection = repository.collection;
|
|
56
|
-
const xlsxExporter = new import_xlsx_exporter.default({
|
|
57
|
-
collectionManager: dataSource.collectionManager,
|
|
58
|
-
collection,
|
|
59
|
-
columns,
|
|
60
|
-
findOptions: {
|
|
61
|
-
filter,
|
|
62
|
-
fields,
|
|
63
|
-
except,
|
|
64
|
-
sort
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const wb = await xlsxExporter.run();
|
|
68
|
-
ctx.body = import_xlsx.default.write(wb, { type: "buffer", bookType: "xlsx" });
|
|
69
|
-
ctx.set({
|
|
70
|
-
"Content-Type": "application/octet-stream",
|
|
71
|
-
"Content-Disposition": `attachment; filename=${encodeURI(title)}.xlsx`
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
async function exportXlsx(ctx, next) {
|
|
75
|
-
if (mutex.isLocked()) {
|
|
76
|
-
throw new Error(`another export action is running, please try again later.`);
|
|
77
|
-
}
|
|
78
|
-
const release = await mutex.acquire();
|
|
79
|
-
try {
|
|
80
|
-
await exportXlsxAction(ctx, next);
|
|
81
|
-
} finally {
|
|
82
|
-
release();
|
|
83
|
-
}
|
|
84
|
-
await next();
|
|
85
|
-
}
|
|
86
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
-
0 && (module.exports = {
|
|
88
|
-
exportXlsx
|
|
89
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export * from './export-xlsx';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var actions_exports = {};
|
|
25
|
-
module.exports = __toCommonJS(actions_exports);
|
|
26
|
-
__reExport(actions_exports, require("./export-xlsx"), module.exports);
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
...require("./export-xlsx")
|
|
30
|
-
});
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from '@nocobase/server';
|
|
10
|
-
export declare class PluginActionExportServer extends Plugin {
|
|
11
|
-
beforeLoad(): void;
|
|
12
|
-
load(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export default PluginActionExportServer;
|
package/dist/server/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var server_exports = {};
|
|
28
|
-
__export(server_exports, {
|
|
29
|
-
PluginActionExportServer: () => PluginActionExportServer,
|
|
30
|
-
default: () => server_default
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(server_exports);
|
|
33
|
-
var import_server = require("@nocobase/server");
|
|
34
|
-
var import_actions = require("./actions");
|
|
35
|
-
class PluginActionExportServer extends import_server.Plugin {
|
|
36
|
-
beforeLoad() {
|
|
37
|
-
this.app.on("afterInstall", async () => {
|
|
38
|
-
if (!this.app.db.getRepository("roles")) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const roleNames = ["admin", "member"];
|
|
42
|
-
const roles = await this.app.db.getRepository("roles").find({
|
|
43
|
-
filter: {
|
|
44
|
-
name: roleNames
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
for (const role of roles) {
|
|
48
|
-
await this.app.db.getRepository("roles").update({
|
|
49
|
-
filter: {
|
|
50
|
-
name: role.name
|
|
51
|
-
},
|
|
52
|
-
values: {
|
|
53
|
-
strategy: {
|
|
54
|
-
...role.strategy,
|
|
55
|
-
actions: [...role.strategy.actions, "export"]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async load() {
|
|
63
|
-
this.app.dataSourceManager.afterAddDataSource((dataSource) => {
|
|
64
|
-
dataSource.resourceManager.registerActionHandler("export", import_actions.exportXlsx);
|
|
65
|
-
dataSource.acl.setAvailableAction("export", {
|
|
66
|
-
displayName: '{{t("Export")}}',
|
|
67
|
-
allowConfigureFields: true
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
var server_default = PluginActionExportServer;
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
PluginActionExportServer
|
|
76
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Migration } from '@nocobase/server';
|
|
10
|
-
export default class extends Migration {
|
|
11
|
-
on: string;
|
|
12
|
-
appVersion: string;
|
|
13
|
-
up(): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var change_locale_module_exports = {};
|
|
28
|
-
__export(change_locale_module_exports, {
|
|
29
|
-
default: () => change_locale_module_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(change_locale_module_exports);
|
|
32
|
-
var import_server = require("@nocobase/server");
|
|
33
|
-
class change_locale_module_default extends import_server.Migration {
|
|
34
|
-
on = "afterLoad";
|
|
35
|
-
// 'beforeLoad' or 'afterLoad'
|
|
36
|
-
appVersion = "<1.0.0-alpha.1";
|
|
37
|
-
async up() {
|
|
38
|
-
const repo = this.db.getRepository("localizationTexts");
|
|
39
|
-
if (!repo) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
await repo.update({
|
|
43
|
-
filter: {
|
|
44
|
-
module: "resources.export"
|
|
45
|
-
},
|
|
46
|
-
values: {
|
|
47
|
-
module: "resources.action-export"
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export declare function deepGet(object: any, path: any): any;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var deep_get_exports = {};
|
|
38
|
-
__export(deep_get_exports, {
|
|
39
|
-
deepGet: () => deepGet
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(deep_get_exports);
|
|
42
|
-
var import_lodash = __toESM(require("lodash"));
|
|
43
|
-
function deepGet(object, path) {
|
|
44
|
-
const pathParts = Array.isArray(path) ? path : path.split(".");
|
|
45
|
-
let current = object;
|
|
46
|
-
for (const part of pathParts) {
|
|
47
|
-
if (Array.isArray(current)) {
|
|
48
|
-
current = current.map((item) => import_lodash.default.get(item, part));
|
|
49
|
-
} else {
|
|
50
|
-
current = import_lodash.default.get(current, part);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return current;
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
deepGet
|
|
58
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { FindOptions, ICollection, ICollectionManager } from '@nocobase/data-source-manager';
|
|
10
|
-
import XLSX from 'xlsx';
|
|
11
|
-
type ExportColumn = {
|
|
12
|
-
dataIndex: Array<string>;
|
|
13
|
-
defaultTitle: string;
|
|
14
|
-
};
|
|
15
|
-
type ExportOptions = {
|
|
16
|
-
collectionManager: ICollectionManager;
|
|
17
|
-
collection: ICollection;
|
|
18
|
-
columns: Array<ExportColumn>;
|
|
19
|
-
findOptions?: FindOptions;
|
|
20
|
-
chunkSize?: number;
|
|
21
|
-
};
|
|
22
|
-
declare class XlsxExporter {
|
|
23
|
-
private options;
|
|
24
|
-
/**
|
|
25
|
-
* You can adjust the maximum number of exported rows based on business needs and system
|
|
26
|
-
* available resources. However, please note that you need to fully understand the risks
|
|
27
|
-
* after the modification. Increasing the maximum number of rows that can be exported may
|
|
28
|
-
* increase system resource usage, leading to increased processing delays for other
|
|
29
|
-
* requests, or even server processes being recycled by the operating system.
|
|
30
|
-
*
|
|
31
|
-
* 您可以根据业务需求和系统可用资源等参数,调整最大导出数量的限制。但请注意,您需要充分了解修改之后的风险,
|
|
32
|
-
* 增加最大可导出的行数可能会导致系统资源占用率升高,导致其他请求处理延迟增加、无法处理、甚至
|
|
33
|
-
* 服务端进程被操作系统回收等问题。
|
|
34
|
-
*/
|
|
35
|
-
limit: number;
|
|
36
|
-
constructor(options: ExportOptions);
|
|
37
|
-
run(ctx?: any): Promise<XLSX.WorkBook>;
|
|
38
|
-
private getAppendOptionsFromColumns;
|
|
39
|
-
private getFindOptions;
|
|
40
|
-
private findFieldByDataIndex;
|
|
41
|
-
private renderHeaders;
|
|
42
|
-
private renderRawValue;
|
|
43
|
-
private renderCellValue;
|
|
44
|
-
}
|
|
45
|
-
export default XlsxExporter;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var xlsx_exporter_exports = {};
|
|
38
|
-
__export(xlsx_exporter_exports, {
|
|
39
|
-
default: () => xlsx_exporter_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(xlsx_exporter_exports);
|
|
42
|
-
var import_xlsx = __toESM(require("xlsx"));
|
|
43
|
-
var import_deep_get = require("./utils/deep-get");
|
|
44
|
-
class XlsxExporter {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
this.options = options;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* You can adjust the maximum number of exported rows based on business needs and system
|
|
50
|
-
* available resources. However, please note that you need to fully understand the risks
|
|
51
|
-
* after the modification. Increasing the maximum number of rows that can be exported may
|
|
52
|
-
* increase system resource usage, leading to increased processing delays for other
|
|
53
|
-
* requests, or even server processes being recycled by the operating system.
|
|
54
|
-
*
|
|
55
|
-
* 您可以根据业务需求和系统可用资源等参数,调整最大导出数量的限制。但请注意,您需要充分了解修改之后的风险,
|
|
56
|
-
* 增加最大可导出的行数可能会导致系统资源占用率升高,导致其他请求处理延迟增加、无法处理、甚至
|
|
57
|
-
* 服务端进程被操作系统回收等问题。
|
|
58
|
-
*/
|
|
59
|
-
limit = process.env["EXPORT_LIMIT"] ? parseInt(process.env["EXPORT_LIMIT"]) : 2e3;
|
|
60
|
-
async run(ctx) {
|
|
61
|
-
const { collection, columns, chunkSize } = this.options;
|
|
62
|
-
const workbook = import_xlsx.default.utils.book_new();
|
|
63
|
-
const worksheet = import_xlsx.default.utils.sheet_new();
|
|
64
|
-
import_xlsx.default.utils.sheet_add_aoa(worksheet, [this.renderHeaders()], {
|
|
65
|
-
origin: "A1"
|
|
66
|
-
});
|
|
67
|
-
let startRowNumber = 2;
|
|
68
|
-
await collection.repository.chunk({
|
|
69
|
-
...this.getFindOptions(),
|
|
70
|
-
chunkSize: chunkSize || 200,
|
|
71
|
-
callback: async (rows, options) => {
|
|
72
|
-
const chunkData = rows.map((r) => {
|
|
73
|
-
return columns.map((col) => {
|
|
74
|
-
return this.renderCellValue(r, col, ctx);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
import_xlsx.default.utils.sheet_add_aoa(worksheet, chunkData, {
|
|
78
|
-
origin: `A${startRowNumber}`
|
|
79
|
-
});
|
|
80
|
-
startRowNumber += rows.length;
|
|
81
|
-
await new Promise((resolve) => {
|
|
82
|
-
setTimeout(resolve, 50);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
import_xlsx.default.utils.book_append_sheet(workbook, worksheet, "Data");
|
|
87
|
-
return workbook;
|
|
88
|
-
}
|
|
89
|
-
getAppendOptionsFromColumns() {
|
|
90
|
-
return this.options.columns.map((col) => {
|
|
91
|
-
if (col.dataIndex.length > 1) {
|
|
92
|
-
return col.dataIndex.join(".");
|
|
93
|
-
}
|
|
94
|
-
const field = this.options.collection.getField(col.dataIndex[0]);
|
|
95
|
-
if (field.isRelationField()) {
|
|
96
|
-
return col.dataIndex[0];
|
|
97
|
-
}
|
|
98
|
-
return null;
|
|
99
|
-
}).filter(Boolean);
|
|
100
|
-
}
|
|
101
|
-
getFindOptions() {
|
|
102
|
-
const { findOptions = {} } = this.options;
|
|
103
|
-
findOptions.limit = this.limit;
|
|
104
|
-
const appendOptions = this.getAppendOptionsFromColumns();
|
|
105
|
-
if (appendOptions.length) {
|
|
106
|
-
return {
|
|
107
|
-
...findOptions,
|
|
108
|
-
appends: appendOptions
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return findOptions;
|
|
112
|
-
}
|
|
113
|
-
findFieldByDataIndex(dataIndex) {
|
|
114
|
-
const { collection } = this.options;
|
|
115
|
-
const currentField = collection.getField(dataIndex[0]);
|
|
116
|
-
if (dataIndex.length > 1) {
|
|
117
|
-
let targetCollection;
|
|
118
|
-
for (let i = 0; i < dataIndex.length - 1; i++) {
|
|
119
|
-
const isLast = i === dataIndex.length - 1;
|
|
120
|
-
if (isLast) {
|
|
121
|
-
return targetCollection.getField(dataIndex[i]);
|
|
122
|
-
}
|
|
123
|
-
targetCollection = currentField.targetCollection();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return currentField;
|
|
127
|
-
}
|
|
128
|
-
renderHeaders() {
|
|
129
|
-
return this.options.columns.map((col) => {
|
|
130
|
-
const field = this.findFieldByDataIndex(col.dataIndex);
|
|
131
|
-
return (field == null ? void 0 : field.options.title) || col.defaultTitle;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
renderRawValue(value) {
|
|
135
|
-
if (typeof value === "object" && value !== null) {
|
|
136
|
-
return JSON.stringify(value);
|
|
137
|
-
}
|
|
138
|
-
return value;
|
|
139
|
-
}
|
|
140
|
-
renderCellValue(rowData, column, ctx) {
|
|
141
|
-
const { dataIndex } = column;
|
|
142
|
-
rowData = rowData.toJSON();
|
|
143
|
-
const value = rowData[dataIndex[0]];
|
|
144
|
-
if (dataIndex.length > 1) {
|
|
145
|
-
const deepValue = (0, import_deep_get.deepGet)(rowData, dataIndex);
|
|
146
|
-
if (Array.isArray(deepValue)) {
|
|
147
|
-
return deepValue.join(",");
|
|
148
|
-
}
|
|
149
|
-
return deepValue;
|
|
150
|
-
}
|
|
151
|
-
const field = this.findFieldByDataIndex(dataIndex);
|
|
152
|
-
if (!field) {
|
|
153
|
-
return this.renderRawValue(value);
|
|
154
|
-
}
|
|
155
|
-
const fieldOptions = field.options;
|
|
156
|
-
const interfaceName = fieldOptions["interface"];
|
|
157
|
-
if (!interfaceName) {
|
|
158
|
-
return this.renderRawValue(value);
|
|
159
|
-
}
|
|
160
|
-
const InterfaceClass = this.options.collectionManager.getFieldInterface(interfaceName);
|
|
161
|
-
if (!InterfaceClass) {
|
|
162
|
-
return this.renderRawValue(value);
|
|
163
|
-
}
|
|
164
|
-
const interfaceInstance = new InterfaceClass(fieldOptions);
|
|
165
|
-
return interfaceInstance.toString(value, ctx);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
var xlsx_exporter_default = XlsxExporter;
|
package/dist/swagger/index.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"openapi": "3.0.2",
|
|
3
|
-
"info": {
|
|
4
|
-
"title": "NocoBase API - Export plugin"
|
|
5
|
-
},
|
|
6
|
-
"tags": [],
|
|
7
|
-
"paths": {
|
|
8
|
-
"/{collectionName}:export": {
|
|
9
|
-
"post": {
|
|
10
|
-
"tags": ["$collection"],
|
|
11
|
-
"description": "",
|
|
12
|
-
"parameters": [],
|
|
13
|
-
"responses": {
|
|
14
|
-
"200": {
|
|
15
|
-
"description": "OK"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|