SudoSOS Back-end API / service/terms-of-service-service / TermsOfServiceService
Class: TermsOfServiceService ​
Constructors ​
Constructor ​
new TermsOfServiceService(): TermsOfServiceService;Returns ​
TermsOfServiceService
Methods ​
asTermsOfServiceResponse() ​
static asTermsOfServiceResponse(tos): TermsOfServiceResponse;Convert a TermsOfService data object to a TermsOfServiceResponse.
Parameters ​
| Parameter | Type |
|---|---|
tos | TermsOfService |
Returns ​
getAcceptances() ​
static getAcceptances(userId): Promise<TermsOfServiceAcceptance[]>;Get all TOS acceptance records of a user, ordered by acceptance date.
Parameters ​
| Parameter | Type |
|---|---|
userId | number |
Returns ​
Promise<TermsOfServiceAcceptance[]>
getCurrentVersion() ​
static getCurrentVersion(): Promise<string>;Get the current TOS version (highest version number). Throws an error if no TOS files exist.
Returns ​
Promise<string>
getLatestTermsOfService() ​
static getLatestTermsOfService(): Promise<TermsOfService>;Get the latest TOS revision (highest version number). Throws an error if no TOS files exist.
Returns ​
Promise<TermsOfService>
getTermsOfService() ​
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 ​
| Parameter | Type |
|---|---|
version | string |
Returns ​
Promise<TermsOfService>
getUsersTosStatus() ​
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 ​
| Parameter | Type | Description |
|---|---|---|
users | Pick<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() ​
static getUserTosStatus(user): Promise<TermsOfServiceStatus>;Derive the TOS status of a user from their acceptance records against the current TOS version.
Parameters ​
| Parameter | Type |
|---|---|
user | Pick<User, "id" | "tosRequired"> |
Returns ​
Promise<TermsOfServiceStatus>
haveUsersAcceptedCurrent() ​
static haveUsersAcceptedCurrent(users, manager?): Promise<boolean>;Whether all given users that are required to accept the TOS have accepted the current version.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
users | Pick<User, "id" | "tosRequired">[] | The users to check. |
manager? | EntityManager | Optional entity manager to read within a specific transaction. Defaults to the global manager when omitted. |
Returns ​
Promise<boolean>
listVersions() ​
static listVersions(): Promise<string[]>;List all available TOS versions, sorted ascending by version number.
Returns ​
Promise<string[]>
resetVersionCache() ​
static resetVersionCache(): void;Clear the ToS version cache, used for testing.
Returns ​
void