npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anonymous-student

v1.1.2

Published

Anonymous student is used to retrieve and save information from our website users.

Downloads

2

Readme

Anonymous-Student

Anonymous student is a client which can be used to save and retrieve information about the student whether the user is logged in or not. This application also implements caching of data to reduce the number of requests made to the StudentAPI. The client is available by subscribing to the AnonymousStudentServiceReady event using the EventAggregationService, please refer to Events for more details.

Table of contents

Usage

All AnonymousStudent interfaces can be installed using

npm install @studyportals/anonymous-student-interfaces

Interface

import { Actor, IStudent, StudentField } from '@studyportals/studentdomain';

interface IAnonymousStudent {
    setStudentData(studentData: IStudent, Actor?: Actor): Promise<void>;
    getStudentData(studentFields: StudentField[]): Promise<IStudent>;
    getStudentDataCompleteness(studentFields: StudentField[]): Promise<number>;
    addDisciplines(ids: number[]): Promise<void>;
    removeDisciplines(ids: number[]): Promise<void>;
    addInterest(type: InterestType, ids: number[]): Promise<void>;
    removeInterest(type: InterestType, ids: number[]): Promise<void>;
    setName(name: string): Promise<void>;
    setGPA(grade_type: string, grade_value: any): Promise<void>;
}

States

The anonymous student application has multiple states which each handle the retrieval and save requests differently.

Pending
In this state, the application does not yet know if the user is logged in or not. To handle this the "Pending" state keeps all request open until it knows if the user is logged in or not. After this, the requests are resolved.

Online
This is the state where the user is logged in. The data will first try to retrieve data from the local cache. If that data is not saved in the local cache (LocalStorage) than it will retrieve data from the student system.

Offline
This state is active whenever the user is not logged in. The data saved will be stored in local storage until the user logs in. When the user logs in, the data is synced to the Online state. After syncing the AnonymousStudentProfileSynced is triggered.

State synchronization

Whenever a new session is created application state will change from Online to Offline. As part of this state change any previously saved data in the Offline state will be synced to the Online state. This will follow the following rules:

Sync state flow

Events

AnonymousStudentServiceReady is triggered when the Anonymous Student Service is ready. A ready-for-use instance of the service is provided as a property of the event. This event has following interface:

interface AnonymousStudentServiceReady {
    static EventType: string;
	eventType: string;

    timestamp: Date;
    anonymousStudentService: IAnonymousStudentService;
}

AnonymousStudentProfileSynced is triggered when information has been synced from the Offline state to the Online state.

interface AnonymousStudentProfileSynced {
    static EventType: string;
	eventType: string;

    timestamp: Date;
    state: StudentRepositoryStateType;
}

AnonymousStudentProfileUpdated is triggered when student information has been updated. This event has following interface:

import { IStudent } from '@studyportals/studentdomain';

interface AnonymousStudentProfileUpdated {
    static EventType: string;
	eventType: string;

    timestamp: Date;
    state: StudentRepositoryStateType;
    changes: IStudent;
}

AnonymousStudentStateChanged is triggered when anonymous student changes its state:

import { StudentRepositoryStateType } from '@studyportals/studentdomain';

interface AnonymousStudentStateChanged {
    static EventType: string;
	eventType: string;

    timestamp: Date;
    oldState: StudentRepositoryStateType;
    newState: StudentRepositoryStateType;
}

Dependencies

EventAggregationService

The above events can be listened to by using the EventAggregationService. Refer to the EventAggregationService documentation for more information on subscribing to domain events.

SessionService

The AnonymousStudent service depends on the SessionService being available. Refer to the SessionService documentation for more information.

StudentDomain

A number of domain interfaces and enums in the Student domain are required for this service. Refer to StudentDomain documentation for more information.