@nocobase/plugin-action-import 1.7.5 → 1.7.7
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/externalVersion.js
CHANGED
|
@@ -10,24 +10,24 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@emotion/css": "11.13.0",
|
|
12
12
|
"@formily/react": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.7.
|
|
13
|
+
"@nocobase/client": "1.7.7",
|
|
14
14
|
"react": "18.2.0",
|
|
15
15
|
"react-i18next": "11.18.6",
|
|
16
16
|
"@ant-design/icons": "5.6.1",
|
|
17
17
|
"@formily/shared": "2.3.2",
|
|
18
18
|
"antd": "5.24.2",
|
|
19
|
-
"@nocobase/utils": "1.7.
|
|
19
|
+
"@nocobase/utils": "1.7.7",
|
|
20
20
|
"@formily/antd-v5": "1.2.3",
|
|
21
21
|
"file-saver": "2.0.5",
|
|
22
22
|
"react-dom": "18.2.0",
|
|
23
23
|
"lodash": "4.17.21",
|
|
24
24
|
"@formily/core": "2.3.0",
|
|
25
|
-
"@nocobase/server": "1.7.
|
|
26
|
-
"@nocobase/actions": "1.7.
|
|
27
|
-
"@nocobase/database": "1.7.
|
|
25
|
+
"@nocobase/server": "1.7.7",
|
|
26
|
+
"@nocobase/actions": "1.7.7",
|
|
27
|
+
"@nocobase/database": "1.7.7",
|
|
28
28
|
"async-mutex": "0.5.0",
|
|
29
|
-
"@nocobase/data-source-manager": "1.7.
|
|
29
|
+
"@nocobase/data-source-manager": "1.7.7",
|
|
30
30
|
"sequelize": "6.35.2",
|
|
31
|
-
"@nocobase/logger": "1.7.
|
|
31
|
+
"@nocobase/logger": "1.7.7",
|
|
32
32
|
"mathjs": "10.6.4"
|
|
33
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2025-06-
|
|
1
|
+
{"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2025-06-10T14:21:13.088Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2025-06-
|
|
1
|
+
{"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2025-06-10T14:21:15.773Z"}
|
|
@@ -46,6 +46,7 @@ export declare class XlsxImporter extends EventEmitter {
|
|
|
46
46
|
resetSeq(options?: RunOptions): Promise<void>;
|
|
47
47
|
private getColumnsByPermission;
|
|
48
48
|
performImport(data: string[][], options?: RunOptions): Promise<any>;
|
|
49
|
+
protected getModel(): typeof Model;
|
|
49
50
|
handleRowValuesWithColumns(row: any, rowValues: any, options: RunOptions): Promise<void>;
|
|
50
51
|
handleChuckRows(chunkRows: string[][], runOptions?: RunOptions, options?: {
|
|
51
52
|
handingRowIndex: number;
|
|
@@ -56,7 +57,8 @@ export declare class XlsxImporter extends EventEmitter {
|
|
|
56
57
|
transaction: Transaction;
|
|
57
58
|
context: any;
|
|
58
59
|
hooks?: boolean;
|
|
59
|
-
}): Promise<Model<
|
|
60
|
+
}): Promise<Model<{}, {}>[]>;
|
|
61
|
+
associateRecords(targets: Model[], options?: any): Promise<void>;
|
|
60
62
|
renderErrorMessage(error: any): any;
|
|
61
63
|
trimString(str: string): string;
|
|
62
64
|
private getExpectedHeaders;
|
|
@@ -180,6 +180,9 @@ class XlsxImporter extends import_events.default {
|
|
|
180
180
|
}
|
|
181
181
|
return imported;
|
|
182
182
|
}
|
|
183
|
+
getModel() {
|
|
184
|
+
return this.repository instanceof import_database.RelationRepository ? this.repository.targetModel : this.repository.model;
|
|
185
|
+
}
|
|
183
186
|
async handleRowValuesWithColumns(row, rowValues, options) {
|
|
184
187
|
for (let index = 0; index < this.options.columns.length; index++) {
|
|
185
188
|
const column = this.options.columns[index];
|
|
@@ -210,12 +213,13 @@ class XlsxImporter extends import_events.default {
|
|
|
210
213
|
}
|
|
211
214
|
rowValues[dataKey] = await interfaceInstance.toValue(this.trimString(str), ctx);
|
|
212
215
|
}
|
|
213
|
-
const
|
|
216
|
+
const model = this.getModel();
|
|
217
|
+
const guard = import_database.UpdateGuard.fromOptions(model, {
|
|
214
218
|
...options,
|
|
215
219
|
action: "create",
|
|
216
220
|
underscored: this.repository.collection.options.underscored
|
|
217
221
|
});
|
|
218
|
-
rowValues = this.repository.model.callSetters(guard.sanitize(rowValues || {}), options);
|
|
222
|
+
rowValues = this.repository instanceof import_database.RelationRepository ? model.callSetters(guard.sanitize(rowValues || {}), options) : guard.sanitize(rowValues);
|
|
219
223
|
}
|
|
220
224
|
async handleChuckRows(chunkRows, runOptions, options) {
|
|
221
225
|
var _a;
|
|
@@ -255,7 +259,7 @@ class XlsxImporter extends import_events.default {
|
|
|
255
259
|
async performInsert(insertOptions) {
|
|
256
260
|
const { values, transaction, context } = insertOptions;
|
|
257
261
|
const instances = await this.loggerService.measureExecutedTime(
|
|
258
|
-
async () => this.
|
|
262
|
+
async () => this.getModel().bulkCreate(values, {
|
|
259
263
|
transaction,
|
|
260
264
|
hooks: insertOptions.hooks == void 0 ? true : insertOptions.hooks,
|
|
261
265
|
returning: true,
|
|
@@ -263,6 +267,9 @@ class XlsxImporter extends import_events.default {
|
|
|
263
267
|
}),
|
|
264
268
|
"Row {{rowIndex}}: bulkCreate completed in {time}ms"
|
|
265
269
|
);
|
|
270
|
+
if (this.repository instanceof import_database.RelationRepository) {
|
|
271
|
+
await this.associateRecords(instances, import_lodash2.default.omit(insertOptions, "values"));
|
|
272
|
+
}
|
|
266
273
|
const db = this.options.collectionManager.db;
|
|
267
274
|
for (let i = 0; i < instances.length; i++) {
|
|
268
275
|
const instance = instances[i];
|
|
@@ -272,7 +279,22 @@ class XlsxImporter extends import_events.default {
|
|
|
272
279
|
`Row ${i + 1}: updateAssociations completed in {time}ms`,
|
|
273
280
|
"debug"
|
|
274
281
|
);
|
|
275
|
-
if (
|
|
282
|
+
if (insertOptions.hooks !== false) {
|
|
283
|
+
await this.loggerService.measureExecutedTime(
|
|
284
|
+
async () => {
|
|
285
|
+
await db.emit(`${this.repository.collection.name}.afterCreate`, instance, {
|
|
286
|
+
transaction
|
|
287
|
+
});
|
|
288
|
+
await db.emitAsync(`${this.repository.collection.name}.afterSave`, instance, {
|
|
289
|
+
transaction
|
|
290
|
+
});
|
|
291
|
+
instance.clearChangedWithAssociations();
|
|
292
|
+
},
|
|
293
|
+
`Row ${i + 1}: afterSave event emitted in {time}ms`,
|
|
294
|
+
"debug"
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
if ((context == null ? void 0 : context.skipWorkflow) !== true) {
|
|
276
298
|
await this.loggerService.measureExecutedTime(
|
|
277
299
|
async () => {
|
|
278
300
|
await db.emitAsync(`${this.repository.collection.name}.afterCreateWithAssociations`, instance, {
|
|
@@ -290,6 +312,30 @@ class XlsxImporter extends import_events.default {
|
|
|
290
312
|
}
|
|
291
313
|
return instances;
|
|
292
314
|
}
|
|
315
|
+
async associateRecords(targets, options = {}) {
|
|
316
|
+
if (!(this.repository instanceof import_database.RelationRepository)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const accessors = this.repository.accessors();
|
|
320
|
+
const sourceModel = await this.repository.getSourceModel();
|
|
321
|
+
if (!accessors || !sourceModel) {
|
|
322
|
+
throw new Error("Missing accessors or source model.");
|
|
323
|
+
}
|
|
324
|
+
if (accessors.addMultiple) {
|
|
325
|
+
await sourceModel[accessors.addMultiple](targets, options);
|
|
326
|
+
} else if (accessors.add) {
|
|
327
|
+
await Promise.all(
|
|
328
|
+
targets.map((target) => sourceModel[accessors.add](target, options))
|
|
329
|
+
);
|
|
330
|
+
} else if (accessors.set) {
|
|
331
|
+
if (targets.length > 1) {
|
|
332
|
+
throw new Error("Cannot associate multiple records to a single-valued relation.");
|
|
333
|
+
}
|
|
334
|
+
await sourceModel[accessors.set](targets[0], options);
|
|
335
|
+
} else {
|
|
336
|
+
throw new Error(`Unsupported association or no usable accessor on ${this.repository["association"]}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
293
339
|
renderErrorMessage(error) {
|
|
294
340
|
let message = error.message;
|
|
295
341
|
if (error.parent) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "操作:导入记录",
|
|
5
5
|
"description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
|
|
6
6
|
"description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
|
|
7
|
-
"version": "1.7.
|
|
7
|
+
"version": "1.7.7",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/action-import",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@nocobase/test": "1.x",
|
|
37
37
|
"@nocobase/utils": "1.x"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "41c87dbed474b3d4007f4e4cf3bb0969d609d942",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Actions"
|
|
42
42
|
]
|