pawnote
Version:
A purrfect API wrapper for PRONOTE.
1,729 lines (1,570 loc) • 52.9 kB
TypeScript
import { Fetcher, FormDataFile } from '@literate.ink/utilities';
declare const cleanURL: (url: string) => string;
declare class BadCredentialsError extends Error {
constructor();
}
declare class AuthenticateError extends Error {
constructor(message: string);
}
declare class AccessDeniedError extends Error {
constructor();
}
declare class AccountDisabledError extends Error {
constructor();
}
declare class DiscussionActionError extends Error {
constructor();
}
declare class DiscussionMessagesMissingError extends Error {
constructor();
}
declare const DoubleAuthMode: {
readonly MGDA_PasEncoreChoisi: 0;
readonly MGDA_Inactive: 1;
readonly MGDA_NotificationSeulement: 2;
readonly MGDA_SaisieCodePIN: 3;
};
type DoubleAuthMode = typeof DoubleAuthMode[keyof typeof DoubleAuthMode];
type PasswordRules = Readonly<{
maxLength: number;
minLength: number;
rules: number[];
}>;
type SecurityModal = Readonly<{
availableSecurityModes: DoubleAuthMode[];
defaultSecurityMode: DoubleAuthMode;
passwordRules: PasswordRules;
shouldCustomPassword: boolean;
shouldCustomDoubleAuth: boolean;
shouldEnterPIN: boolean;
shouldEnterSource: boolean;
/**
* Should be internal use only.
*/
context: {
authentication: any;
identity: any;
initialUsername?: string;
};
}>;
declare class SecurityError extends Error {
handle: SecurityModal;
constructor(authentication: any, identity: any, initialUsername?: string);
}
declare class SecuritySourceTooLongError extends Error {
constructor(limit: number);
}
declare class SuspendedIPError extends Error {
constructor();
}
declare class SessionExpiredError extends Error {
constructor();
}
declare class PageUnavailableError extends Error {
constructor();
}
declare class BusyPageError extends Error {
constructor();
}
declare class RateLimitedError extends Error {
constructor();
}
declare class ServerSideError extends Error {
constructor(message?: string);
}
declare class UnreachableError extends Error {
constructor(fn: string);
}
declare class UploadSizeError extends Error {
constructor(maxSizeInBytes: number);
}
declare class UploadFailedError extends Error {
constructor();
}
declare const AccountKind: {
readonly STUDENT: 6;
readonly PARENT: 7;
readonly TEACHER: 8;
};
type AccountKind = typeof AccountKind[keyof typeof AccountKind];
type Account = Readonly<{
address: string[];
postalCode: string;
province: string;
country: string;
city: string;
email: string;
/** @format `+[country-code][phone-number]` */
phone: string;
INE: string;
/**
* Only available on instances with PRONOTE version 2024 or higher.
*
* iCal feature also requires to be enabled on the instance.
*/
iCalToken?: string;
}>;
declare const AssignmentDifficulty: {
readonly None: 0;
readonly Easy: 1;
readonly Medium: 2;
readonly Hard: 3;
};
type AssignmentDifficulty = typeof AssignmentDifficulty[keyof typeof AssignmentDifficulty];
declare const AssignmentReturnKind: {
readonly None: 0;
readonly Paper: 1;
readonly FileUpload: 2;
readonly Kiosk: 3;
/** Only available since version 2024. */
readonly AudioRecording: 4;
};
type AssignmentReturnKind = typeof AssignmentReturnKind[keyof typeof AssignmentReturnKind];
declare const AttachmentKind: {
readonly Link: 0;
readonly File: 1;
};
type AttachmentKind = typeof AttachmentKind[keyof typeof AttachmentKind];
type Attachment = Readonly<{
kind: AttachmentKind;
name: string;
url: string;
id: string;
}>;
type AssignmentReturn = {
readonly kind: AssignmentReturnKind;
/**
* File that the user uploaded.
*/
uploaded?: Attachment;
/**
* Whether the user can upload a file or not.
*/
canUpload: boolean;
};
type Subject = Readonly<{
id: string;
name: string;
/**
* Whether the subject is only within groups.
*/
inGroups: boolean;
}>;
type AssignmentTheme = Readonly<{
id: string;
name: string;
subject: Subject;
}>;
type Assignment = Readonly<{
id: string;
subject: Subject;
description: string;
backgroundColor: string;
done: boolean;
deadline: Date;
attachments: Array<Attachment>;
difficulty: AssignmentDifficulty;
/** Time that should take, in minutes, to do the homework. */
length?: number;
/** Themes associated with this homework. */
themes: AssignmentTheme[];
return: AssignmentReturn;
/**
* If defined, can be used to retrieve
* the lesson contents from the resources tab.
*/
resourceID?: string;
}>;
type AuthenticationQR = Readonly<{
url: string;
token: string;
username: string;
kind: AccountKind;
}>;
declare const DiscussionCommand: {
readonly lu: "lu";
readonly nonLu: "nonLu";
readonly archiver: "archiver";
readonly desarchiver: "desarchiver";
readonly transferer: "transferer";
readonly signaler: "signaler";
readonly modifierCategories: "modifierCategories";
readonly fermerDiscussion: "fermerDiscussion";
readonly ouvrirDiscussion: "ouvrirDiscussion";
readonly signalerSuppression: "signalerSuppression";
readonly Trash: "corbeille";
readonly Restore: "restauration";
readonly Delete: "suppression";
readonly brouillon: "brouillon";
readonly plus: "plus";
readonly purger: "purger";
readonly discussionEnFenetre: "discussionEnFenetre";
readonly entrerSortirDiscussion: "entrerSortirDiscussion";
readonly modificationObjetDiscussion: "modificationObjetDiscussion";
readonly afficherDestinataires: "afficherDestinataires";
readonly copierContenuVisu: "copierContenuVisu";
readonly repondreMessage: "repondreMessage";
readonly afficherDiscussion: "afficherDiscussion";
};
type DiscussionCommand = typeof DiscussionCommand[keyof typeof DiscussionCommand];
type DiscussionDraftMessage = Readonly<{
isHTML: boolean;
possessionID: string;
replyMessageID: string;
}> & {
content: string;
};
declare const DiscussionFolderKind: {
readonly OCEM_Utilisateur: 0;
readonly OCEM_Pre_Reception: 1;
readonly OCEM_Pre_Archive: 2;
readonly OCEM_Pre_Envoye: 3;
readonly OCEM_Pre_Brouillon: 4;
readonly OCEM_Pre_Poubelle: 5;
readonly OCEM_Pre_Signalement: 6;
readonly OCEM_Expl_Bleu: 7;
readonly OCEM_Expl_Vert: 8;
readonly OCEM_Expl_Rouge: 9;
readonly OCEM_Pre_CarnetLiaison: 10;
readonly OCEM_Pre_Alerte: 11;
readonly OCEM_Pre_ContactVS: 12;
readonly OCEM_Pre_Conversation: 13;
readonly OCEM_Pre_InvisiblePlageDesactivee: 14;
};
type DiscussionFolderKind = typeof DiscussionFolderKind[keyof typeof DiscussionFolderKind];
type DiscussionFolder = Readonly<{
id: string;
name: string;
kind: DiscussionFolderKind;
}>;
declare const EntityKind: {
readonly Aucune: 0;
readonly Classe: 1;
readonly Group: 2;
readonly Teacher: 3;
readonly Student: 4;
readonly Responsable: 5;
readonly Niveau: 6;
readonly Orientation: 7;
readonly Specialite: 8;
readonly OptionSpecialite: 9;
readonly Etablissement: 10;
readonly Period: 11;
readonly Service: 12;
readonly Absence: 13;
readonly Delay: 14;
readonly Exclusion: 15;
readonly Subject: 16;
readonly Room: 17;
readonly CoEnseignant: 18;
readonly Suivis: 19;
readonly Cours: 20;
readonly Infirmerie: 21;
readonly AbsenceRepas: 22;
readonly Pilier: 23;
readonly ElementPilier: 24;
readonly Competence: 25;
readonly _DisciplineBrevet: 26;
readonly Palier: 27;
readonly SousItem: 28;
readonly Evaluation: 29;
readonly Stage: 30;
readonly SousMatiere: 31;
readonly MaitreDeStage: 32;
readonly InspecteurPedagogique: 33;
readonly Personal: 34;
readonly EvaluationHistorique: 35;
readonly DossierProgression: 36;
readonly ContenuDeCours: 37;
readonly TravailAFaire: 38;
readonly Progression: 39;
readonly Dispense: 40;
readonly Punishment: 41;
readonly Sanction: 42;
readonly Communication: 43;
readonly AbsenceInternat: 44;
readonly Observation: 45;
readonly ObservationProfesseurEleve: 46;
readonly ConvocationVS: 47;
readonly DocumentJoint: 48;
readonly InternetCategorie: 49;
readonly DocJointEtablissement: 50;
readonly Option: 51;
readonly ProgrammationPunition: 52;
readonly ReportPunition: 53;
readonly DisciplineLivretScolaire: 54;
readonly QCM: 55;
readonly ExecutionQCM: 56;
readonly QCMEditeur: 57;
readonly PartieDeClasse: 58;
readonly DocJointEleve: 59;
readonly Devoir: 60;
readonly InternetEnumere: 61;
readonly AppreciationBulletinCompetence: 62;
readonly Entreprise: 63;
readonly DomaineProfessionnel: 64;
readonly OffreDeStage: 65;
readonly SujetDeStage: 66;
readonly DocumentCasier: 67;
readonly Message: 68;
readonly PossessionMessage: 69;
readonly RelationMessageDocJointEtablissement: 70;
readonly Engagement: 71;
readonly PrecautionaryMeasure: 72;
readonly SousCategorieObjetDossier: 73;
readonly Incident: 74;
readonly ProtagonisteIncident: 75;
readonly RelationIncidentFichierExterne: 76;
readonly RegimeEleve: 77;
readonly RepasAPreparer: 78;
readonly SessionDeStage: 79;
readonly Materiel: 80;
readonly Bourse: 81;
readonly RelationTravailAFaireEleve: 82;
readonly LieuDossier: 83;
readonly ElementProgramme: 84;
readonly ChapitreEltPgm: 85;
readonly EltPgmTravailleCDT: 86;
readonly Appreciation: 87;
readonly ExecutionDevoirKiosque: 88;
readonly PanierRessourceKiosque: 89;
readonly RessourceNumeriqueKiosque: 90;
readonly MetaMatiere: 91;
readonly EvaluationSujet: 92;
readonly EvaluationCorrige: 93;
readonly LibelleCours: 94;
readonly Site: 95;
readonly QuestionQCM: 96;
readonly RelationElevePilierDeCompetence: 97;
readonly QuestionCopieQCM: 98;
readonly Coordonnees: 99;
readonly ResponsablePostulant: 100;
readonly ExecutionQCMEleve: 101;
readonly DocJointInscription: 102;
readonly CategorieDossier: 103;
readonly MEFGEP: 104;
readonly AutreOrientation: 105;
readonly Commission: 106;
readonly ReponseEducative: 107;
readonly SuiviReponseEducative: 108;
readonly NatureDocumentEleve: 109;
};
type EntityKind = typeof EntityKind[keyof typeof EntityKind];
type DiscussionMessageRecipient = Readonly<{
name: string;
kind: EntityKind;
}>;
type DiscussionMessage = Readonly<{
id: string;
content: string;
creationDate: Date;
/**
* When undefined, the author is the user itself.
*/
author?: DiscussionMessageRecipient;
/**
* When undefined, the receiver is the user itself.
*/
receiver?: DiscussionMessageRecipient;
partialVisibility: boolean;
amountOfRecipients: number;
files: Attachment[];
}>;
declare const DiscussionSendAction: {
readonly Send: 0;
readonly SendEveryone: 1;
readonly SendEveryoneExceptParentsAndStudents: 3;
readonly ReplyEveryone: 2;
readonly ReplyEveryoneExceptParentsAndStudents: 4;
readonly Close: 5;
};
type DiscussionSendAction = typeof DiscussionSendAction[keyof typeof DiscussionSendAction];
type DiscussionSentMessage = DiscussionMessage & Readonly<{
replyMessageID: string;
replyingTo?: DiscussionMessage;
transferredMessages: DiscussionMessage[];
}>;
type DiscussionMessages = Readonly<{
defaultReplyMessageID: string;
sents: Array<DiscussionSentMessage>;
drafts: Array<DiscussionDraftMessage>;
/**
* Can't create message in the discussion if
* this is not defined.
*/
sendAction?: DiscussionSendAction;
/**
* Whether the button "include students and parents"
* appears on the UI or not.
*/
canIncludeStudentsAndParents: boolean;
}>;
type DiscussionRecipient = Readonly<{
id: string;
name: string;
kind: typeof EntityKind.Teacher | typeof EntityKind.Student | typeof EntityKind.Personal;
disallowMessages: boolean;
}>;
type _DiscussionsCache = {
[key: string]: any;
_: Discussion[];
};
type Discussion = Readonly<{
creator?: string;
recipientName?: string;
/**
* Output is very variable, see example below.
* Because of this behavior, we can't transform this into a date.
*
* Maybe, we could parse this manually, but it's not a priority.
*
* @example
* "lundi 08h53"
* // or can just be the hour
* "07h26"
*/
dateAsFrenchText: string;
/**
* Internal string containing the ID of the message
* needed to fetch the participants of the discussion.
*/
participantsMessageID: string;
/**
* Property used internally to manage messages in
* this discussion in requests.
*
* You can ignore this property.
*/
possessions: any;
/**
* Title of the discussion.
*/
subject: string;
numberOfDrafts: number;
numberOfMessages: number;
numberOfMessagesUnread: number;
folders: DiscussionFolder[];
closed: boolean;
/**
* Internal use only,
* please never use this manually as it
* could break internal references.
*/
cache: _DiscussionsCache;
}> & {
/**
* Only available after requesting them.
* The handle will automatically add them here.
*/
messages?: DiscussionMessages;
};
type Discussions = Readonly<{
folders: Array<DiscussionFolder>;
items: Array<Discussion>;
}>;
declare const DishKind: {
readonly Entry: 0;
readonly Main: 1;
readonly Side: 2;
readonly Drink: 3;
readonly Dessert: 4;
readonly Fromage: 5;
};
type DishKind = typeof DishKind[keyof typeof DishKind];
declare const DocumentFileFormat: {
readonly UNKNOWN: 0;
readonly TEXT: 1;
readonly PDF: 2;
readonly EXCEL: 3;
readonly ARCHIVE: 4;
readonly IMAGE: 5;
readonly SOUND: 6;
readonly VIDEO: 7;
readonly DIAPORAMA: 8;
readonly GEOGEBRA: 9;
};
type DocumentFileFormat = typeof DocumentFileFormat[keyof typeof DocumentFileFormat];
declare const DocumentKind: {
readonly URL: 0;
readonly FILE: 1;
readonly CLOUD: 2;
readonly KIOSK_LINK: 3;
readonly CONFERENCE_LINK: 4;
};
type DocumentKind = typeof DocumentKind[keyof typeof DocumentKind];
declare const DoubleAuthClientAction: {
readonly AIHMSC_PersonnalisationMotDePasse: 0;
readonly AIHMSC_ChoixStrategie: 1;
readonly AIHMSC_ChoixCodePINetSource: 2;
readonly AIHMSC_SaisieCodePINetSource: 3;
readonly AIHMSC_ReinitCodePINetSource: 4;
readonly AIHMSC_SaisieSourcePourNotifSeulement: 5;
};
type DoubleAuthClientAction = typeof DoubleAuthClientAction[keyof typeof DoubleAuthClientAction];
declare const DoubleAuthServerAction: {
readonly csch_VerifierPIN: 0;
readonly csch_VerifierMotDePassePersonnalise: 1;
readonly csch_LibellesSourceConnexionDejaConnus: 2;
readonly csch_EnregistrerChoixUtilisateur: 3;
readonly csch_AffecterModeDoubleAuthentification: 4;
readonly csch_AffecterCodePIN: 5;
readonly csch_RenommerSourceConnexionConnue: 6;
readonly csch_SupprimerSourceConnexionConnue: 7;
readonly csch_AffecterMotDePassePersonnalise: 8;
readonly csch_ModifierLogin: 9;
readonly csch_DemandeReinitialisationPIN: 10;
readonly csch_VerifierCodeReinitialisationPIN: 11;
};
type DoubleAuthServerAction = typeof DoubleAuthServerAction[keyof typeof DoubleAuthServerAction];
declare const EntityState: {
readonly NONE: 0;
readonly CREATION: 1;
readonly MODIFICATION: 2;
readonly DELETION: 3;
readonly CHILDREN_MODIFICATION: 4;
};
type EntityState = typeof EntityState[keyof typeof EntityState];
type Skill = Readonly<{
id: string;
/**
* Order the skill should be shown.
* For example, if this value is `2`, then it should be shown
* as the second skill on the evaluation skills table.
*/
order: number;
/** @example "Très bonne maîtrise" */
level: string;
/** @example "A+" */
abbreviation: string;
/** Apparently there's a coefficient on skills... not sure how it's calculated though. */
coefficient: number;
/**
* ID of the domain tree containing that skill.
*/
domainID: string;
/**
* ID of the domain tree containing that skill.
* @example "Écouter et comprendre"
*/
domainName: string;
/**
* ID of the skill's item.
*/
itemID?: string;
/**
* Name of the skill's item.
* @example "Se familiariser aux réalités sonores de la langue, et s’entraîner à la mémorisation."
*/
itemName?: string;
/**
* Skill's pillar.
* This is linked to the student's level.
*/
pillarID: string;
/**
* @example "LANGUES VIVANTES (ÉTRANGÈRES OU RÉGIONALES)"
*/
pillarName: string;
/**
* @example ["D1.2", "D2"]
*/
pillarPrefixes: Array<string>;
}>;
type Evaluation = Readonly<{
name: string;
id: string;
teacher: string;
coefficient: number;
description: string;
subject: Subject;
/** @example ["Cycle 4"] */
levels: Array<string>;
skills: Array<Skill>;
date: Date;
}>;
type FoodAllergen = Readonly<{
name: string;
/**
* As a hexadecimal color.
* @example "#FF3838"
*/
color: string;
}>;
type FoodLabel = Readonly<{
name: string;
/**
* As a hexadecimal color.
* @example "#FF3838"
*/
color: string;
}>;
type Food = Readonly<{
name: string;
allergens: ReadonlyArray<FoodAllergen>;
labels: ReadonlyArray<FoodLabel>;
}>;
type GeolocatedInstance = Readonly<{
url: string;
name: string;
latitude: number;
longitude: number;
postalCode: number;
distance: number;
}>;
declare const GradeKind: {
readonly Error: -1;
readonly Grade: 0;
readonly Absent: 1;
readonly Exempted: 2;
readonly NotGraded: 3;
readonly Unfit: 4;
readonly Unreturned: 5;
readonly AbsentZero: 6;
readonly UnreturnedZero: 7;
readonly Congratulations: 8;
};
type GradeKind = typeof GradeKind[keyof typeof GradeKind];
type GradeValue = Readonly<{
kind: GradeKind;
points: number;
}>;
type Grade = Readonly<{
/** the id of the grade (used internally) */
id: string;
/** the actual grade */
value: GradeValue;
/** the maximum amount of points */
outOf: GradeValue;
/** the default maximum amount of points */
defaultOutOf?: GradeValue;
/** the date on which the grade was given */
date: Date;
/** the subject in which the grade was given */
subject: Subject;
/** the average of the class */
average?: GradeValue;
/** the highest grade */
max?: GradeValue;
/** the lowest grade */
min?: GradeValue;
/** the coefficient of the grade */
coefficient: number;
/** comment on the grade description */
comment: string;
/** note on the grade */
commentaireSurNote?: string;
/** is the grade bonus : only points above 10 count */
isBonus: boolean;
/** is the grade optional : the grade only counts if it increases the average */
isOptional: boolean;
/** is the grade out of 20. Example 8/10 -> 16/20 */
isOutOf20: boolean;
/** the file of the subject */
subjectFile?: Attachment;
/** the file of the correction */
correctionFile?: Attachment;
}>;
type SubjectAverages = Readonly<{
/** students average in the subject */
student?: GradeValue;
/** classes average in the subject */
class_average?: GradeValue;
/** highest average in the class */
max?: GradeValue;
/** lowest average in the class */
min?: GradeValue;
/** maximum amount of points */
outOf?: GradeValue;
/** the default maximum amount of points */
defaultOutOf?: GradeValue;
/** subject the average is from */
subject: Subject;
/** background color of the subject */
backgroundColor: string;
}>;
type GradesOverview = Readonly<{
subjectsAverages: SubjectAverages[];
overallAverage?: GradeValue;
classAverage?: GradeValue;
grades: Grade[];
}>;
type Holiday = Readonly<{
id: string;
name: string;
startDate: Date;
endDate: Date;
}>;
type HomepageLink = Readonly<{
url: string;
name: string;
description: string;
}>;
type Partner = Readonly<{
/**
* Object to send to PRONOTE to login using SSO.
*/
sso: any;
}>;
type PartnerARDWallet = Readonly<{
name: string;
description: string;
warning: boolean;
balance: number;
balanceDescription: string;
}>;
type PartnerARD = Partner & Readonly<{
canRefreshData: boolean;
wallets: PartnerARDWallet[];
}>;
type Homepage = Readonly<{
partnerARD?: PartnerARD;
partnerTurboself?: Partner;
links: Array<HomepageLink>;
}>;
type Period = Readonly<{
id: string;
name: string;
kind: number;
startDate: Date;
endDate: Date;
}>;
type WeekFrequency = Readonly<{
label: string;
fortnight: number;
}>;
type InstanceParameters = Readonly<{
nextBusinessDay: Date;
firstMonday: Date;
firstDate: Date;
lastDate: Date;
/**
* Allows to recognize the device for next authentications.
*/
navigatorIdentifier: string;
version: number[];
endings: string[];
periods: Period[];
holidays: Holiday[];
weekFrequencies: Map<number, WeekFrequency>;
blocksPerDay: number;
}>;
type Instance = Readonly<{
version: number[];
name: string;
date: Date;
accounts: Array<{
name: string;
path: string;
}>;
casURL?: string;
casToken?: string;
}>;
declare const MealKind: {
readonly Lunch: 0;
readonly Dinner: 1;
};
type MealKind = typeof MealKind[keyof typeof MealKind];
type Meal = Readonly<{
name?: string;
entry?: ReadonlyArray<Food>;
main?: ReadonlyArray<Food>;
side?: ReadonlyArray<Food>;
drink?: ReadonlyArray<Food>;
fromage?: ReadonlyArray<Food>;
dessert?: ReadonlyArray<Food>;
}>;
type Menu = Readonly<{
date: Date;
lunch?: Meal;
dinner?: Meal;
}>;
type NewDiscussionRecipientFunction = Readonly<{
id: string;
name: string;
}>;
type NewDiscussionRecipientSubSubject = Readonly<{
id: string;
name: string;
from: string;
}>;
type NewDiscussionRecipientSubject = Readonly<{
id: string;
name: string;
sub: Array<NewDiscussionRecipientSubSubject>;
}>;
type NewDiscussionRecipient = Readonly<{
name: string;
kind: typeof EntityKind.Teacher | typeof EntityKind.Student | typeof EntityKind.Personal;
id: string;
isPrincipal: boolean;
subjects: Array<NewDiscussionRecipientSubject>;
function?: NewDiscussionRecipientFunction;
}>;
type NewsCategory = Readonly<{
id: string;
name: string;
/**
* Whether this category is the default selected in the UI.
*/
default: boolean;
}>;
type NewsItem = Readonly<{
id: string;
title?: string;
category: NewsCategory;
creationDate: Date;
startDate: Date;
endDate: Date;
/**
* Name of the author of the information / survey.
* @example "John D."
*/
author: string;
/**
* Low level data about the public information of the user that'll send answers.
* Used internally when sending answers to the server.
*
* Most of the time, you won't need this.
*/
public: any;
}> & {
/**
* Whether this news have been read or not.
*/
read: boolean;
};
type NewsQuestionChoice = Readonly<{
value: string;
position: number;
isTextInput: boolean;
}>;
declare const NewsQuestionKind: {
/** Text from an information news. */
readonly InformationText: 0;
/** Question where there's only text (only from an survey news). */
readonly SurveyText: 5;
readonly TextInput: 1;
readonly UniqueChoice: 2;
readonly MultipleChoice: 3;
};
type NewsQuestionKind = typeof NewsQuestionKind[keyof typeof NewsQuestionKind];
type NewsQuestion = Readonly<{
id: string;
position: number;
kind: NewsQuestionKind;
fullTitle: string;
title: string;
shouldRespectMaximumChoices: boolean;
maximumChoices: number;
maximumLength: number;
attachments: Array<Attachment>;
content: string;
answerID: string;
shouldAnswer: boolean;
choices: Array<NewsQuestionChoice>;
}> & {
selectedAnswers?: Array<number>;
textInputAnswer?: string;
answered: boolean;
answerDate?: Date;
};
type NewsInformation = NewsItem & Readonly<{
is: "information";
get attachments(): Array<Attachment>;
/**
* Whether this news have been acknowledged or not.
* @remark This is not the same as reading the news, see `read` property.
*/
get acknowledged(): boolean;
/**
* Date when the news have been acknowledged.
* Only available if `acknowledged` is `true`.
*/
get acknowledgedDate(): Date | undefined;
get needToAcknowledge(): boolean;
get content(): string;
/**
* Low level data about the "question" contained inside this information.
*
* Internally, `acknowledged`, `content`, `attachments`, ... are getters for this,
* we're just renaming the properties to make the naming better.
*
* @remark Most of the time, you won't need this, but it's here if you need it.
*/
question: NewsQuestion;
}>;
type NewsSurvey = NewsItem & Readonly<{
is: "survey";
/**
* List of the questions contained in this survey.
* You can answer them by reassigning the `answer` property.
*
* @example
* question.answer = "[1..2]";
*/
questions: NewsQuestion[];
/** Whether your reply is anonymous or not. */
isAnonymous: boolean;
}>;
declare const NewsView: {
readonly Reception: 0;
readonly Broadcast: 1;
readonly Draft: 2;
readonly Template: 3;
};
type NewsView = typeof NewsView[keyof typeof NewsView];
type News = Readonly<{
categories: NewsCategory[];
items: Array<NewsInformation | NewsSurvey>;
}>;
type NotebookAbsence = Readonly<{
id: string;
startDate: Date;
endDate: Date;
justified: boolean;
opened: boolean;
daysMissed: number;
hoursMissed: number;
minutesMissed: number;
shouldParentsJustify: boolean;
administrativelyFixed: boolean;
isReasonUnknown: boolean;
reason?: string;
}>;
type NotebookDelay = Readonly<{
id: string;
date: Date;
minutes: number;
justified: boolean;
justification?: string;
shouldParentsJustify: boolean;
administrativelyFixed: boolean;
isReasonUnknown: boolean;
reason?: string;
}>;
declare const NotebookObservationKind: {
/** @original `OVS_DefautCarnet` */
readonly LogBookIssue: 0;
/** @original `OVS_ObservationParent` */
readonly Observation: 1;
/** @original `OVS_Encouragement` */
readonly Encouragement: 2;
/** @original `OVS_Autres` */
readonly Other: 3;
};
type NotebookObservationKind = typeof NotebookObservationKind[keyof typeof NotebookObservationKind];
type NotebookObservation = Readonly<{
id: string;
date: Date;
opened: boolean;
shouldParentsJustify: boolean;
name: string;
kind: NotebookObservationKind;
/**
* ID of the observation section.
*
* Might be useful when you're looking for the same
* observation section when going through an `StudentObservation` array.
*/
sectionID: string;
subject?: Subject;
reason?: string;
}>;
type NotebookPrecautionaryMeasure = Readonly<{
id: string;
title: string;
comments: string;
reasons: string[];
exclusion: boolean;
circumstances: string;
circumstancesDocuments: Attachment[];
decisionMaker: string;
giver: string;
dateGiven: Date;
startDate: Date;
endDate: Date;
disallowedAccesses: number[];
}>;
type NotebookPunishment = Readonly<{
id: string;
title: string;
reasons: string[];
isDuringLesson: boolean;
exclusion: boolean;
workToDo: string;
workToDoDocuments: Array<Attachment>;
circumstances: string;
circumstancesDocuments: Array<Attachment>;
giver: string;
dateGiven: Date;
durationMinutes: number;
}>;
type Notebook = Readonly<{
absences: NotebookAbsence[];
delays: NotebookDelay[];
punishments: NotebookPunishment[];
observations: NotebookObservation[];
precautionaryMeasures: NotebookPrecautionaryMeasure[];
}>;
type RefreshInformation = Readonly<{
url: string;
/**
* Acts as a replacement for the password.
* Whenever you need to authenticate, you should use this token
* from now on if you want to avoid entering your password again.
*
* Note that this token is only valid for the `deviceUUID` you provided
* in the authentication options.
*/
token: string;
username: string;
kind: AccountKind;
navigatorIdentifier: string;
}>;
declare const ResourceContentCategory: {
readonly NONE: 0;
/** Corresponds to "Cours" */
readonly LESSON: 1;
/** Corresponds to "Correction" */
readonly CORRECTION: 2;
/** Corresponds to "Devoir sur table" */
readonly DST: 3;
/** Corresponds to "Interrogation orale" */
readonly ORAL_INTERROGATION: 4;
/** Corresponds to "Travaux dirigés" */
readonly TD: 5;
/** Corresponds to "Travaux pratiques" */
readonly TP: 6;
/** Corresponds to "Évaluation de compétences" */
readonly EVALUATION_COMPETENCES: 7;
/** Corresponds to "EPI" */
readonly EPI: 8;
/** Corresponds to "AP" */
readonly AP: 9;
/** Corresponds to "Visio" */
readonly VISIO: 12;
};
type ResourceContentCategory = typeof ResourceContentCategory[keyof typeof ResourceContentCategory];
type ResourceContent = Readonly<{
id: string;
/**
* @remark Optional because teachers can just write nothing here and only give a description.
*/
title?: string;
/**
* An HTML string to preserve all the formatting done in the UI.
* @remark Optional because teachers can just write the title with no description.
*/
description?: string;
category: ResourceContentCategory;
categoryText?: string;
files: Attachment[];
/** Themes associated with the lesson. */
themes: AssignmentTheme[];
/** `-1` when not defined. */
educativeValue: number;
}>;
type Resource = Readonly<{
id: string;
startDate: Date;
endDate: Date;
subject: Subject;
haveAssignment: boolean;
assignmentDeadline?: Date;
/** Color of the resource in HEX. */
backgroundColor: string;
contents: Array<ResourceContent>;
teachers: string[];
groups: string[];
}>;
declare const SessionAccessKind: {
readonly ACCOUNT: 0;
readonly ACCOUNT_CONNECTION: 1;
readonly DIRECT_CONNECTION: 2;
readonly TOKEN_ACCOUNT_CONNECTION: 3;
readonly TOKEN_DIRECT_CONNECTION: 4;
readonly COOKIE_CONNECTION: 5;
};
type SessionAccessKind = typeof SessionAccessKind[keyof typeof SessionAccessKind];
declare class Queue {
private queue;
private pendingPromise;
push<T extends unknown>(promise: () => Promise<T>): Promise<T>;
private dequeue;
}
interface SessionInformation {
readonly id: number;
readonly accountKind: AccountKind;
/** Whether the instance is demo or not. */
readonly demo: boolean;
readonly url: string;
/**
* How the session is accessed.
* @default SessionAccessKind.ACCOUNT
*/
readonly accessKind: SessionAccessKind;
readonly rsaModulus: string;
readonly rsaExponent: string;
/**
* Since PRONOTE 2023, RSA modulus and exponent are hardcoded.
* Before, we would need to pick them up in the session object.
*
* Eventually, this update also added a different behavior during
* login phase when using constants.
*
* That's why we have this property to know which values
* are there and what method we should use.
*/
readonly rsaFromConstants: boolean;
aesKey: string;
aesIV: string;
/**
* Whether we should skip request encryption or not.
*/
readonly skipEncryption: boolean;
/**
* Whether we should skip request compression or not.
*/
readonly skipCompression: boolean;
/**
* Only defined and `true` when the instance doesn't have an SSL certificate
* that is linked directly inside the PRONOTE.net server.
*
* On latest versions of PRONOTE, this adds an encryption layer
* on the request and responses.
*/
readonly http: boolean;
/**
* Whether polling should be used instead of presence.
*
* Pawnote doesn't take this into account
* and only sends presence requests.
*/
readonly poll: boolean;
/**
* Current order of requests in the queue.
*
* Every request made and response received increment this value by one.
* That means that an HTTP request should increment this by 2.
*
* Starts with `0`.
*/
order: number;
}
declare const TabLocation: {
readonly Grades: 198;
readonly Resources: 89;
readonly Assignments: 88;
readonly Timetable: 16;
readonly Evaluations: 201;
readonly Account: 49;
readonly Presence: 7;
readonly News: 8;
readonly Notebook: 19;
readonly Discussions: 131;
readonly Gradebook: 13;
readonly Menus: 10;
};
type TabLocation = typeof TabLocation[keyof typeof TabLocation];
type UserAuthorizations = Readonly<{
/**
* Whether the user is allowed to read discussions.
*/
canReadDiscussions: boolean;
/**
* Whether the user is allowed to create messages in discussions.
*/
canDiscuss: boolean;
/**
* Whether the user is allowed to discuss with staff.
*/
canDiscussWithStaff: boolean;
/**
* Whether the user is allowed to discuss with parents.
*/
canDiscussWithParents: boolean;
/**
* Whether the user is allowed to discuss with students.
*/
canDiscussWithStudents: boolean;
/**
* Whether the user is allowed to discuss with teachers.
*/
canDiscussWithTeachers: boolean;
/**
* Whether the user is allowed to send HTML through discussions.
* Otherwise the user should send plain text.
*/
hasAdvancedDiscussionEditor: boolean;
/**
* The maximum file size allowed for assignment uploads.
* @example 4194304 // for 4MB.
*/
maxAssignmentFileUploadSize: number;
/**
* Allowed tabs for the user.
*
* You should use this to know if a user have access
* to a tab before requesting the data for it.
*/
tabs: TabLocation[];
}>;
type Tab = Readonly<{
defaultPeriod?: Period;
location: TabLocation;
periods: Period[];
}>;
type UserResource = Readonly<{
id: string;
kind: number;
name: string;
className?: string;
establishmentName: string;
profilePicture: Attachment | null;
isDirector: boolean;
isDelegate: boolean;
isMemberCA: boolean;
tabs: Map<TabLocation, Tab>;
}>;
type UserParameters = Readonly<{
id: string;
kind: number;
name: string;
authorizations: UserAuthorizations;
resources: Array<UserResource>;
}>;
type SessionHandle = {
/**
* Equivalent of a PRONOTE session.
* Contains metadata, AES keys, RSA modulus, and more.
*/
information: SessionInformation;
instance: InstanceParameters;
user: UserParameters;
/**
* Can be updated with the `pronote.use(number | UserResource)` method.
* @default user.resources[0] // first resource from the user
*/
userResource: UserResource;
readonly queue: Queue;
readonly fetcher: Fetcher;
presence: null | ReturnType<typeof setInterval>;
};
type TimetableClass = Readonly<{
id: string;
backgroundColor?: string;
startDate: Date;
endDate: Date;
blockLength: number;
blockPosition: number;
notes?: string;
weekNumber: number;
}>;
type TimetableClassActivity = TimetableClass & Readonly<{
is: "activity";
title: string;
attendants: string[];
resourceTypeName: string;
resourceValue: string;
}>;
type TimetableClassDetention = TimetableClass & Readonly<{
is: "detention";
title?: string;
personalNames: string[];
teacherNames: string[];
classrooms: string[];
}>;
type TimetableClassLesson = TimetableClass & Readonly<{
is: "lesson";
kind: number;
/**
* @example "Classe absente"
*/
status?: string;
/**
* Whether this lesson has been canceled or not.
*/
canceled: boolean;
/**
* Whether the user is exempted from this lesson or not.
*/
exempted: boolean;
/**
* Whether there will be a test in the lesson or not.
*/
test: boolean;
/**
* List of URLs for virtual classrooms.
*/
virtualClassrooms: string[];
/**
* List of personal names.
*/
personalNames: string[];
/**
* List of teacher names.
*/
teacherNames: string[];
/**
* List of classrooms.
*/
classrooms: string[];
/**
* List of group names.
*/
groupNames: string[];
/**
* Subject of the lesson.
*/
subject?: Subject;
/**
* Returns `undefined` when there's no resource attached to this lesson.
* Otherwise, it'll return an ID that can be used in `lessonResource()` method.
*/
lessonResourceID?: string;
}>;
type Timetable = Readonly<{
classes: Array<TimetableClassLesson | TimetableClassActivity | TimetableClassDetention>;
absences: any;
withCanceledClasses: boolean;
}>;
type WeekMenu = Readonly<{
containsLunch: boolean;
containsDinner: boolean;
/**
* Menu for each day of the week.
*/
days: ReadonlyArray<Menu>;
/**
* Week numbers that are available
* for the menu.
*/
weeks: ReadonlyArray<number>;
allergens: ReadonlyArray<FoodAllergen>;
labels: ReadonlyArray<FoodLabel>;
}>;
declare const frequency: (session: SessionHandle, weekNumber: number) => WeekFrequency | undefined;
declare const timetableICalURL: (session: SessionHandle, iCalToken: string, fileName?: string) => string;
declare const loginCredentials: (session: SessionHandle, auth: {
url: string;
username: string;
password: string;
kind: AccountKind;
deviceUUID: string;
navigatorIdentifier?: string;
}) => Promise<RefreshInformation>;
declare const loginToken: (session: SessionHandle, auth: {
url: string;
username: string;
token: string;
kind: AccountKind;
deviceUUID: string;
navigatorIdentifier?: string;
}) => Promise<RefreshInformation>;
declare const loginQrCode: (session: SessionHandle, info: {
deviceUUID: string;
pin: string;
qr: any;
navigatorIdentifier?: string;
}) => Promise<RefreshInformation>;
declare const finishLoginManually: (session: SessionHandle, authentication: any, identity: any, initialUsername?: string) => Promise<RefreshInformation>;
declare const newsQuestionLocalMutate: {
(question: NewsQuestion, textInputAnswer?: string): void;
(question: NewsQuestion, selectedAnswers?: number[], otherFieldTextValue?: string): void;
(question: NewsQuestion, answers?: number[] | string, textInput?: string): void;
};
/**
* Mutates the original timetable object to parse it.
* This method is using the official PRONOTE way to parse the timetable.
*
* ## Why this isn't the responsibility of the internal `decodeTimetable()` ?
*
* Simply because it may be too overkill and not everyone would want this.
* We must provide the data as is and let the user decide what to do with it.
*
* That's why we provide this helper function to parse the timetable.
*/
declare const parseTimetable: (session: SessionHandle, timetable: Timetable, { withSuperposedCanceledClasses, withCanceledClasses, withPlannedClasses }: {
withSuperposedCanceledClasses?: boolean | undefined;
withCanceledClasses?: boolean | undefined;
withPlannedClasses?: boolean | undefined;
}) => void;
/**
* @param interval Custom interval (in ms) for `Presence` requests.
* Defaults to 2 minutes: same value as from Pronote.
*/
declare const startPresenceInterval: (session: SessionHandle, interval?: number) => void;
declare const clearPresenceInterval: (session: SessionHandle) => void;
declare const createSessionHandle: (fetcher?: Fetcher) => SessionHandle;
declare function use(session: SessionHandle, index: number): void;
declare function use(session: SessionHandle, resource: UserResource): void;
declare const translateToWeekNumber: (dateToTranslate: Date, startDay: Date) => number;
declare const account: (session: SessionHandle) => Promise<Account>;
declare const assignmentRemoveFile: (session: SessionHandle, assignmentID: string) => Promise<void>;
declare const assignmentStatus: (session: SessionHandle, assignmentID: string, done: boolean) => Promise<void>;
declare const assignmentUploadFile: (session: SessionHandle, assignmentID: string, file: FormDataFile, fileName: string) => Promise<void>;
declare const assignmentsFromWeek: (session: SessionHandle, weekNumber: number, extendsToWeekNumber?: number) => Promise<Array<Assignment>>;
declare const assignmentsFromIntervals: (session: SessionHandle, startDate: Date, endDate: Date) => Promise<Array<Assignment>>;
declare const discussionCreateDraft: (session: SessionHandle, discussion: Discussion, content: string, replyTo?: string | undefined) => Promise<void>;
declare const discussionDelete: (session: SessionHandle, discussion: Discussion) => Promise<void>;
/**
* Fetches the messages and writes them in the discussion.
* By default it won't mark the messages as read even after fetching them.
*
* You can change this behavior by setting `markAsRead` to `true`.
* There's no other way to mark the messages as read.
*
* @param markAsRead Whether to mark the messages as read after fetching them.
*/
declare const discussionMessages: (session: SessionHandle, discussion: Discussion, markAsRead?: boolean) => Promise<DiscussionMessages>;
/**
* Mark a discussion as read.
* @remark Shortcut of `discussionMessages` but here we don't return anything.
*/
declare const discussionRead: (session: SessionHandle, discussion: Discussion) => Promise<void>;
/**
* Fetches the recipients of the discussion.
*
* A recipient is someone who is part of the discussion.
* They don't have to send a message to be considered as a recipient.
*/
declare const discussionRecipients: (session: SessionHandle, discussion: Discussion) => Promise<Array<DiscussionRecipient>>;
/**
* Send local changes to the object
* to the server.
*/
declare const discussionRemoteMutateDraft: (session: SessionHandle, discussion: Discussion, draft: DiscussionDraftMessage) => Promise<void>;
declare const discussionRemoveDraft: (session: SessionHandle, discussion: Discussion, draft: DiscussionDraftMessage) => Promise<void>;
declare const discussionRestoreTrash: (session: SessionHandle, discussion: Discussion) => Promise<void>;
declare const discussionSendDraft: (session: SessionHandle, discussion: Discussion, draft: DiscussionDraftMessage, includeParentsAndStudents?: boolean) => Promise<void>;
declare const discussionSendMessage: (session: SessionHandle, discussion: Discussion, content: string, includeParentsAndStudents?: boolean, replyTo?: string | undefined) => Promise<void>;
declare const discussionTrash: (session: SessionHandle, discussion: Discussion) => Promise<void>;
declare const discussions: (session: SessionHandle, cache?: _DiscussionsCache) => Promise<Discussions>;
declare const evaluations: (session: SessionHandle, period: Period) => Promise<Array<Evaluation>>;
declare const geolocation: (position: {
latitude: number;
longitude: number;
}, fetcher?: Fetcher) => Promise<Array<GeolocatedInstance>>;
/**
* @param period - Period the grades report will be from.
* @returns URL to download the PDF file.
*/
declare const gradebookPDF: (session: SessionHandle, period: Period) => Promise<string>;
type GradeBook = Readonly<{
message?: string;
/**
* The differents assessments like the mentions or the overall rating
*/
overallAssessments: {
name: string;
value: string;
}[];
/**
* graph image as base64 png (with white backgound)
*/
graph?: string;
subjects: GradeBookSubject[];
url: string;
}>;
type GradeBookSubject = {
subject: Subject;
subjectGroup: string;
coef: number;
averages: {
student: number;
classOverall: number;
max: number;
min: number;
};
assessments: string[];
teachers: string[];
};
declare const gradebook: (session: SessionHandle, period: Period) => Promise<GradeBook>;
/**
* Get grades overview for a specific period.
* Including student's grades with averages and the global averages
*/
declare const gradesOverview: (session: SessionHandle, period: Period) => Promise<GradesOverview>;
/**
* Retrieve data from the homepage for the given session.
*/
declare const homepage: (session: SessionHandle, day?: Date) => Promise<Homepage>;
declare const instance: (url: string, fetcher?: Fetcher) => Promise<Instance>;
declare const menus: (session: SessionHandle, date?: Date) => Promise<WeekMenu>;
/**
* Returns a list of possible recipients when creating a discussion.
*
* This step is required before creating a discussion.
* It allows to know who can be the recipient of the discussion.
*
* @param kind The kind of entity to create a discussion with. Only `Teacher`, `Student` and `Personal` are allowed.
*/
declare const newDiscussionRecipients: (session: SessionHandle, kind: EntityKind) => Promise<Array<NewDiscussionRecipient>>;
/**
* Create a discussion.
*
* Sadly, we can't get the ID of the created discussion
* or anything else related to it, you need to request the
* discussions list once again.
*/
declare const newDiscussion: (session: SessionHandle, subject: string, content: string, recipients: Array<NewDiscussionRecipient>) => Promise<void>;
/**
* Will delete the item from the user's news feed.
* @remark You can never get the item back after this.
*/
declare const newsDelete: (session: SessionHandle, item: NewsInformation | NewsSurvey) => Promise<void>;
/**
* Will acknowledge the news if needed,
* so if the news doesn't need to be acknowledged (`!needToAcknowledge`)
* or is already `acknowledged`, we will just do the read step.
*
* When acknowledging, the news will be directly marked as read.
* If you want to change this behavior, you can change the `alsoMarkAsRead` parameter.
*
* @remark You can't un-acknowledge a news.
*/
declare const newsInformationAcknowledge: (session: SessionHandle, information: NewsInformation, alsoMarkAsRead?: boolean) => Promise<void>;
/**
* Patches the `read` state of the news to the given value.
* @remark Will do nothing if `read === status`.
*/
declare const newsRead: (session: SessionHandle, item: NewsInformation | NewsSurvey, read: boolean) => Promise<void>;
/**
* Answers the survey with the given answers.
* By default, it'll answer with the questions that were given when the survey was created.
*
* You can either manipulate the questions directly or pass in your own answers.
*/
declare const newsSurveySend: (session: SessionHandle, survey: NewsSurvey, alsoMarkAsRead?: boolean) => Promise<void>;
declare const news: (session: SessionHandle) => Promise<News>;
declare const notebook: (session: SessionHandle, period: Period) => Promise<Notebook>;
declare const partnerURL: (session: SessionHandle, partner: Partner) => Promise<string>;
declare const presence: (session: SessionHandle) => Promise<void>;
/**
* Retrieve assignments from a resource.
*/
declare const resourceAssignments: (session: SessionHandle, resourceID: string) => Promise<Array<Assignment>>;
declare const resource: (session: SessionHandle, resourceID: string) => Promise<Resource>;
declare const resourcesFromWeek: (session: SessionHandle, weekNumber: number, extendsToWeekNumber?: number) => Promise<Resource[]>;
declare const resourcesFromIntervals: (session: SessionHandle, startDate: Date, endDate: Date) => Promise<Resource[]>;
declare const securityCheckCustomPassword: (session: SessionHandle, newPassword: string) => Promise<boolean>;
declare const securityCheckPIN: (session: SessionHandle, pin: string) => Promise<boolean>;
declare const securitySave: (session: SessionHandle, handle: SecurityModal, options: {
password?: string;
deviceName?: string;
pin?: string;
mode?: DoubleAuthMode;
}) => Promise<void>;
/**
* @returns true if the source is already known
*/
declare const securitySource: (session: SessionHandle, source: string) => Promise<boolean>;
declare const sessionInformation: (options: {
base: string;
kind: AccountKind;
params: Record<string, any>;
cookies: string[];
}, fetcher?: Fetcher) => Promise<SessionInformation>;
declare const timetableFromWeek: (session: SessionHandle, weekNumber: number) => Promise<Timetable>;
declare const timetableFromIntervals: (session: SessionHandle, startDate: Date, endDate?: Date) => Promise<Timetable>;
export { AccessDeniedError, type Account, AccountDisabledError, AccountKind, type Assignment, AssignmentDifficulty, type AssignmentReturn, AssignmentReturnKind, type AssignmentTheme, type Attachment, AttachmentKind, AuthenticateError, type AuthenticationQR, BadCredentialsError, BusyPageError, type Discussion, DiscussionActionError, DiscussionCommand, type DiscussionDraft