@nocobase/plugin-action-import 1.2.13-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.
Files changed (67) hide show
  1. package/package.json +2 -2
  2. package/dist/client/ImportActionInitializer.d.ts +0 -12
  3. package/dist/client/ImportDesigner.d.ts +0 -10
  4. package/dist/client/ImportModal.d.ts +0 -14
  5. package/dist/client/ImportPluginProvider.d.ts +0 -11
  6. package/dist/client/constants.d.ts +0 -9
  7. package/dist/client/context.d.ts +0 -37
  8. package/dist/client/index.d.ts +0 -17
  9. package/dist/client/index.js +0 -33
  10. package/dist/client/locale/index.d.ts +0 -10
  11. package/dist/client/schemaSettings.d.ts +0 -10
  12. package/dist/client/useFields.d.ts +0 -9
  13. package/dist/client/useImportAction.d.ts +0 -15
  14. package/dist/client/useShared.d.ts +0 -84
  15. package/dist/externalVersion.js +0 -30
  16. package/dist/index.d.ts +0 -11
  17. package/dist/index.js +0 -52
  18. package/dist/locale/en-US.json +0 -28
  19. package/dist/locale/es-ES.json +0 -27
  20. package/dist/locale/ko_KR.json +0 -28
  21. package/dist/locale/pt-BR.json +0 -27
  22. package/dist/locale/zh-CN.json +0 -30
  23. package/dist/node_modules/xlsx/LICENSE +0 -201
  24. package/dist/node_modules/xlsx/bin/xlsx.njs +0 -310
  25. package/dist/node_modules/xlsx/bower.json +0 -22
  26. package/dist/node_modules/xlsx/dist/cpexcel.d.ts +0 -39
  27. package/dist/node_modules/xlsx/dist/cpexcel.js +0 -1506
  28. package/dist/node_modules/xlsx/dist/shim.min.js +0 -2
  29. package/dist/node_modules/xlsx/dist/xlsx.core.min.js +0 -17
  30. package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +0 -27961
  31. package/dist/node_modules/xlsx/dist/xlsx.full.min.js +0 -24
  32. package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +0 -10
  33. package/dist/node_modules/xlsx/dist/xlsx.zahl.js +0 -4
  34. package/dist/node_modules/xlsx/dist/zahl.d.ts +0 -4
  35. package/dist/node_modules/xlsx/package.json +0 -1
  36. package/dist/node_modules/xlsx/types/index.d.ts +0 -1033
  37. package/dist/node_modules/xlsx/xlsx.js +0 -7
  38. package/dist/node_modules/xlsx/xlsxworker.js +0 -14
  39. package/dist/server/actions/download-xlsx-template.d.ts +0 -10
  40. package/dist/server/actions/download-xlsx-template.js +0 -67
  41. package/dist/server/actions/import-xlsx.d.ts +0 -10
  42. package/dist/server/actions/import-xlsx.js +0 -94
  43. package/dist/server/actions/index.d.ts +0 -10
  44. package/dist/server/actions/index.js +0 -32
  45. package/dist/server/index.d.ts +0 -14
  46. package/dist/server/index.js +0 -86
  47. package/dist/server/locale/en-US.d.ts +0 -19
  48. package/dist/server/locale/en-US.js +0 -41
  49. package/dist/server/locale/fr-FR.d.ts +0 -19
  50. package/dist/server/locale/fr-FR.js +0 -41
  51. package/dist/server/locale/index.d.ts +0 -10
  52. package/dist/server/locale/index.js +0 -49
  53. package/dist/server/locale/zh-CN.d.ts +0 -20
  54. package/dist/server/locale/zh-CN.js +0 -42
  55. package/dist/server/middleware/index.d.ts +0 -10
  56. package/dist/server/middleware/index.js +0 -43
  57. package/dist/server/migrations/20240425223956-change-locale-module.d.ts +0 -14
  58. package/dist/server/migrations/20240425223956-change-locale-module.js +0 -51
  59. package/dist/server/services/template-creator.d.ts +0 -24
  60. package/dist/server/services/template-creator.js +0 -70
  61. package/dist/server/services/xlsx-importer.d.ts +0 -39
  62. package/dist/server/services/xlsx-importer.js +0 -197
  63. package/dist/server/utils/index.d.ts +0 -14
  64. package/dist/server/utils/index.js +0 -63
  65. package/dist/server/utils/transform.d.ts +0 -92
  66. package/dist/server/utils/transform.js +0 -235
  67. package/dist/swagger/index.json +0 -33
@@ -1,235 +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 transform_exports = {};
38
- __export(transform_exports, {
39
- _: () => _,
40
- boolean: () => boolean,
41
- checkbox: () => checkbox,
42
- checkboxGroup: () => checkboxGroup,
43
- checkboxes: () => checkboxes,
44
- chinaRegion: () => chinaRegion,
45
- datetime: () => datetime,
46
- email: () => email,
47
- m2m: () => m2m,
48
- m2o: () => m2o,
49
- multipleSelect: () => multipleSelect,
50
- o2m: () => o2m,
51
- o2o: () => o2o,
52
- obo: () => obo,
53
- oho: () => oho,
54
- password: () => password,
55
- percent: () => percent,
56
- radio: () => radio,
57
- radioGroup: () => radioGroup,
58
- select: () => select,
59
- time: () => time
60
- });
61
- module.exports = __toCommonJS(transform_exports);
62
- var import_utils = require("@nocobase/utils");
63
- var math = __toESM(require("mathjs"));
64
- var import__ = require("../../");
65
- async function _({ value, field }) {
66
- return value;
67
- }
68
- async function email({ value, field, ctx }) {
69
- if (!(value == null ? void 0 : value.trim())) {
70
- return value;
71
- }
72
- const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
73
- if (!emailReg.test(value)) {
74
- throw new Error(ctx.t("Incorrect email format", { ns: import__.namespace }));
75
- }
76
- return value;
77
- }
78
- async function password({ value, field, ctx }) {
79
- if (value === void 0 || value === null) {
80
- throw new Error(ctx.t("password is empty", { ns: import__.namespace }));
81
- }
82
- return `${value}`;
83
- }
84
- async function o2o({ value, column, field, ctx }) {
85
- const { dataIndex, enum: enumData } = column;
86
- const repository = ctx.db.getRepository(field.options.target);
87
- let enumItem = null;
88
- if ((enumData == null ? void 0 : enumData.length) > 0) {
89
- enumItem = enumData.find((e) => e.label === value);
90
- }
91
- const val = await repository.findOne({ filter: { [dataIndex[1]]: (enumItem == null ? void 0 : enumItem.value) ?? value } });
92
- return val;
93
- }
94
- const oho = o2o;
95
- const obo = o2o;
96
- async function o2m({ value, column, field, ctx }) {
97
- let results = [];
98
- const values = value.split(";").map((val) => val.trim());
99
- const { dataIndex, enum: enumData } = column;
100
- const repository = ctx.db.getRepository(field.options.target);
101
- if ((enumData == null ? void 0 : enumData.length) > 0) {
102
- const enumValues = values.map((val) => {
103
- const v = enumData.find((e) => e.label === val);
104
- if (v === void 0) {
105
- throw new Error(`not found enum value ${val}`);
106
- }
107
- return v.value;
108
- });
109
- results = await repository.find({ filter: { [dataIndex[1]]: enumValues } });
110
- } else {
111
- results = await repository.find({ filter: { [dataIndex[1]]: values } });
112
- }
113
- return results;
114
- }
115
- async function m2o({ value, column, field, ctx }) {
116
- var _a;
117
- let results = null;
118
- const { dataIndex, enum: enumData } = column;
119
- const repository = ctx.db.getRepository(field.options.target);
120
- if ((enumData == null ? void 0 : enumData.length) > 0) {
121
- const enumValue = (_a = enumData.find((e) => e.label === (value == null ? void 0 : value.trim()))) == null ? void 0 : _a.value;
122
- results = await repository.findOne({ filter: { [dataIndex[1]]: enumValue } });
123
- } else {
124
- results = await repository.findOne({ filter: { [dataIndex[1]]: value } });
125
- }
126
- return results;
127
- }
128
- async function m2m({ value, column, field, ctx }) {
129
- let results = [];
130
- const values = value.split(";").map((val) => val.trim());
131
- const { dataIndex, enum: enumData } = column;
132
- const repository = ctx.db.getRepository(field.options.target);
133
- if ((enumData == null ? void 0 : enumData.length) > 0) {
134
- const enumValues = values.map((val) => {
135
- const v = enumData.find((e) => e.label === val);
136
- if (v === void 0) {
137
- throw new Error(`not found enum value ${val}`);
138
- }
139
- return v.value;
140
- });
141
- results = await repository.find({ filter: { [dataIndex[1]]: enumValues } });
142
- } else {
143
- results = await repository.find({ filter: { [dataIndex[1]]: values } });
144
- }
145
- return results;
146
- }
147
- async function datetime({ value, field, ctx }) {
148
- var _a, _b;
149
- if (!value) {
150
- return "";
151
- }
152
- const utcOffset = ctx.get("X-Timezone");
153
- const props = ((_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) ?? {};
154
- const m = (0, import_utils.str2moment)(value, { ...props, utcOffset });
155
- if (!m.isValid()) {
156
- throw new Error(ctx.t("Incorrect date format", { ns: import__.namespace }));
157
- }
158
- return m.toDate();
159
- }
160
- async function time({ value, field, ctx }) {
161
- var _a, _b;
162
- const { format } = ((_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) ?? {};
163
- if (format) {
164
- const m = (0, import_utils.dayjs)(value, format);
165
- if (!m.isValid()) {
166
- throw new Error(ctx.t("Incorrect time format", { ns: import__.namespace }));
167
- }
168
- return m.format(format);
169
- }
170
- return value;
171
- }
172
- async function percent({ value, field, ctx }) {
173
- var _a;
174
- if (value) {
175
- const numberValue = Number(((_a = value == null ? void 0 : value.split("%")) == null ? void 0 : _a[0]) ?? value);
176
- if (isNaN(numberValue)) {
177
- throw new Error(ctx.t("Illegal percentage format", { ns: import__.namespace }));
178
- }
179
- return math.round(numberValue / 100, 9);
180
- }
181
- return 0;
182
- }
183
- async function checkbox({ value, column, field, ctx }) {
184
- return value === ctx.t("Yes", { ns: import__.namespace }) ? 1 : 0;
185
- }
186
- const boolean = checkbox;
187
- async function select({ value, column, field, ctx }) {
188
- const { enum: enumData } = column;
189
- const item = enumData.find((item2) => item2.label === value);
190
- return item == null ? void 0 : item.value;
191
- }
192
- const radio = select;
193
- const radioGroup = select;
194
- async function multipleSelect({ value, column, field, ctx }) {
195
- const values = value == null ? void 0 : value.split(";");
196
- const { enum: enumData } = column;
197
- const results = values == null ? void 0 : values.map((val) => {
198
- const item = enumData.find((item2) => item2.label === val);
199
- return item;
200
- });
201
- return results == null ? void 0 : results.map((result) => result == null ? void 0 : result.value);
202
- }
203
- const checkboxes = multipleSelect;
204
- const checkboxGroup = multipleSelect;
205
- async function chinaRegion({ value, column, field, ctx }) {
206
- var _a;
207
- const values = (_a = value == null ? void 0 : value.split("/")) == null ? void 0 : _a.map((val) => val.trim());
208
- const repository = ctx.db.getRepository("chinaRegions");
209
- const results = await repository.find({ filter: { name: values } });
210
- return results;
211
- }
212
- // Annotate the CommonJS export names for ESM import in node:
213
- 0 && (module.exports = {
214
- _,
215
- boolean,
216
- checkbox,
217
- checkboxGroup,
218
- checkboxes,
219
- chinaRegion,
220
- datetime,
221
- email,
222
- m2m,
223
- m2o,
224
- multipleSelect,
225
- o2m,
226
- o2o,
227
- obo,
228
- oho,
229
- password,
230
- percent,
231
- radio,
232
- radioGroup,
233
- select,
234
- time
235
- });
@@ -1,33 +0,0 @@
1
- {
2
- "openapi": "3.0.2",
3
- "info": {
4
- "title": "NocoBase API - Import plugin"
5
- },
6
- "tags": [],
7
- "paths": {
8
- "/{collectionName}:importXlsx": {
9
- "post": {
10
- "tags": ["$collection"],
11
- "description": "",
12
- "parameters": [],
13
- "responses": {
14
- "200": {
15
- "description": "OK"
16
- }
17
- }
18
- }
19
- },
20
- "/{collectionName}:downloadXlsxTemplate": {
21
- "post": {
22
- "tags": ["$collection"],
23
- "description": "",
24
- "parameters": [],
25
- "responses": {
26
- "200": {
27
- "description": "OK"
28
- }
29
- }
30
- }
31
- }
32
- }
33
- }