nicot 1.1.30 → 1.1.31
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/dist/index.cjs +13 -9
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +13 -9
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -203,6 +203,16 @@ var BigintTransformer = class {
|
|
|
203
203
|
var import_nesties4 = require("nesties");
|
|
204
204
|
|
|
205
205
|
// src/utility/type-transformer.ts
|
|
206
|
+
var nonTransformableTypes = /* @__PURE__ */ new Set([String, Number, Boolean]);
|
|
207
|
+
var toValue = (cl, value) => {
|
|
208
|
+
if (nonTransformableTypes.has(cl)) {
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
if (cl === Date) {
|
|
212
|
+
return new Date(value);
|
|
213
|
+
}
|
|
214
|
+
return Object.assign(new cl(), value);
|
|
215
|
+
};
|
|
206
216
|
var TypeTransformer = class {
|
|
207
217
|
constructor(definition) {
|
|
208
218
|
this.definition = definition;
|
|
@@ -212,11 +222,9 @@ var TypeTransformer = class {
|
|
|
212
222
|
return dbValue;
|
|
213
223
|
}
|
|
214
224
|
if (Array.isArray(this.definition)) {
|
|
215
|
-
return dbValue.map(
|
|
216
|
-
(value) => Object.assign(new this.definition[0](), value)
|
|
217
|
-
);
|
|
225
|
+
return dbValue.map((value) => toValue(this.definition[0], value));
|
|
218
226
|
}
|
|
219
|
-
return
|
|
227
|
+
return toValue(this.definition, dbValue);
|
|
220
228
|
}
|
|
221
229
|
to(entValue) {
|
|
222
230
|
return entValue;
|
|
@@ -795,11 +803,7 @@ function StringIdBase(idOptions) {
|
|
|
795
803
|
const decs = [
|
|
796
804
|
Reflect.metadata("design:type", String),
|
|
797
805
|
QueryEqual(),
|
|
798
|
-
...idOptions.uuid ? [
|
|
799
|
-
UuidColumn({ ...columnOptions, generated: true }),
|
|
800
|
-
(0, import_typeorm3.Generated)("uuid"),
|
|
801
|
-
NotWritable()
|
|
802
|
-
] : [
|
|
806
|
+
...idOptions.uuid ? [UuidColumn({ ...columnOptions, generated: true }), NotWritable()] : [
|
|
803
807
|
StringColumn(idOptions.length || 255, columnOptions),
|
|
804
808
|
(0, import_class_validator6.IsNotEmpty)(),
|
|
805
809
|
NotChangeable()
|