Global

Members

(constant) ENCRYPTION_KEY

How this encryption key was generated 👇

.

How this encryption key was generated 👇

Source:
Example
import crypto from "crypto";

crypto.randomBytes(32).toString('hex');

(constant) cookiePolicyMap

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

Source:

(constant) privacyPolicyMap

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

Source:

(constant) termsAndConditionsMap

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

TODO: Evaluate if it's best to break these components into JSONs so we can have a single components pointing to the translations.

Source:

Methods

Editor()

The editor which is used to create the annotation.

The editor which is used to create the annotation. Supports formatting.

Source:

Navigation items are organized by usage order (data from G.A.)

.

Navigation items are organized by usage order (data from G.A.)

Source:

addMissingAICommentData()

Source:

addMissingWordFreqData()

Source:

connectToDatabase()

Connects to the database and returns the database object.

Connects to the database and returns the database object. Uses exponential backoff to retry the connection if it fails.

Source:

cosineSimilarity(vecA, vecB) → {number}

Function to calculate cosine similarity between two vectors

.

Function to calculate cosine similarity between two vectors

Parameters:
Name Type Description
vecA object

first vector

vecB object

second vector

Source:
Returns:

cosine similarity between the two vectors

Type
number

cosineSimilarityScore(seq1, seq2) → {number}

Function to calculate cosine similarity score between two strings

.

Function to calculate cosine similarity score between two strings

Parameters:
Name Type Description
seq1 string

first sequence

seq2 string

second sequence

Source:
Returns:

cosine similarity score

Type
number

createComment(data) → {Promise.<{insertedId: string}>}

This method is responsible for creating a comment.

This method is responsible for creating a comment. It also creates an inbox message for the post owner. If the post owner is the same as the user, no inbox message is created. It has a special case for the AI user, which is a bot that creates comments. The AI user doesn't have a database object, so it skips getting the user's database object.

Parameters:
Name Type Description
data object

The data object

Properties
Name Type Description
comment string

The comment text

postId string

The post ID

session object

The session object

Properties
Name Type Description
user object

The user object

Properties
Name Type Description
name string

The user's name

email string

The user's email

image string

The user's image

Source:
Returns:
Type
Promise.<{insertedId: string}>

createPost()

Method responsible for creating a post.

Method responsible for creating a post. It encrypts the post if it's private. It generates insights from the post text (word frequency and character count).

This method is only called from the frontend the first time a post is synced. The subsequent times, the post is updated.

Source:

deleteAccount(userEmail) → {Promise.<{success: boolean}>}

Method responsible for deleting a user's account.

Method responsible for deleting a user's account. This method is called when a user deletes their account. It deletes all dreams, comments and stars related to the user, and the user's account.

Parameters:
Name Type Description
userEmail string

The user's email

Source:
Returns:
Type
Promise.<{success: boolean}>

deleteAllInboxMessages()

Deletes all inbox messages.

Deletes all inbox messages.

Source:

deleteComment(commentId, postId) → {Promise.<any>}

This method is responsible for deleting a comment from a post.

This method is responsible for deleting a comment from a post. It also deletes the inbox message for the post owner.

Parameters:
Name Type Description
commentId string

The comment ID

postId string

The post ID

Source:
Returns:
Type
Promise.<any>

deletePost(postId) → {Promise.<{success: boolean}>}

Method responsible for deleting a post

.

Method responsible for deleting a post

Parameters:
Name Type Description
postId string

The post id

Source:
Returns:
Type
Promise.<{success: boolean}>

deleteSomeInboxMessages()

Deletes the inbox messages with the provided IDs.

Deletes the inbox messages with the provided IDs.

Source:

dotProduct(vecA, vecB) → {number}

Function to calculate the dot product of two vectors

.

Function to calculate the dot product of two vectors

Parameters:
Name Type Description
vecA object

first vector

vecB object

second vector

Source:
Returns:

dot product of the two vectors

Type
number

generateUrlLoc(pages)

Generates an XML URL loc

.

Generates an XML URL loc

Parameters:
Name Type Description
pages Array.<string>

The set of filenames under the pages folder.

Source:

getAccountsCollection()

Connects to the database and gets the users collection.

Connects to the database and gets the users collection. This collection is automatically generated by next-auth

Source:

getAuthProps()

Must be used on every authenticated page

.

Must be used on every authenticated page

Source:
Example
export default function Page(props) {
  const { serverSession } = props;

  if (serverSession?.user) {
    return <Authenticated serverSession={serverSession} />;
  }

  return <NotAuthenticated/>;
}

export async function getServerSideProps(context) {
   return getAuthProps(context);
}

getCommandOptionValue()

Get the value from the option passed into the command.

Get the value from the option passed into the command.

Source:

getCommentById(commentId)

Gets a comment on a publication by its id

.

Gets a comment on a publication by its id

Parameters:
Name Type Description
commentId string

The comment id

Source:

getComments(postId)

Gets all the comments from a publication

.

Gets all the comments from a publication

Parameters:
Name Type Description
postId string
Source:

getCommentsByUserId(userId)

Gets all the comments from a user

.

Gets all the comments from a user

Parameters:
Name Type Description
userId string
Source:

getCommentsCollection()

Connects to the database and gets the comments collection.

Connects to the database and gets the comments collection.

Source:

getCompletionsCollection()

Connects to the database and gets the completions collection.

Connects to the database and gets the completions collection.

Source:

getCosineSimilarityCollection()

Connects to the database and gets the cosine_similarity collection.

Connects to the database and gets the cosine_similarity collection. This collections is never read from (on this codebase), only written to. It is used to store the results of the cosine similarity score between post texts, which help evolve the platform.

Source:

getInbox(userEmail)

Gets the inbox data of a user

.

Gets the inbox data of a user

Parameters:
Name Type Description
userEmail string

The user email

Source:

getInboxCollection()

Connects to the database and gets the inbox collection.

Connects to the database and gets the inbox collection.

Source:

getInboxCount(userEmail)

Gets the count of unread messages in the inbox

.

Gets the count of unread messages in the inbox

Parameters:
Name Type Description
userEmail string

The user email

Source:

getLatestPublicPosts()

Gets the latest public posts from a user

.

Gets the latest public posts from a user

Source:

getMongoClient()

Gets and resolves the MongoDB client promise.

Gets and resolves the MongoDB client promise.

Source:

getPostById(postId)

Get a post by its id and optionally filter the results

.

Get a post by its id and optionally filter the results

Parameters:
Name Type Description
postId string

The post id

Source:

getPosts(userEmail)

Get all the posts from a user

.

Get all the posts from a user

Parameters:
Name Type Description
userEmail string

The user email

Source:

getPostsCollection()

Connects to the database and gets the posts collection.

Connects to the database and gets the posts collection.

Source:

getPostsInsights(userEmail)

Gets the insights from the posts of a user

.

Gets the insights from the posts of a user

Parameters:
Name Type Description
userEmail string

The user email

Source:

getShortcutString()

Get a normalized shortcut as a string.

Get a normalized shortcut as a string.

Source:

getStar(userEmail, postId)

Gets a star from a specific publication by its id

.

Gets a star from a specific publication by its id

Parameters:
Name Type Description
userEmail string

The user email

postId string

The publication id

Source:

getStarredPosts(userEmail)

Gets all the starred posts from a user

.

Gets all the starred posts from a user

Parameters:
Name Type Description
userEmail string

The user email

Source:

getStarsByUserEmail(userEmail)

Gets all the stars from a user

.

Gets all the stars from a user

Parameters:
Name Type Description
userEmail string

The user email

Source:

getStarsCollection()

Connects to the database and gets the stars collection.

Connects to the database and gets the stars collection.

Source:

getUiShortcutString()

Get the string value from the available UI Shortcut.

Get the string value from the available UI Shortcut.

Source:

getUserByEmail(userEmail)

Gets an user by its email

.

Gets an user by its email

Parameters:
Name Type Description
userEmail string

The user email

Source:

getUserById(userId)

Gets an user by its id

.

Gets an user by its id

Parameters:
Name Type Description
userId userId

The user id

Source:

getUsersCollection()

Connects to the database and gets the users collection.

Connects to the database and gets the users collection. This collection is automatically generated by next-auth

Source:

hasAiCommentedOnPost(postId) → {Promise.<boolean>}

Checks if the AI has commented on a post

.

Checks if the AI has commented on a post

Parameters:
Name Type Description
postId string

The post id

Source:
Returns:
Type
Promise.<boolean>

hasCommentedOnPost(userName, postId) → {Promise.<boolean>}

Checks whether a user has commented on a post or not

.

Checks whether a user has commented on a post or not

Parameters:
Name Type Description
userName string

The user name

postId string

The post id

Source:
Returns:
Type
Promise.<boolean>

hitChiron()

Hit Chiron with data for AI training.

Hit Chiron with data for AI training. Starts a Human in the Loop workflow.

Source:

isStringArray()

Checks whether the first element in an array is a string and assumes the whole array is a string array.

Checks whether the first element in an array is a string and assumes the whole array is a string array.

Source:

magnitude(vec) → {number}

Function to calculate the magnitude of a vector

.

Function to calculate the magnitude of a vector

Parameters:
Name Type Description
vec object

vector

Source:
Returns:

magnitude of the vector

Type
number

markAllInboxMessagesAsRead()

Marks all inbox messages as read.

Marks all inbox messages as read.

Source:

markSomeInboxMessagesAsRead()

Marks some inbox messages as read.

Marks some inbox messages as read.

Source:

module:pages()

The home page and landing page.

The home page and landing page. This page is only accessible for logged out users.

Source:

module:pages/api/auth/error()

This page is shown when the user encounters an error while signing up or signing in.

This page is shown when the user encounters an error while signing up or signing in.

Source:

module:pages/api/auth/signin(props)

Sign in page.

Sign in page. This page shows the user a sign in form. The user can sign in with their email or with a third-party provider. The user can also sign up seamlessly on this page.

Parameters:
Name Type Description
props Object

The props this component gets from getServerSideProps

Source:

module:pages/dreams(props)

The home page for logged in users.

The home page for logged in users. This page shows a feed with the latest public dreams.

Parameters:
Name Type Description
props Object

The props this component gets from getServerSideProps

Source:

module:pages/dreams/:dreamId(props)

Dream page.

Dream page. This page shows a user's dream.

Parameters:
Name Type Description
props Object

The props this component gets from getServerSideProps

Source:

module:pages/publish/:postId(props)

The page for editing a dream.

The page for editing a dream. This page is only accessible for logged in users. This page is used for creating dreams. Once the dream is synced to the cloud, it redirects the user to another page that looks exactly the same as this, which is used for editing dreams.

Parameters:
Name Type Description
props Object

The props this component gets from getServerSideProps

Source:

searchPosts(query)

Fuzzy searches posts from all users given a query

.

Fuzzy searches posts from all users given a query

Parameters:
Name Type Description
query string
Source:

starPost(data) → {Promise.<{insertedId: string}>}

This method is responsible for starring a post.

This method is responsible for starring a post. It also creates an inbox message for the post owner. If the post owner is the same as the user, no inbox message is created.

Parameters:
Name Type Description
data object

The data object

Properties
Name Type Description
postId string

The post ID

session object

The session object

Properties
Name Type Description
user object

The user object

Properties
Name Type Description
name string

The user's name

email string

The user's email

image string

The user's image

Source:
Returns:
Type
Promise.<{insertedId: string}>

text()

Email Text body (fallback for email clients that don't render HTML, e.g.

Email Text body (fallback for email clients that don't render HTML, e.g. feature phones)

Source:

textToFreqMap(text) → {object}

Function to convert text to a frequency map

.

Function to convert text to a frequency map

Parameters:
Name Type Description
text string

text to be converted

Source:
Returns:

frequency map of the text

Type
object

unstarPost()

This method is responsible for unstarring a post.

This method is responsible for unstarring a post.

Source:

updatePost()

Updates a post, auto-saving it.

Updates a post, auto-saving it. It encrypts the post if it's private before updating it. It also updates insights from the post text (word frequency and character count).

Source:

updatePostVisibility(postId, visibility, userEmail) → {Promise.<{success: boolean}>}

Method responsible for updating a dream's visibility.

Method responsible for updating a dream's visibility. In case a dream is going from public to private and doesn't have an AI input, it also generates one.

Parameters:
Name Type Description
postId string

The dream's ID

visibility string

"public" or "private"

userEmail string

The dream owner user's email

Source:
Returns:
Type
Promise.<{success: boolean}>

updateUser(data) → {Promise.<boolean>}

Updates the user's data.

Updates the user's data.

Parameters:
Name Type Description
data object
Source:
Returns:
Type
Promise.<boolean>

updateUser(userId, data)

Updates a user's account with the provided data.

Updates a user's account with the provided data.

Parameters:
Name Type Description
userId string
data object
Source: