From 784aa497187e4d79dbac936d5771bfa16684d436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Thu, 20 Apr 2023 17:55:08 +0200 Subject: [PATCH] fix: fix BaseObject types --- src/index.ts | 4 ++-- src/models/App/User.ts | 4 ++-- src/models/Assiduite/AbsenceFile.ts | 2 +- src/models/Evaluation/Evaluation.ts | 15 +++++++++++---- src/models/Evaluation/EvaluationDetail.ts | 10 +++++----- src/models/Evaluation/EvaluationSettings.ts | 4 ++-- src/models/Evaluation/PeriodicReportsFile.ts | 4 ++-- src/models/Messagerie/Communication.ts | 5 +++-- src/models/Messagerie/Participation.ts | 18 ++++++++++++++---- src/models/Messagerie/UsersMailSettings.ts | 13 ++++++++----- src/models/School/SchoolInfo.ts | 5 +++-- 11 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6881469..ca5725d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,8 +21,6 @@ import { PeriodicReportsFile } from './models/Evaluation/PeriodicReportsFile' import { AbsenceFile, AbsenceFileIncluded } from './models/Assiduite/AbsenceFile' import { AbsenceReason } from './models/Assiduite/AbsenceReasons' -export { TokenSet } from 'openid-client' - const BASE_URL = 'https://api.skolengo.com/api/v1/bff-sko-app' const OID_CLIENT_ID = Buffer.from('U2tvQXBwLlByb2QuMGQzNDkyMTctOWE0ZS00MWVjLTlhZjktZGY5ZTY5ZTA5NDk0', 'base64').toString('ascii') // base64 du client ID de l'app mobile const OID_CLIENT_SECRET = Buffer.from('N2NiNGQ5YTgtMjU4MC00MDQxLTlhZTgtZDU4MDM4NjkxODNm', 'base64').toString('ascii') // base64 du client Secret de l'app mobile @@ -791,3 +789,5 @@ export class Skolengo { } } } + +export { TokenSet } diff --git a/src/models/App/User.ts b/src/models/App/User.ts index 500f896..ae86121 100644 --- a/src/models/App/User.ts +++ b/src/models/App/User.ts @@ -18,7 +18,7 @@ export type UserAttributes = { permissions: ( UserPermission<'EVAL', 'READ_EVALUATIONS'> | UserPermission<'CDT', 'READ_LESSONS'> | - UserPermission<'TAF', 'READ_HOMEWORK_ASSIGNMENTS'> | + UserPermission<'TAF', 'READ_HOMEWORK_ASSIGNMENTS' | 'MARK_HOMEWORK_ASSIGNMENT_AS_DONE'> | UserPermission<'ABS', 'READ_ABSENCE_FILES' | 'READ_ABSENCE_FILES_DETAILS' | 'COMPLETE_ABSENCE_FILES'> | UserPermission<'MSG', 'READ_MESSAGES' | 'WRITE_MESSAGES'> | UserPermission )[]; @@ -42,7 +42,7 @@ export type User = BaseResponse[]; }; subject: { data: BaseObject<'subject'> @@ -38,17 +38,24 @@ export type EvaluationIncludedAttributes = SimpleUser | { } | { label: string; color: null | string; +} | { + shortLabel: string +} | { + level: string } export type EvaluationIncludedRelationships = { subSkills?: { - data: BaseObject[]; + data: BaseObject<'subSkill'>[]; }; evaluationResult?: { - data: BaseObject + data: BaseObject<'evaluationResult'> }; subSkillsEvaluationResults?: { - data: BaseObject[]; + data: BaseObject<'subSkillEvaluationResult'>[]; + }, + subSkill?: { + data: BaseObject<'subSkill'> } } diff --git a/src/models/Evaluation/EvaluationDetail.ts b/src/models/Evaluation/EvaluationDetail.ts index 1197bc1..1d7b545 100644 --- a/src/models/Evaluation/EvaluationDetail.ts +++ b/src/models/Evaluation/EvaluationDetail.ts @@ -14,16 +14,16 @@ export type EvaluationDetailAttributes = { export type EvaluationDetailRelationships = { subSkills: { - data: BaseObject[] | null; + data: BaseObject<'subSkill'>[] | null; }; subSubject: { - data: BaseObject[] | null; + data: BaseObject<'subSubject'> | null; }; evaluationService: { - data: BaseObject + data: BaseObject<'evaluationService'> }; evaluationResult: { - data: BaseObject + data: BaseObject<'evaluationResult'> }; } @@ -45,7 +45,7 @@ export type EvaluationDetailIncludedAttributes = SimpleUser | { export type EvaluationDetailIncludedRelationships = { subSkillsEvaluationResults?: { - data: BaseObject[] | null; + data: BaseObject<'subSkillEvaluationResult'>[] | null; }; subject?: { data: BaseObject<'subject'> diff --git a/src/models/Evaluation/EvaluationSettings.ts b/src/models/Evaluation/EvaluationSettings.ts index 9e3ebf4..675a7d5 100644 --- a/src/models/Evaluation/EvaluationSettings.ts +++ b/src/models/Evaluation/EvaluationSettings.ts @@ -17,7 +17,7 @@ export type EvaluationSettingsIncludedAttributes = { export type EvaluationSettingsIncludedRelationships = { skillAcquisitionColors: { - data: BaseObject + data: BaseObject<'skillAcquisitionColors'> }; } @@ -34,7 +34,7 @@ export type EvaluationSettingsRelationships = { data: BaseObject<'period'>[]; }; skillsSetting: { - data: BaseObject + data: BaseObject<'skillsSetting'> }; } diff --git a/src/models/Evaluation/PeriodicReportsFile.ts b/src/models/Evaluation/PeriodicReportsFile.ts index fad968d..2fd2695 100644 --- a/src/models/Evaluation/PeriodicReportsFile.ts +++ b/src/models/Evaluation/PeriodicReportsFile.ts @@ -1,4 +1,4 @@ -import { BaseResponse } from '../Globals' +import { BaseObject, BaseResponse } from '../Globals' export type PeriodicReportsFileAttributes = { name: string @@ -11,7 +11,7 @@ export type PeriodicReportsFileAttributes = { export type PeriodicReportsFileRelationships = { period: { - data :any + data : BaseObject<'period'> | null } } diff --git a/src/models/Messagerie/Communication.ts b/src/models/Messagerie/Communication.ts index df68716..ab846c3 100644 --- a/src/models/Messagerie/Communication.ts +++ b/src/models/Messagerie/Communication.ts @@ -1,5 +1,6 @@ import { SimpleUser } from '../App/User' import { BaseResponse, BaseObject } from '../Globals' +import { PersonType } from './UsersMailSettings' export type CommunicationAttributes = { subject: string; @@ -37,10 +38,10 @@ export type CommunicationIncluded = BaseResponse | null; }; person?: { - data: BaseObject | null; + data: BaseObject | null; }; }> diff --git a/src/models/Messagerie/Participation.ts b/src/models/Messagerie/Participation.ts index 54895dc..24f67cf 100644 --- a/src/models/Messagerie/Participation.ts +++ b/src/models/Messagerie/Participation.ts @@ -1,4 +1,6 @@ +import { SimpleUser } from '../App/User' import { BaseResponse, BaseObject } from '../Globals' +import { PersonType } from './UsersMailSettings' export type Participation = BaseResponse<{ dateTime: string; @@ -13,18 +15,26 @@ export type Participation = BaseResponse<{ }; }, 'participation'> -export type ParticipationIncluded = BaseResponse<{ +export type ParticipationIncludedAttributes = { category: string; additionalInfo: any|null; fromGroup: boolean; } | { label: string; logoUrl: any|null; -}, { +} | SimpleUser + +export type ParticipationIncludedRelationships = { technicalUser: { data: BaseObject[] | BaseObject | null; }; person: { - data: BaseObject[] | BaseObject | null; + data: BaseObject[] | BaseObject | null; }; -}> +} | { + school: { + data: any + } +} + +export type ParticipationIncluded = BaseResponse diff --git a/src/models/Messagerie/UsersMailSettings.ts b/src/models/Messagerie/UsersMailSettings.ts index 71fa1b5..190d60c 100644 --- a/src/models/Messagerie/UsersMailSettings.ts +++ b/src/models/Messagerie/UsersMailSettings.ts @@ -6,16 +6,18 @@ export type UsersMailSettings = BaseResponse<{ maxCharsInCommunicationSubject: number; }, { folders: { - data: BaseObject[] | BaseObject | null; + data: BaseObject<'folder'>[]; }; signature: { data: BaseObject<'signature'> }; contacts: { - data: BaseObject[] | BaseObject | null; + data: BaseObject<'personContact' | 'groupContact'>[]; }; }, 'userMailSetting'> +export type PersonType = 'person' | 'student' | 'personInContactWithStudent' | 'nonTeachingStaff' | 'teacher' + export type UsersMailSettingsIncluded = BaseResponse<{ content?: string; } | { @@ -27,18 +29,19 @@ export type UsersMailSettingsIncluded = BaseResponse<{ linksWithUser: { description: null | string; additionalInfo: string[]; - type: string; + type: ('SCHOOL' | 'FAMILY' | 'GROUP' | string); studentId?: string; schoolId?: string; + groupId?: string }[] | null; } | SimpleUser, { parent?: { data: BaseObject[] | BaseObject | null; }; personContacts?: { - data: BaseObject[] | BaseObject | null; + data: BaseObject<'personContact'>[] | BaseObject<'personContact'> | null; }; person?: { - data: BaseObject[] | BaseObject | null; + data: BaseObject[] | BaseObject | null; }; }> diff --git a/src/models/School/SchoolInfo.ts b/src/models/School/SchoolInfo.ts index 07fee72..f2a4060 100644 --- a/src/models/School/SchoolInfo.ts +++ b/src/models/School/SchoolInfo.ts @@ -1,6 +1,7 @@ import { PublicAttachment } from './Attachment' import { BaseResponse, BaseObject } from '../Globals' import { SimpleUser } from '../App/User' +import { PersonType } from '../Messagerie/UsersMailSettings' export type SchoolInfoAttributes = { publicationDateTime: string; @@ -50,10 +51,10 @@ type SchoolInfoSchool = { export type SchoolInfoIncludedAttributes = SimpleUser | PublicAttachment | SchoolInfoSchool | SchoolInfoAuthor export type SchoolInfoIncludedRelationships = { technicalUser: { - data: BaseObject | null; + data: BaseObject<'technicalUser'> | null; }; person: { - data: BaseObject | null; + data: BaseObject | null; }; }