nicot 1.2.0 → 1.2.2

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/README.md CHANGED
@@ -520,6 +520,26 @@ isActive: boolean;
520
520
 
521
521
  ---
522
522
 
523
+ ### RestfulFactory 配置项
524
+
525
+ ```ts
526
+ export interface RestfulFactoryOptions<T> {
527
+ fieldsToOmit?: (keyof T)[]; // 不出现在任何输入 DTO 中的字段
528
+ writeFieldsToOmit?: (keyof T)[]; // 不出现在创建与更新 DTO 中的字段
529
+ createFieldsToOmit?: (keyof T)[]; // 不出现在创建 DTO 中的字段
530
+ updateFieldsToOmit?: (keyof T)[]; // 不出现在更新 DTO 中的字段
531
+ findAllFieldsToOmit?: (keyof T)[]; // 不出现在查询 DTO 中的字段
532
+ outputFieldsToOmit?: (keyof T)[]; // 不出现在任何输出 DTO 中的字段
533
+ prefix?: string; // 接口的路由前缀
534
+ keepEntityVersioningDates?: boolean; // 在返回结果中保留实体的 createTime / updateTime 字段
535
+ entityClassName?: string; // 实体类名称,如果存在同一 Entity 的多个 RestfulFactory 实例时需要指定,避免 OpenAPI 类型冲突
536
+ relations?: (string | RelationDef)[]; // 关联加载的关系字段,传给 CrudService 的 relations 参数,以及用于生成关系 DTO
537
+ skipNonQueryableFields?: boolean; // 在查询 DTO 中跳过所有没有 @QueryXXX() 装饰器的字段
538
+ }
539
+ ```
540
+
541
+ ---
542
+
523
543
  ### 示例 Controller
524
544
 
525
545
  ```ts
package/dist/index.cjs CHANGED
@@ -1061,7 +1061,12 @@ function IdBase(idOptions = {}) {
1061
1061
  }),
1062
1062
  Reflect.metadata("design:type", Number),
1063
1063
  (0, import_typeorm4.Generated)("increment"),
1064
- QueryEqual()
1064
+ QueryEqual(),
1065
+ Metadata.set(
1066
+ "notRequiredButHasDefault",
1067
+ true,
1068
+ "notRequiredButHasDefaultFields"
1069
+ )
1065
1070
  ]);
1066
1071
  dec(cl.prototype, "id");
1067
1072
  return cl;
@@ -1083,6 +1088,11 @@ function StringIdBase(idOptions) {
1083
1088
  const decs = [
1084
1089
  Reflect.metadata("design:type", String),
1085
1090
  QueryEqual(),
1091
+ Metadata.set(
1092
+ "notRequiredButHasDefault",
1093
+ true,
1094
+ "notRequiredButHasDefaultFields"
1095
+ ),
1086
1096
  ...idOptions.uuid ? [UuidColumn({ ...columnOptions, generated: true }), NotWritable()] : [
1087
1097
  StringColumn(idOptions.length || 255, columnOptions),
1088
1098
  (0, import_class_validator6.IsNotEmpty)(),