Skip to content

Commit

Permalink
refactor: remove events_groups - remove unique constraint - rename pa… (
Browse files Browse the repository at this point in the history
#217)

* refactor: remove events_groups - remove unique constraint - rename parent_id

* fix: remove old types

* chore: add a little more docs

* chore: add more docs (2)

* fix: generate TS types

* chore: adapt docs on the JS side
  • Loading branch information
GuillaumeDecMeetsMore authored Feb 19, 2025
1 parent b23f28f commit aa48405
Show file tree
Hide file tree
Showing 75 changed files with 287 additions and 2,474 deletions.
12 changes: 4 additions & 8 deletions bins/nittei/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,8 @@ async fn test_crud_events() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -533,12 +532,11 @@ async fn test_crud_events() {
event_id: event.id.clone(),
title: None,
description: None,
group_id: None,
event_type: None,
location: None,
status: None,
all_day: None,
parent_id: None,
external_parent_id: None,
external_id: None,
busy: None,
duration: None,
Expand Down Expand Up @@ -765,9 +763,8 @@ async fn test_freebusy_multiple() {
let _event1 = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand All @@ -793,9 +790,8 @@ async fn test_freebusy_multiple() {
let _event2 = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
3 changes: 1 addition & 2 deletions bins/nittei/tests/api_loadtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ async fn create_300_events_1_month(
.create(CreateEventInput {
user_id: user_id.clone(),
calendar_id: calendar_id.clone(),
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
21 changes: 7 additions & 14 deletions bins/nittei/tests/api_recurring_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ async fn test_create_event_validation() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -117,9 +116,8 @@ async fn test_expand_daily_recurring_event() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -214,9 +212,8 @@ async fn test_expand_weekly_recurring_event() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -307,9 +304,8 @@ async fn test_expand_monthly_recurring_event() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -395,9 +391,8 @@ async fn test_expand_recurring_event_and_remove_exceptions() {
let event = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -432,9 +427,8 @@ async fn test_expand_recurring_event_and_remove_exceptions() {
let exception_changed = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -462,9 +456,8 @@ async fn test_expand_recurring_event_and_remove_exceptions() {
let exception_removed = admin_client
.event
.create(CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
3 changes: 1 addition & 2 deletions bins/nittei/tests/collective_team_scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ async fn test_collective_team_scheduling() {

for (host, calendar) in hosts_with_calendar {
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
12 changes: 4 additions & 8 deletions bins/nittei/tests/group_team_scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ async fn test_group_team_scheduling() {
assert!(booking_intend.create_event_for_hosts);
for (host, calendar) in hosts_with_calendar {
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -524,9 +523,8 @@ async fn test_group_team_scheduling_increase_max_count() {
);
assert!(booking_intend.create_event_for_hosts);
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -959,9 +957,8 @@ async fn test_group_team_scheduling_decrease_max_count() {
);
assert!(booking_intend.create_event_for_hosts);
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -1176,9 +1173,8 @@ async fn test_combination_of_services() {

// And then create service event which is not busy
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
15 changes: 5 additions & 10 deletions bins/nittei/tests/round_robin_scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ async fn test_round_robin_scheduling_simple_test() {

// Create service event
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -315,9 +314,8 @@ async fn test_round_robin_equal_distribution_scheduling() {
for _ in 0..*upcoming_service_events {
// Create service event
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -380,9 +378,8 @@ async fn test_round_robin_equal_distribution_scheduling() {
.find(|(h, _)| h.id == booking_intend.selected_hosts[0].id)
.expect("To find selected host");
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -514,9 +511,8 @@ async fn test_round_robin_availability_scheduling() {
{
// Create service event
let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down Expand Up @@ -598,9 +594,8 @@ async fn test_round_robin_availability_scheduling() {
.expect("To find selected host");

let service_event = CreateEventInput {
parent_id: None,
external_parent_id: None,
external_id: None,
group_id: None,
title: None,
description: None,
event_type: None,
Expand Down
14 changes: 5 additions & 9 deletions clients/javascript/lib/eventClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NitteiBaseClient } from './baseClient'
import type {
GetEventsByExternalIdAPIResponse,
GetEventsByExternalIdQueryParams,
SearchEventsAPIResponse,
SearchEventsRequestBody,
} from './gen_types'
Expand Down Expand Up @@ -78,19 +77,16 @@ export class NitteiEventClient extends NitteiBaseClient {

/**
* Get events by external id
* This returns an array of events
* It can be empty if no events are found
* @param externalId - external id of the event
* @param queryParams - query params (optional) - allow to specify that the events from groups should be included
*
* This returns an array of events (it can match zero, one or more events)
* @param externalId - external id of the event(s) to search
* @returns - the events found
*/
public async getByExternalId(
externalId: string,
queryParams?: GetEventsByExternalIdQueryParams
externalId: string
): Promise<GetEventsByExternalIdAPIResponse> {
const res = await this.get<GetEventsByExternalIdAPIResponse>(
`/user/events/external_id/${externalId}`,
queryParams
`/user/events/external_id/${externalId}`
)

return {
Expand Down
84 changes: 0 additions & 84 deletions clients/javascript/lib/eventGroupClient.ts

This file was deleted.

13 changes: 8 additions & 5 deletions clients/javascript/lib/gen_types/CalendarEventDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ export type CalendarEventDTO = {
status: CalendarEventStatus
/**
* Optional parent event ID
* This is useful for external applications that need to link Nittei's events to a wider data model (e.g. a project, an order, etc.)
* Example: If the event is a meeting, the parent ID could be the project ID (ObjectId, UUID or any other string)
*/
parentId: string | null
externalParentId: string | null
/**
* Optional external ID
* This is useful for external applications that need to link Nittei's events to their own data models
* Example: If the event is a meeting, the external ID could be the meeting ID in the external system
*
* Note that nothing prevents multiple events from having the same external ID
* This can also be a way to link events together
*/
externalId: string | null
/**
Expand Down Expand Up @@ -98,10 +105,6 @@ export type CalendarEventDTO = {
* UUID of the user
*/
userId: ID
/**
* Optional group ID
*/
groupId: ID | null
/**
* List of reminders
*/
Expand Down
Loading

0 comments on commit aa48405

Please sign in to comment.