From 4b3ad0a9eaf631708ce3d4761361924c22c70205 Mon Sep 17 00:00:00 2001 From: Max Richter <83216211+mrclickbits@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:34:50 +0100 Subject: [PATCH 1/3] Use IsoDate type for dates on absences (#144) This might break some TypeScript builds, but since it's not changing runtime behavior, we won't publish this as breaking change. You need to cast the type explicitly to `IsoDate` first. --- src/clockodo.test.ts | 12 ++++++------ src/models/absence.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/clockodo.test.ts b/src/clockodo.test.ts index 65431515..30b93f1a 100644 --- a/src/clockodo.test.ts +++ b/src/clockodo.test.ts @@ -884,8 +884,8 @@ describe("Clockodo (instance)", () => { describe("addAbsence()", () => { it("correctly builds addAbsence() request", async () => { const expectedParameters = { - date_since: "2017-08-18 00:00:00", - date_until: "2018-02-09 00:00:00", + date_since: "2017-08-18", + date_until: "2018-02-09", type: AbsenceType.SpecialLeave, note: "elternzeit", }; @@ -895,8 +895,8 @@ describe("Clockodo (instance)", () => { .reply(200, {}); await clockodo.addAbsence({ - dateSince: "2017-08-18 00:00:00", - dateUntil: "2018-02-09 00:00:00", + dateSince: "2017-08-18", + dateUntil: "2018-02-09", type: AbsenceType.SpecialLeave, note: "elternzeit", }); @@ -909,8 +909,8 @@ describe("Clockodo (instance)", () => { return expect( // @ts-expect-error Intentional error just for the test clockodo.addAbsence({ - dateSince: "2017-08-18 00:00:00", - dateUntil: "2018-02-09 00:00:00", + dateSince: "2017-08-18", + dateUntil: "2018-02-09", }) ).rejects.toThrowError('Missing required parameter "type"'); }); diff --git a/src/models/absence.ts b/src/models/absence.ts index ba747958..c574ee9c 100644 --- a/src/models/absence.ts +++ b/src/models/absence.ts @@ -1,15 +1,17 @@ +import { IsoDate } from "./dateTime.js"; + type CommonAbsence = { /** ID of the absence */ id: number; /** ID of the corresponding co-worker */ usersId: number; /** Start date in YYYY-MM-DD format */ - dateSince: string; + dateSince: IsoDate; /** * End date in YYYY-MM-DD format * Is the same date as dateSince in case the absence is only one day long **/ - dateUntil: string; // | null (as stated in the docs) doesn't seem to be correct + dateUntil: IsoDate; // | null (as stated in the docs) doesn't seem to be correct /** * Status of the absence. */ @@ -27,12 +29,12 @@ type CommonAbsence = { * Date at which the absence request has been enquired in YYYY-MM-DD format. * Only with access rights for absence administration or in case of own absences */ - dateEnquired?: string | null; + dateEnquired?: IsoDate | null; /** * Date at which the absence request has been approved, declined or cancelled in format YYYY-MM-DD. * Only with access rights for absence administration or in case of own absences */ - dateApproved?: string | null; + dateApproved?: IsoDate | null; /** * The ID of the co-worker who has approved, declined or cancelled the request. * Only with access rights for absence administration or in case of own absences From 16543bffc60339daf05f1ad1f46efd2a4ef30207 Mon Sep 17 00:00:00 2001 From: Dominik Sumer Date: Tue, 21 Nov 2023 11:12:04 +0100 Subject: [PATCH 2/3] fix: Rename HolidaysQuota and HolidaysCarryover (#145) BREAKING CHANGE: We've renamed `HolidayscarryRow` to `HolidaysCarryover` and `HolidaysquotaRow` to `HolidaysQuota` and adjusted all method names accordingly to make the naming more consistent. --- src/clockodo.test.ts | 12 ++++---- src/clockodo.ts | 28 +++++++++---------- src/index.ts | 4 +-- src/mocks.ts | 4 +-- ...ry.mocks.ts => holidaysCarryover.mocks.ts} | 6 ++-- ...{holidayscarry.ts => holidaysCarryover.ts} | 2 +- ...squota.mocks.ts => holidaysQuota.mocks.ts} | 6 ++-- .../{holidaysquota.ts => holidaysQuota.ts} | 7 +---- 8 files changed, 32 insertions(+), 37 deletions(-) rename src/models/{holidayscarry.mocks.ts => holidaysCarryover.mocks.ts} (71%) rename src/models/{holidayscarry.ts => holidaysCarryover.ts} (85%) rename src/models/{holidaysquota.mocks.ts => holidaysQuota.mocks.ts} (81%) rename src/models/{holidaysquota.ts => holidaysQuota.ts} (72%) diff --git a/src/clockodo.test.ts b/src/clockodo.test.ts index 30b93f1a..d0a3e035 100644 --- a/src/clockodo.test.ts +++ b/src/clockodo.test.ts @@ -665,25 +665,25 @@ describe("Clockodo (instance)", () => { }); }); - describe("getHolidaysquota()", () => { - it("correctly builds getHolidaysquota() request", async () => { + describe("getHolidaysQuotas()", () => { + it("correctly builds getHolidaysQuotas() request", async () => { const nockScope = nock(CLOCKODO_API) .get("/holidaysquota?users_id=17") .reply(200, {}); - await clockodo.getHolidaysquota({ usersId: 17 }); + await clockodo.getHolidaysQuotas({ usersId: 17 }); nockScope.done(); }); }); - describe("getHolidayscarry()", () => { - it("correctly builds getHolidayscarry() request", async () => { + describe("getHolidaysCarryovers()", () => { + it("correctly builds getHolidaysCarryovers() request", async () => { const nockScope = nock(CLOCKODO_API) .get("/holidayscarry?users_id=17&year=2028") .reply(200, {}); - await clockodo.getHolidayscarry({ usersId: 17, year: 2028 }); + await clockodo.getHolidaysCarryovers({ usersId: 17, year: 2028 }); nockScope.done(); }); diff --git a/src/clockodo.ts b/src/clockodo.ts index 1f3acaa6..bcf5928b 100644 --- a/src/clockodo.ts +++ b/src/clockodo.ts @@ -42,8 +42,8 @@ import { WorkTimeDay, } from "./models/workTimes.js"; import { OvertimecarryRow } from "./models/overtimecarry.js"; -import { HolidaysquotaRow } from "./models/holidaysquota.js"; -import { HolidayscarryRow } from "./models/holidayscarry.js"; +import { HolidaysQuota } from "./models/holidaysQuota.js"; +import { HolidaysCarryover } from "./models/holidaysCarryover.js"; export class Clockodo { api: Api; @@ -846,15 +846,15 @@ export class Clockodo { return this.api.get("/overtimecarry", params); } - async getHolidaysquota( - params?: Params - ): Promise { + async getHolidaysQuotas( + params?: Params + ): Promise { return this.api.get("/holidaysquota", params); } - async getHolidayscarry( - params?: Params - ): Promise { + async getHolidaysCarryovers( + params?: Params + ): Promise { return this.api.get("/holidayscarry", params); } } @@ -1173,18 +1173,18 @@ export type OvertimecarryRowParams = { year?: number; }; -export type HolidaysquotaRowReturnType = { - holidaysquota: Array; +export type HolidaysQuotasReturnType = { + holidaysquota: Array; }; -export type HolidaysquotaRowParams = { +export type HolidaysQuotasParams = { /** The user ID by which the holidays quota rows should be filtered */ usersId?: number; }; -export type HolidayscarryRowReturnType = { - holidayscarry: Array; +export type HolidaysCarryoversReturnType = { + holidayscarry: Array; }; -export type HolidayscarryRowParams = { +export type HolidaysCarryoversParams = { /** The user ID by which the holidays carry rows should be filtered */ usersId?: number; /** The year to which the data should be restricted to */ diff --git a/src/index.ts b/src/index.ts index 8ef76776..2a260cb4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,8 +6,8 @@ export * from "./models/dateTime.js"; export * from "./models/entriesText.js"; export * from "./models/entry.js"; export * from "./models/entryGroup.js"; -export * from "./models/holidayscarry.js"; -export * from "./models/holidaysquota.js"; +export * from "./models/holidaysCarryover.js"; +export * from "./models/holidaysQuota.js"; export * from "./models/lumpsumService.js"; export * from "./models/nonbusinessDay.js"; export * from "./models/nonbusinessGroup.js"; diff --git a/src/mocks.ts b/src/mocks.ts index 3b831aa6..53369e53 100644 --- a/src/mocks.ts +++ b/src/mocks.ts @@ -4,8 +4,8 @@ export * from "./models/absence.mocks.js"; export * from "./models/customer.mocks.js"; export * from "./models/entry.mocks.js"; // export * from "./models/entryGroup.mocks.js"; -export * from "./models/holidayscarry.mocks.js"; -export * from "./models/holidaysquota.mocks.js"; +export * from "./models/holidaysCarryover.mocks.js"; +export * from "./models/holidaysQuota.mocks.js"; export * from "./models/lumpsumService.mocks.js"; export * from "./models/service.mocks.js"; export * from "./models/nonbusinessDay.mocks.js"; diff --git a/src/models/holidayscarry.mocks.ts b/src/models/holidaysCarryover.mocks.ts similarity index 71% rename from src/models/holidayscarry.mocks.ts rename to src/models/holidaysCarryover.mocks.ts index 296db69f..e3ca59dc 100644 --- a/src/models/holidayscarry.mocks.ts +++ b/src/models/holidaysCarryover.mocks.ts @@ -1,16 +1,16 @@ import { faker } from "@faker-js/faker"; -import { HolidayscarryRow } from "./holidayscarry.js"; +import { HolidaysCarryover } from "./holidaysCarryover.js"; type Options = { count?: number; yearMinMax?: [number, number]; }; -export const createHolidayscarryMocks = ({ +export const createHolidaysCarryoverMocks = ({ count = 1, yearMinMax = [1900, 2024], }: Options = {}) => { - return Array.from({ length: count }, (): HolidayscarryRow => { + return Array.from({ length: count }, (): HolidaysCarryover => { return { usersId: 0, year: faker.datatype.number({ min: yearMinMax[0], max: yearMinMax[1] }), diff --git a/src/models/holidayscarry.ts b/src/models/holidaysCarryover.ts similarity index 85% rename from src/models/holidayscarry.ts rename to src/models/holidaysCarryover.ts index 2badd637..8d920571 100644 --- a/src/models/holidayscarry.ts +++ b/src/models/holidaysCarryover.ts @@ -1,4 +1,4 @@ -export type HolidayscarryRow = { +export type HolidaysCarryover = { /** The related employee's ID */ usersId: number; /** diff --git a/src/models/holidaysquota.mocks.ts b/src/models/holidaysQuota.mocks.ts similarity index 81% rename from src/models/holidaysquota.mocks.ts rename to src/models/holidaysQuota.mocks.ts index b858f543..48ca39a7 100644 --- a/src/models/holidaysquota.mocks.ts +++ b/src/models/holidaysQuota.mocks.ts @@ -1,5 +1,5 @@ import { faker } from "@faker-js/faker"; -import { HolidaysquotaRow } from "./holidaysquota.js"; +import { HolidaysQuota } from "./holidaysQuota.js"; type Options = { count?: number; @@ -7,12 +7,12 @@ type Options = { yearUntilMinMax?: [number, number]; }; -export const createHolidaysquotaMocks = ({ +export const createHolidaysQuotaMocks = ({ count = 1, yearSinceMinMax = [2020, 2021], yearUntilMinMax = [2021, 2022], }: Options = {}) => { - return Array.from({ length: count }, (_, index): HolidaysquotaRow => { + return Array.from({ length: count }, (_, index): HolidaysQuota => { const id = index; return { diff --git a/src/models/holidaysquota.ts b/src/models/holidaysQuota.ts similarity index 72% rename from src/models/holidaysquota.ts rename to src/models/holidaysQuota.ts index 0d5bffeb..9c248eb6 100644 --- a/src/models/holidaysquota.ts +++ b/src/models/holidaysQuota.ts @@ -1,4 +1,4 @@ -export type HolidaysquotaRow = { +export type HolidaysQuota = { /** The ID of the holiday quota settings */ id: number; /** The related employee's ID */ @@ -15,8 +15,3 @@ export type HolidaysquotaRow = { count: number; note: string | null; }; - -/** - * @deprecated Please use HolidaysquotaRow type - */ -export type HolidayquotaRow = HolidaysquotaRow; From de86396665016bf6391577836075503b6ef0e2e8 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 21 Nov 2023 10:13:09 +0000 Subject: [PATCH 3/3] chore(release): 23.0.0 [skip ci] # [23.0.0](https://github.com/peerigon/clockodo/compare/v22.2.0...v23.0.0) (2023-11-21) ### Bug Fixes * Rename HolidaysQuota and HolidaysCarryover ([#145](https://github.com/peerigon/clockodo/issues/145)) ([16543bf](https://github.com/peerigon/clockodo/commit/16543bffc60339daf05f1ad1f46efd2a4ef30207)) ### BREAKING CHANGES * We've renamed `HolidayscarryRow` to `HolidaysCarryover` and `HolidaysquotaRow` to `HolidaysQuota` and adjusted all method names accordingly to make the naming more consistent. --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d25503d..f02d3cf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +# [23.0.0](https://github.com/peerigon/clockodo/compare/v22.2.0...v23.0.0) (2023-11-21) + + +### Bug Fixes + +* Rename HolidaysQuota and HolidaysCarryover ([#145](https://github.com/peerigon/clockodo/issues/145)) ([16543bf](https://github.com/peerigon/clockodo/commit/16543bffc60339daf05f1ad1f46efd2a4ef30207)) + + +### BREAKING CHANGES + +* We've renamed `HolidayscarryRow` to `HolidaysCarryover` and `HolidaysquotaRow` to `HolidaysQuota` and adjusted all method names accordingly to make the naming more consistent. + # [22.2.0](https://github.com/peerigon/clockodo/compare/v22.1.0...v22.2.0) (2023-11-06)