### Install Pawnote Library with Package Managers Source: https://js.pawnote.docs.literate.ink/index Install the Pawnote library using your preferred package manager. This library is designed to interact with the PRONOTE school management application. ```shell # pnpm pnpm add pawnote # Yarn yarn add pawnote # npm npm add pawnote # Bun bun add pawnote ``` -------------------------------- ### startPresenceInterval Source: https://js.pawnote.docs.literate.ink/functions/startPresenceInterval Starts an interval for sending Presence requests. Allows for custom intervals to be set, overriding the default 2-minute interval. ```APIDOC ## startPresenceInterval ### Description Starts an interval for sending Presence requests. Allows for custom intervals to be set, overriding the default 2-minute interval. ### Method `startPresenceInterval` (This is a function call, not a typical HTTP method) ### Endpoint N/A (Client-side function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Assuming sessionHandle is a valid SessionHandle object startPresenceInterval(sessionHandle, 30000); // Set interval to 30 seconds startPresenceInterval(sessionHandle); // Use default interval (2 minutes) ``` ### Response #### Success Response void (This function does not return a value) #### Response Example N/A ``` -------------------------------- ### Get Resources from Interval (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/resourcesFromIntervals Retrieves a list of educational resources within a specified date range. It requires a session handle, start date, and end date. The function returns a promise that resolves to an array of resource objects, each containing details like deadlines, content, dates, and associated subjects. ```typescript /** * Get the resources from a specific date range. * @param session The current session handle. * @param startDate The start date of the range. * @param endDate The end date of the range. * @returns A promise that resolves to an array of resources. */ async function resourcesFromIntervals( session: SessionHandle, startDate: Date, endDate: Date, ): Promise[]; id: string; themes: Readonly<{ id: string; name: string; subject: Subject }>[]; title?: string; }, >[]; endDate: Date; groups: string[]; haveAssignment: boolean; id: string; startDate: Date; subject: Subject; teachers: string[]; }, >[], > { // Implementation details to fetch resources based on the provided parameters. // This is a placeholder and would involve actual API calls or data retrieval logic. console.log(`Fetching resources from ${startDate} to ${endDate} with session: ${session}`); // Example return structure (replace with actual data fetching) return []; } ``` -------------------------------- ### Session Handle Creation Source: https://js.pawnote.docs.literate.ink/functions/createsessionhandle This endpoint allows you to create a new session handle with default configurations. It's the starting point for interacting with the Pawnote service. ```APIDOC ## POST /websites/js_pawnote_literate_ink/createSessionHandle ### Description Creates a session handle with default values. ### Method POST ### Endpoint /websites/js_pawnote_literate_ink/createSessionHandle ### Parameters #### Query Parameters - **fetcher** (Fetcher) - Optional - The fetcher to use for the current session handle. ### Request Example ```json { "fetcher": "defaultFetcher" } ``` ### Response #### Success Response (200) - **sessionHandle** (SessionHandle) - A session handle with default values. #### Response Example ```json { "sessionHandle": { "id": "some_session_id", "createdAt": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Start Presence Interval - TypeScript Source: https://js.pawnote.docs.literate.ink/functions/startpresenceinterval Initiates an interval for sending presence updates. It accepts a session handle and an optional custom interval in milliseconds. If no interval is provided, it defaults to 2 minutes, matching the Pronote default. ```typescript /** * Starts an interval for sending presence updates. * @param session The current session handle. * @param interval Custom interval (in ms) for `Presence` requests. Defaults to 2 minutes. */ function startPresenceInterval(session: SessionHandle, interval?: number): void; ``` -------------------------------- ### Get Resources from Interval (JavaScript) Source: https://js.pawnote.docs.literate.ink/functions/resourcesfromintervals Retrieves resources within a specified date range using the `resourcesFromIntervals` function. This function requires a session handle, a start date, and an end date. It returns a promise that resolves to an array of resource objects, each containing details like deadlines, content, dates, and associated subjects. Dependencies include `SessionHandle`, `Date`, `ResourceContentCategory`, `AttachmentKind`, and `Subject` types. ```javascript /** * Get the resources from a specific date range. * @param {SessionHandle} session - The current session handle. * @param {Date} startDate - The start date of the range. * @param {Date} endDate - The end date of the range. * @returns {Promise>; id: string; themes: ReadonlyArray>; title?: string }>>; endDate: Date; groups: string[]; haveAssignment: boolean; id: string; startDate: Date; subject: Subject; teachers: string[] }>>>} A promise that resolves to an array of resources. */ async function resourcesFromIntervals(session, startDate, endDate) { // Implementation details would go here return []; } ``` -------------------------------- ### GET /discussions Source: https://js.pawnote.docs.literate.ink/functions/discussions Retrieves discussions from the server, optionally using a cache. ```APIDOC ## GET /discussions ### Description Retrieve discussions from the server. ### Method GET ### Endpoint /discussions ### Parameters #### Query Parameters - **session** (SessionHandle) - Required - The current session handle. - **cache** (_DiscussionsCache) - Optional - The cache to store discussions. ### Response #### Success Response (200) - **folders** (Readonly>) - A list of discussion folders. - **items** (Discussion[]) - A list of discussion items. #### Response Example ```json { "folders": [ { "id": "folder1", "kind": "general", "name": "General Discussions" } ], "items": [ { "id": "discussion1", "title": "First Discussion", "content": "This is the content of the first discussion." } ] } ``` ``` -------------------------------- ### Get Resources from Week (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/resourcesfromweek Retrieves educational resources for a specified week, with an option to extend the search to subsequent weeks. It requires a session handle and the week number. The function returns a promise that resolves to an array of resource objects, each containing details like deadlines, content, dates, groups, and subjects. ```typescript /** * Get the resources from a specific week. * @param session The current session handle. * @param weekNumber The week number to get resources from. * @param extendsToWeekNumber The week number to extend the search to (optional). * @returns A promise that resolves to an array of resources. */ async function resourcesFromWeek( session: SessionHandle, weekNumber: number, extendsToWeekNumber?: number ): Promise; id: string; themes: Readonly; title?: string; }>>; endDate: Date; groups: string[]; haveAssignment: boolean; id: string; startDate: Date; subject: Subject; teachers: string[]; }>>> { // Implementation details to fetch resources from the API // ... return []; // Placeholder for actual return value } ``` -------------------------------- ### Get Grades Overview (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/gradesOverview Retrieves a detailed overview of a student's grades for a given academic period. This function returns aggregated data including individual grades, subject averages, and overall class averages. It requires a valid session handle and period object. ```typescript /** * Get grades overview for a specific period. Including student's grades with averages and the global averages * @param session SessionHandle * @param period Period * @returns Promise; * grades: Readonly< * { * average?: Readonly<{ kind: GradeKind; points: number }>; * coefficient: number; * comment: string; * commentaireSurNote?: string; * correctionFile?: Readonly<{ id: string; kind: AttachmentKind; name: string; url: string }>; * date: Date; * defaultOutOf?: Readonly<{ kind: GradeKind; points: number }>; * id: string; * isBonus: boolean; * isOptional: boolean; * isOutOf20: boolean; * max?: Readonly<{ kind: GradeKind; points: number }>; * min?: Readonly<{ kind: GradeKind; points: number }>; * outOf: GradeValue; * subject: Subject; * subjectFile?: Readonly<{ id: string; kind: AttachmentKind; name: string; url: string }>; * value: GradeValue; * }, * >[]; * overallAverage?: Readonly<{ kind: GradeKind; points: number }>; * subjectsAverages: Readonly< * { * backgroundColor: string; * class_average?: Readonly<{ kind: GradeKind; points: number }>; * defaultOutOf?: Readonly<{ kind: GradeKind; points: number }>; * max?: Readonly<{ kind: GradeKind; points: number }>; * min?: Readonly<{ kind: GradeKind; points: number }>; * outOf?: Readonly<{ kind: GradeKind; points: number }>; * student?: Readonly<{ kind: GradeKind; points: number }>; * subject: Subject; * }, * >[]; * }>> */ function gradesOverview( session: SessionHandle, period: Period ): Promise; grades: Readonly< { average?: Readonly<{ kind: GradeKind; points: number }>; coefficient: number; comment: string; commentaireSurNote?: string; correctionFile?: Readonly<{ id: string; kind: AttachmentKind; name: string; url: string }>; date: Date; defaultOutOf?: Readonly<{ kind: GradeKind; points: number }>; id: string; isBonus: boolean; isOptional: boolean; isOutOf20: boolean; max?: Readonly<{ kind: GradeKind; points: number }>; min?: Readonly<{ kind: GradeKind; points: number }>; outOf: GradeValue; subject: Subject; subjectFile?: Readonly<{ id: string; kind: AttachmentKind; name: string; url: string }>; value: GradeValue; }, >[]; overallAverage?: Readonly<{ kind: GradeKind; points: number }>; subjectsAverages: Readonly< { backgroundColor: string; class_average?: Readonly<{ kind: GradeKind; points: number }>; defaultOutOf?: Readonly<{ kind: GradeKind; points: number }>; max?: Readonly<{ kind: GradeKind; points: number }>; min?: Readonly<{ kind: GradeKind; points: number }>; outOf?: Readonly<{ kind: GradeKind; points: number }>; student?: Readonly<{ kind: GradeKind; points: number }>; subject: Subject; }, >[]; }>>; ``` -------------------------------- ### Get Notebook Entries Source: https://js.pawnote.docs.literate.ink/functions/notebook Retrieves a comprehensive list of notebook entries for a specified session and period. This includes absences, delays, observations, precautionary measures, and punishments. ```APIDOC ## GET /notebook ### Description Retrieves a comprehensive list of notebook entries for a specified session and period. This includes absences, delays, observations, precautionary measures, and punishments. ### Method GET ### Endpoint /notebook ### Parameters #### Query Parameters - **session** (SessionHandle) - Required - The session handle for authentication and context. - **period** (Period) - Required - The period for which to retrieve notebook entries. ### Response #### Success Response (200) - **absences** (Readonly) - A list of absence records. - **administrativelyFixed** (boolean) - Indicates if the absence was administratively fixed. - **daysMissed** (number) - The number of days missed due to the absence. - **endDate** (Date) - The end date of the absence. - **hoursMissed** (number) - The number of hours missed due to the absence. - **id** (string) - The unique identifier for the absence. - **isReasonUnknown** (boolean) - Indicates if the reason for absence is unknown. - **justified** (boolean) - Indicates if the absence was justified. - **minutesMissed** (number) - The number of minutes missed due to the absence. - **opened** (boolean) - Indicates if the absence record is open. - **reason** (string) - Optional - The reason for the absence. - **shouldParentsJustify** (boolean) - Indicates if parents should justify the absence. - **startDate** (Date) - The start date of the absence. - **delays** (Readonly) - A list of delay records. - **administrativelyFixed** (boolean) - Indicates if the delay was administratively fixed. - **date** (Date) - The date of the delay. - **id** (string) - The unique identifier for the delay. - **isReasonUnknown** (boolean) - Indicates if the reason for the delay is unknown. - **justification** (string) - Optional - The justification for the delay. - **justified** (boolean) - Indicates if the delay was justified. - **minutes** (number) - The number of minutes of the delay. - **reason** (string) - Optional - The reason for the delay. - **shouldParentsJustify** (boolean) - Indicates if parents should justify the delay. - **observations** (Readonly) - A list of observation records. - **date** (Date) - The date of the observation. - **id** (string) - The unique identifier for the observation. - **kind** (NotebookObservationKind) - The type of observation. - **name** (string) - The name or title of the observation. - **opened** (boolean) - Indicates if the observation record is open. - **reason** (string) - Optional - The reason for the observation. - **sectionID** (string) - The ID of the section the observation pertains to. - **shouldParentsJustify** (boolean) - Indicates if parents should justify the observation. - **subject** (Readonly) - Optional - Information about the subject related to the observation. - **id** (string) - The subject's ID. - **inGroups** (boolean) - Indicates if the subject is in groups. - **name** (string) - The subject's name. - **precautionaryMeasures** (Readonly) - A list of precautionary measure records. - **circumstances** (string) - The circumstances under which the measure was given. - **circumstancesDocuments** (Readonly) - A list of documents related to the circumstances. - **id** (string) - The document ID. - **kind** (AttachmentKind) - The type of attachment. - **name** (string) - The document name. - **url** (string) - The URL of the document. - **comments** (string) - Additional comments about the measure. - **dateGiven** (Date) - The date the measure was given. - **decisionMaker** (string) - The entity that made the decision. - **disallowedAccesses** (Array) - A list of disallowed access IDs. - **endDate** (Date) - The end date of the measure. - **exclusion** (boolean) - Indicates if the measure involves exclusion. - **giver** (string) - The entity that gave the measure. - **id** (string) - The unique identifier for the precautionary measure. - **reasons** (Array) - A list of reasons for the measure. - **startDate** (Date) - The start date of the measure. - **title** (string) - The title of the precautionary measure. - **punishments** (Readonly) - A list of punishment records. - **circumstances** (string) - The circumstances under which the punishment was given. - **circumstancesDocuments** (Readonly) - A list of documents related to the circumstances. - **id** (string) - The document ID. - **kind** (AttachmentKind) - The type of attachment. - **name** (string) - The document name. - **url** (string) - The URL of the document. - **dateGiven** (Date) - The date the punishment was given. - **durationMinutes** (number) - The duration of the punishment in minutes. - **exclusion** (boolean) - Indicates if the punishment involves exclusion. - **giver** (string) - The entity that gave the punishment. - **id** (string) - The unique identifier for the punishment. - **isDuringLesson** (boolean) - Indicates if the punishment occurred during a lesson. - **reasons** (Array) - A list of reasons for the punishment. - **title** (string) - The title of the punishment. - **workToDo** (string) - Description of any work to be done as part of the punishment. - **workToDoDocuments** (Readonly) - A list of documents related to the work to do. - **id** (string) - The document ID. - **kind** (AttachmentKind) - The type of attachment. - **name** (string) - The document name. - **url** (string) - The URL of the document. #### Response Example ```json { "absences": [ { "administrativelyFixed": false, "daysMissed": 1, "endDate": "2023-10-27T00:00:00.000Z", "hoursMissed": 5, "id": "abs-123", "isReasonUnknown": false, "justified": true, "minutesMissed": 300, "opened": true, "reason": "Illness", "shouldParentsJustify": false, "startDate": "2023-10-27T00:00:00.000Z" } ], "delays": [ { "administrativelyFixed": false, "date": "2023-10-27T08:15:00.000Z", "id": "del-456", "isReasonUnknown": false, "justification": "Bus delay", "justified": true, "minutes": 15, "reason": "Transportation issue", "shouldParentsJustify": false } ], "observations": [ { "date": "2023-10-26T10:00:00.000Z", "id": "obs-789", "kind": "BEHAVIOR", "name": "Disruptive behavior in class", "opened": true, "reason": "Disturbing other students", "sectionID": "sec-abc", "shouldParentsJustify": true, "subject": { "id": "sub-math", "inGroups": false, "name": "Mathematics" } } ], "precautionaryMeasures": [], "punishments": [] } ``` ``` -------------------------------- ### Get Resources from Week (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/resourcesFromWeek Retrieves resources for a given week number, with an optional extension to subsequent weeks. It returns a promise that resolves to an array of resource objects, each containing details like deadlines, content, dates, groups, and subjects. This function is essential for accessing structured learning materials. ```typescript function resourcesFromWeek( session: SessionHandle, weekNumber: number, extendsToWeekNumber?: number ): Promise[ ]; id: string; themes: Readonly<{ id: string; name: string; subject: Subject }>[ ]; title?: string; },>[ ]; endDate: Date; groups: string[]; haveAssignment: boolean; id: string; startDate: Date; subject: Subject; teachers: string[]; },>[ ]> { // Implementation details to fetch resources based on weekNumber and extendsToWeekNumber // This would involve interacting with the session handle and potentially an API. return Promise.resolve([]); // Placeholder for actual implementation } ``` -------------------------------- ### Get Timetable Data for a Week (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/timetablefromweek The `timetableFromWeek` function fetches timetable information for a given week. It requires a `SessionHandle` and a `weekNumber` as input. The function returns a Promise that resolves to a read-only object containing absences, classes (which can be activities, detentions, or lessons), and a flag indicating if there were canceled classes. ```typescript function timetableFromWeek( session: SessionHandle, weekNumber: number ): Promise< Readonly< { absences: any; classes: ( | TimetableClassActivity | TimetableClassDetention | TimetableClassLesson )[]; withCanceledClasses: boolean; }, >, > { // Implementation details would go here return Promise.resolve({ absences: null, classes: [], withCanceledClasses: false }); } ``` -------------------------------- ### Initialize Pawnote Instance Source: https://js.pawnote.docs.literate.ink/functions/instance The `instance` function initializes a Pawnote instance by fetching project metadata from a given URL. It accepts an optional fetcher object for custom network requests. The function returns a promise that resolves to a read-only object containing project details like accounts, CAS token, CAS URL, date, name, and version. ```typescript import { instance, Fetcher } from "@pawnote/core"; async function getProjectInstance(url: string, fetcher?: Fetcher) { const projectData = await instance(url, fetcher); console.log(projectData.name); console.log(projectData.accounts); return projectData; } ``` -------------------------------- ### Get Timetable Data with timetableFromIntervals Source: https://js.pawnote.docs.literate.ink/functions/timetablefromintervals The timetableFromIntervals function fetches timetable data, including classes and absences, between a start date and an optional end date. It requires a SessionHandle for authentication and returns a Promise containing a read-only object with timetable details. The function can handle various class types and indicates if canceled classes are included. ```typescript import { SessionHandle, TimetableClassActivity, TimetableClassDetention, TimetableClassLesson } from "./types"; async function timetableFromIntervals( session: SessionHandle, startDate: Date, endDate?: Date ): Promise< Readonly< { absences: any; classes: ( | TimetableClassActivity | TimetableClassDetention | TimetableClassLesson )[]; withCanceledClasses: boolean; }, >, > { // Implementation details to fetch timetable data // ... return Promise.resolve({ absences: [], classes: [], withCanceledClasses: false }); } ``` -------------------------------- ### Pawnote Instance Function Source: https://js.pawnote.docs.literate.ink/functions/instance Fetches project data including accounts, CAS token/URL, date, name, and version. ```APIDOC ## Function instance ### Description Fetches project data including accounts, CAS token/URL, date, name, and version. ### Method GET ### Endpoint /websites/js_pawnote_literate_ink/instance ### Parameters #### Query Parameters - **url** (string) - Required - The URL to fetch the instance data from. - **fetcher** (Fetcher) - Optional - A custom fetcher function. Defaults to `defaultFetcher`. ### Response #### Success Response (200) - **accounts** (array) - An array of account objects, each with `name` (string) and `path` (string). - **casToken** (string) - Optional - The CAS token. - **casURL** (string) - Optional - The CAS URL. - **date** (Date) - The date the instance was created or last updated. - **name** (string) - The name of the instance. - **version** (array) - An array of numbers representing the version. #### Response Example ```json { "accounts": [ { "name": "account1", "path": "/path/to/account1" }, { "name": "account2", "path": "/path/to/account2" } ], "casToken": "your_cas_token", "casURL": "https://your.cas.url.com", "date": "2023-10-27T10:00:00Z", "name": "my_pawnote_instance", "version": [1, 0, 0] } ``` ``` -------------------------------- ### UploadSizeError Class Documentation Source: https://js.pawnote.docs.literate.ink/classes/UploadSizeError Provides detailed information about the UploadSizeError class, its inheritance, constructors, properties, and methods. ```APIDOC ## Class UploadSizeError ### Hierarchy * Error * UploadSizeError ### Constructors #### constructor * `new UploadSizeError(maxSizeInBytes: number)`: UploadSizeError ##### Parameters * `maxSizeInBytes` (number) - The maximum allowed size in bytes. ##### Returns * `UploadSizeError` ### Properties #### `Optional`cause * `cause?: unknown` * Description: The cause of the error. #### message * `message: string` * Description: The error message. #### name * `name: string` * Description: The name of the error. #### `Optional`stack * `stack?: string` * Description: The stack trace of the error. #### `Static`stackTraceLimit * `stackTraceLimit: number` * Description: The maximum number of stack frames to capture. ### Methods #### `Static`captureStackTrace * `captureStackTrace(targetObject: object, constructorOpt?: Function): void` * Description: Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()` was called. The optional `constructorOpt` argument can be used to hide implementation details from the stack trace. ##### Parameters * `targetObject` (object) - The object to attach the stack trace to. * `constructorOpt` (Function, Optional) - A function to omit frames above in the stack trace. ##### Returns * `void` ##### Example ```javascript const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` ``` #### `Static`isError * `isError(error: unknown): error is Error` * Description: Indicates whether the argument provided is a built-in Error instance or not. ##### Parameters * `error` (unknown) - The value to check. ##### Returns * `error is Error` - True if the value is an instance of Error, false otherwise. #### `Static`prepareStackTrace * `prepareStackTrace(err: Error, stackTraces: CallSite[]): any` * Description: Allows customization of stack trace formatting. * See: https://v8.dev/docs/stack-trace-api#customizing-stack-traces ##### Parameters * `err` (Error) - The error object. * `stackTraces` (CallSite[]) - An array of stack trace frames. ##### Returns * `any` ``` -------------------------------- ### Calculate Week Number using translateToWeekNumber Source: https://js.pawnote.docs.literate.ink/functions/translateToWeekNumber This function calculates the week number of a given date relative to a specified start date. It takes two Date objects as input: the date to translate and the start date for the calculation. It returns a number representing the week number. ```typescript /** * Calculates the week number based on a given date and a start date. * @param dateToTranslate The date to translate into a week number. * @param startDay The start date from which to calculate the week number. * @returns The calculated week number. */ function translateToWeekNumber(dateToTranslate: Date, startDay: Date): number { // Implementation details would go here return 0; // Placeholder } ``` -------------------------------- ### Static prepareStackTrace Method Source: https://js.pawnote.docs.literate.ink/classes/authenticateerror Allows for customizing the format of stack traces. ```APIDOC ## `Static` prepareStackTrace(err: Error, stackTraces: CallSite[]): any ### Description This static method is used internally by V8 to format stack traces. It can be overridden to provide custom stack trace formatting. ### Method Static ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Example of overriding prepareStackTrace (advanced usage) Error.prepareStackTrace = function (err, stackTraces) { // Custom formatting logic here return stackTraces.map(site => site.getFunctionName()).join('\n'); }; ``` ### Response #### Success Response (200) - **any** - The formatted stack trace. #### Response Example N/A (Return value depends on the custom formatting logic. ``` -------------------------------- ### Calculate Week Number using translateToWeekNumber Source: https://js.pawnote.docs.literate.ink/functions/translatetoweeknumber This function calculates the week number of a given date based on a provided start date. It takes two Date objects as input: the date to translate and the start date for the calculation. It returns a number representing the calculated week number. ```typescript /** * Calculates the week number based on a given date and a start date. * @param dateToTranslate The date to translate into a week number. * @param startDay The start date from which to calculate the week number. * @returns The calculated week number. */ function translateToWeekNumber(dateToTranslate: Date, startDay: Date): number { // Implementation details would go here const timeDiff = dateToTranslate.getTime() - startDay.getTime(); const daysDiff = timeDiff / (1000 * 60 * 60 * 24); const weekNumber = Math.floor(daysDiff / 7) + 1; return weekNumber; } ``` -------------------------------- ### finishLoginManually Source: https://js.pawnote.docs.literate.ink/functions/finishLoginManually Completes the login process manually using session, authentication, and identity details. ```APIDOC ## POST /finishLoginManually ### Description Completes the login process manually. This endpoint is used after initial authentication and identification steps to finalize the user's session. ### Method POST ### Endpoint /finishLoginManually ### Parameters #### Request Body - **session** (SessionHandle) - Required - The current session handle. - **authentication** (any) - Required - The authentication object returned from the `authenticate()` function. - **identity** (any) - Required - The identity object returned from the `identify()` function. - **initialUsername** (string) - Optional - The initial username used for login. ### Response #### Success Response (200) - **kind** (AccountKind) - The type of account. - **navigatorIdentifier** (string) - Identifier for the navigator. - **token** (string) - The authentication token for the session. - **url** (string) - The URL associated with the session. - **username** (string) - The username of the logged-in user. #### Response Example ```json { "kind": "user", "navigatorIdentifier": "nav-123", "token": "auth-token-xyz", "url": "https://example.com/session", "username": "testuser" } ``` ``` -------------------------------- ### GET /resource/{resourceID} Source: https://js.pawnote.docs.literate.ink/functions/resource Retrieves detailed information about a specific resource using its unique identifier. ```APIDOC ## GET /resource/{resourceID} ### Description Retrieve a specific resource by its ID. ### Method GET ### Endpoint /resource/{resourceID} ### Parameters #### Path Parameters - **resourceID** (string) - Required - The ID of the resource to retrieve. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **assignmentDeadline** (Date) - Optional - The deadline for assignments related to the resource. - **backgroundColor** (string) - The background color associated with the resource. - **contents** (Array) - An array of content objects associated with the resource. - **category** (ResourceContentCategory) - The category of the content. - **categoryText** (string) - Optional - Textual representation of the content category. - **description** (string) - Optional - A description of the content. - **educativeValue** (number) - The educational value of the content. - **files** (Array) - An array of files associated with the content. - **id** (string) - The ID of the file. - **kind** (AttachmentKind) - The type or kind of the attachment. - **name** (string) - The name of the file. - **url** (string) - The URL of the file. - **id** (string) - The ID of the content. - **themes** (Array) - An array of themes associated with the content. - **id** (string) - The ID of the theme. - **name** (string) - The name of the theme. - **subject** (Subject) - The subject of the theme. - **title** (string) - Optional - The title of the content. - **endDate** (Date) - The end date of the resource. - **groups** (Array) - An array of groups associated with the resource. - **haveAssignment** (boolean) - Indicates if the resource has an associated assignment. - **id** (string) - The unique identifier of the resource. - **startDate** (Date) - The start date of the resource. - **subject** (Subject) - The subject of the resource. - **teachers** (Array) - An array of teachers associated with the resource. #### Response Example ```json { "assignmentDeadline": "2023-12-31T23:59:59Z", "backgroundColor": "#FFFFFF", "contents": [ { "category": "LECTURE", "educativeValue": 10, "files": [ { "id": "file123", "kind": "PDF", "name": "Introduction.pdf", "url": "http://example.com/files/intro.pdf" } ], "id": "content456", "themes": [ { "id": "theme789", "name": "Introduction to Subject", "subject": "MATH" } ], "title": "Chapter 1: Basics" } ], "endDate": "2023-12-31T23:59:59Z", "groups": ["Group A", "Group B"], "haveAssignment": true, "id": "resource101", "startDate": "2023-01-01T00:00:00Z", "subject": "MATH", "teachers": ["Dr. Smith", "Prof. Jones"] } ``` ``` -------------------------------- ### AuthenticateError Constructor Source: https://js.pawnote.docs.literate.ink/classes/authenticateerror Initializes a new instance of the AuthenticateError class. ```APIDOC ## new AuthenticateError(message: string): AuthenticateError ### Description Creates a new instance of the AuthenticateError class. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript const error = new AuthenticateError("Authentication failed"); ``` ### Response #### Success Response (200) N/A (Constructor does not return a value in the typical sense) #### Response Example N/A ``` -------------------------------- ### Login with QR Code (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/loginqrcode Logs in a user using QR code authentication. This function requires a session handle and authentication information including device UUID, PIN, and QR code data. It returns a promise that resolves with the refreshed session details upon successful login. ```typescript function loginQrCode( session: SessionHandle, info: { deviceUUID: string; navigatorIdentifier?: string; pin: string; qr: any; }, ): Promise< Readonly< { kind: AccountKind; navigatorIdentifier: string; token: string; url: string; username: string; }, >, > { // Implementation details for QR code login } ``` -------------------------------- ### GET /websites/js_pawnote_literate_ink/resourceAssignments Source: https://js.pawnote.docs.literate.ink/functions/resourceAssignments Retrieves a list of assignments for a specified resource ID. This endpoint requires a valid session handle and the resource's unique identifier. ```APIDOC ## GET /websites/js_pawnote_literate_ink/resourceAssignments ### Description Retrieve assignments from a resource. ### Method GET ### Endpoint /websites/js_pawnote_literate_ink/resourceAssignments ### Parameters #### Query Parameters - **session** (SessionHandle) - Required - The current session handle. - **resourceID** (string) - Required - The ID of the resource. ### Response #### Success Response (200) - **attachments** (Readonly>) - List of attachments for the assignment. - **backgroundColor** (string) - The background color associated with the assignment. - **deadline** (Date) - The deadline for the assignment. - **description** (string) - A detailed description of the assignment. - **difficulty** (AssignmentDifficulty) - The difficulty level of the assignment. - **done** (boolean) - Indicates whether the assignment is completed. - **id** (string) - The unique identifier for the assignment. - **length** (number) - Optional - The length of the assignment. - **resourceID** (string) - Optional - The ID of the resource the assignment belongs to. - **return** (AssignmentReturn) - Information about the assignment return. - **subject** (Subject) - The subject the assignment is related to. - **themes** (Readonly>) - List of themes associated with the assignment. #### Response Example { "assignments": [ { "attachments": [ { "id": "attach_123", "kind": "document", "name": "Introduction.pdf", "url": "http://example.com/attachments/intro.pdf" } ], "backgroundColor": "#f0f0f0", "deadline": "2023-12-31T23:59:59Z", "description": "Write a summary of the first chapter.", "difficulty": "medium", "done": false, "id": "assign_abc", "length": 500, "resourceID": "res_xyz", "return": { "type": "file", "format": "pdf" }, "subject": { "id": "subj_math", "name": "Mathematics" }, "themes": [ { "id": "theme_algebra", "name": "Algebra", "subject": { "id": "subj_math", "name": "Mathematics" } } ] } ] } ``` -------------------------------- ### Login with QR Code (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/loginQrCode The `loginQrCode` function authenticates a user via QR code. It requires a session handle and authentication information including device UUID, PIN, and QR code data. It returns a promise that resolves with the user's account kind, navigator identifier, authentication token, URL, and username. ```typescript /** * Logs in using a QR code. * @param session The current session handle. * @param info The authentication information including device UUID, PIN, QR code data, and optional navigator identifier. * @returns A promise resolving to the refreshed session information. */ async function loginQrCode( session: SessionHandle, info: { deviceUUID: string; navigatorIdentifier?: string; pin: string; qr: any; } ): Promise< Readonly< { kind: AccountKind; navigatorIdentifier: string; token: string; url: string; username: string; }, > > { // Implementation details for QR code login // ... return {} as any; // Placeholder for actual return value } ``` -------------------------------- ### Define Holiday Type Alias Source: https://js.pawnote.docs.literate.ink/types/Holiday This TypeScript type alias defines the structure for holiday objects. It includes properties for the holiday's name, a unique identifier, and its start and end dates. The `Readonly` utility type ensures that once a holiday object is created, its properties cannot be modified. ```typescript type Holiday = Readonly<{ endDate: Date; id: string; name: string; startDate: Date }> ``` -------------------------------- ### POST /loginToken Source: https://js.pawnote.docs.literate.ink/functions/logintoken Authenticates a user using a provided token and returns session information. ```APIDOC ## POST /loginToken ### Description Logs in using a token. This endpoint authenticates a user with provided credentials and returns session details. ### Method POST ### Endpoint /loginToken ### Parameters #### Request Body - **session** (SessionHandle) - Required - The current session handle. - **auth** (TokenAuthenticationParams) - Required - The authentication details including URL, username, token, account kind, device UUID, and optional navigator identifier. ### Request Example ```json { "session": { "handle": "some_session_handle" }, "auth": { "url": "https://example.com", "username": "user123", "token": "auth_token_string", "accountKind": "personal", "deviceUUID": "uuid_device_123", "navigatorIdentifier": "optional_navigator_id" } } ``` ### Response #### Success Response (200) - **kind** (AccountKind) - The kind of account. - **navigatorIdentifier** (string) - The identifier for the navigator. - **token** (string) - The authentication token for the session. - **url** (string) - The URL associated with the session. - **username** (string) - The username for the session. #### Response Example ```json { "kind": "personal", "navigatorIdentifier": "navigator_abc", "token": "refreshed_session_token", "url": "https://example.com", "username": "user123" } ``` ``` -------------------------------- ### Login with Token (TypeScript) Source: https://js.pawnote.docs.literate.ink/functions/loginToken The `loginToken` function facilitates logging in by utilizing a token. It requires a `SessionHandle` and `TokenAuthenticationParams` as input, and returns a promise that resolves to account and session details, including a new token and URL. This function is crucial for authenticating users and establishing a session. ```typescript /** * Logs in using a token. * @param session The current session handle. * @param auth The authentication details including URL, username, token, account kind, device UUID, and optional navigator identifier. * @returns A promise resolving to the refreshed session information. */ loginToken( session: SessionHandle, auth: TokenAuthenticationParams ): Promise< Readonly< { kind: AccountKind; navigatorIdentifier: string; token: string; url: string; username: string; }, >, > { // Implementation details for loginToken would go here // This is a placeholder and does not contain actual executable code. return Promise.resolve({ kind: 'user', navigatorIdentifier: 'some-identifier', token: 'new-auth-token', url: 'https://example.com/api', username: 'testuser' }); } ``` -------------------------------- ### SecurityError Constructor Source: https://js.pawnote.docs.literate.ink/classes/SecurityError Initializes a new instance of the SecurityError class. ```APIDOC ## new SecurityError(authentication: any, identity: any, initialUsername?: string) ### Description Initializes a new instance of the SecurityError class. ### Method Constructor ### Parameters #### Path Parameters * **authentication** (any) - Required - The authentication details. * **identity** (any) - Required - The identity associated with the error. * **initialUsername** (string) - Optional - The initial username, if provided. ### Returns SecurityError ### Request Example ```json { "authentication": "some_auth_data", "identity": "user_id_123", "initialUsername": "testuser" } ``` ### Response #### Success Response (200) * **SecurityError** (object) - An instance of the SecurityError class. ```