Methods
_generateSlugName(str) → {String}
Generate a URL-friendly slug from a string
Parameters:
| Name | Type | Description |
|---|---|---|
str |
String | Source string |
- Source:
Returns:
Slug name
- Type
- String
(async) _getReviewTeams(reviewId) → {Promise.<Array>}
Get teams associated with a review
Parameters:
| Name | Type | Description |
|---|---|---|
reviewId |
String | Review ID |
- Source:
Returns:
Array of team objects
- Type
- Promise.<Array>
(async) _getTeamJoinRequests(teamId, withDetails) → {Promise.<Array.<Object>>}
Get team join requests
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
teamId |
String | Team ID |
|
withDetails |
Boolean | false | Whether to include user details |
- Source:
Returns:
Array of join request objects
- Type
- Promise.<Array.<Object>>
(async) _getTeamMembers(teamId) → {Promise.<Array.<User>>}
Get team members from join table
Parameters:
| Name | Type | Description |
|---|---|---|
teamId |
String | Team ID |
- Source:
Returns:
Array of user objects
- Type
- Promise.<Array.<User>>
(async) _getTeamModerators(teamId) → {Promise.<Array.<User>>}
Get team moderators from join table
Parameters:
| Name | Type | Description |
|---|---|---|
teamId |
String | Team ID |
- Source:
Returns:
Array of user objects
- Type
- Promise.<Array.<User>>
(async) _getTeamReviews(teamId, limit, offsetDate) → {Promise.<Object>}
Get team reviews with pagination
Parameters:
| Name | Type | Description |
|---|---|---|
teamId |
String | Team ID |
limit |
Number | Maximum number of reviews |
offsetDate |
Date | Date offset for pagination |
- Source:
Returns:
Object with reviews array and total count
- Type
- Promise.<Object>
_isValidURL(url) → {Boolean}
Validate URL format
Parameters:
| Name | Type | Description |
|---|---|---|
url |
String | URL to check |
- Source:
Throws:
-
if invalid
- Type
- ReportedError
Returns:
true if valid
- Type
- Boolean
_validateConfersPermissions(value) → {Boolean}
Validate confers_permissions object structure
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Object | Object to validate |
- Source:
Returns:
true if valid
- Type
- Boolean
_validateMetadata(metadata) → {Boolean}
Validate metadata JSONB structure
Parameters:
| Name | Type | Description |
|---|---|---|
metadata |
Object | Metadata object to validate |
- Source:
Returns:
true if valid
- Type
- Boolean
_validateTextHtmlObject(value) → {Boolean}
Validate text/html object structure for description and rules
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Object | Object to validate |
- Source:
Returns:
true if valid
- Type
- Boolean
(async) attachUserTeams(user) → {Promise.<void>}
Attach team membership and moderator data to the user instance
Parameters:
| Name | Type | Description |
|---|---|---|
user |
User | user instance to enrich with team data |
- Source:
Returns:
- Type
- Promise.<void>
buildInviteURL(invite) → {string|undefined}
Build the canonical registration URL for an invite link instance.
Parameters:
| Name | Type | Description |
|---|---|---|
invite |
Object | Invite link instance or plain object |
- Source:
Returns:
Fully qualified invite URL
- Type
- string | undefined
canonicalize(name) → {String}
Transform a user name to its canonical internal form (upper case), used for duplicate checking.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | name to transform |
- Source:
Returns:
canonical form
- Type
- String
(async) createBio(user, bioObj) → {User}
Associate a new bio text with a given user and save both
Parameters:
| Name | Type | Description |
|---|---|---|
user |
User | user object to associate the bio with |
bioObj |
Object | plain object with data conforming to UserMeta schema |
- Source:
Returns:
updated user
- Type
- User
(async) createReview(reviewObj, optionsopt) → {Review}
Create and save a review and the associated Thing and Teams.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
reviewObj |
Object | object containing the data to associate with this review |
||||||||||
options |
Object |
<optional> |
options for the created revision Properties
|
- Source:
Returns:
the saved review
- Type
- Review
(async) createUser(userObj) → {User}
Create a new user from an object containing the user data. Hashes the password, checks for uniqueness, validates. Saves.
Parameters:
| Name | Type | Description |
|---|---|---|
userObj |
Object | plain object containing data supported by this model |
- Source:
Throws:
-
if user exists, password is too short, or there are other validation problems.
- Type
- NewUserError
Returns:
the created user
- Type
- User
(async) ensureUnique(name) → {Boolean}
Throw if we already have a user with this name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | username to check |
- Source:
Throws:
-
if exists
- Type
- NewUserError
Returns:
true if unique
- Type
- Boolean
(async) fetchWithTimeout()
Helper utilities around Node 18+ native fetch.
- Source:
(async) findByURLName(name, optionsopt) → {User}
Find a user by the urldecoded URL name (spaces replaced with underscores)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
String | decoded URL name |
|||||||||||||||||
options |
Object |
<optional> |
query criteria Properties
|
- Source:
Throws:
-
if not found
- Type
- Error
Returns:
the matching user object
- Type
- User
(async) findOrCreateThing(reviewObj) → {Thing}
Locate the review subject (Thing) for a new review, or create and save a new Thing.
Parameters:
| Name | Type | Description |
|---|---|---|
reviewObj |
Object | the data associated with the review |
- Source:
Returns:
the located or created Thing
- Type
- Thing
(async) getAvailable(user) → {Promise.<Array.<Object>>}
Get pending invite links created by the given user.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
user |
Object | User whose pending invites to load Properties
|
- Source:
Returns:
Pending invite links, newest first
- Type
- Promise.<Array.<Object>>
(async) getFeed(optionsopt) → {Object}
Get an ordered array of reviews, optionally filtered by various criteria.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Feed selection criteria Properties
|
- Source:
Returns:
feed object with items and optional offsetDate
- Type
- Object
(async) getFileFeed(options) → {Promise.<Object>}
Get a feed of completed files with pagination
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Feed options Properties
|
- Source:
Returns:
Feed object with items and optional offsetDate
- Type
- Promise.<Object>
(async) getInviteByID(id) → {Promise.<Object>}
Fetch a single invite link by its identifier.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | Invite link identifier (UUID) |
- Source:
Throws:
-
When no invite with the provided id exists
- Type
- DocumentNotFound
Returns:
Invite link instance
- Type
- Promise.<Object>
getLabel(thing, language) → {String}
Get label for a given thing in the provided language, or fall back to a prettified URL.
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Thing | the thing object to get a label for |
language |
String | the language code of the preferred language |
- Source:
Returns:
the best available label
- Type
- String
(async) getPostgresBlogPostModel(dal)
Get the PostgreSQL BlogPost model (initialize if needed)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) getPostgresFileModel(dal)
Get the PostgreSQL File model (initialize if needed)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) getPostgresInviteLinkModel(dalopt) → {Promise.<(function()|null)>}
Obtain the PostgreSQL InviteLink model, initializing if necessary.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dal |
DataAccessLayer |
<optional> |
null | Optional DAL for testing |
- Source:
Returns:
Initialized model constructor or null
- Type
- Promise.<(function()|null)>
(async) getPostgresTeamSlugModel(dal)
Get the PostgreSQL TeamSlug model (initialize if needed)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) getPostgresThingSlugModel(dalopt)
Get the PostgreSQL ThingSlug model (initialize if needed)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dal |
DataAccessLayer | null |
<optional> |
null | Optional DAL instance for testing |
- Source:
(async) getPostgresUserMetaModel(dal) → {Promise.<(Model|null)>}
Retrieve the initialized UserMeta model, creating it if necessary
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
Returns:
UserMeta model or null if unavailable
- Type
- Promise.<(Model|null)>
getSourceIDsOfActiveSyncs() → {Array.<String>}
Get the identifiers of all sources for which relevant information is being fetched for this review subject.
- Source:
Returns:
array of the source IDs
- Type
- Array.<String>
(async) getStashedUpload(userID, name) → {Promise.<(File|undefined)>}
Get a stashed (incomplete) upload by user ID and name
Parameters:
| Name | Type | Description |
|---|---|---|
userID |
String | User ID who uploaded the file |
name |
String | File name |
- Source:
Returns:
File instance or undefined if not found
- Type
- Promise.<(File|undefined)>
getThingLabel(thing, locale) → {string}
Resolve a thing's display label in the current locale, with safe fallbacks.
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Object | Thing object or plain data used by the template |
locale |
string | Active locale for rendering |
- Source:
Returns:
Localized label, prettified URL, or an empty string
- Type
- string
(async) getUsed(user) → {Promise.<Array.<Object>>}
Get redeemed invite links created by the given user, including user info.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
user |
Object | User whose redeemed invites to load Properties
|
- Source:
Returns:
Redeemed invite links, newest first
- Type
- Promise.<Array.<Object>>
getValidLicenses() → {Array.<String>}
Get array of valid license values
- Source:
Returns:
Array of valid license strings
- Type
- Array.<String>
(async) getWithData(id) → {Review}
Get a review by ID, including commonly joined data.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | the unique ID to look up |
- Source:
Returns:
the review and associated data
- Type
- Review
(async) getWithData(id, optionsopt) → {Team}
Retrieve a team and some of the joined data like reviews or members
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
String | the team to look up |
|||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
query criteria Properties
|
- Source:
Returns:
team with joined data
- Type
- Team
(async) getWithData(id, optionsopt) → {Thing}
Get a Thing object by ID, plus some of the data linked to it.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
String | the unique ID of the Thing object |
|||||||||||||
options |
Object |
<optional> |
which data to include Properties
|
- Source:
Returns:
the Thing object
- Type
- Thing
(async) getWithTeams(id, options) → {Promise.<User>}
Obtain user and all associated teams
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
id |
String | user ID to look up |
||||||
options |
Object | query options Properties
|
- Source:
Returns:
user with associated teams
- Type
- Promise.<User>
(async) increaseInviteLinkCount(id) → {Number}
Increase the invite link count by 1 for a given user
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | unique ID of the user |
- Source:
Returns:
updated invite count
- Type
- Number
(async) initializeBlogPostModel(dal)
Initialize the PostgreSQL BlogPost model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeFileModel(dal)
Initialize the PostgreSQL File model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeInviteLinkModel(dal)
Initialize the PostgreSQL InviteLink model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeReviewModel(dal)
Initialize the PostgreSQL Review model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeTeamJoinRequestModel(dal)
Initialize the PostgreSQL TeamJoinRequest model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeTeamModel(dal)
Initialize the PostgreSQL Team model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeTeamSlugModel(dal)
Initialize the PostgreSQL TeamSlug model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeThingModel(dal)
Initialize the PostgreSQL Thing model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeThingSlugModel(dal)
Initialize the PostgreSQL ThingSlug model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) initializeUserMetaModel(dal) → {Promise.<(Model|null)>}
Initialize the PostgreSQL UserMeta model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
Returns:
Initialized model or null if DAL unavailable
- Type
- Promise.<(Model|null)>
(async) initializeUserModel(dal)
Initialize the PostgreSQL User model
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dal |
DataAccessLayer | null | Optional DAL instance for testing |
- Source:
(async) lookupByURL(url, userIDopt) → {Promise.<Array.<Thing>>}
Find a Thing object using a URL. May return multiple matches (but ordinarily should not).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
url |
String | the URL to look up |
|
userID |
String |
<optional> |
include any review(s) of this thing by the given user |
- Source:
Returns:
array of matching things
- Type
- Promise.<Array.<Thing>>
normalizeInviteInstance(invite) → {Object}
Normalize fields on a hydrated invite link instance.
Parameters:
| Name | Type | Description |
|---|---|---|
invite |
Object | Invite link instance |
- Source:
Returns:
The normalized invite instance
- Type
- Object
validateSocialImage(optionsopt)
Ensure that the social media image specified for this review is associated with the review subject or in the list of newly uploaded files.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Validation data Properties
|
- Source: