0.26.5 • Published 3 years ago

resolve-module-comments v0.26.5

Weekly downloads
690
License
MIT
Repository
github
Last release
3 years ago

resolve-module-comments

npm version

Usage

import { merge } from 'resolve-scripts'
import createModuleComments from 'resolve-module-comments'

merge(
  resolveConfig,
  createModuleComments()
)

Customization of module options

import { merge } from 'resolve-scripts'
import createModuleComments from 'resolve-module-comments'

merge(
  resolveConfig,
  createModuleComments({
    aggregateName: 'CustomCommentsAggregateName', // default = 'Comments'
    readModelName: 'CustomCommentsReadModelName', // default = 'Comments'
    readModelConnector: {
      module: 'CustomreadModelConnector', // default = resolve-readmodel-lite'
      options: {}                       // default = {}
    },
    commentsTableName: 'CustomCommentsTableName', // default = 'Comments'
    reducerName: 'CustomReducerName',             // default = 'comments'
    eventTypes: {
      COMMENT_CREATED: 'CUSTOM_COMMENT_CREATED', // default = 'COMMENT_CREATED'
      COMMENT_UPDATED: 'CUSTOM_COMMENT_UPDATED', // default = 'COMMENT_UPDATED'
      COMMENT_REMOVED: 'CUSTOM_COMMENT_REMOVED'  // default = 'COMMENT_REMOVED'
    },
    commandTypes: {
      createComment: 'customCreateComment', // default = 'createComment'
      updateComment: 'customUpdateComment', // default = 'updateComment'
      removeComment: 'customRemoveComment', // default = 'removeComment'
    },
    resolverNames: {
      commentsTree: 'customCommentsTree',                 // default = 'commentsTree',
      foreignCommentsCount: 'customForeignCommentsCount', // default = 'foreignCommentsCount',
      allCommentsPaginate: 'customAllCommentsPaginate',   // default = 'allCommentsPaginate'
    },
    maxNestedLevel: 2,                                            // default = undefined
    verifyCommand: path.join(__dirname, 'customVerifyCommand.js') // default = 'resolve-module-comments/lib/aggregates/verify-command.js'
  })
)

Customization of verifyCommand

// customVerifyCommand.js

const verifyCommand = async (state, command, jwtToken) => {
  // ...
}

export default verifyCommand

Analytics

Commands

createComment(aggregateId, {
  authorId,
  commentId
  parentCommentId,
  content
})

updateComment(aggregateId, {
  authorId,
  commentId
  content
})

removeComment(aggregateId, {
  authorId,
  commentId
})

Renderless Connectors

import React from 'react'

import {
  CommentsTreeRenderless,
  CommentsPaginateRenderless,
  CommentsNotificationRenderless,
  RefreshHelperRenderless
} from 'resolve-module-comments'

export const CommentsTree = (props) =>
  <CommentsTreeRenderless
    treeId="treeId"
    parentCommentId="parentCommentId"
    authorId="authorId"
  >
    {({ comments, createComment, renameComment, removeComment }) => {
      // eslint-disable-next-line
      console.log('comments:', comments)
      return null
    }}
  </CommentsTreeRenderless>

export const CommentsPaginate = ({ itemsOnPage }) => 
  <CommentsPaginateRenderless
    itemsOnPage
    pageNumber
    readModelName="customReadModelName"      // default = 'readModelName'
    resolverName="customAllCommentsPaginate" // default = 'allCommentsPaginate'
  >
    {({ pageNumber, comments }) => {
      // eslint-disable-next-line
      console.log(
        `comments (pageNumber: ${pageNumber}, itemsOnPage: ${itemsOnPage}):`,
        comments
      )
      return null
    }}
  </CommentsPaginateRenderless>

export const CommentsNotification = (props) =>
  <CommentsNotificationRenderless
    treeId="treeId"
    parentCommentId="parentCommentId"
    authorId="authorId"
    readModelName="customReadModelName" // default = 'readModelName'
    resolverName="customResolverName"   // default = 'foreignCommentsCount'
    {...props}
  >
    {({ count, onClick }) => {
      if(count === 0) return null
      return (
        <div onClick={onClick}>
          Comments had been updated - refresh page to see them
        </div>
      )
    }}
  </CommentsNotificationRenderless>

export const RefreshHelper = () =>
  <RefreshHelperRenderless>
    {({ refreshId, refresh }) => (
      <div onClick={refresh}>
        {refreshId}
      </div>
    )}
  </RefreshHelperRenderless>
0.27.15-alpha

3 years ago

0.27.14-alpha

3 years ago

0.27.12-alpha

3 years ago

0.27.11-alpha

3 years ago

0.27.10-alpha

3 years ago

0.27.9-alpha

3 years ago

0.27.8-alpha

3 years ago

0.27.7-alpha

3 years ago

0.27.6-alpha

3 years ago

0.27.5-alpha

3 years ago

0.27.4-alpha

3 years ago

0.27.3-alpha

3 years ago

0.26.5

3 years ago

0.27.2-alpha

3 years ago

0.27.0-alpha

3 years ago

0.26.4

3 years ago

0.26.3

3 years ago

0.26.2

3 years ago

0.26.1

3 years ago

0.26.0

3 years ago

0.25.18

3 years ago

0.25.17

4 years ago

0.25.16

4 years ago

0.25.15

4 years ago

0.25.14

4 years ago

0.25.13

4 years ago

0.25.12

4 years ago

0.25.11

4 years ago

0.25.10

4 years ago

0.25.9

4 years ago

0.25.8

4 years ago

0.25.7

4 years ago

0.25.6

4 years ago

0.25.5

4 years ago

0.25.4

4 years ago

0.25.3

4 years ago

0.25.2

4 years ago

0.25.1

4 years ago

0.25.0

4 years ago

0.24.23

4 years ago

0.24.22

4 years ago

0.24.21

4 years ago

0.24.20

4 years ago

0.24.19

4 years ago

0.24.18

4 years ago

0.24.17

4 years ago

0.24.16

4 years ago

0.24.15

4 years ago

0.24.14

4 years ago

0.24.13

4 years ago

0.24.12

4 years ago

0.24.11

4 years ago

0.24.10

4 years ago

0.24.9

4 years ago

0.24.8

4 years ago

0.24.7

4 years ago

0.24.6

4 years ago

0.24.5

4 years ago

0.24.4

4 years ago

0.24.3-alpha.0

4 years ago

0.24.3

4 years ago

0.24.2

4 years ago

0.24.0

4 years ago

0.23.2

4 years ago

0.23.1

4 years ago

0.23.0

4 years ago

0.22.15

4 years ago

0.22.14

4 years ago

0.22.12

4 years ago

0.22.13

4 years ago

0.22.11

4 years ago

0.22.10

4 years ago

0.22.9

4 years ago

0.22.8

4 years ago

0.22.7

4 years ago

0.22.6

4 years ago

0.22.5

4 years ago

0.22.4

4 years ago

0.22.3

4 years ago

0.22.2

4 years ago

0.22.1

4 years ago

0.22.0

4 years ago

0.21.15

4 years ago

0.21.14

4 years ago

0.21.13

4 years ago

0.21.12

4 years ago

0.21.11

4 years ago

0.21.10

4 years ago

0.21.9

4 years ago

0.21.8

4 years ago

0.21.7

4 years ago

0.21.6

4 years ago

0.21.5

4 years ago

0.21.4

4 years ago

0.21.3

4 years ago

0.21.2

4 years ago

0.21.0-alpha.15

4 years ago

0.21.0

4 years ago

0.21.0-alpha.6

4 years ago

0.21.0-alpha.5

4 years ago

0.21.0-alpha.3

4 years ago

0.21.0-alpha.2

4 years ago

0.21.0-alpha.1

4 years ago

0.21.0-alpha.0

4 years ago

0.20.29

4 years ago

0.20.28

5 years ago

0.20.27

5 years ago

0.20.26

5 years ago

0.20.25

5 years ago

0.20.24

5 years ago

0.20.23

5 years ago

0.20.22

5 years ago

0.20.21

5 years ago

0.20.20

5 years ago

0.20.19

5 years ago

0.20.18

5 years ago

0.20.17

5 years ago

0.20.16

5 years ago

0.20.15

5 years ago

0.20.14

5 years ago

0.20.13

5 years ago

0.20.12

5 years ago

0.20.11

5 years ago

0.20.10

5 years ago

0.20.9

5 years ago

0.20.8

5 years ago

0.20.7

5 years ago

0.20.6

5 years ago

0.20.5

5 years ago

0.20.4

5 years ago

0.20.3

5 years ago

0.20.2

5 years ago

0.20.1

5 years ago

0.20.0

5 years ago

0.19.8

5 years ago

0.19.7

5 years ago

0.19.6

5 years ago

0.19.5

5 years ago

0.19.4

5 years ago

0.19.3

5 years ago

0.19.2

5 years ago

0.19.1

5 years ago

0.19.0

5 years ago

0.18.17

5 years ago

0.18.16

5 years ago

0.18.15

5 years ago

0.18.14

5 years ago

0.18.13

5 years ago

0.18.12

5 years ago

0.18.11

5 years ago

0.18.10

5 years ago

0.18.9

5 years ago

0.18.8

5 years ago

0.18.7

5 years ago

0.18.6

5 years ago

0.18.5

5 years ago

0.18.4

5 years ago

0.18.3

5 years ago

0.18.2

5 years ago

0.18.1

5 years ago

0.18.0

5 years ago