Skip to content

SudoSOS Back-end API / service/terms-of-service-service / TermsOfServiceService

Class: TermsOfServiceService ​

Constructors ​

Constructor ​

ts
new TermsOfServiceService(): TermsOfServiceService;

Returns ​

TermsOfServiceService

Methods ​

asTermsOfServiceResponse() ​

ts
static asTermsOfServiceResponse(tos): TermsOfServiceResponse;

Convert a TermsOfService data object to a TermsOfServiceResponse.

Parameters ​

ParameterType
tosTermsOfService

Returns ​

TermsOfServiceResponse


getAcceptances() ​

ts
static getAcceptances(userId): Promise<TermsOfServiceAcceptance[]>;

Get all TOS acceptance records of a user, ordered by acceptance date.

Parameters ​

ParameterType
userIdnumber

Returns ​

Promise<TermsOfServiceAcceptance[]>


getCurrentVersion() ​

ts
static getCurrentVersion(): Promise<string>;

Get the current TOS version (highest version number). Throws an error if no TOS files exist.

Returns ​

Promise<string>


getLatestTermsOfService() ​

ts
static getLatestTermsOfService(): Promise<TermsOfService>;

Get the latest TOS revision (highest version number). Throws an error if no TOS files exist.

Returns ​

Promise<TermsOfService>


getTermsOfService() ​

ts
static getTermsOfService(version): Promise<TermsOfService>;

Get a specific TOS revision by version string (e.g. "1.0"). Throws an error if the version does not exist.

Parameters ​

ParameterType
versionstring

Returns ​

Promise<TermsOfService>


getUsersTosStatus() ​

ts
static getUsersTosStatus(users): Promise<Map<number, TermsOfServiceStatus>>;

Compute the TOS status of each given user against the current version. Uses a single acceptance lookup for all users, so it is safe to call on paginated lists without incurring a query per user.

Parameters ​

ParameterTypeDescription
usersPick<User, "id" | "tosRequired">[]The users to compute the status for.

Returns ​

Promise<Map<number, TermsOfServiceStatus>>

A map from user id to their computed TermsOfServiceStatus.


getUserTosStatus() ​

ts
static getUserTosStatus(user): Promise<TermsOfServiceStatus>;

Derive the TOS status of a user from their acceptance records against the current TOS version.

Parameters ​

ParameterType
userPick<User, "id" | "tosRequired">

Returns ​

Promise<TermsOfServiceStatus>


haveUsersAcceptedCurrent() ​

ts
static haveUsersAcceptedCurrent(users, manager?): Promise<boolean>;

Whether all given users that are required to accept the TOS have accepted the current version.

Parameters ​

ParameterTypeDescription
usersPick<User, "id" | "tosRequired">[]The users to check.
manager?EntityManagerOptional entity manager to read within a specific transaction. Defaults to the global manager when omitted.

Returns ​

Promise<boolean>


listVersions() ​

ts
static listVersions(): Promise<string[]>;

List all available TOS versions, sorted ascending by version number.

Returns ​

Promise<string[]>


resetVersionCache() ​

ts
static resetVersionCache(): void;

Clear the ToS version cache, used for testing.

Returns ​

void