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');

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:

completionsReviewHandler()

This endpoint is hit by Chiron after a review is completed.

This endpoint is hit by Chiron after a review is completed. To learn more about Chiron, visit:

Source:

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 dream owner. If the dream 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

dreamId string

The dream 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}>

createDream()

Source:
To Do:
  • document this

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()

Source:
To Do:
  • document this

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

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

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

Parameters:
Name Type Description
commentId string

The comment ID

dreamId string

The dream ID

Source:
Returns:
Type
Promise.<any>

deleteDream(dreamId) → {Promise.<{success: boolean}>}

Method responsible for deleting a dream.

Method responsible for deleting a dream.

Parameters:
Name Type Description
dreamId string

The dream's ID

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

deleteSomeInboxMessages()

Source:
To Do:
  • document this

generateCompletion(dreamId, text, session, userId)

Starts the completion generation process, which is followed by a human-in-the-loop review process until it gets back to this service

session and userId params are optional because this method has two possible workflows, one using the session and the other using the userIds.

Starts the completion generation process, which is followed by a human-in-the-loop review process until it gets back to this service

session and userId params are optional because this method has two possible workflows, one using the session and the other using the userIds. The session workflow starts on the frontend, while the userId workflow starts on the backend.

This is this way because saveCompletions method is, and this method calls it.

Parameters:
Name Type Description
dreamId string

The dream id

text string

The dream data text

session object

(Optional) The session object. If not provided, the userId must be provided.

userId string

(Optional) The user id. If not provided, the session must be provided.

Source:

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()

This collection is automatically generated by next-auth

.

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:

getDreamById(dreamId)

Get a dream by its id and optionally filter the results

.

Get a dream by its id and optionally filter the results

Parameters:
Name Type Description
dreamId string

The dream id

Source:

getLatestPublicDreams()

Source:

getShortcutString()

Get a normalized shortcut as a string.

Get a normalized shortcut as a string.

Source:

getUiShortcutString()

Get the string value from the available UI Shortcut.

Get the string value from the available UI Shortcut.

Source:

getUserByEmail()

Source:

getUserById()

Source:

getUsersCollection()

This collection is automatically generated by next-auth

.

This collection is automatically generated by next-auth

Source:

hasAiCommentedOnDream(dreamId)

Checks if the AI has commented on a dream

.

Checks if the AI has commented on a dream

Parameters:
Name Type Description
dreamId string
Source:
To Do:
  • Make it more efficient by using a single query

hitChiron()

Hit Chiron with data for AI training.

Hit Chiron with data for AI training. What is Chiron? Read below 👇

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:

markAllInboxMessagesAsRead()

Source:
To Do:
  • document this

markSomeInboxMessagesAsRead()

Source:
To Do:
  • document this

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:

saveCompletion(completion, dreamId, userEmail, userId)

Saves a completion to the database

.

Saves a completion to the database

Parameters:
Name Type Description
completion *
dreamId *
userEmail *
userId *
Source:

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

This method is responsible for starring a dream.

This method is responsible for starring a dream. It also creates an inbox message for the dream owner. If the dream 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
dreamId string

The dream 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:

unstarDream()

Source:
To Do:
  • document this

updateDream()

Source:
To Do:
  • document this

updateDreamVisibility(dreamId, 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
dreamId string

The dream's ID

visibility string

"public" or "private"

userEmail string

The dream owner user's email

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