@comet/api-generator 8.9.0-canary-20251201141029 → 8.9.0

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.
@@ -270,7 +270,7 @@ function generatePaginatedDto({ generatorOptions, metadata }) {
270
270
  function generateArgsDto({ generatorOptions, metadata }) {
271
271
  var _a;
272
272
  const { classNameSingular, fileNameSingular } = (0, build_name_variants_1.buildNameVariants)(metadata);
273
- const { scopeProp, argsClassName, hasSearchArg, hasSortArg, hasFilterArg, dedicatedResolverArgProps, hasPositionProp } = (0, build_options_1.buildOptions)(metadata, generatorOptions);
273
+ const { scopeProp, argsClassName, hasSearchArg, hasSortArg, hasFilterArg, dedicatedResolverArgProps, hasPositionProp, crudSortProps } = (0, build_options_1.buildOptions)(metadata, generatorOptions);
274
274
  const imports = [];
275
275
  if (scopeProp && scopeProp.targetMeta) {
276
276
  imports.push(generateEntityImport(scopeProp.targetMeta, `${generatorOptions.targetDirectory}/dto`));
@@ -282,6 +282,8 @@ function generateArgsDto({ generatorOptions, metadata }) {
282
282
  else if (metadata.props.some((prop) => prop.name === "createdAt" && prop.type === "Date")) {
283
283
  defaultSortField = "createdAt";
284
284
  }
285
+ if (!crudSortProps.includes(defaultSortField))
286
+ defaultSortField = null;
285
287
  const argsOut = `import { ArgsType, Field, IntersectionType, registerEnumType, ID } from "@nestjs/graphql";
286
288
  import { Type } from "class-transformer";
287
289
  import { IsOptional, IsString, ValidateNested, IsEnum, IsUUID } from "class-validator";
@@ -339,10 +341,11 @@ function generateArgsDto({ generatorOptions, metadata }) {
339
341
 
340
342
  ${hasSortArg
341
343
  ? `
342
- @Field(() => [${classNameSingular}Sort], { defaultValue: [{ field: ${classNameSingular}SortField.${defaultSortField}, direction: SortDirection.ASC }] })
344
+ @Field(() => [${classNameSingular}Sort], { ${defaultSortField === null ? "nullable: true" : `defaultValue: [{ field: ${classNameSingular}SortField.${defaultSortField}, direction: SortDirection.ASC }]`} })
343
345
  @ValidateNested({ each: true })
344
346
  @Type(() => ${classNameSingular}Sort)
345
- sort: ${classNameSingular}Sort[];
347
+ ${defaultSortField === null ? "@IsOptional()" : ""}
348
+ sort${defaultSortField === null ? "?" : ""}: ${classNameSingular}Sort[];
346
349
  `
347
350
  : ""}
348
351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/api-generator",
3
- "version": "8.9.0-canary-20251201141029",
3
+ "version": "8.9.0",
4
4
  "description": "Comet API Generator CLI tool",
5
5
  "repository": {
6
6
  "directory": "packages/api/api-generator",
@@ -25,7 +25,7 @@
25
25
  "ts-morph": "^25.0.1",
26
26
  "ts-node": "^10.9.2",
27
27
  "typescript": "5.9.3",
28
- "@comet/cms-api": "8.9.0-canary-20251201141029"
28
+ "@comet/cms-api": "8.9.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@mikro-orm/cli": "^6.4.16",
@@ -44,7 +44,7 @@
44
44
  "rimraf": "^6.0.1",
45
45
  "ts-jest": "^29.4.0",
46
46
  "uuid": "^11.1.0",
47
- "@comet/eslint-config": "8.9.0-canary-20251201141029"
47
+ "@comet/eslint-config": "8.9.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@mikro-orm/cli": "^6.0.0",