oak-domain 5.1.18 → 5.1.19

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/lib/data/i18n.js CHANGED
@@ -25,6 +25,7 @@ const i18ns = [
25
25
  "preconditionUnset": "前置条件未满足",
26
26
  "externalException": "外部接口调用异常",
27
27
  "socketConnectException": "连接出现问题,请尝试刷新页面",
28
+ "applicationHasToUpgrade": "应用需要升级",
28
29
  "importedDataParseError": "import的数据存在异常"
29
30
  }
30
31
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo } from "../types";
2
+ import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo, OakException } from "../types";
3
3
  import { EntityDict as BaseEntityDict } from '../base-app-domain';
4
4
  import { IncomingHttpHeaders } from "http";
5
5
  /**
@@ -61,6 +61,7 @@ export declare abstract class AsyncContext<ED extends EntityDict & BaseEntityDic
61
61
  abstract initialize(data?: any, later?: boolean): Promise<void>;
62
62
  abstract allowUserUpdate(): boolean;
63
63
  abstract openRootMode(): () => void;
64
+ abstract tryDeduceException(err: Error): Promise<OakException<any> | void>;
64
65
  }
65
66
  export interface AsyncRowStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> extends RowStore<ED> {
66
67
  operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
@@ -186,6 +186,9 @@ export declare class OakExternalException<ED extends EntityDict & BaseEntityDict
186
186
  export declare class OakSocketConnectException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
187
187
  constructor(message?: string, _module?: string, params?: Record<string, any>);
188
188
  }
189
+ export declare class OakApplicationHasToUpgrade<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
190
+ constructor(message?: string, _module?: string, params?: Record<string, any>);
191
+ }
189
192
  export declare function makeException<ED extends EntityDict & BaseEntityDict>(data: {
190
193
  name: string;
191
194
  message?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeException = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakDataInvisibleException = exports.OakOperationUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakSignatureVerificationException = exports.OakClockDriftException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakRequestTimeoutException = exports.OakException = void 0;
3
+ exports.makeException = exports.OakApplicationHasToUpgrade = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakDataInvisibleException = exports.OakOperationUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakSignatureVerificationException = exports.OakClockDriftException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakRequestTimeoutException = exports.OakException = void 0;
4
4
  const relation_1 = require("../store/relation");
5
5
  const lodash_1 = require("../utils/lodash");
6
6
  class OakException extends Error {
@@ -423,6 +423,12 @@ class OakSocketConnectException extends OakUserException {
423
423
  }
424
424
  exports.OakSocketConnectException = OakSocketConnectException;
425
425
  ;
426
+ class OakApplicationHasToUpgrade extends OakUserException {
427
+ constructor(message, _module, params) {
428
+ super(message || 'error::applicationHasToUpgrade', _module || 'oak-domain', params);
429
+ }
430
+ }
431
+ exports.OakApplicationHasToUpgrade = OakApplicationHasToUpgrade;
426
432
  function makeException(data) {
427
433
  const { name, message, _module, params } = data;
428
434
  let e = undefined;
@@ -531,6 +537,10 @@ function makeException(data) {
531
537
  e = new OakSignatureVerificationException(message, _module, params);
532
538
  break;
533
539
  }
540
+ case 'OakApplicationHasToUpgrade': {
541
+ e = new OakApplicationHasToUpgrade(message, _module, params);
542
+ break;
543
+ }
534
544
  default:
535
545
  return;
536
546
  }
@@ -1,5 +1,5 @@
1
1
  import { SelectOption, CheckerType } from ".";
2
- import { GenericAction } from "../actions/action";
2
+ import { ExcludeUpdateAction } from "../actions/action";
3
3
  import { AsyncContext } from "../store/AsyncRowStore";
4
4
  import { SyncContext } from "../store/SyncRowStore";
5
5
  import { EntityDict, OperateOption } from "../types/Entity";
@@ -56,7 +56,7 @@ export type CreateTrigger<ED extends EntityDict & BaseEntityDict, T extends keyo
56
56
  * 只要有,就会触发trigger。要注意的是这个条件是exists而不是all
57
57
  */
58
58
  export interface UpdateTriggerBase<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends TriggerBase<ED, T> {
59
- action: Exclude<ED[T]['Action'], GenericAction> | 'update' | Array<Exclude<ED[T]['Action'], GenericAction> | 'update'>;
59
+ action: Exclude<ED[T]['Action'], ExcludeUpdateAction> | Array<Exclude<ED[T]['Action'], ExcludeUpdateAction>>;
60
60
  attributes?: keyof ED[T]['OpSchema'] | Array<keyof ED[T]['OpSchema']>;
61
61
  mt?: ModiTurn;
62
62
  check?: (operation: ED[T]['Update']) => boolean;
@@ -4,4 +4,10 @@
4
4
  * @param reqVersion 比较版本
5
5
  * @returns
6
6
  */
7
- export declare const compareVersion: (curVersion: string, reqVersion: string) => number;
7
+ export declare function compareVersion(curVersion: string, reqVersion: string): number;
8
+ /**
9
+ * 是不是一个有效的版本号
10
+ * @param version
11
+ * @returns
12
+ */
13
+ export declare function isVersion(version: string): boolean;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareVersion = void 0;
3
+ exports.isVersion = exports.compareVersion = void 0;
4
4
  /**
5
5
  * 版本比较
6
6
  * @param curVersion 当前版本
7
7
  * @param reqVersion 比较版本
8
8
  * @returns
9
9
  */
10
- const compareVersion = (curVersion, reqVersion) => {
10
+ function compareVersion(curVersion, reqVersion) {
11
11
  const v1 = curVersion.split('.');
12
12
  const v2 = reqVersion.split('.');
13
13
  for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
@@ -17,5 +17,15 @@ const compareVersion = (curVersion, reqVersion) => {
17
17
  return num1 - num2;
18
18
  }
19
19
  return 0;
20
- };
20
+ }
21
21
  exports.compareVersion = compareVersion;
22
+ ;
23
+ /**
24
+ * 是不是一个有效的版本号
25
+ * @param version
26
+ * @returns
27
+ */
28
+ function isVersion(version) {
29
+ return /([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])*\.([1-9][0-9]*|[0-9])*(\-[0-9A-Za-z-](\.[0-9A-Za-z-])*)*/g.test(version);
30
+ }
31
+ exports.isVersion = isVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "5.1.18",
3
+ "version": "5.1.19",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },