升级ts到5版本
This commit is contained in:
parent
e32f45fd76
commit
ffd1b88fb0
|
|
@ -2,7 +2,7 @@ import { EntityDict, OperateOption, SelectOption, OperationResult, AggregationRe
|
|||
import { AmapInstance } from "oak-external-sdk";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { AsyncContext } from "oak-domain/lib/store/AsyncRowStore";
|
||||
export declare type CommonAspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
export type CommonAspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
operate: <T extends keyof ED, OP extends OperateOption>(params: {
|
||||
entity: T;
|
||||
operation: ED[T]['Operation'] | ED[T]['Operation'][];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export declare function operate<ED extends BaseEntityDict & EntityDict, T extend
|
|||
entity: T;
|
||||
operation: ED[T]['Operation'] | ED[T]['Operation'][];
|
||||
option?: OP;
|
||||
}, context: Cxt): Promise<import("oak-domain/lib/types").OperationResult<ED> | Awaited<import("oak-domain/lib/types").OperationResult<ED>>[]>;
|
||||
}, context: Cxt): Promise<import("oak-domain/lib/types").OperationResult<ED> | import("oak-domain/lib/types").OperationResult<ED>[]>;
|
||||
export declare function select<ED extends BaseEntityDict & EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends SelectOption>(params: {
|
||||
entity: T;
|
||||
selection: ED[T]['Selection'];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { EntityDict, OperateOption, SelectOption, OperationResult, AggregationRe
|
|||
import { AmapInstance } from "oak-external-sdk";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { AsyncContext } from "oak-domain/lib/store/AsyncRowStore";
|
||||
export declare type CommonAspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
export type CommonAspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
operate: <T extends keyof ED, OP extends OperateOption>(params: {
|
||||
entity: T;
|
||||
operation: ED[T]['Operation'] | ED[T]['Operation'][];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export declare function operate<ED extends BaseEntityDict & EntityDict, T extend
|
|||
entity: T;
|
||||
operation: ED[T]['Operation'] | ED[T]['Operation'][];
|
||||
option?: OP;
|
||||
}, context: Cxt): Promise<import("oak-domain/lib/types").OperationResult<ED> | Awaited<import("oak-domain/lib/types").OperationResult<ED>>[]>;
|
||||
}, context: Cxt): Promise<import("oak-domain/lib/types").OperationResult<ED> | import("oak-domain/lib/types").OperationResult<ED>[]>;
|
||||
export declare function select<ED extends BaseEntityDict & EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends SelectOption>(params: {
|
||||
entity: T;
|
||||
selection: ED[T]['Selection'];
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.count = exports.fetchRows = exports.aggregate = exports.select = exports.operate = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const types_1 = require("oak-domain/lib/types");
|
||||
const relation_1 = require("oak-domain/lib/store/relation");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
async function operate(params, context) {
|
||||
const { entity, operation, option } = params;
|
||||
/* const userId = context.getCurrentUserId();
|
||||
|
|
@ -49,7 +48,7 @@ function pruneAggrResult(schema, entity, result) {
|
|||
}
|
||||
}
|
||||
else if (rel instanceof Array) {
|
||||
(0, assert_1.default)(r[attr] instanceof Array);
|
||||
(0, assert_1.assert)(r[attr] instanceof Array);
|
||||
const rr = r[attr].map((ele) => pruneInner(rel[0], ele));
|
||||
if (rr.find((ele) => !ele)) {
|
||||
hasAggr = true;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ async function searchPoi(options) {
|
|||
});
|
||||
const { records } = await result.json();
|
||||
const pois = await Promise.all(records.map(async (ele) => {
|
||||
let { area, standard_name, gdm, id, province_name, city_name, area_name, place_type } = ele;
|
||||
let { area, standard_name, gdm, id, province_name, city_name, area_name, place_type, } = ele;
|
||||
// 对返回的area数据进行一些清洗,不规范
|
||||
if (area.length === 9) {
|
||||
if (area.endsWith('999')) {
|
||||
|
|
@ -37,6 +37,6 @@ async function searchPoi(options) {
|
|||
detail: `${province_name}${city_name}${area_name}${standard_name}(${place_type})`,
|
||||
};
|
||||
}));
|
||||
return pois.filter(poi => !!poi);
|
||||
return pois.filter((poi) => !!poi);
|
||||
}
|
||||
exports.searchPoi = searchPoi;
|
||||
|
|
|
|||
17
lib/port.js
17
lib/port.js
|
|
@ -1,20 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getImportationTemplate = exports.exportEntity = exports.importEntity = exports.clearPorts = exports.registerPorts = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const xlsx_1 = require("xlsx");
|
||||
const Importations = {};
|
||||
const Exportations = {};
|
||||
function registerPorts(importations, exportations) {
|
||||
for (const i of importations) {
|
||||
(0, assert_1.default)(!Importations.hasOwnProperty(i.id), `Importation中的id【${i.id}】重复了`);
|
||||
(0, assert_1.assert)(!Importations.hasOwnProperty(i.id), `Importation中的id【${i.id}】重复了`);
|
||||
Object.assign(Importations, {
|
||||
[i.id]: i,
|
||||
});
|
||||
}
|
||||
for (const e of exportations) {
|
||||
(0, assert_1.default)(!Exportations.hasOwnProperty(e.id), `Exportation中的id【${e.id}】重复了`);
|
||||
(0, assert_1.assert)(!Exportations.hasOwnProperty(e.id), `Exportation中的id【${e.id}】重复了`);
|
||||
Object.assign(Exportations, {
|
||||
[e.id]: e,
|
||||
});
|
||||
|
|
@ -31,11 +30,11 @@ function clearPorts() {
|
|||
}
|
||||
exports.clearPorts = clearPorts;
|
||||
function getImportation(id) {
|
||||
(0, assert_1.default)(Importations.hasOwnProperty(id), `id为[${id}]的importation不存在`);
|
||||
(0, assert_1.assert)(Importations.hasOwnProperty(id), `id为[${id}]的importation不存在`);
|
||||
return Importations[id];
|
||||
}
|
||||
function getExportation(id) {
|
||||
(0, assert_1.default)(Exportations.hasOwnProperty(id), `id为[${id}]的exportation不存在`);
|
||||
(0, assert_1.assert)(Exportations.hasOwnProperty(id), `id为[${id}]的exportation不存在`);
|
||||
return Exportations[id];
|
||||
}
|
||||
async function importEntity(params, context) {
|
||||
|
|
@ -87,12 +86,14 @@ async function exportEntity(params, context) {
|
|||
data: projection,
|
||||
}, {});
|
||||
const headers2 = makeHeaders ? makeHeaders(dataList) : headers;
|
||||
(0, assert_1.default)(headers2 && headers2.length > 0, '导出未传入表头');
|
||||
(0, assert_1.assert)(headers2 && headers2.length > 0, '导出未传入表头');
|
||||
const fittedDatalist = [];
|
||||
for (const data of dataList) {
|
||||
fittedDatalist.push(await fn(data, context, properties));
|
||||
}
|
||||
const exportSheet = xlsx_1.utils.json_to_sheet(fittedDatalist, { header: headers2 });
|
||||
const exportSheet = xlsx_1.utils.json_to_sheet(fittedDatalist, {
|
||||
header: headers2,
|
||||
});
|
||||
const exportBook = xlsx_1.utils.book_new();
|
||||
xlsx_1.utils.book_append_sheet(exportBook, exportSheet);
|
||||
return await (0, xlsx_1.write)(exportBook, { type: 'buffer' });
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@
|
|||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/node": "^20.6.0",
|
||||
"assert": "^2.0.0",
|
||||
"ts-node": "~10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "~4.7.4"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue