nicot 1.1.31 → 1.1.33
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 +3 -4
- package/dist/index.cjs +153 -87
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +94 -26
- package/dist/index.mjs.map +4 -4
- package/dist/src/restful.d.ts +1 -0
- package/dist/src/utility/index.d.ts +0 -1
- package/dist/src/utility/metadata.d.ts +1 -0
- package/dist/src/utility/non-transformable-types.d.ts +1 -0
- package/dist/src/utility/patch-column-in-get.d.ts +2 -0
- package/package.json +2 -2
- package/dist/src/utility/rename-class.d.ts +0 -1
package/dist/index.mjs
CHANGED
|
@@ -140,16 +140,60 @@ 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
|
|
144
|
-
var nonTransformableTypes = /* @__PURE__ */ new Set([String, Number, Boolean]);
|
|
145
186
|
var toValue = (cl, value) => {
|
|
146
|
-
if (nonTransformableTypes.has(cl)) {
|
|
147
|
-
return value;
|
|
148
|
-
}
|
|
149
187
|
if (cl === Date) {
|
|
150
188
|
return new Date(value);
|
|
151
189
|
}
|
|
152
|
-
|
|
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;
|
|
153
197
|
};
|
|
154
198
|
var TypeTransformer = class {
|
|
155
199
|
constructor(definition) {
|
|
@@ -311,7 +355,8 @@ var BoolColumn = (options = {}) => MergePropertyDecorators2([
|
|
|
311
355
|
}),
|
|
312
356
|
Column("boolean", columnDecoratorOptions(options)),
|
|
313
357
|
validatorDecorator(options),
|
|
314
|
-
swaggerDecorator(options, { type: Boolean })
|
|
358
|
+
swaggerDecorator(options, { type: Boolean }),
|
|
359
|
+
Metadata.set("boolColumn", true, "boolColumnFields")
|
|
315
360
|
]);
|
|
316
361
|
var JsonColumn = (definition, options = {}) => {
|
|
317
362
|
const cl = getClassFromClassOrArray2(definition);
|
|
@@ -431,12 +476,6 @@ var applyQueryMatchBoolean = createQueryCondition(
|
|
|
431
476
|
}
|
|
432
477
|
);
|
|
433
478
|
|
|
434
|
-
// src/utility/rename-class.ts
|
|
435
|
-
function RenameClass(cls, name) {
|
|
436
|
-
Object.defineProperty(cls, "name", { value: name });
|
|
437
|
-
return cls;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
479
|
// src/decorators/query.ts
|
|
441
480
|
import { MergePropertyDecorators as MergePropertyDecorators3 } from "nesties";
|
|
442
481
|
|
|
@@ -1657,7 +1696,8 @@ import {
|
|
|
1657
1696
|
BlankReturnMessageDto as BlankReturnMessageDto3,
|
|
1658
1697
|
MergeMethodDecorators,
|
|
1659
1698
|
PaginatedReturnMessageDto as PaginatedReturnMessageDto2,
|
|
1660
|
-
ReturnMessageDto as ReturnMessageDto2
|
|
1699
|
+
ReturnMessageDto as ReturnMessageDto2,
|
|
1700
|
+
getApiProperty as getApiProperty2
|
|
1661
1701
|
} from "nesties";
|
|
1662
1702
|
import {
|
|
1663
1703
|
ApiBadRequestResponse,
|
|
@@ -1667,13 +1707,13 @@ import {
|
|
|
1667
1707
|
ApiOkResponse,
|
|
1668
1708
|
ApiOperation,
|
|
1669
1709
|
ApiParam,
|
|
1670
|
-
ApiProperty as
|
|
1710
|
+
ApiProperty as ApiProperty6,
|
|
1671
1711
|
IntersectionType,
|
|
1672
1712
|
OmitType as OmitType2,
|
|
1673
1713
|
PartialType
|
|
1674
1714
|
} from "@nestjs/swagger";
|
|
1675
1715
|
import _4, { upperFirst } from "lodash";
|
|
1676
|
-
import {
|
|
1716
|
+
import { RenameClass } from "nesties";
|
|
1677
1717
|
|
|
1678
1718
|
// src/bases/base-restful-controller.ts
|
|
1679
1719
|
var RestfulMethods = [
|
|
@@ -1734,6 +1774,27 @@ var OmitTypeExclude = (cl, keys) => {
|
|
|
1734
1774
|
return omitted;
|
|
1735
1775
|
};
|
|
1736
1776
|
|
|
1777
|
+
// src/utility/patch-column-in-get.ts
|
|
1778
|
+
import { ApiProperty as ApiProperty5 } from "@nestjs/swagger";
|
|
1779
|
+
import { getApiProperty } from "nesties";
|
|
1780
|
+
var PatchColumnsInGet = (cl, originalCl = cl, fieldsToOmit = []) => {
|
|
1781
|
+
const omit2 = new Set(fieldsToOmit);
|
|
1782
|
+
const boolFields = getSpecificFields(originalCl || cl, "boolColumn").filter(
|
|
1783
|
+
(f) => !omit2.has(f)
|
|
1784
|
+
);
|
|
1785
|
+
for (const field of boolFields) {
|
|
1786
|
+
const originalApiProp = getApiProperty(originalCl, field);
|
|
1787
|
+
ApiProperty5({
|
|
1788
|
+
...originalApiProp,
|
|
1789
|
+
type: String,
|
|
1790
|
+
required: false,
|
|
1791
|
+
enum: ["", "1"],
|
|
1792
|
+
default: originalApiProp?.default === true ? "1" : originalApiProp?.default === false ? "" : void 0
|
|
1793
|
+
})(cl.prototype, field);
|
|
1794
|
+
}
|
|
1795
|
+
return cl;
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1737
1798
|
// src/restful.ts
|
|
1738
1799
|
var getCurrentLevelRelations = (relations) => relations.filter((r) => !r.includes("."));
|
|
1739
1800
|
var getNextLevelRelations = (relations, enteringField) => relations.filter((r) => r.includes(".") && r.startsWith(`${enteringField}.`)).map((r) => r.split(".").slice(1).join("."));
|
|
@@ -1761,14 +1822,22 @@ var RestfulFactory = class _RestfulFactory {
|
|
|
1761
1822
|
`Create${this.entityClass.name}Dto`
|
|
1762
1823
|
);
|
|
1763
1824
|
this.importDto = ImportDataDto(this.createDto);
|
|
1825
|
+
this.fieldsInGetToOmit = _4.uniq([
|
|
1826
|
+
...this.fieldsToOmit,
|
|
1827
|
+
...getSpecificFields(this.entityClass, "notQueryable")
|
|
1828
|
+
]);
|
|
1764
1829
|
this.findAllDto = RenameClass(
|
|
1765
1830
|
PartialType(
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
this.
|
|
1769
|
-
|
|
1831
|
+
PatchColumnsInGet(
|
|
1832
|
+
OmitTypeExclude(
|
|
1833
|
+
this.entityClass instanceof PageSettingsDto ? this.entityClass : IntersectionType(
|
|
1834
|
+
this.entityClass,
|
|
1835
|
+
PageSettingsDto
|
|
1836
|
+
),
|
|
1837
|
+
this.fieldsInGetToOmit
|
|
1770
1838
|
),
|
|
1771
|
-
|
|
1839
|
+
this.entityClass,
|
|
1840
|
+
this.fieldsInGetToOmit
|
|
1772
1841
|
)
|
|
1773
1842
|
),
|
|
1774
1843
|
`Find${this.entityClass.name}Dto`
|
|
@@ -1845,13 +1914,13 @@ var RestfulFactory = class _RestfulFactory {
|
|
|
1845
1914
|
const resultDto = OmitType2(this.entityClass, [...outputFieldsToOmit]);
|
|
1846
1915
|
for (const relation of relations) {
|
|
1847
1916
|
if (outputFieldsToOmit.has(relation.propertyName)) continue;
|
|
1917
|
+
if (nonTransformableTypes.has(relation.propertyClass)) continue;
|
|
1848
1918
|
const replace = (useClass) => {
|
|
1849
|
-
const oldApiProperty =
|
|
1850
|
-
|
|
1851
|
-
this.entityClass.prototype,
|
|
1919
|
+
const oldApiProperty = getApiProperty2(
|
|
1920
|
+
this.entityClass,
|
|
1852
1921
|
relation.propertyName
|
|
1853
|
-
)
|
|
1854
|
-
|
|
1922
|
+
);
|
|
1923
|
+
ApiProperty6({
|
|
1855
1924
|
...oldApiProperty,
|
|
1856
1925
|
required: false,
|
|
1857
1926
|
type: () => relation.isArray ? [useClass[0]] : useClass[0]
|
|
@@ -2201,7 +2270,6 @@ export {
|
|
|
2201
2270
|
QuerySearch,
|
|
2202
2271
|
Relation,
|
|
2203
2272
|
RelationComputed,
|
|
2204
|
-
RenameClass,
|
|
2205
2273
|
RestfulFactory,
|
|
2206
2274
|
StringColumn,
|
|
2207
2275
|
StringIdBase,
|