nicot 1.1.30 → 1.1.32

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 CHANGED
@@ -202,7 +202,61 @@ var BigintTransformer = class {
202
202
  // src/decorators/property.ts
203
203
  var import_nesties4 = require("nesties");
204
204
 
205
+ // src/utility/non-transformable-types.ts
206
+ var nonTransformableTypes = /* @__PURE__ */ new Set([
207
+ // Primitive wrappers
208
+ String,
209
+ Number,
210
+ Boolean,
211
+ BigInt,
212
+ Symbol,
213
+ // Built-ins
214
+ Date,
215
+ RegExp,
216
+ Error,
217
+ Array,
218
+ Object,
219
+ Function,
220
+ Promise,
221
+ // Collections
222
+ Map,
223
+ Set,
224
+ WeakMap,
225
+ WeakSet,
226
+ // Node / Buffer
227
+ Buffer,
228
+ ArrayBuffer,
229
+ SharedArrayBuffer,
230
+ DataView,
231
+ Int8Array,
232
+ Uint8Array,
233
+ Uint8ClampedArray,
234
+ Int16Array,
235
+ Uint16Array,
236
+ Int32Array,
237
+ Uint32Array,
238
+ Float32Array,
239
+ Float64Array,
240
+ BigInt64Array,
241
+ BigUint64Array,
242
+ // URL stuff
243
+ URL,
244
+ URLSearchParams
245
+ ]);
246
+
205
247
  // src/utility/type-transformer.ts
248
+ var toValue = (cl, value) => {
249
+ if (cl === Date) {
250
+ return new Date(value);
251
+ }
252
+ if (nonTransformableTypes.has(cl) || value instanceof cl) {
253
+ return value;
254
+ }
255
+ if (typeof value === "object") {
256
+ return Object.assign(new cl(), value);
257
+ }
258
+ return value;
259
+ };
206
260
  var TypeTransformer = class {
207
261
  constructor(definition) {
208
262
  this.definition = definition;
@@ -212,11 +266,9 @@ var TypeTransformer = class {
212
266
  return dbValue;
213
267
  }
214
268
  if (Array.isArray(this.definition)) {
215
- return dbValue.map(
216
- (value) => Object.assign(new this.definition[0](), value)
217
- );
269
+ return dbValue.map((value) => toValue(this.definition[0], value));
218
270
  }
219
- return Object.assign(new this.definition(), dbValue);
271
+ return toValue(this.definition, dbValue);
220
272
  }
221
273
  to(entValue) {
222
274
  return entValue;
@@ -795,11 +847,7 @@ function StringIdBase(idOptions) {
795
847
  const decs = [
796
848
  Reflect.metadata("design:type", String),
797
849
  QueryEqual(),
798
- ...idOptions.uuid ? [
799
- UuidColumn({ ...columnOptions, generated: true }),
800
- (0, import_typeorm3.Generated)("uuid"),
801
- NotWritable()
802
- ] : [
850
+ ...idOptions.uuid ? [UuidColumn({ ...columnOptions, generated: true }), NotWritable()] : [
803
851
  StringColumn(idOptions.length || 255, columnOptions),
804
852
  (0, import_class_validator6.IsNotEmpty)(),
805
853
  NotChangeable()
@@ -1866,6 +1914,7 @@ var RestfulFactory = class _RestfulFactory {
1866
1914
  const resultDto = (0, import_swagger6.OmitType)(this.entityClass, [...outputFieldsToOmit]);
1867
1915
  for (const relation of relations) {
1868
1916
  if (outputFieldsToOmit.has(relation.propertyName)) continue;
1917
+ if (nonTransformableTypes.has(relation.propertyClass)) continue;
1869
1918
  const replace = (useClass) => {
1870
1919
  const oldApiProperty = Reflect.getMetadata(
1871
1920
  import_constants.DECORATORS.API_MODEL_PROPERTIES,