0.80.15 • Published 2 years ago

@izberg/izberg-backoffice-store v0.80.15

Weekly downloads
3,849
License
UNLICENSED
Repository
-
Last release
2 years ago

izberg-backoffice-store

izberg-backoffice-store is an abstraction of redux store, useful for creating Izberg web applications, without having to reconfigure redux. It also contains methods for common actions like fetching data from Izberg API, Izberg BO Settings, etc.

izberg-backoffice-store exposes several modules, with different levels of abstractions.

Models contains all API-related operations, e.g. actions creators,selectors & fetch methods.

Models documentation

There are selectors specific to BO environment, e.g. currentApplication or isSellerBO.

BO Store documentation

The most useful/interesting module might be AsyncStore. It allows third-party packages to quickly allocate a part of the state, with its own actions/reducers/selectors. It is also private (not accessible from other selectors). The state reducers are injected asynchronously, thus enable code-splitting and lazy-loading modules.

AsyncStore documentation


API Reference

Models

resourceKey

resource key string

_get({ id, queryParams }) -> Promise

performs a GET operation on a model.

E.g. Models.mapperConfiguration.get({ id: 2 }) will make an HTTP call to /v1/mapper_configuration/2 and returns a promise

_collectionGet({ queryParams })

performs a GET operation to on model with query parameters.

E.g. Models.mapperConfiguration.collectionGet({ queryParams: { application: 1, order__by: 'status' }}) will make an HTTP call to v1/mapper_configuration/?application=1&order__by=status

_save(data) -> Promise

performs a save operation with data in request body (PUT request if id field exists in data, POST if it doesn't)

_patch({ id, data }) -> Promise

performs a GET operation on a model with data in request body

_delete({ id }) -> Promise

performs a DELETE operation on a model with data in request body

executeAction({ id, action, options }) -> Promise

performs custom operation on model. E.g.

// no id is provided
Models.application.executeAction({ action: 'batch_start' }) 
// --> will call /v1/application/batch_start

// id is provided
Models.application.executeAction({ id: 42, action: 'pause' }) 
// --> will call /v1/application/42/pause

options:

  • type: http type. one of 'GET', 'POST', 'PUT'
  • body: request body data (relevant in case of POST / PUT operations)

get({ id, queryParams })

action creator that calls _get method and update redux state

save({ id })

action creator that calls _save method with current data in state, and update redux state with API response data

patch({ id, data })

action creator that calls _patch method and update redux state

collectionGet({ queryParams })

action creator that calls _collectionGet method and update redux state

delete({ id })

action creator that calls _delete method and remove data from redux state

localUpdate({ data })

action creator that updates model data in state with argument data (a field id must exists in data)

localDelete({ ids })

action creator that removes models with id in ids list from state

fetchSchema()

action creator that fetches the model api schema and save in redux state

localGetById({ id })

selector that returns model with corresponding id

localGet({ queryParams })

selector that returns models list that match queryParams

getSchema()

selector that returns model api schema


BO Store

currentApplication(state) -> application

return current application object

currentMerchant(state) -> merchant

return current merchant object

isSellerBO(state) -> boolean

return true if user is in BOS, false if BOO


AsyncStore

inject(storeId: String, reducer: function) -> { getState: function }

inject asynchronously a reducer function in current store

  • storeId: a global unique id to identify custom store
  • reducer(state, action) -> state: a reducer that receives a partial state of the store

returns getState(globalState) -> partialState: a helper function that takes globalState as argument (provided by react-redux mapStateToProps), and returns partial state of the store. Useful for creating local selectors.

E.g.

import { AsyncStore } from '@izberg/izberg-backoffice-store';
const { getState } = AsyncStore.inject('my_store_id', (state, action) => state);

const mySelector = globalState => {
    const state = getState(globalState);
    const local_id = state.local_id;
    return Models.mapperConfiguration.localGetById({ id: local_id })(globalState);
};
0.80.17

2 years ago

0.80.15

2 years ago

0.80.16

2 years ago

0.80.13

2 years ago

0.80.14

2 years ago

0.80.12

2 years ago

0.80.11

2 years ago

0.79.0

2 years ago

0.81.0

2 years ago

0.80.0

2 years ago

0.80.1

2 years ago

0.80.2

2 years ago

0.77.0

2 years ago

0.78.1

2 years ago

0.76.0

2 years ago

0.72.0

3 years ago

0.75.0

2 years ago

0.71.0

3 years ago

0.70.0

3 years ago

0.69.0

3 years ago

0.66.0

3 years ago

0.65.0

3 years ago

0.64.0

3 years ago

0.63.0

3 years ago

0.62.0

3 years ago

0.61.0

3 years ago

0.60.0

4 years ago

0.59.0

4 years ago

0.58.0

4 years ago

0.57.0

4 years ago

0.56.0

4 years ago

0.55.0

4 years ago

0.54.0

4 years ago

0.53.0

4 years ago

0.52.0

4 years ago

0.51.0

4 years ago

0.50.0

4 years ago

0.49.0

4 years ago

0.48.0

4 years ago

0.47.1

4 years ago

0.47.0

4 years ago

0.46.0

4 years ago

0.45.0

4 years ago

0.44.0

4 years ago

0.43.1

4 years ago

0.43.0

5 years ago

0.42.0

5 years ago

0.36.6-0

5 years ago

0.41.0

5 years ago

0.40.0

5 years ago

0.39.0

5 years ago

0.38.1

5 years ago

0.38.0

5 years ago

0.37.0

5 years ago

0.36.5

5 years ago

0.36.4

5 years ago

0.36.3

5 years ago

0.36.2

5 years ago

0.36.1

5 years ago

0.36.0

5 years ago

0.35.0

5 years ago

0.34.1

5 years ago

0.34.0

5 years ago

1.0.0-alpha.4

5 years ago

1.0.0-alpha.3

5 years ago

1.0.0-alpha.2

5 years ago

0.33.0

5 years ago

1.0.0-alpha.1

5 years ago

1.0.0-alpha.0

5 years ago

0.32.0

5 years ago

0.31.0

5 years ago

0.30.1

5 years ago

0.30.0

5 years ago

0.29.0

5 years ago

0.28.0

5 years ago

0.27.1

5 years ago

0.27.0

5 years ago

0.26.0

5 years ago

0.25.1

5 years ago

0.25.0

5 years ago

0.24.0

5 years ago

0.23.1

6 years ago

0.23.0

6 years ago

0.22.1

6 years ago

0.22.0

6 years ago

0.21.0

6 years ago

0.20.0

6 years ago

0.19.1

6 years ago

0.19.0

6 years ago

0.18.1

6 years ago

0.18.0

6 years ago

0.17.0

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.14.2

6 years ago

0.14.1

6 years ago

0.14.0

6 years ago

0.13.0

6 years ago

0.12.0

6 years ago

0.11.0

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.1.0

7 years ago