@buka/nestjs-kit 4.3.4 → 4.3.5
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/CHANGELOG.md +7 -0
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2754,6 +2754,21 @@ function resolveEntityType(entityRef, eager) {
|
|
|
2754
2754
|
if (!cls) return Object;
|
|
2755
2755
|
return eager ? cls : PrimaryKeyType(cls);
|
|
2756
2756
|
}
|
|
2757
|
+
/**
|
|
2758
|
+
* 为 Swagger schema 解析实体类引用。始终返回完整实体类(非 PrimaryKeyType),
|
|
2759
|
+
* 保证 `$ref` 指向正确注册的 schema。
|
|
2760
|
+
*
|
|
2761
|
+
* 返回函数形式以支持延迟求值,避免装饰器执行时的循环引用问题。
|
|
2762
|
+
*/
|
|
2763
|
+
function resolveEntitySchemaType(entityRef) {
|
|
2764
|
+
return () => {
|
|
2765
|
+
if (!entityRef) return Object;
|
|
2766
|
+
const result = entityRef();
|
|
2767
|
+
const entityName = Array.isArray(result) ? result[0] : result;
|
|
2768
|
+
if (!entityName) return Object;
|
|
2769
|
+
return resolveEntityClass(entityName) || Object;
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2757
2772
|
//#endregion
|
|
2758
2773
|
//#region src/modules/mikro-orm/decorators/cardinality/many-to-one.cardinality.ts
|
|
2759
2774
|
/**
|
|
@@ -2866,8 +2881,8 @@ function OneToMany$1(options) {
|
|
|
2866
2881
|
},
|
|
2867
2882
|
schema: {
|
|
2868
2883
|
description: options.comment,
|
|
2869
|
-
type:
|
|
2870
|
-
|
|
2884
|
+
type: resolveEntitySchemaType(entityRef),
|
|
2885
|
+
isArray: true
|
|
2871
2886
|
}
|
|
2872
2887
|
})(target, propertyKey);
|
|
2873
2888
|
};
|
|
@@ -2907,8 +2922,8 @@ function ManyToMany$1(entity, mappedBy, options) {
|
|
|
2907
2922
|
},
|
|
2908
2923
|
schema: {
|
|
2909
2924
|
description: resolvedOptions?.comment,
|
|
2910
|
-
type:
|
|
2911
|
-
|
|
2925
|
+
type: resolveEntitySchemaType(entityRef),
|
|
2926
|
+
isArray: true
|
|
2912
2927
|
}
|
|
2913
2928
|
})(target, propertyKey);
|
|
2914
2929
|
};
|