oak-domain 5.1.25 → 5.1.27

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.
@@ -749,7 +749,7 @@ function injectDataIndexFile(dataIndexFile, briefNames, printer) {
749
749
  * @param fromDir 依赖项目的目录
750
750
  * @param toDir 当前项目的目录
751
751
  */
752
- function tryCopyFilesRecursively(fromDir, toDir) {
752
+ function tryCopyFilesRecursively(fromDir, toDir, rebuild) {
753
753
  const files = (0, fs_1.readdirSync)(fromDir);
754
754
  files.forEach((file) => {
755
755
  const fromFile = join(fromDir, file);
@@ -757,7 +757,12 @@ function tryCopyFilesRecursively(fromDir, toDir) {
757
757
  const stat = (0, fs_1.statSync)(fromFile);
758
758
  if (stat.isFile()) {
759
759
  if ((0, fs_1.existsSync)(join(toDir, file))) {
760
- console.log(`覆盖文件${toFile}`);
760
+ if (rebuild) {
761
+ console.log(`覆盖文件${toFile}`);
762
+ }
763
+ else {
764
+ console.log(`忽略文件${toFile}`);
765
+ }
761
766
  }
762
767
  else {
763
768
  console.log(`拷贝文件${toFile}`);
@@ -771,7 +776,7 @@ function tryCopyFilesRecursively(fromDir, toDir) {
771
776
  console.log(`创建文件夹${toFile}`);
772
777
  (0, fs_extra_1.mkdirSync)(toFile);
773
778
  }
774
- tryCopyFilesRecursively(fromFile, toFile);
779
+ tryCopyFilesRecursively(fromFile, toFile, rebuild);
775
780
  }
776
781
  });
777
782
  }
@@ -781,7 +786,7 @@ function tryCopyFilesRecursively(fromDir, toDir) {
781
786
  * @param dependencies
782
787
  * @param briefNames
783
788
  */
784
- function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
789
+ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild) {
785
790
  const injectDataIndexFileDependencies = [];
786
791
  const injectDataIndexFileBriefNames = [];
787
792
  dependencies.forEach((dep, idx) => {
@@ -792,7 +797,7 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
792
797
  const dataFile = join(moduleTemplateDir, 'data.ts');
793
798
  if ((0, fs_1.existsSync)(dataFile)) {
794
799
  const prjDataFile = join(cwd, 'src', 'data', `${briefNames[idx]}Data.ts`);
795
- if (!(0, fs_1.existsSync)(prjDataFile)) {
800
+ if (!(0, fs_1.existsSync)(prjDataFile) || rebuild) {
796
801
  console.log(`拷贝${dataFile}到${prjDataFile}中`);
797
802
  (0, fs_extra_1.copySync)(dataFile, prjDataFile);
798
803
  injectDataIndexFileDependencies.push(dep);
@@ -802,7 +807,7 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
802
807
  // src下面的文件是可以拷贝到项目中的
803
808
  const srcDir = join(moduleTemplateDir, 'src');
804
809
  if ((0, fs_1.existsSync)(srcDir)) {
805
- tryCopyFilesRecursively(srcDir, join(cwd, 'src'));
810
+ tryCopyFilesRecursively(srcDir, join(cwd, 'src'), rebuild);
806
811
  }
807
812
  }
808
813
  });
@@ -1020,7 +1025,7 @@ function buildDependency(rebuild) {
1020
1025
  }
1021
1026
  // 把各个依赖项目的一些初始化的文件拷贝过去
1022
1027
  if (!isModule) {
1023
- tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer);
1028
+ tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild);
1024
1029
  }
1025
1030
  }
1026
1031
  exports.default = buildDependency;
@@ -167,8 +167,11 @@ function polishSelection(schema, entity, selection, context, option) {
167
167
  }
168
168
  const toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
169
169
  const projectionNodeDict = {};
170
- const checkProjectionNode = (entity2, projectionNode) => {
171
- const necessaryAttrs = ['id', '$$createAt$$', '$$updateAt$$']; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
170
+ const checkProjectionNode = (entity2, projectionNode, root) => {
171
+ const necessaryAttrs = [types_1.PrimaryKeyAttribute, Entity_1.CreateAtAttribute, Entity_1.UpdateAtAttribute]; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
172
+ if (root && option?.includedDeleted) {
173
+ necessaryAttrs.push(Entity_1.DeleteAtAttribute);
174
+ }
172
175
  for (const attr in projectionNode) {
173
176
  if (attr === '#id') {
174
177
  (0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], `projection中结点的id有重复, ${projectionNode[attr]}`);
@@ -264,7 +267,7 @@ function polishSelection(schema, entity, selection, context, option) {
264
267
  }
265
268
  }
266
269
  };
267
- checkProjectionNode(entity, data);
270
+ checkProjectionNode(entity, data, true);
268
271
  if (!sorter && relevantIds.length === 0) {
269
272
  // 如果没有sorter,就给予一个按createAt逆序的sorter
270
273
  Object.assign(selection, {
@@ -1702,7 +1705,7 @@ class CascadeStore extends RowStore_1.RowStore {
1702
1705
  const entityBranch = lastOperation.d[entity];
1703
1706
  if (entityBranch) {
1704
1707
  rows.forEach((row) => {
1705
- if (row && row.id) { // 如果没有row.id就不加入结果集了
1708
+ if (row && row.id && !row[Entity_1.DeleteAtAttribute]) { // 如果没有row.id就不加入结果集了
1706
1709
  const { id } = row;
1707
1710
  if (!entityBranch[id]) {
1708
1711
  Object.assign(entityBranch, {
@@ -1727,7 +1730,7 @@ class CascadeStore extends RowStore_1.RowStore {
1727
1730
  }
1728
1731
  const entityBranch = {};
1729
1732
  rows.forEach((row) => {
1730
- if (row) {
1733
+ if (row && row.id && !row[Entity_1.DeleteAtAttribute]) {
1731
1734
  const { id } = row;
1732
1735
  Object.assign(entityBranch, {
1733
1736
  [id]: (0, lodash_1.cloneDeep)(row),
@@ -54,8 +54,8 @@ export type ServerConfiguration = {
54
54
  internalExceptionMask?: string;
55
55
  koaBody?: IKoaBodyOptions;
56
56
  socket?: (ctx: Koa.ParameterizedContext<any, KoaRouter.IRouterParamContext<any, {}>, any>) => {
57
- url?: string;
58
- };
57
+ url: string;
58
+ } | undefined;
59
59
  };
60
60
  /**
61
61
  * 前后台访问配置
@@ -23,4 +23,8 @@ export declare const isVehicleNumber: ValidatorFunction;
23
23
  export declare const isEmail: ValidatorFunction;
24
24
  export declare function checkAttributesNotNull<ED extends EntityDict, T extends keyof EntityDict>(entity: T, data: Partial<ED[T]['CreateOperationData']>, attributes: Array<keyof ED[T]['CreateOperationData']>, allowEmpty?: true): void;
25
25
  export declare function checkAttributesScope<ED extends EntityDict, T extends keyof EntityDict>(entity: T, data: Partial<ED[T]['CreateOperationData']>, attributes: Array<keyof ED[T]['CreateOperationData']>): void;
26
+ export declare const isIPV4: ValidatorFunction;
27
+ export declare const isIPV6: ValidatorFunction;
28
+ export declare const isIP: ValidatorFunction;
29
+ export declare const isDomain: ValidatorFunction;
26
30
  export {};
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isEmail = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isTel = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0;
6
+ exports.isDomain = exports.isIP = exports.isIPV6 = exports.isIPV4 = exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isEmail = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isTel = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0;
7
7
  const types_1 = require("../types");
8
8
  const isMobile = (text) => {
9
9
  return ((text) && (typeof text === "string") && ((/^1[3|4|5|6|7|8|9]\d{9}$/.test(text))));
@@ -131,3 +131,25 @@ function checkAttributesScope(entity, data, attributes) {
131
131
  }
132
132
  }
133
133
  exports.checkAttributesScope = checkAttributesScope;
134
+ const isIPV4 = (ip) => {
135
+ // IPv4正则
136
+ const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
137
+ return ipv4Regex.test(ip);
138
+ };
139
+ exports.isIPV4 = isIPV4;
140
+ const isIPV6 = (ip) => {
141
+ // IPv6正则(简化版,匹配常见格式)
142
+ const ipv6Regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$|^[0-9a-fA-F]{1,4}::([0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1}:([0-9a-fA-F]{1,4}:){0,4}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){2}:([0-9a-fA-F]{1,4}:){0,3}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){3}:([0-9a-fA-F]{1,4}:){0,2}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){4}:([0-9a-fA-F]{1,4}:){0,1}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){5}:[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1,6}:$/;
143
+ return ipv6Regex.test(ip);
144
+ };
145
+ exports.isIPV6 = isIPV6;
146
+ const isIP = (ip) => {
147
+ return (0, exports.isIPV4)(ip) || (0, exports.isIPV6)(ip);
148
+ };
149
+ exports.isIP = isIP;
150
+ const isDomain = (domain) => {
151
+ //基础域名验证正则
152
+ const domainRegex = /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/;
153
+ return domainRegex.test(domain);
154
+ };
155
+ exports.isDomain = isDomain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "5.1.25",
3
+ "version": "5.1.27",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },