HouseEntity
This commit is contained in:
parent
58e069bb1b
commit
8533a93fe2
13
lib/port.js
13
lib/port.js
|
|
@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.exportEntity = exports.importEntity = exports.clearPorts = exports.registerPorts = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const xlsx_1 = require("xlsx");
|
||||
const Importations = {};
|
||||
const Exportations = {};
|
||||
function registerPorts(importations, exportations) {
|
||||
|
|
@ -41,10 +42,18 @@ async function importEntity(params, context) {
|
|||
const entity = params.get('entity');
|
||||
const file = params.get('file');
|
||||
const id = params.get('id');
|
||||
throw new Error('not implement yet');
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const workbook = (0, xlsx_1.read)(arrayBuffer);
|
||||
const { SheetNames, Sheets } = workbook;
|
||||
for (const sheetName of SheetNames) {
|
||||
const sheet = Sheets[sheetName];
|
||||
const dataList = xlsx_1.utils.sheet_to_json(sheet, {});
|
||||
console.log(dataList);
|
||||
}
|
||||
// throw new Error('not implement yet');
|
||||
}
|
||||
exports.importEntity = importEntity;
|
||||
async function exportEntity(params, context) {
|
||||
throw new Error('not implement yet');
|
||||
throw new Error('export not implement yet');
|
||||
}
|
||||
exports.exportEntity = exportEntity;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"lodash": "^4.17.21",
|
||||
"oak-domain": "file:../oak-domain",
|
||||
"oak-external-sdk": "file:../oak-external-sdk",
|
||||
"xlsx": "0.18.5"
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.0.0",
|
||||
|
|
@ -27,4 +27,4 @@
|
|||
"tslib": "^2.4.0",
|
||||
"typescript": "~4.7.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
src/port.ts
18
src/port.ts
|
|
@ -1,7 +1,7 @@
|
|||
import assert from 'assert';
|
||||
import { Importation, Exportation, EntityDict, SelectOption } from 'oak-domain/lib/types/Entity';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
|
||||
import { read, utils } from 'xlsx';
|
||||
const Importations: Record<string, any> = {};
|
||||
const Exportations: Record<string, any> = {};
|
||||
|
||||
|
|
@ -47,8 +47,18 @@ export async function importEntity<
|
|||
const entity = params.get('entity') as keyof ED;
|
||||
const file = params.get('file') as File;
|
||||
const id = params.get('id') as string;
|
||||
|
||||
throw new Error('not implement yet');
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const workbook = read(arrayBuffer);
|
||||
const { SheetNames, Sheets } = workbook;
|
||||
for (const sheetName of SheetNames) {
|
||||
const sheet = Sheets[sheetName];
|
||||
const dataList = utils.sheet_to_json(
|
||||
sheet
|
||||
);
|
||||
console.log(dataList);
|
||||
}
|
||||
|
||||
// throw new Error('not implement yet');
|
||||
}
|
||||
|
||||
export async function exportEntity<
|
||||
|
|
@ -60,5 +70,5 @@ export async function exportEntity<
|
|||
id: string;
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
}, context: Cxt): Promise<NodeJS.ReadableStream> {
|
||||
throw new Error('not implement yet');
|
||||
throw new Error('export not implement yet');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue