forked from wangziqi/gongxue-base
fix: remove vulnerable excel runtime dependency
This commit is contained in:
@@ -5,7 +5,7 @@ import http from 'node:http';
|
||||
import net from 'node:net';
|
||||
import pg from 'pg';
|
||||
import { SignJWT, exportJWK } from 'jose';
|
||||
import ExcelJS from 'exceljs';
|
||||
import writeXlsxFile from 'write-excel-file/node';
|
||||
|
||||
const DEFAULT_DATABASE_URL = 'postgresql://postgres:postgres@127.0.0.1:54322/postgres';
|
||||
const MAIN_TENANT_ID = process.env.TENANT_ID || '00000000-0000-0000-0000-000000000001';
|
||||
@@ -5886,24 +5886,36 @@ async function testTenantContentAssetsAndImports() {
|
||||
'mixed scoreline import should create record after school and major',
|
||||
);
|
||||
|
||||
const scorelineWorkbook = new ExcelJS.Workbook();
|
||||
scorelineWorkbook.addWorksheet('fields').addRows([
|
||||
['legacyId', 'fieldKey', 'fieldName', 'fieldType', 'isTrend'],
|
||||
['integration-scoreline-xlsx-field-min', 'xlsxMinScore', 'Excel最低分', 'number', '是'],
|
||||
]);
|
||||
scorelineWorkbook.addWorksheet('schools').addRows([
|
||||
['legacyId', 'schoolName', 'isHot'],
|
||||
['integration-scoreline-xlsx-school', 'Excel导入学院', 'true'],
|
||||
]);
|
||||
scorelineWorkbook.addWorksheet('majors').addRows([
|
||||
['legacyId', 'schoolLegacyId', 'majorName'],
|
||||
['integration-scoreline-xlsx-major', 'integration-scoreline-xlsx-school', 'Excel专业'],
|
||||
]);
|
||||
scorelineWorkbook.addWorksheet('records').addRows([
|
||||
['legacyId', 'schoolLegacyId', 'majorLegacyId', 'year', 'xlsxMinScore'],
|
||||
['integration-scoreline-xlsx-record-2027', 'integration-scoreline-xlsx-school', 'integration-scoreline-xlsx-major', 2027, 233],
|
||||
]);
|
||||
const scorelineExcelBuffer = await scorelineWorkbook.xlsx.writeBuffer();
|
||||
const scorelineExcelBuffer = await writeXlsxFile([
|
||||
{
|
||||
sheet: 'fields',
|
||||
data: [
|
||||
['legacyId', 'fieldKey', 'fieldName', 'fieldType', 'isTrend'],
|
||||
['integration-scoreline-xlsx-field-min', 'xlsxMinScore', 'Excel最低分', 'number', '是'],
|
||||
],
|
||||
},
|
||||
{
|
||||
sheet: 'schools',
|
||||
data: [
|
||||
['legacyId', 'schoolName', 'isHot'],
|
||||
['integration-scoreline-xlsx-school', 'Excel导入学院', 'true'],
|
||||
],
|
||||
},
|
||||
{
|
||||
sheet: 'majors',
|
||||
data: [
|
||||
['legacyId', 'schoolLegacyId', 'majorName'],
|
||||
['integration-scoreline-xlsx-major', 'integration-scoreline-xlsx-school', 'Excel专业'],
|
||||
],
|
||||
},
|
||||
{
|
||||
sheet: 'records',
|
||||
data: [
|
||||
['legacyId', 'schoolLegacyId', 'majorLegacyId', 'year', 'xlsxMinScore'],
|
||||
['integration-scoreline-xlsx-record-2027', 'integration-scoreline-xlsx-school', 'integration-scoreline-xlsx-major', 2027, 233],
|
||||
],
|
||||
},
|
||||
]).toBuffer();
|
||||
const scorelineExcelPreview = await request('/api/tenant-content/imports/preview/scoreline', {
|
||||
userId: TENANT_ADMIN_USER_ID,
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user