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.mjs CHANGED
@@ -140,7 +140,61 @@ var BigintTransformer = class {
140
140
  // src/decorators/property.ts
141
141
  import { getClassFromClassOrArray as getClassFromClassOrArray2 } from "nesties";
142
142
 
143
+ // src/utility/non-transformable-types.ts
144
+ var nonTransformableTypes = /* @__PURE__ */ new Set([
145
+ // Primitive wrappers
146
+ String,
147
+ Number,
148
+ Boolean,
149
+ BigInt,
150
+ Symbol,
151
+ // Built-ins
152
+ Date,
153
+ RegExp,
154
+ Error,
155
+ Array,
156
+ Object,
157
+ Function,
158
+ Promise,
159
+ // Collections
160
+ Map,
161
+ Set,
162
+ WeakMap,
163
+ WeakSet,
164
+ // Node / Buffer
165
+ Buffer,
166
+ ArrayBuffer,
167
+ SharedArrayBuffer,
168
+ DataView,
169
+ Int8Array,
170
+ Uint8Array,
171
+ Uint8ClampedArray,
172
+ Int16Array,
173
+ Uint16Array,
174
+ Int32Array,
175
+ Uint32Array,
176
+ Float32Array,
177
+ Float64Array,
178
+ BigInt64Array,
179
+ BigUint64Array,
180
+ // URL stuff
181
+ URL,
182
+ URLSearchParams
183
+ ]);
184
+
143
185
  // src/utility/type-transformer.ts
186
+ var toValue = (cl, value) => {
187
+ if (cl === Date) {
188
+ return new Date(value);
189
+ }
190
+ if (nonTransformableTypes.has(cl) || value instanceof cl) {
191
+ return value;
192
+ }
193
+ if (typeof value === "object") {
194
+ return Object.assign(new cl(), value);
195
+ }
196
+ return value;
197
+ };
144
198
  var TypeTransformer = class {
145
199
  constructor(definition) {
146
200
  this.definition = definition;
@@ -150,11 +204,9 @@ var TypeTransformer = class {
150
204
  return dbValue;
151
205
  }
152
206
  if (Array.isArray(this.definition)) {
153
- return dbValue.map(
154
- (value) => Object.assign(new this.definition[0](), value)
155
- );
207
+ return dbValue.map((value) => toValue(this.definition[0], value));
156
208
  }
157
- return Object.assign(new this.definition(), dbValue);
209
+ return toValue(this.definition, dbValue);
158
210
  }
159
211
  to(entValue) {
160
212
  return entValue;
@@ -739,11 +791,7 @@ function StringIdBase(idOptions) {
739
791
  const decs = [
740
792
  Reflect.metadata("design:type", String),
741
793
  QueryEqual(),
742
- ...idOptions.uuid ? [
743
- UuidColumn({ ...columnOptions, generated: true }),
744
- Generated2("uuid"),
745
- NotWritable()
746
- ] : [
794
+ ...idOptions.uuid ? [UuidColumn({ ...columnOptions, generated: true }), NotWritable()] : [
747
795
  StringColumn(idOptions.length || 255, columnOptions),
748
796
  IsNotEmpty2(),
749
797
  NotChangeable()
@@ -1841,6 +1889,7 @@ var RestfulFactory = class _RestfulFactory {
1841
1889
  const resultDto = OmitType2(this.entityClass, [...outputFieldsToOmit]);
1842
1890
  for (const relation of relations) {
1843
1891
  if (outputFieldsToOmit.has(relation.propertyName)) continue;
1892
+ if (nonTransformableTypes.has(relation.propertyClass)) continue;
1844
1893
  const replace = (useClass) => {
1845
1894
  const oldApiProperty = Reflect.getMetadata(
1846
1895
  DECORATORS.API_MODEL_PROPERTIES,