@tachybase/plugin-action-export 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/ExportActionInitializer.d.ts +8 -0
- package/dist/client/ExportDesigner.d.ts +2 -0
- package/dist/client/ExportPluginProvider.d.ts +2 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +14 -0
- package/dist/client/schemaSettings.d.ts +2 -0
- package/dist/client/useExportAction.d.ts +3 -0
- package/dist/client/useFields.d.ts +1 -0
- package/dist/client/useShared.d.ts +70 -0
- package/dist/externalVersion.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.cjs +95 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.d.cts +1 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.d.ts +1 -0
- package/dist/node_modules/node-xlsx/dist/bin/cli.js +37 -0
- package/dist/node_modules/node-xlsx/dist/chunk-ID6OMQGT.js +78 -0
- package/dist/node_modules/node-xlsx/dist/index.cjs +7 -0
- package/dist/node_modules/node-xlsx/dist/index.d.cts +46 -0
- package/dist/node_modules/node-xlsx/dist/index.d.ts +46 -0
- package/dist/node_modules/node-xlsx/dist/index.js +13 -0
- package/dist/node_modules/node-xlsx/node_modules/.bin/xlsx +17 -0
- package/dist/node_modules/node-xlsx/package.json +1 -0
- package/dist/server/actions/export-xlsx.d.ts +2 -0
- package/dist/server/actions/export-xlsx.js +132 -0
- package/dist/server/actions/index.d.ts +1 -0
- package/dist/server/actions/index.js +21 -0
- package/dist/server/constants.d.ts +2 -0
- package/dist/server/constants.js +30 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +122 -0
- package/dist/server/renders/index.d.ts +10 -0
- package/dist/server/renders/index.js +159 -0
- package/dist/server/renders/renders.d.ts +21 -0
- package/dist/server/renders/renders.js +163 -0
- package/dist/server/utils/columns2Appends.d.ts +1 -0
- package/dist/server/utils/columns2Appends.js +45 -0
- package/dist/server/utils/index.d.ts +1 -0
- package/dist/server/utils/index.js +21 -0
- package/dist/swagger/index.json +21 -0
- package/package.json +35 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var renders_exports = {};
|
|
19
|
+
__export(renders_exports, {
|
|
20
|
+
_: () => _,
|
|
21
|
+
attachment: () => attachment,
|
|
22
|
+
boolean: () => boolean,
|
|
23
|
+
checkbox: () => checkbox,
|
|
24
|
+
checkboxGroup: () => checkboxGroup,
|
|
25
|
+
checkboxes: () => checkboxes,
|
|
26
|
+
chinaRegion: () => chinaRegion,
|
|
27
|
+
datetime: () => datetime,
|
|
28
|
+
linkTo: () => linkTo,
|
|
29
|
+
multipleSelect: () => multipleSelect,
|
|
30
|
+
percent: () => percent,
|
|
31
|
+
radio: () => radio,
|
|
32
|
+
radioGroup: () => radioGroup,
|
|
33
|
+
select: () => select,
|
|
34
|
+
subTable: () => subTable
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(renders_exports);
|
|
37
|
+
var import_utils = require("@tachybase/utils");
|
|
38
|
+
async function _(field, row, ctx, column) {
|
|
39
|
+
if ((column == null ? void 0 : column.dataIndex.length) > 1) {
|
|
40
|
+
const result = column.dataIndex.reduce((result2, col) => {
|
|
41
|
+
if (Array.isArray(result2)) {
|
|
42
|
+
const subResults = [];
|
|
43
|
+
for (const r of result2) {
|
|
44
|
+
subResults.push(r == null ? void 0 : r[col]);
|
|
45
|
+
}
|
|
46
|
+
return subResults;
|
|
47
|
+
} else {
|
|
48
|
+
if (Array.isArray(result2 == null ? void 0 : result2[col])) {
|
|
49
|
+
const subResults = [];
|
|
50
|
+
for (const r of result2[col]) {
|
|
51
|
+
subResults.push(r);
|
|
52
|
+
}
|
|
53
|
+
return subResults;
|
|
54
|
+
} else {
|
|
55
|
+
return result2 == null ? void 0 : result2[col];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, row);
|
|
59
|
+
if (Array.isArray(result)) {
|
|
60
|
+
return result.join(",");
|
|
61
|
+
} else {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
return row.get(field.name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function datetime(field, row, { utcOffset }) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const value = row.get(field.name);
|
|
71
|
+
if (!value) {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
const props = ((_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) ?? {};
|
|
75
|
+
const format = (0, import_utils.getDefaultFormat)(props);
|
|
76
|
+
const m = (0, import_utils.str2moment)(value, { ...props, utcOffset });
|
|
77
|
+
return m ? m.format(format) : "";
|
|
78
|
+
}
|
|
79
|
+
async function percent(field, row, ctx) {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
const value = row.get(field.name);
|
|
82
|
+
const step = ((_c = (_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) == null ? void 0 : _c["step"]) ?? 0;
|
|
83
|
+
return value && `${(0, import_utils.toFixedByStep)(value * 100, step)}%`;
|
|
84
|
+
}
|
|
85
|
+
async function boolean(field, row, ctx, column) {
|
|
86
|
+
const value = row.get(field.name);
|
|
87
|
+
const { enum: enumData } = column ?? {};
|
|
88
|
+
if ((enumData == null ? void 0 : enumData.length) > 0) {
|
|
89
|
+
const option = enumData.find((item) => item.value === value);
|
|
90
|
+
return option == null ? void 0 : option.label;
|
|
91
|
+
} else {
|
|
92
|
+
return value ? "\u662F" : value === null || value === void 0 ? "" : "\u5426";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const checkbox = boolean;
|
|
96
|
+
async function select(field, row, { db }, column) {
|
|
97
|
+
const value = row.get(field.name);
|
|
98
|
+
let { enum: enumData } = column ?? {};
|
|
99
|
+
if (!enumData) {
|
|
100
|
+
const repository = db.getCollection("uiSchemas").repository;
|
|
101
|
+
const model = await repository.findById(field.options.uiSchemaUid);
|
|
102
|
+
enumData = model.get("enum");
|
|
103
|
+
}
|
|
104
|
+
const option = enumData.find((item) => item.value === value);
|
|
105
|
+
return option == null ? void 0 : option.label;
|
|
106
|
+
}
|
|
107
|
+
async function multipleSelect(field, row, { db }, column) {
|
|
108
|
+
var _a;
|
|
109
|
+
const values = row.get(field.name);
|
|
110
|
+
let { enum: enumData } = column ?? {};
|
|
111
|
+
if (!enumData) {
|
|
112
|
+
const repository = db.getCollection("uiSchemas").repository;
|
|
113
|
+
const model = await repository.findById(field.options.uiSchemaUid);
|
|
114
|
+
enumData = model.get("enum");
|
|
115
|
+
}
|
|
116
|
+
return (_a = values == null ? void 0 : values.map((value) => {
|
|
117
|
+
const option = enumData.find((item) => item.value === value);
|
|
118
|
+
return option == null ? void 0 : option.label;
|
|
119
|
+
})) == null ? void 0 : _a.join();
|
|
120
|
+
}
|
|
121
|
+
const radio = select;
|
|
122
|
+
const radioGroup = select;
|
|
123
|
+
const checkboxes = multipleSelect;
|
|
124
|
+
const checkboxGroup = multipleSelect;
|
|
125
|
+
async function subTable(field, row, ctx) {
|
|
126
|
+
return (row.get(field.name) || []).map((item) => item[field.sourceKey]);
|
|
127
|
+
}
|
|
128
|
+
async function linkTo(field, row, ctx, column) {
|
|
129
|
+
return (row.get(field.name) || []).map((item) => {
|
|
130
|
+
return column.dataIndex.reduce((buf, cur) => {
|
|
131
|
+
buf = item[cur];
|
|
132
|
+
return buf;
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async function attachment(field, row, ctx) {
|
|
137
|
+
return (row.get(field.name) || []).map((item) => item[field.url]).join(" ");
|
|
138
|
+
}
|
|
139
|
+
async function chinaRegion(field, row, ctx, column) {
|
|
140
|
+
const value = row.get(field.name);
|
|
141
|
+
const values = (Array.isArray(value) ? value : [value]).sort(
|
|
142
|
+
(a, b) => a.level !== b.level ? a.level - b.level : a.sort - b.sort
|
|
143
|
+
);
|
|
144
|
+
return values.map((item) => item.name).join("/");
|
|
145
|
+
}
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
_,
|
|
149
|
+
attachment,
|
|
150
|
+
boolean,
|
|
151
|
+
checkbox,
|
|
152
|
+
checkboxGroup,
|
|
153
|
+
checkboxes,
|
|
154
|
+
chinaRegion,
|
|
155
|
+
datetime,
|
|
156
|
+
linkTo,
|
|
157
|
+
multipleSelect,
|
|
158
|
+
percent,
|
|
159
|
+
radio,
|
|
160
|
+
radioGroup,
|
|
161
|
+
select,
|
|
162
|
+
subTable
|
|
163
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function columns2Appends(columns: any, ctx: any): any[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var columns2Appends_exports = {};
|
|
19
|
+
__export(columns2Appends_exports, {
|
|
20
|
+
columns2Appends: () => columns2Appends
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(columns2Appends_exports);
|
|
23
|
+
function columns2Appends(columns, ctx) {
|
|
24
|
+
const { resourceName } = ctx.action;
|
|
25
|
+
const appends = /* @__PURE__ */ new Set([]);
|
|
26
|
+
for (const column of columns) {
|
|
27
|
+
let collection = ctx.db.getCollection(resourceName);
|
|
28
|
+
const appendColumns = [];
|
|
29
|
+
for (let i = 0, iLen = column.dataIndex.length; i < iLen; i++) {
|
|
30
|
+
const field = collection.getField(column.dataIndex[i]);
|
|
31
|
+
if (field == null ? void 0 : field.target) {
|
|
32
|
+
appendColumns.push(column.dataIndex[i]);
|
|
33
|
+
collection = ctx.db.getCollection(field.target);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (appendColumns.length > 0) {
|
|
37
|
+
appends.add(appendColumns.join("."));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Array.from(appends);
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
columns2Appends
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './columns2Appends';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var utils_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(utils_exports);
|
|
17
|
+
__reExport(utils_exports, require("./columns2Appends"), module.exports);
|
|
18
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
19
|
+
0 && (module.exports = {
|
|
20
|
+
...require("./columns2Appends")
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.2",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "TachyBase 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
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tachybase/plugin-action-export",
|
|
3
|
+
"displayName": "Action: Export records",
|
|
4
|
+
"version": "0.23.8",
|
|
5
|
+
"description": "Export filtered records to excel, you can configure which fields to export.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Actions"
|
|
8
|
+
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"main": "./dist/server/index.js",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/node-xlsx": "^0.15.3",
|
|
13
|
+
"antd": "5.22.5",
|
|
14
|
+
"file-saver": "^2.0.5",
|
|
15
|
+
"lodash": "4.17.21",
|
|
16
|
+
"node-xlsx": "^0.24.0",
|
|
17
|
+
"react": "^18.3.1",
|
|
18
|
+
"react-i18next": "^15.2.0",
|
|
19
|
+
"@tachybase/schema": "0.23.8",
|
|
20
|
+
"@tachybase/components": "0.23.8"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@tachybase/actions": "0.23.8",
|
|
24
|
+
"@tachybase/client": "0.23.8",
|
|
25
|
+
"@tachybase/database": "0.23.8",
|
|
26
|
+
"@tachybase/test": "0.23.8",
|
|
27
|
+
"@tachybase/utils": "0.23.8",
|
|
28
|
+
"@tachybase/server": "0.23.8"
|
|
29
|
+
},
|
|
30
|
+
"description.zh-CN": "导出筛选后的记录到 Excel 中,可以配置导出哪些字段。",
|
|
31
|
+
"displayName.zh-CN": "操作:导出记录",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tachybase-build --no-dts @tachybase/plugin-action-export"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|