oak-domain 5.0.19 → 5.0.20

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.
@@ -124,7 +124,7 @@ function makeWebAllRouters(namespaceDir, projectDir, routerFileDir) {
124
124
  let path2 = path;
125
125
  if (params2[path]) {
126
126
  // 如果有参数,接在path后面
127
- path2 += `/:${params2[path]}`;
127
+ path2 += path2 ? `/:${params2[path]}` : `:${params2[path]}`;
128
128
  }
129
129
  const properties = [
130
130
  factory.createPropertyAssignment('path', factory.createStringLiteral(path2)),
@@ -1229,7 +1229,12 @@ class CascadeStore extends RowStore_1.RowStore {
1229
1229
  // 变成对modi的插入
1230
1230
  // 优化,这里如果是对同一个targetEntity反复update,则变成对最后一条create/update的modi进行update,以避免发布文章这样的需求时产生过多的modi
1231
1231
  let modiUpsert;
1232
- if (action !== 'remove') {
1232
+ if (action === 'update') {
1233
+ // 如果action本身是update,且没有实际update属性,这里可以忽略
1234
+ const updateAttrCount = Object.keys(data).length;
1235
+ if (updateAttrCount === 0) {
1236
+ return {};
1237
+ }
1233
1238
  const upsertModis = await this.selectAbjointRowAsync('modi', {
1234
1239
  data: {
1235
1240
  id: 1,
@@ -79,7 +79,7 @@ function createUniqueCheckers(schema) {
79
79
  entity,
80
80
  action: 'create',
81
81
  type: 'logicalData',
82
- priority: types_1.CHECKER_MAX_PRIORITY,
82
+ priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
83
83
  checker: (operation, context) => {
84
84
  const { data } = operation;
85
85
  if (data instanceof Array) {
@@ -95,9 +95,9 @@ function createUniqueCheckers(schema) {
95
95
  }
96
96
  }, {
97
97
  entity,
98
- action: 'update',
98
+ action: 'update', // 只检查update,其它状态转换的action应该不会涉及unique约束的属性
99
99
  type: 'logicalData',
100
- priority: types_1.CHECKER_MAX_PRIORITY,
100
+ priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
101
101
  checker: (operation, context) => {
102
102
  const { data, filter: operationFilter } = operation;
103
103
  if (data) {
@@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) {
227
227
  action: 'create',
228
228
  type: 'logical',
229
229
  entity,
230
- priority: 10,
230
+ priority: 10, // 优先级要高,先于真正的data检查进行
231
231
  checker: (operation) => {
232
232
  const { data } = operation;
233
233
  if (data instanceof Array) {
@@ -19,6 +19,8 @@ export declare class OakException<ED extends EntityDict & BaseEntityDict> extend
19
19
  tag2?: boolean;
20
20
  tag3?: any;
21
21
  }
22
+ export declare class OakMakeSureByMySelfException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
23
+ }
22
24
  export declare class OakPartialSuccess<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
23
25
  }
24
26
  export declare class OakDataException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.OakPartialSuccess = exports.OakException = void 0;
3
+ 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.OakPartialSuccess = exports.OakMakeSureByMySelfException = 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 {
@@ -90,6 +90,10 @@ class OakException extends Error {
90
90
  tag3;
91
91
  }
92
92
  exports.OakException = OakException;
93
+ // 这个异常表示模块自己处理跨事务一致性,框架pass(在分布式数据传递时会用到)(backend-base老版本有使用先保留)
94
+ class OakMakeSureByMySelfException extends OakException {
95
+ }
96
+ exports.OakMakeSureByMySelfException = OakMakeSureByMySelfException;
93
97
  // 这个异常表示事务虽然没有完全成功,但是仍然应该提交并抛出异常(在分布式数据传递时会用到)
94
98
  class OakPartialSuccess extends OakException {
95
99
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  /**
2
3
  * 防止assert打包体积过大,从这里引用
3
4
  */
@@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) {
60
60
  },
61
61
  filter: relationFilter,
62
62
  } // as ED['userRelation']['Selection']
63
- },
63
+ }, // as ED[keyof ED]['Selection']['data'],
64
64
  getData: (d) => {
65
65
  return d.userRelation$entity;
66
66
  },
@@ -13,8 +13,10 @@ const isPassword = (text) => {
13
13
  return ((text) && (typeof text === "string") && (/^[a-zA-Z0-9!.@]{8,16}$/.test(text)));
14
14
  };
15
15
  exports.isPassword = isPassword;
16
- const isCaptcha = (text) => {
17
- return ((text) && (typeof text === "string") && (/^\d{4}$/.test(text)));
16
+ const isCaptcha = (text, num) => {
17
+ const n = num || 4;
18
+ const regex = new RegExp(`^\\d{${n}}$`);
19
+ return ((text) && (typeof text === "string") && (regex.test(text)));
18
20
  };
19
21
  exports.isCaptcha = isCaptcha;
20
22
  const isIdCardNumber = (text) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "5.0.19",
3
+ "version": "5.0.20",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },