nicot 1.1.32 → 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/dist/index.mjs CHANGED
@@ -355,7 +355,8 @@ var BoolColumn = (options = {}) => MergePropertyDecorators2([
355
355
  }),
356
356
  Column("boolean", columnDecoratorOptions(options)),
357
357
  validatorDecorator(options),
358
- swaggerDecorator(options, { type: Boolean })
358
+ swaggerDecorator(options, { type: Boolean }),
359
+ Metadata.set("boolColumn", true, "boolColumnFields")
359
360
  ]);
360
361
  var JsonColumn = (definition, options = {}) => {
361
362
  const cl = getClassFromClassOrArray2(definition);
@@ -475,12 +476,6 @@ var applyQueryMatchBoolean = createQueryCondition(
475
476
  }
476
477
  );
477
478
 
478
- // src/utility/rename-class.ts
479
- function RenameClass(cls, name) {
480
- Object.defineProperty(cls, "name", { value: name });
481
- return cls;
482
- }
483
-
484
479
  // src/decorators/query.ts
485
480
  import { MergePropertyDecorators as MergePropertyDecorators3 } from "nesties";
486
481
 
@@ -1701,7 +1696,8 @@ import {
1701
1696
  BlankReturnMessageDto as BlankReturnMessageDto3,
1702
1697
  MergeMethodDecorators,
1703
1698
  PaginatedReturnMessageDto as PaginatedReturnMessageDto2,
1704
- ReturnMessageDto as ReturnMessageDto2
1699
+ ReturnMessageDto as ReturnMessageDto2,
1700
+ getApiProperty as getApiProperty2
1705
1701
  } from "nesties";
1706
1702
  import {
1707
1703
  ApiBadRequestResponse,
@@ -1711,13 +1707,13 @@ import {
1711
1707
  ApiOkResponse,
1712
1708
  ApiOperation,
1713
1709
  ApiParam,
1714
- ApiProperty as ApiProperty5,
1710
+ ApiProperty as ApiProperty6,
1715
1711
  IntersectionType,
1716
1712
  OmitType as OmitType2,
1717
1713
  PartialType
1718
1714
  } from "@nestjs/swagger";
1719
1715
  import _4, { upperFirst } from "lodash";
1720
- import { DECORATORS } from "@nestjs/swagger/dist/constants";
1716
+ import { RenameClass } from "nesties";
1721
1717
 
1722
1718
  // src/bases/base-restful-controller.ts
1723
1719
  var RestfulMethods = [
@@ -1778,6 +1774,27 @@ var OmitTypeExclude = (cl, keys) => {
1778
1774
  return omitted;
1779
1775
  };
1780
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
+
1781
1798
  // src/restful.ts
1782
1799
  var getCurrentLevelRelations = (relations) => relations.filter((r) => !r.includes("."));
1783
1800
  var getNextLevelRelations = (relations, enteringField) => relations.filter((r) => r.includes(".") && r.startsWith(`${enteringField}.`)).map((r) => r.split(".").slice(1).join("."));
@@ -1805,14 +1822,22 @@ var RestfulFactory = class _RestfulFactory {
1805
1822
  `Create${this.entityClass.name}Dto`
1806
1823
  );
1807
1824
  this.importDto = ImportDataDto(this.createDto);
1825
+ this.fieldsInGetToOmit = _4.uniq([
1826
+ ...this.fieldsToOmit,
1827
+ ...getSpecificFields(this.entityClass, "notQueryable")
1828
+ ]);
1808
1829
  this.findAllDto = RenameClass(
1809
1830
  PartialType(
1810
- OmitTypeExclude(
1811
- this.entityClass instanceof PageSettingsDto ? this.basicInputDto : IntersectionType(
1812
- this.basicInputDto,
1813
- PageSettingsDto
1831
+ PatchColumnsInGet(
1832
+ OmitTypeExclude(
1833
+ this.entityClass instanceof PageSettingsDto ? this.entityClass : IntersectionType(
1834
+ this.entityClass,
1835
+ PageSettingsDto
1836
+ ),
1837
+ this.fieldsInGetToOmit
1814
1838
  ),
1815
- getSpecificFields(this.entityClass, "notQueryable")
1839
+ this.entityClass,
1840
+ this.fieldsInGetToOmit
1816
1841
  )
1817
1842
  ),
1818
1843
  `Find${this.entityClass.name}Dto`
@@ -1891,12 +1916,11 @@ var RestfulFactory = class _RestfulFactory {
1891
1916
  if (outputFieldsToOmit.has(relation.propertyName)) continue;
1892
1917
  if (nonTransformableTypes.has(relation.propertyClass)) continue;
1893
1918
  const replace = (useClass) => {
1894
- const oldApiProperty = Reflect.getMetadata(
1895
- DECORATORS.API_MODEL_PROPERTIES,
1896
- this.entityClass.prototype,
1919
+ const oldApiProperty = getApiProperty2(
1920
+ this.entityClass,
1897
1921
  relation.propertyName
1898
- ) || {};
1899
- ApiProperty5({
1922
+ );
1923
+ ApiProperty6({
1900
1924
  ...oldApiProperty,
1901
1925
  required: false,
1902
1926
  type: () => relation.isArray ? [useClass[0]] : useClass[0]
@@ -2246,7 +2270,6 @@ export {
2246
2270
  QuerySearch,
2247
2271
  Relation,
2248
2272
  RelationComputed,
2249
- RenameClass,
2250
2273
  RestfulFactory,
2251
2274
  StringColumn,
2252
2275
  StringIdBase,