feat: v2 bookings createdAt filter (#20054)

* feat: add before and after updated filter to core handler

* feat: afterCreatedAt and beforeCreatedAt v2 bookings filters

* wip

* finish

* chore: bump libraries

* fix: tests

* refactor: implement feedback
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2025-03-14 15:49:57 +02:00
1 parent 580b03f2b9
commit 13044cb5b0
8 files changed
+5908 -69

No files matched your search

@@ -152,6 +152,26 @@ export class GetBookingsInput_2024_08_13 {
})
beforeEnd?: string;
@IsOptional()
@IsISO8601({ strict: true }, { message: "fromDate must be a valid ISO 8601 date." })
@ApiProperty({
type: String,
required: false,
description: "Filter bookings that have been created after this date string.",
example: "?afterCreatedAt=2025-03-07T10:00:00.000Z",
})
afterCreatedAt?: string;
@IsOptional()
@IsISO8601({ strict: true }, { message: "toDate must be a valid ISO 8601 date." })
@ApiProperty({
type: String,
required: false,
description: "Filter bookings that have been created before this date string.",
example: "?beforeCreatedAt=2025-03-14T11:00:00.000Z",
})
beforeCreatedAt?: string;
@IsOptional()
@IsISO8601({ strict: true }, { message: "fromDate must be a valid ISO 8601 date." })
@ApiProperty({
@@ -336,6 +336,24 @@ export async function getBookings({
},
]
: []),
...(filters?.afterCreatedDate
? [
{
createdAt: {
gte: dayjs.utc(filters.afterCreatedDate).toDate(),
},
},
]
: []),
...(filters?.beforeCreatedDate
? [
{
createdAt: {
lte: dayjs.utc(filters.beforeCreatedDate).toDate(),
},
},
]
: []),
],
};
@@ -14,6 +14,8 @@ export const ZGetInputSchema = z.object({
beforeEndDate: z.string().optional(),
afterUpdatedDate: z.string().optional(),
beforeUpdatedDate: z.string().optional(),
afterCreatedDate: z.string().optional(),
beforeCreatedDate: z.string().optional(),
}),
limit: z.number().min(1).max(100),
offset: z.number(),