open-index/open-npm huggingface dataset:
npm package: @opensrp/card-support
Description: OpenSRP card support features
Author: OpenSRP Engineering
Latest version: 0.0.9

# Card Support

This package has a set of components that are used for OpenSRP card support features

## Installation

```sh
yarn add @opensrp/card-support
```

### Code examples

#### Download Client Data

Download client data feature, enables the user to download client data in CSV format

![Download Client Data](public/assets/img/download-client-data.png)

To make use of the download client data feature

```tsx
import { DownloadClientData } from '@opensrp/card-support';


...

<Route path="/download-client-data">
  <DownloadClientData opensrpBaseURL="https://opensrp-stage.smartregister.org/opensrp/rest" />
</Route>
```

`DownloadClientData` component takes the following props:

- **opensrpBaseURL:**(string)
  - **required**
  - Opensrp API base URL
npm package: @opensrp/error-boundary-fallback
Description: Error boundry fallback
Author: OpenSRP Engineering
Latest version: 0.0.7

# Error Boundary Fallback

This package provides a fallback component which you can use as an error boundary fallback.

## Installation

```node
yarn add @opensrp/error-boundary-fallback
```

## Usage

`error-boundary-fallback` makes use of the following options

- **homeUrl:**(string)
  - **required**
  - URL to redirect after clicking on back to home button

#### Code example

```javascript
import App from '..';
import * as Sentry from '@sentry/react';
import { ErrorBoundaryFallback } from '@opensrp/error-boundary-fallback';

ReactDOM.render(
  <Sentry.ErrorBoundary fallback={() => <ErrorBoundaryFallback homeUrl={'/home'} />}>
    <App />
  </Sentry.ErrorBoundary>,
  document.getElementById('root')
);
```
npm package: @opensrp/keycloak-service
Description: Keycloak Admin API service
Author: Ona Engineering
Latest version: 0.0.17

# Keycloak API Service

The keycloak api service module allows for making HTTP requests to the keycloak api from the app. It supports the below methods

- **create** - post a data object to an api.
- **read** - get a single data object using its unique id
- **update** - Modify an entity on the api
- **list** - get many entities from specified entry point
- **delete** - make a `DELETE` request to the api

## Installation

```node
yarn add @opensrp/keycloak-service
```

## Usage

`KeycloakService` makes use of the following options

- **accessToken**(string)

  - **required**
  - oauth2 token to be used when making requests to the keycloak endpoints

- **endpoint:**(string)
  - **required**
  - the endpoint.
- **baseURL:**(string)
  - **required**
  - uri of the api
- **getOptions:**(Function)

  - optional
  - A function thats given the signal and method to use. Used to add custom options that you might want to pass on tho the fetch request

- **signal:**(AbortSignal)
  - optional
  - optionally used to cancel pending requests.

### Errors

Keycloak service module exposes 2 additional error classes:

#### HTTPError

This is thrown when the statusCode is not within the allowed success range for any respective operation.

The fetch.response.text() value from the api is attached to the error as the value of `description`.

Also attaches the following fields from the response to the thrown error object: - statusCode - statusText - url

#### NetworkError

This is thrown when the fetch error cannot go through due to a failed internet connection.

### Code example

```typescript
import { KeycloakService } from '@opensrp/keycloak-service';

const loadClients = async () => {
  const clientService = new KeycloakService(accessToken, keycloakEndpoint, keycloakBaseURL);
  return await clientService.list();
};
```
npm package: @opensrp/notifications
Description: Utility functions for dispaying OpenSRP web notifications
Author: OpenSRP Engineering
Latest version: 0.0.5

# Notifications

The package contains utility functions for displaying notifications

## Installation

```sh
yarn add @opensrp/notifications
```

## Usage

The following available functions support different types of notifications:

`sendSuccessNotification`: Used to display a success popup

`sendInfoNotification`: Used to display an information popup

`sendWarningNotification`: Used to display a warning popup

`sendErrorNotification`: Used to display an error popup

Each of these methods accepts the following arguments:

1. `message`: **string**

This is the notification title and is required

2. `description`: **string**

This is the content of the notification. It's optional. A blank body will be displayed if it's not
provided.

### Code examples

```ts
/**
 * antd notification popup.
 *
 * @param {user} user details object
 */
export const openNotification = (user: User): void => {
  sendSuccessNotification(`Welcome back, ${user.username}`, 'You have 8 new messages');
};
```
npm package: @opensrp/opensrp-table
Description: A table component for displaying data
Author: Ona Engineering
Latest version: 0.0.5

# OpenSRP Table

This provides an OpenSRPTable component that can be used to display data on a page.
It adds an extra abstraction layer over [react-table](https://github.com/tannerlinsley/react-table#readme) that makes it much easier to use within the more limited scope of opensrp-web. Currently it only re-exposes the sorting api from react-table.

## Installation

```node
yarn add @opensrp/opensrp-table
```

### Options

-   **tableColumns**(Column as defined by [react-table](https://github.com/tannerlinsley/react-table#readme)
    -   **required**
    -   A memoized array of columns, see example below
-   **data**(< T >)
    -   **required**
    -   an array of items to be displayed on the grid

#### an example

```typescript
import React from 'react';
import { OpenSRPTable } from '@opensrp/opensrp-table';
import '@opensrp/opensrp-table/dist/index.css';

export const useColumns = () => {
    return React.useMemo(() => [
        {
            Header: 'First Name',
            accessor: 'firstName',
        },
        {
            Header: 'Last Name',
            accessor: 'lastName',
        },
    ],[]);
};

const data = [
    { firstName: 'Soap', lastName: 'MacTavish' },
    { firstName: 'captain', lastName: 'Price' },
];

const CustomTable: React.FC<ANCTableProps> = () => {
    return <OpenSRPTable {...{ data, tableColumns: useColumns() }} />;
};
```
npm package: @opensrp/plan-form
Description: Form component for creating OpenSRP pages
Author: OpenSRP Engineering
Latest version: 0.0.4

# PlanForm

Component that renders a form to create or edit OpenSRP plans. It implements custom UI and user interactions as required by opensrp-web apps that use antd.

## Installation

```sh
yarn add @opensrp/plan-form
```

```typescript
import '@opensrp/plan-form/dist/index.css';
```

## Usage

### Props/ Configuration

#### envConfigs

_Optional_(`EnvConfigs`)

an object containing the env configuration options

#### hiddenFields

_Optional_(`PlanFormFieldsKeys[]`)

an array of keys for fields that should be hidden

#### disabledFields

_Optional_(`PlanFormFieldsKeys[]`)

an array of keys for fields that should be disabled

#### disabledActivityFields

_Optional_(`string[]`)

an array of keys for fields that should be disabled in the activities section

#### afterSubmit

_Optional_(`Function`)

hook called after payload is successfully sent to the API

#### beforeSubmit

_Optional_(`(payload) => boolean`)

hook called before the submitting is initiated, return boolean to indicate if submitting should proceed

#### getRedirectPath

**required**(`(planStatus) => string`)

callback to get the path to redirect after successfully form submission

#### onCancel

**required**(`() => void`)

callback called once user clicks on cancel in the plan form

#### allFormActivities

_Optional_()

List of allowed activities

#### initialValues

_Optional_()

predefine form field values

### Code examples

```typescript
import {PlanForm} form '@opensrp/plan-form';
import '@opensrp/plan-form/dist/index.css';

const formPage = () => {
  return (<PlanForm />)
}
```
npm package: @opensrp/plan-form-core
Description: Core utils to support UIs for creating or editing plans
Author: OpenSRP Engineering
Latest version: 0.0.4

# PlanForm Core

Core functions and utilities that support the plan creation and editing activities.
The main pieces exposed from here are:

- types: types defining the supported plan structure, supported form fields structure
- utility functions: Utilities that help parse form data and plan definition payloads to and fro, pieces not covered include any Form-implementation specific stuff e.g validating form fields, or utilities such as reading errors from a form
- constants: The plan structure defines a few constants that we re-expose for use in your projects, just to avoid duplication and trivial syntax errors

The intention for this package, is to serve as a common building block for several different user-facing form components that can create or edit opensrp plans.

## Installation

```sh
yarn add @opensrp/planform-core
```

## Usage

The 2 major helpers provided are:

**generatePlanDefinition**

```typescript
getPlanFormValues(planObject: PlanDefinition,envConfigs?: Partial<EnvConfig>)
```

creates a plan defintion object from form values

**getPlanFormValues**

```typescript
generatePlanDefinition(
  formValue: PlanFormFields,
  planObj: PlanDefinition | null = null,
  isEditMode = false,
  envConfigs?: Partial<EnvConfig>
): PlanDefinition
```

transform a planDefinition to form values object

### Props/ Configuration

Some of the util functions exposed can optionally take a config object shaped as follows:

```typescript
/** describes all possible configuration options */
export interface EnvConfig {
  dateFormat: string;
  defaultPlanDurationDays: number;
  defaultPlanVersion: string;
  enabledFiReasons: FIReasonType[];
  planTypesAllowedToCreate: InterventionType[];
  planTypesWithMultiJurisdictions: InterventionType[];
  actionUuidNamespace: string;
  planUuidNamespace: string;
  defaultTime: string;
  defaultActivityDurationDays: number;
  displayedPlanTypes: InterventionType[];
  taskGenerationStatus: taskGenerationStatusType;
}
```

### Read the code

For more, and for specific details on what parameters all the above take, we encourage you to read the code. It is also just good practice.
npm package: @opensrp/plans
Description: Opensrp plans
Author: OpenSRP Engineering
Latest version: 0.0.10

# Plans Views/Pages

This package contains the plan Ui elements, utilities and redux modules that it will use

This package includes set of components that interact with missions/plan api. It currently has the following components

- PlansListView - Shows a list of plans, also allows creating, editing and deleting plans
- CreateEditView - A mission/plan form to allow admin to create/update plan info

## Installation

```sh
yarn add @opensrp/plans
```

```typescript
import '@opensrp/plans/dist/index.css';
```
npm package: @opensrp/population-characteristics
Description: Edit characteristics settings
Author: Ona Engineering
Latest version: 0.0.6

# Population Characteristics

This package provides a UI for Editing OpenSrp population characteristics.
With a list of all population characteristics for a specific location and ability to traverse through location hierarchies it is easy to edit each characteristic.

## Instalation

```node
yarn add @opensrp/population-characteristics
```

Importing default characteristics table styles

```ts
import '@opensrp/population-characteristics/dist/styles/index.css';
```

## Edit characteristics

```typescript
import ConnectedEditSetings from '@opensrp/population-characteristics'

const EditSetingsPage = () => {

    const editSetingsProps = {
        LoadingComponent: <loading component>, // optional,
        baseURL: <OpenSRP API base url without rest at end>,
        getPayload: <function for generating OpenSrp API headers>,
        locationsEndpoint: <OpenSrp API location tree endpoint>,
        restBaseURL: <OpenSRP API base url>,
        secAuthEndpoint: <OpenSrp API security authenticate endpoint>,
        settingsEndpoint: <OpenSrp API settings endpoint>,
        v2BaseUrl: <OpenSRP API v2 base url without rest at end>
    };
    return <ConnectedEditSetings {...editSetingsProps} />
};
```

### Required props

_baseURL_: OpenSRP API base url without rest at end i.e https://.../opensrp/
_getPayload_: Function for generating OpenSrp API headers
_locationsEndpoint_: OpenSrp API location tree endpoint
_restBaseURL_: OpenSRP API base url
_secAuthEndpoint_: OpenSrp API security authenticate endpoint,
_settingsEndpoint_: OpenSrp API settings endpoint,
_v2BaseUrl_: OpenSRP API v2 base url without rest at end

### Optional props

_debounceTime_: debounce time in milliseconds. expects a value of type number.
_labels_: object with the following keys:
&nbsp;&nbsp; _descriptionLabel_
&nbsp;&nbsp; _editLabel_
&nbsp;&nbsp; _inheritedLable_
&nbsp;&nbsp; _inheritSettingsLabel_
&nbsp;&nbsp; _nameLabel_
&nbsp;&nbsp; _noDataFound_
&nbsp;&nbsp; _pageTitle_
&nbsp;&nbsp; _placeholder_
&nbsp;&nbsp; _settingLabel_
&nbsp;&nbsp; _setToNoLabel_
&nbsp;&nbsp; _setToYesLabel_
All of the `label` keys expect values of type strings.
npm package: @opensrp/react-utils
Description: A couple of utils that work with react
Author: OpenSRP Engineering
Latest version: 0.0.12

# React Utils

A couple of utils being used in opensrp-web that work with react

## Installation

```sh
yarn add @opensrp/react-utils
```

## Usage

This package currently exposes the following components:

### Broken Page

This is a util component that is shown when a page runs into a non-recoverable error.
it also comes with the `useHandleBrokenPage` hook that helps manage the workflow of a broken page

#### Props/ Configuration

##### title

_Optional_(`string` | defaults `Something went wrong`)

Error title

##### errorMessage

_Optional_(`string` | defaults `Error`)

Error description

##### homeUrl

_Optional_(`string` | defaults `/`)

url path to home page

### Resource404

This is a util component shown when a requested resource is not found;
the more canonical 404 component, is shown when a page is not yet bound
to the routing system, this component is to be used within an existing page
but where one or more resources to be shown on that page are deemed missing.

#### Props/ Configuration

##### title

_Optional_(`string` | defaults `Sorry, the resource you requested for, does not exist`)

Error title

##### errorMessage

_Optional_(`string` | defaults `Error`)

Error description

##### homeUrl

_Optional_(`string` | defaults `/`)

url path to home page

### Code examples

```tsx
import { Resource404, BrokenPage, useHandleBrokenPage } from '@opensrp/react-utils';

const Foo = () => {
  const { broken, handleBrokenPage } = useHandleBrokenPage;
  if (broken) {
    return <BrokenPage />;
  }
  if (!object) {
    return <Resource404 />;
  }
};
```
npm package: @opensrp/server-logout
Description: A util to logout from opensrp server that uses keycloak
Author: Ona Engineering
Latest version: 0.0.2

# Opensrp server Logout

Exposes a helper function that can be re-used to logout from an opensrp server that uses keycloak for user management.

## Installation

```node
yarn add @opensrp/server-logout
```

### Options

- **payload**
  - `{ headers: HeadersInit; method: HTTPMethod; }`
  - **required**
  - options to add to fetch for instance: the authorization headers
- **opensrpLogoutUri**
  - `string`
  - **required**
  - opensrp server logout uri, this is invoked as a fetch function call
- **keycloakLogoutUri**
  - `string`
  - **required**
  - kecloack server logout uri, this is invoked by redirecting the browser to the url
- **redirectUri**
  - `string`
  - **required**
  - the uri to redirect to after succesfully logging out of keycloak
- **idtoken**
  - `string`
  - **optional**
  - id_token when scope is 'openid', if present then a query string is added to the logout url, which enables keycloak to auto logout user.

#### an example

```typescript
import React from 'react';
import { logout } from '@opensrp/server-logout';

const payload = {
  method: 'GET',
  headers: {
    authorization: 'Bearer <token>',
  },
};
const opensrpLogoutUri = 'https://global.smartregister.org/opensrp/logout.do';
const keycloakLogoutUri = 'https://keycloak.smartregister.org/realm/<realm>/openid-connect/logout';
const redirectUri = 'https://opensrp-web.smartregister.org';

export const logoutComponent = () => {
  logout(payload, opensrpLogoutUri, keycloakLogoutUri, redirectUri).catch(() => {
    /** logout failed*/
  });
  return null;
};
```
npm package: @opensrp/server-service
Description: Wrapper around OpenSRP Server REST API
Author: Ona Engineering
Latest version: 0.0.17

# OpenSRP Service

Exposes an api that abstracts making CRUD requests to a server. This module was built for the openSRPService but is
generic enough to be used on most apis. It exposes the below methods.

- **create** - post a data object to an api.
- **read** - get a single data object using its unique id
- **update** - Modify an entity on the api
- **list** - get many entities from specified entry point
- **delete** - make a `DELETE` request to the api

## Installation

```node
yarn add @opensrp/server-service
```

## Usage

`OpenSRPService` makes use of the following options

- **accessTokenOrCallBack:**(string | function)
  - **required**
  - an async call back function that returns access token
- **baseURL:**(string)
  - **required**
  - uri of the api
- **endpoint:**(string)
  - **required**
  - the endpoint.
- **signal:**(AbortSignal)
  - optional
  - optionally used to cancel pending requests.
- **getOptions:**(Function)
  - optional
  - A function thats given the signal and method to use. Used to add custom options that you might want to pass on tho the fetch request

### Errors

OpenSRP exposes 2 additional error classes:

#### HTTPError

This is thrown when the statusCode is not within the allowed success range for any respective operation.

The fetch.response.text() value from the api is attached to the error as the value of `description`.

Also attaches the following fields from the response to the thrown error object: - statusCode - statusText - url

#### NetworkError

This is thrown when the fetch error cannot go through due to a failed internet connection.

### Code example

```typescript
import OpenSRPService from '@opensrp/server-service';

function getFetchOptions(
  signal: AbortSignal,
  method: HTTPMethod
): { headers: HeadersInit; method: HTTPMethod } {
  return {
    headers: {
      /**... */
    },
    method,
    signal,
  };
}

const loadClients = async () => {
  const clientService = new openSRPService(
    OPENSRP_API_BASE_URL,
    OPENSRP_CLIENT_ENDPOINT,
    getFetchOptions
  );
  return await clientService.list();
};
```
npm package: @opensrp/team-assignment
Description: Contains team assignment page
Author: OpenSRP Engineering
Latest version: 0.0.6

# Team Assignment

This package contains components that list locations and their assigned teams, update and create new assigmnents.

## Installation

```sh
yarn add @opensrp/team-assignment
```

## Usage

### Tean Assignment ListView

This component allows assigning teams to locations from the admin panel.
To add the team assignment list view component:

```tsx
import { TeamAssignmentView } from '@opensrp/team-assignment';

export const teamAssignmentProps = {
  opensrpBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest'
  defaultPlanId: `<insert default plan id set in env>`,
};

<Route path={`/team-assignment`}>
  <TeamAssignmentView {...teamAssignmentProps} />
</Route>
```

- **opensrpBaseURL:**(string)

  - **required**
  - Opensrp API base URL

- **defaultPlanId:**(string)

  - **required**
  - Opensrp default plan id which is an env var
npm package: @opensrp/template
Description: <!-- package description -->
Author: OpenSRP Engineering
Latest version: 0.0.15

# Package

<!-- package description -->

## Installation

```sh
yarn add @opensrp/template
```

<!--
Include further installation instructions, for instance if the package requires for the user
to manually add css.
-->

## Usage

<!--

### Props/ Configuration

#### linkerField

_Optional_(`string` | `undefined` = `undefined`)

When the table is rendered, you can click anywhere on a row to drill down to the next level of the hierarchy. However, you may want to display some kind of indication that it is possible to drill down on a row of data. The `linkerField` prop allows you to define which field should have this indicator. By default this is set to the `id` field.

-->

### Code examples

<!--

A single simple, minimal, working snippet for each use-case that the package supports

```tsx
import { DrillDownTable, columnsFromObjects } from '@onaio/drill-down-table/';

const props = {
  columns: columnsFromObjects(data),
  data
};
<DrillDownTable {...props} />;
```

-->
npm package: @opensrp/user-management
Description: Keycloak user management UI
Latest version: 0.1.19

# Keycloak User Management Module

This package has a set of components that are used to interact with keycloak api. It currently has 3 components

- UserListView - Shows a list of keycloak users, also allows the admin to create, edit or delete users
- CreateEditView - A user form to allow admin to update user info
- Credentials - Allows the admin to set passords to newly created users or update passwords for existing users

## Installation

```node
yarn add @opensrp/keycloak-user-management
```

## Code example

```JSX
import {
  ConnectedUserList,
  ConnectedCreateEditUser,
  ConnectedUserCredentials,
  URL_USER,
  URL_USER_EDIT,
  ROUTE_PARAM_USER_ID,
  URL_USER_CREATE,
  URL_USER_CREDENTIALS,
} from '@opensrp/user-management';

const App = () => {
  return (
    <Layout>
      <Content>
        <Switch>
           <ConnectedPrivateRoute
              redirectPath={APP_CALLBACK_URL}
              disableLoginProtection={DISABLE_LOGIN_PROTECTION}
              exact
              path={URL_USER}
              component={(props: any) => (
                <ConnectedUserList {...props} keycloakBaseURL={KEYCLOAK_API_BASE_URL} />
              )}
            />
            <ConnectedPrivateRoute
              redirectPath={APP_CALLBACK_URL}
              disableLoginProtection={DISABLE_LOGIN_PROTECTION}
              exact
              path={`${URL_USER_EDIT}/:${ROUTE_PARAM_USER_ID}`}
              component={(props: any) => (
                <ConnectedCreateEditUser {...props} keycloakBaseURL={KEYCLOAK_API_BASE_URL} />
              )}
            />
            <ConnectedPrivateRoute
              redirectPath={APP_CALLBACK_URL}
              disableLoginProtection={DISABLE_LOGIN_PROTECTION}
              exact
              path={URL_USER_CREATE}
              component={(props: any) => (
                <ConnectedCreateEditUser {...props} keycloakBaseURL={KEYCLOAK_API_BASE_URL} />
              )}
            />
            <ConnectedPrivateRoute
              redirectPath={APP_CALLBACK_URL}
              disableLoginProtection={DISABLE_LOGIN_PROTECTION}
              exact
              path={`${URL_USER_CREDENTIALS}/:${ROUTE_PARAM_USER_ID}`}
              component={(props: any) => (
                <ConnectedUserCredentials {...props} keycloakBaseURL={KEYCLOAK_API_BASE_URL} />
              )}
            />
        </Switch>
      </Content>
    </Layout>
  );
};

export default App;
```
npm package: @openst/openst-contracts
Description: Openst contracts provide ABIs and BINs for EVM smart contracts to enable developers to program token economies.
Author: OpenST Foundation Ltd.
Latest version: 0.10.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# OpenST Contracts - Empowering Decentralized Economies

OpenST Contracts is a collection of smart contracts that enable developers to
program Token Economies.

## Getting Started

These instructions will get you a copy of the project up and running on your
local machine for development and testing purposes. See deployment for notes on
how to deploy the project on a live system.

### Prerequisites

Project requires [node](https://nodejs.org/en/) and
[npm](https://www.npmjs.com/get-npm) to be installed on dev machine.

### Cloning

In case of fresh clone, use `--recursive-submodules` option while cloning:

```bash
git clone --recursive-submodules git@github.com:openst/openst-contracts.git
```

To update git submodules for already cloned repos, run:

```bash
git submodule update --init --recursive
```

### Installing

Install npm packages, by running:

```bash
npm install
```

Afterwards, add `./node_modules/.bin` to `PATH` environment variable:

```bash
export PATH=./node_modules/.bin:${PATH}
```

## Compiling the contracts

The following npm script compiles updated contracts from the last call:

```bash
npm run compile
```

, to compile all contracts, run:

```bash
npm run compile-all
```

## Linters

### Solidity

In `openst-contracts` to lint solidity files we use [Ethlint](https://github.com/duaraghav8/Ethlint).
The following npm script lints all contracts within `./contracts` directory:

```bash
npm run lint:sol
```

[Ethlint](https://github.com/duaraghav8/Ethlint) is able to fix a subset of rules.
The following npm script fixes (only a subset of rules) contracts within `./contracts` directory:

```bash
npm run lint:sol:fix
```

### JS

[ESLint](https://eslint.org) is used to lint js files.

To lint all js files within `./test` directory, run:

```bash
npm run lint:js
```

[ESLint](https://eslint.org) is able to fix a subset of rules.
To fix js files, run:

```bash
npm run lint:js:fix
```

## Running the tests

Before running the tests run `ganache-cli` by:

```bash
npm run ganache-cli
```

Run tests by calling:

```bash
npm run test
```

## Contributing

Please read [CODE_OF_CONDUCT.md](https://github.com/openst/openst-contracts/blob/develop/CODE_OF_CONDUCT.md)
for details on our code of conduct, and the process for submitting pull
requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available,
see the [tags on this repository](https://github.com/openst/openst-contracts/tags).

## Authors

See also the list of [contributors](https://github.com/openst/openst-contracts/contributors)
who participated in this project.

## License

This contracts are licensed under the Apache License Version 2.0 - see
the [LICENSE.md](https://github.com/openst/openst-contracts/blob/develop/LICENSE.md)
file for details.