Skip to content

Commit

Permalink
Rename DateFilter to DateTimeFilter (#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarnutsch authored Jun 25, 2024
1 parent 06768a7 commit caefa1c
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 84 deletions.
18 changes: 18 additions & 0 deletions .changeset/long-bottles-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@comet/cms-api": major
---

Rename `DateFilter` to `DateTimeFilter`

This leaves room for a future DateFilter that only filters by date, not time.

**Upgrading**

1. Change import

```diff
- import { DateFilter } from "@comet/cms-api";
+ import { DateTimeFilter } from "@comet/cms-api";
```

2. Re-run API Generator.
32 changes: 16 additions & 16 deletions demo/api/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ input RedirectFilter {
generationType: StringFilter
source: StringFilter
active: BooleanFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [RedirectFilter!]
or: [RedirectFilter!]
}
Expand All @@ -836,7 +836,7 @@ input BooleanFilter {
equal: Boolean
}

input DateFilter {
input DateTimeFilter {
equal: DateTime
lowerThan: DateTime
greaterThan: DateTime
Expand Down Expand Up @@ -892,11 +892,11 @@ input NewsFilter {
slug: StringFilter
title: StringFilter
status: NewsStatusEnumFilter
date: DateFilter
date: DateTimeFilter
category: NewsCategoryEnumFilter
comments: OneToManyFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [NewsFilter!]
or: [NewsFilter!]
}
Expand Down Expand Up @@ -942,14 +942,14 @@ input ProductFilter {
price: NumberFilter
inStock: BooleanFilter
soldCount: NumberFilter
availableSince: DateFilter
availableSince: DateTimeFilter
colors: OneToManyFilter
variants: OneToManyFilter
category: ManyToOneFilter
tags: ManyToManyFilter
tagsWithStatus: OneToManyFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
manufacturer: ManyToOneFilter
and: [ProductFilter!]
or: [ProductFilter!]
Expand Down Expand Up @@ -1016,8 +1016,8 @@ input ProductCategoryFilter {
title: StringFilter
slug: StringFilter
products: OneToManyFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [ProductCategoryFilter!]
or: [ProductCategoryFilter!]
}
Expand All @@ -1038,8 +1038,8 @@ input ProductTagFilter {
title: StringFilter
products: ManyToManyFilter
productsWithStatus: OneToManyFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [ProductTagFilter!]
or: [ProductTagFilter!]
}
Expand All @@ -1057,8 +1057,8 @@ enum ProductTagSortField {

input ProductVariantFilter {
name: StringFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [ProductVariantFilter!]
or: [ProductVariantFilter!]
}
Expand All @@ -1085,7 +1085,7 @@ input ManufacturerFilter {
addressAsEmbeddable_alternativeAddress_streetNumber: NumberFilter
addressAsEmbeddable_alternativeAddress_zip: NumberFilter
addressAsEmbeddable_alternativeAddress_country: StringFilter
updatedAt: DateFilter
updatedAt: DateTimeFilter
and: [ManufacturerFilter!]
or: [ManufacturerFilter!]
}
Expand Down
20 changes: 10 additions & 10 deletions demo/api/src/news/generated/dto/news.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { createEnumFilter, DateFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { createEnumFilter, DateTimeFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Type } from "class-transformer";
import { IsOptional, ValidateNested } from "class-validator";
Expand Down Expand Up @@ -32,11 +32,11 @@ export class NewsFilter {
@Type(() => NewsStatusEnumFilter)
status?: NewsStatusEnumFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
date?: DateFilter;
@Type(() => DateTimeFilter)
date?: DateTimeFilter;

@Field(() => NewsCategoryEnumFilter, { nullable: true })
@ValidateNested()
Expand All @@ -50,17 +50,17 @@ export class NewsFilter {
@Type(() => OneToManyFilter)
comments?: OneToManyFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
createdAt?: DateFilter;
@Type(() => DateTimeFilter)
createdAt?: DateTimeFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => [NewsFilter], { nullable: true })
@Type(() => NewsFilter)
Expand Down
8 changes: 4 additions & 4 deletions demo/api/src/products/generated/dto/manufacturer.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { DateFilter, NumberFilter, StringFilter } from "@comet/cms-api";
import { DateTimeFilter, NumberFilter, StringFilter } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Type } from "class-transformer";
import { IsOptional, ValidateNested } from "class-validator";
Expand Down Expand Up @@ -61,11 +61,11 @@ export class ManufacturerFilter {
@Type(() => StringFilter)
addressAsEmbeddable_alternativeAddress_country?: StringFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => [ManufacturerFilter], { nullable: true })
@Type(() => ManufacturerFilter)
Expand Down
14 changes: 7 additions & 7 deletions demo/api/src/products/generated/dto/product-category.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { DateFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { DateTimeFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Type } from "class-transformer";
import { IsOptional, ValidateNested } from "class-validator";
Expand All @@ -25,17 +25,17 @@ export class ProductCategoryFilter {
@Type(() => OneToManyFilter)
products?: OneToManyFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
createdAt?: DateFilter;
@Type(() => DateTimeFilter)
createdAt?: DateTimeFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => [ProductCategoryFilter], { nullable: true })
@Type(() => ProductCategoryFilter)
Expand Down
14 changes: 7 additions & 7 deletions demo/api/src/products/generated/dto/product-tag.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { DateFilter, ManyToManyFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { DateTimeFilter, ManyToManyFilter, OneToManyFilter, StringFilter } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Type } from "class-transformer";
import { IsOptional, ValidateNested } from "class-validator";
Expand All @@ -25,17 +25,17 @@ export class ProductTagFilter {
@Type(() => OneToManyFilter)
productsWithStatus?: OneToManyFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
createdAt?: DateFilter;
@Type(() => DateTimeFilter)
createdAt?: DateTimeFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => [ProductTagFilter], { nullable: true })
@Type(() => ProductTagFilter)
Expand Down
14 changes: 7 additions & 7 deletions demo/api/src/products/generated/dto/product-variant.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { DateFilter, StringFilter } from "@comet/cms-api";
import { DateTimeFilter, StringFilter } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Type } from "class-transformer";
import { IsOptional, ValidateNested } from "class-validator";
Expand All @@ -13,17 +13,17 @@ export class ProductVariantFilter {
@Type(() => StringFilter)
name?: StringFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
createdAt?: DateFilter;
@Type(() => DateTimeFilter)
createdAt?: DateTimeFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => [ProductVariantFilter], { nullable: true })
@Type(() => ProductVariantFilter)
Expand Down
20 changes: 10 additions & 10 deletions demo/api/src/products/generated/dto/product.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
BooleanFilter,
createEnumFilter,
createEnumsFilter,
DateFilter,
DateTimeFilter,
ManyToManyFilter,
ManyToOneFilter,
NumberFilter,
Expand Down Expand Up @@ -81,11 +81,11 @@ export class ProductFilter {
@Type(() => NumberFilter)
soldCount?: NumberFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
availableSince?: DateFilter;
@Type(() => DateTimeFilter)
availableSince?: DateTimeFilter;

@Field(() => OneToManyFilter, { nullable: true })
@ValidateNested()
Expand Down Expand Up @@ -117,17 +117,17 @@ export class ProductFilter {
@Type(() => OneToManyFilter)
tagsWithStatus?: OneToManyFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
createdAt?: DateFilter;
@Type(() => DateTimeFilter)
createdAt?: DateTimeFilter;

@Field(() => DateFilter, { nullable: true })
@Field(() => DateTimeFilter, { nullable: true })
@ValidateNested()
@IsOptional()
@Type(() => DateFilter)
updatedAt?: DateFilter;
@Type(() => DateTimeFilter)
updatedAt?: DateTimeFilter;

@Field(() => ManyToOneFilter, { nullable: true })
@ValidateNested()
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cms-api/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ input RedirectFilter {
generationType: StringFilter
source: StringFilter
active: BooleanFilter
createdAt: DateFilter
updatedAt: DateFilter
createdAt: DateTimeFilter
updatedAt: DateTimeFilter
and: [RedirectFilter!]
or: [RedirectFilter!]
}
Expand All @@ -398,7 +398,7 @@ input BooleanFilter {
equal: Boolean
}

input DateFilter {
input DateTimeFilter {
equal: DateTime
lowerThan: DateTime
greaterThan: DateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Field, InputType } from "@nestjs/graphql";
import { IsDate, IsOptional } from "class-validator";

@InputType()
export class DateFilter {
export class DateTimeFilter {
@Field({ nullable: true })
@IsOptional()
@IsDate()
Expand Down
4 changes: 2 additions & 2 deletions packages/api/cms-api/src/common/filter/mikro-orm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BooleanFilter } from "./boolean.filter";
import { DateFilter } from "./date.filter";
import { DateTimeFilter } from "./date-time.filter";
import { filtersToMikroOrmQuery, filterToMikroOrmQuery, searchToMikroOrmQuery, splitSearchString } from "./mikro-orm";
import { NumberFilter } from "./number.filter";
import { StringFilter } from "./string.filter";
Expand Down Expand Up @@ -291,7 +291,7 @@ describe("filtersToMikroOrmQuery", () => {
} else if (
filterValue instanceof StringFilter ||
filterValue instanceof NumberFilter ||
filterValue instanceof DateFilter ||
filterValue instanceof DateTimeFilter ||
filterValue instanceof BooleanFilter
) {
acc[filterKey] = filterToMikroOrmQuery(filterValue, filterKey);
Expand Down
Loading

0 comments on commit caefa1c

Please sign in to comment.