Merge branch 'dev'
This commit is contained in:
commit
a4fcf15434
|
|
@ -340,7 +340,6 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) {
|
|||
}
|
||||
}
|
||||
if (f) {
|
||||
const rr = (0, filter_1.contains)(entity, context.getSchema(), data, f);
|
||||
const result = (0, filter_1.checkFilterContains)(entity, context, f, filter, true);
|
||||
if (result instanceof Promise) {
|
||||
return result.then((v) => {
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ class RelationAuth {
|
|||
// extraFilter?: ED[T2]['Selection']['filter'],
|
||||
path, child, hasParent, extraFilter) => {
|
||||
const { action, data, filter } = operation;
|
||||
const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : (0, lodash_1.cloneDeep)(filter);
|
||||
const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : filter ? (0, lodash_1.cloneDeep)(filter) : {};
|
||||
(0, assert_1.default)(filter2);
|
||||
if (extraFilter) {
|
||||
Object.assign(filter2, extraFilter);
|
||||
|
|
|
|||
|
|
@ -15,21 +15,6 @@ export declare class OakMakeSureByMySelfException<ED extends EntityDict> extends
|
|||
}
|
||||
export declare class OakDataException<ED extends EntityDict> extends OakException<ED> {
|
||||
}
|
||||
export declare class OakUniqueViolationException<ED extends EntityDict> extends OakException<ED> {
|
||||
rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>;
|
||||
constructor(rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>, message?: string);
|
||||
}
|
||||
export declare class OakImportDataParseException<ED extends EntityDict> extends OakException<ED> {
|
||||
line: number;
|
||||
header?: string;
|
||||
constructor(message: string, line: number, header?: string);
|
||||
}
|
||||
export declare class OakNoRelationDefException<ED extends EntityDict, T extends keyof ED> extends OakDataException<ED> {
|
||||
entity: T;
|
||||
actions: ED[T]['Action'][];
|
||||
|
|
@ -55,6 +40,21 @@ export declare class OakRowUnexistedException<ED extends EntityDict> extends Oak
|
|||
*/
|
||||
export declare class OakUserException<ED extends EntityDict> extends OakException<ED> {
|
||||
}
|
||||
export declare class OakUniqueViolationException<ED extends EntityDict> extends OakUserException<ED> {
|
||||
rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>;
|
||||
constructor(rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>, message?: string);
|
||||
}
|
||||
export declare class OakImportDataParseException<ED extends EntityDict> extends OakUserException<ED> {
|
||||
line: number;
|
||||
header?: string;
|
||||
constructor(message: string, line: number, header?: string);
|
||||
}
|
||||
/**
|
||||
* 网络中断异常
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakDataException = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
||||
exports.makeException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
||||
class OakException extends Error {
|
||||
opRecords;
|
||||
constructor(message) {
|
||||
|
|
@ -51,25 +51,6 @@ exports.OakMakeSureByMySelfException = OakMakeSureByMySelfException;
|
|||
class OakDataException extends OakException {
|
||||
}
|
||||
exports.OakDataException = OakDataException;
|
||||
class OakUniqueViolationException extends OakException {
|
||||
rows;
|
||||
constructor(rows, message) {
|
||||
super(message || '您更新的数据违反了唯一性约束');
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
exports.OakUniqueViolationException = OakUniqueViolationException;
|
||||
class OakImportDataParseException extends OakException {
|
||||
line;
|
||||
header;
|
||||
// message必传,描述具体错误的数据内容
|
||||
constructor(message, line, header) {
|
||||
super(message);
|
||||
this.line = line;
|
||||
this.header = header;
|
||||
}
|
||||
}
|
||||
exports.OakImportDataParseException = OakImportDataParseException;
|
||||
class OakNoRelationDefException extends OakDataException {
|
||||
entity;
|
||||
actions;
|
||||
|
|
@ -117,6 +98,25 @@ class OakUserException extends OakException {
|
|||
}
|
||||
exports.OakUserException = OakUserException;
|
||||
;
|
||||
class OakUniqueViolationException extends OakUserException {
|
||||
rows;
|
||||
constructor(rows, message) {
|
||||
super(message || '您更新的数据违反了唯一性约束');
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
exports.OakUniqueViolationException = OakUniqueViolationException;
|
||||
class OakImportDataParseException extends OakUserException {
|
||||
line;
|
||||
header;
|
||||
// message必传,描述具体错误的数据内容
|
||||
constructor(message, line, header) {
|
||||
super(message);
|
||||
this.line = line;
|
||||
this.header = header;
|
||||
}
|
||||
}
|
||||
exports.OakImportDataParseException = OakImportDataParseException;
|
||||
/**
|
||||
* 网络中断异常
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
*
|
||||
* @param units 各个执行单元,需要流水线执行,可能是同步也可能是异步
|
||||
*/
|
||||
export declare function pipeline(...units: Array<(result?: any) => any>): any;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pipeline = void 0;
|
||||
/**
|
||||
*
|
||||
* @param units 各个执行单元,需要流水线执行,可能是同步也可能是异步
|
||||
*/
|
||||
function pipeline(...units) {
|
||||
const exec = (idx, resultPrev) => {
|
||||
const unit = units[idx];
|
||||
if (!unit) {
|
||||
return resultPrev;
|
||||
}
|
||||
const result = unit(resultPrev);
|
||||
if (result instanceof Promise) {
|
||||
return result.then((resultSync) => exec(idx + 1, resultSync));
|
||||
}
|
||||
return exec(idx + 1, result);
|
||||
};
|
||||
return exec(0);
|
||||
}
|
||||
exports.pipeline = pipeline;
|
||||
|
|
@ -2,5 +2,5 @@ declare const ToCent: (float: number) => number;
|
|||
declare const ToYuan: (int: number) => number;
|
||||
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
||||
declare const CentToString: (value: number, fixed?: number) => string | undefined;
|
||||
declare const ThousandCont: (value: number, decimalPlaces?: number) => string | undefined;
|
||||
declare const ThousandCont: (value: number | string, decimalPlaces?: number) => string | undefined;
|
||||
export { ToCent, ToYuan, StringToCent, CentToString, ThousandCont };
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const CentToString = (value, fixed) => {
|
|||
};
|
||||
exports.CentToString = CentToString;
|
||||
const ThousandCont = (value, decimalPlaces) => {
|
||||
let value1 = `${value}`;
|
||||
let value1 = typeof value === 'number' ? `${value}` : value;
|
||||
const numArr = value1.split('.');
|
||||
value1 = numArr[0];
|
||||
let result = '';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oak-domain",
|
||||
"version": "5.0.6",
|
||||
"version": "5.0.7",
|
||||
"author": {
|
||||
"name": "XuChang"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -414,7 +414,6 @@ function createAttrUpdateCheckers<ED extends EntityDict & BaseEntityDict, Cxt ex
|
|||
}
|
||||
}
|
||||
if (f) {
|
||||
const rr = contains<ED, keyof ED>(entity, context.getSchema(), data, f);
|
||||
const result = checkFilterContains<ED, keyof ED, Cxt | FrontCxt>(entity, context, f, filter, true);
|
||||
if (result instanceof Promise) {
|
||||
return result.then(
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict> {
|
|||
hasParent?: true,
|
||||
extraFilter?: ED[T2]['Selection']['filter']): OperationTree<ED> => {
|
||||
const { action, data, filter } = operation;
|
||||
const filter2 = action === 'create' ? makeCreateFilter(entity, operation as Omit<ED[T]['CreateSingle'], 'id'>) : cloneDeep(filter);
|
||||
const filter2 = action === 'create' ? makeCreateFilter(entity, operation as Omit<ED[T]['CreateSingle'], 'id'>) : filter ? cloneDeep(filter) : {} as typeof filter;
|
||||
assert(filter2);
|
||||
if (extraFilter) {
|
||||
Object.assign(filter2, extraFilter);
|
||||
|
|
|
|||
|
|
@ -57,32 +57,6 @@ export class OakDataException<ED extends EntityDict> extends OakException<ED> {
|
|||
// 表示由数据层发现的异常
|
||||
}
|
||||
|
||||
export class OakUniqueViolationException<ED extends EntityDict> extends OakException<ED> {
|
||||
rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>;
|
||||
constructor(rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>, message?: string) {
|
||||
super(message || '您更新的数据违反了唯一性约束');
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
|
||||
export class OakImportDataParseException<ED extends EntityDict> extends OakException<ED> {
|
||||
line: number;
|
||||
header?: string;
|
||||
|
||||
// message必传,描述具体错误的数据内容
|
||||
constructor(message: string, line: number, header?: string) {
|
||||
super(message);
|
||||
this.line = line;
|
||||
this.header = header;
|
||||
}
|
||||
}
|
||||
|
||||
export class OakNoRelationDefException<ED extends EntityDict, T extends keyof ED> extends OakDataException<ED> {
|
||||
entity: T;
|
||||
actions: ED[T]['Action'][];
|
||||
|
|
@ -137,6 +111,33 @@ export class OakUserException<ED extends EntityDict> extends OakException<ED> {
|
|||
// 继承了这个类的异常统一视为“可接受的、由用户操作造成的异常”
|
||||
};
|
||||
|
||||
|
||||
export class OakUniqueViolationException<ED extends EntityDict> extends OakUserException<ED> {
|
||||
rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>;
|
||||
constructor(rows: Array<{
|
||||
id?: string;
|
||||
attrs: string[];
|
||||
}>, message?: string) {
|
||||
super(message || '您更新的数据违反了唯一性约束');
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
|
||||
export class OakImportDataParseException<ED extends EntityDict> extends OakUserException<ED> {
|
||||
line: number;
|
||||
header?: string;
|
||||
|
||||
// message必传,描述具体错误的数据内容
|
||||
constructor(message: string, line: number, header?: string) {
|
||||
super(message);
|
||||
this.line = line;
|
||||
this.header = header;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络中断异常
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* @param units 各个执行单元,需要流水线执行,可能是同步也可能是异步
|
||||
*/
|
||||
export function pipeline(...units: Array<(result?: any) => any>) {
|
||||
const exec = (idx: number, resultPrev?: any):any => {
|
||||
const unit = units[idx];
|
||||
if (!unit) {
|
||||
return resultPrev;
|
||||
}
|
||||
const result = unit(resultPrev);
|
||||
if (result instanceof Promise) {
|
||||
return result.then(
|
||||
(resultSync) => exec(idx + 1, resultSync)
|
||||
);
|
||||
}
|
||||
return exec(idx + 1, result);
|
||||
};
|
||||
|
||||
return exec(0);
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@ const CentToString: (value: number, fixed?: number) => string | undefined = (val
|
|||
}
|
||||
};
|
||||
|
||||
const ThousandCont: (value: number, decimalPlaces?: number) => string | undefined = (value, decimalPlaces) => {
|
||||
let value1 = `${value}`;
|
||||
const ThousandCont: (value: number | string, decimalPlaces?: number) => string | undefined = (value, decimalPlaces) => {
|
||||
let value1 = typeof value === 'number' ? `${value}`: value;
|
||||
const numArr = value1.split('.');
|
||||
value1 = numArr[0];
|
||||
let result = '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue