npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@autoinvent/conveyor-redux

v0.6.4

Published

Generates reducers and epics for use with conveyor

Downloads

39

Readme

conveyor-redux

npm version

A JavaScript Redux implementation of the state and actions needed by conveyor

Docs

View the docs here

Installation

With yarn:

yarn add @autoinvent/conveyor-redux

With npm:

npm install --save @autoinvent/conveyor-redux

Usage:

To generate the reducer to be used by conveyor:

  • Note: The key MUST be conveyor.
import { makeConveyorReducer } from 'conveyor-redux'

const rootReducer = combineReducers({
  conveyor: makeConveyorReducer(schema, config, overrides),
  ...otherReducers
})

Where schema is the same schema used for conveyor (a 'SchemaBuilder' type object created with conveyor-schema), config is a user-defined object for customization, and overrides is an map object which maps a reducer slice name (key) to a reducer (value).

To generate the epic to be used by conveyor:

import { makeConveyorEpic } from 'conveyor-redux'

const conveyorEpic = makeConveyorEpic(schema, queryTool, config, disabledEpics)

Where schema is the same schema used for conveyor (a 'SchemaBuilder' type object created with conveyor-schema), queryTool is a 'QueryTool' type object created with magql-query, config is a user-defined object for customization, and disabledEpics is an array of epic names (string) to not include

Note: Schema functions that normally receive customProps (getDisplayValue, etc.), which are used by the library, are NOT going to be received by the Reducers.

Reducer Overrides

The reducer overrides should be an map of conveyor reducer slice keys to reducer functions.

The list of slice reducers that can be overriden or disabled are: alerts, create, edit, index, modal, model, options, search, userPreferences, tableView, and tooltip. (REDUCER_KEY)

If it is a falsy value, the reducer will be disabled (not included).

Example:

const overrides = {
  alerts: false
  search: yourSearchReducer
}

const rootReducer = combineReducers({
  conveyor: makeConveyorReducer(schema, config, overrides),
  ...otherReducers
})

In this example, the alerts reducer slice is disabled while the search reducer is replaced with your own search reducer.

Disabling Epics

Individual epics can be disabled with the disabledEpics parameter passed to makeConveyorEpic.

The list of epics that can be disabled are:

addAlert, fetchModelDetail, fetchModelIndex, requestDeleteModel, requestDeleteModelFromDetailPage, requestDeleteRelTableModel, querySelectMenuOpen, relationshipSelectMenuOpenEpic, locationChange, fetchSearchEntries, triggerSearch, indexTableFilterSubmit, indexTableSortChange, fetchModelTooltip, detailAttributeEditSubmit, detailTableEditSubmit, detailTableRemoveSubmit, editSubmit, inlineFileDelete, inlineFileSubmit, detailAttributeEditSubmitCheck, detailTableEditSubmitCheck, editSubmitCheck, saveCreateCheck, saveCreate, fetchDeleteDetail

Example:

const disabledEpics = ['addAlert', 'saveCreateCheck']

const conveyorEpic = makeConveyorEpic(schema, queryTool, config, disabledEpics)

In this example, the addAlert and saveCreateCheck epics are disabled.

Special Features

Conveyor-Redux handles the special features below:

Pagination

The amount of table content that is displayed can be divided through pagination if paginate is set to true in Schema (paginate is true by default). The default amount of data displayed per a page is 20, but can be modified by passing in a config when instantiating the Conveyor Reducer and Epic.

Sorting

Table data can be sorted by a field's increasing or decreasing order if sortable is set to true in Schema (sortable is true by default). Sorting is toggleable by clicking the Table Header of a column Field. Sort order iterates over 'No Order ↕ -> Ascending Order ⬆ -> Descending Order ⬇'.

Filtering

Table data can be filtered by one or more filter rules set by the user if filterable is true in Schema (filterable is true by default). Number of filter options are available depending on the field type (string, integer, date, etc.)

Config

The config parameter is provided to makeConveyorReducer and makeConveyorEpic functions.

For example, the following config option changes the amount of data displayed per a page on a table.

const config = {
  tableView: {
    defaultPerPage: 10  // Displays only 10 rows on a table per page
  }
}
// Pass to makeConveyorReducer
makeConveyorReducer(schema, config, overrides)
// Pass to makeConveyorEpic
makeConveyorEpic(schema, queryTool, config, disabledEpics)

Redux structure

At the bottom is the default redux store structure (assuming no Reducers are overriden). router holds data for when handling actions from react-router while conveyor holds data for use with conveyor. Custom data can also be updated or added to the store through overrides. For example, the code below will add a new object called customQuery to the store and have a value of {someResult: "...Loading..."} in state:

export const customQuery = (state = initState, action) => {
  const payload = action.payload

  switch (action.type) {
    case (constants.CUSTOM_QUERY) : {
      return { "someResult": "...Loading" }
    }
    default:
      return state
  }
}
router
| action
| location
| | pathname
| | search
| | hash
| | key
| | query
conveyor
| alerts
| create
| | index
| | stack
| | originPath
| edit
| | modelName
| | | id
| | | | fieldName
| modal
| | modelName
| | | order
| | | values
| | Delete
| | | index
| model
| | modelName
| | | order
| | | values
| options
| | modelName
| | | fieldName
| | | | index
| tooltip
| | modelName
| | | id
| tableView
| | modelName
| | | page
| | | fields
| | | | fieldName
| | | | | page
| search
| | queryText
| | entries
| | dropdown
| userPreferences
| | darkMode
customQuery (If added)