diff --git a/shareable/types/documents/employee_schedule.ts b/shareable/types/documents/employee_schedule.ts index 6ce8c4246..5bbf7ba02 100644 --- a/shareable/types/documents/employee_schedule.ts +++ b/shareable/types/documents/employee_schedule.ts @@ -1,16 +1,21 @@ import type { Day } from "$/types/database" import type { Serializable } from "$/types/general" -import type { UserIdentifierDocument } from "$/types/documents/user" +import type { UserIdentifierDocument, DeserializedUserDocument } from "$/types/documents/user" import type { Completeness, Format, Resource, - Relationships, Attributes, ResourceIdentifier, DeserializedResource, + DeriveRelationships, + DeriveRelationshipNames, + GeneralRelationshipData, + DeriveDeserializedRelationships, + PartialOrPickDeserializedRelationship, + ResourceDocument, ResourceListDocument, DeserializedResourceDocument, @@ -31,7 +36,22 @@ export interface EmployeeScheduleAttributes ext dayName: Day } -export type EmployeeScheduleRelationships = Relationships<{ "user": UserIdentifierDocument }> +interface EmployeeScheduleRelationshipData +extends GeneralRelationshipData { + user: { + serialized: UserIdentifierDocument, + deserialized: DeserializedUserDocument + } +} + +export type EmployeeScheduleRelationshipNames += DeriveRelationshipNames + +export type EmployeeScheduleRelationships += DeriveRelationships> + +export type DeserializedEmployeeScheduleRelationships += DeriveDeserializedRelationships> export type EmployeeScheduleResource = Resource< T, @@ -41,9 +61,17 @@ export type EmployeeScheduleResource = Resour T extends "create" ? EmployeeScheduleRelationships : Serializable ) -export type DeserializedEmployeeScheduleResource = DeserializedResource< +export type DeserializedEmployeeScheduleResource< + T extends EmployeeScheduleRelationshipNames|undefined = undefined +> = DeserializedResource< EmployeeScheduleResourceIdentifier<"read">, EmployeeScheduleAttributes<"deserialized"> +> & PartialOrPickDeserializedRelationship< + EmployeeScheduleRelationshipData<"read">, + DeserializedEmployeeScheduleRelationships<"read">, + EmployeeScheduleRelationshipNames, + T extends EmployeeScheduleRelationshipNames ? true : false, + T extends EmployeeScheduleRelationshipNames ? T : EmployeeScheduleRelationshipNames > export type EmployeeScheduleDocument = ResourceDocument< @@ -60,16 +88,20 @@ export type EmployeeScheduleListDocument = Reso EmployeeScheduleResource > -export type DeserializedEmployeeScheduleDocument = DeserializedResourceDocument< +export type DeserializedEmployeeScheduleDocument< + T extends EmployeeScheduleRelationshipNames|undefined = undefined +> = DeserializedResourceDocument< EmployeeScheduleResourceIdentifier<"read">, EmployeeScheduleAttributes<"deserialized">, - DeserializedEmployeeScheduleResource + DeserializedEmployeeScheduleResource > -export type DeserializedEmployeeScheduleListDocument = DeserializedResourceListDocument< +export type DeserializedEmployeeScheduleListDocument< + T extends EmployeeScheduleRelationshipNames|undefined = undefined +> = DeserializedResourceListDocument< EmployeeScheduleResourceIdentifier<"read">, EmployeeScheduleAttributes<"deserialized">, - DeserializedEmployeeScheduleResource + DeserializedEmployeeScheduleResource > export type EmployeeScheduleIdentifierDocument