# kuu-tools

> Kuu front-end tools

Latest version **0.3.2** (published 2024-07-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install kuu-tools
pnpm add kuu-tools
yarn add kuu-tools
bun add kuu-tools
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2024-07-14 |
| First published | 2019-07-05 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 49.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Daniel Yin |
| Maintainers | ystyle, yinfxs |
| Keywords | kuu, tools, utils, sdk |

## Links

- npm: https://www.npmjs.com/package/kuu-tools
- Repository: https://github.com/kuuland/kuu-tools
- Homepage: https://github.com/kuuland/kuu-tools#readme
- Issues: https://github.com/kuuland/kuu-tools/issues
- npm.io page: https://npm.io/package/kuu-tools

## Dependencies (6)

- [qs](https://npm.io/package/qs.md) ^6.9.4
- [react](https://npm.io/package/react.md) ^16.13.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [react-dom](https://npm.io/package/react-dom.md) ^16.13.1
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^2.2.1
- [hoist-non-react-statics](https://npm.io/package/hoist-non-react-statics.md) ^3.3.2

## Recent versions

- 0.3.2 (latest) — 2024-07-14
- 0.3.1 — 2023-12-21
- 0.3.0 — 2023-12-12
- 0.2.17 — 2021-12-22
- 0.2.16 — 2021-06-16
- 0.2.15 — 2021-06-11
- 0.2.14 — 2021-04-25
- 0.2.13 — 2020-08-20
- 0.2.12 — 2020-08-06
- 0.2.11 — 2020-08-06
- 0.2.10 — 2020-08-04
- 0.2.9 — 2020-08-04
- 0.2.8 — 2020-07-29
- 0.2.7 — 2020-04-24
- 0.2.6 — 2020-04-24
- … 31 more at https://npm.io/package/kuu-tools/versions

## README

# kuu-tools

[![NPM version](https://img.shields.io/npm/v/kuu-tools.svg?style=flat)](https://npmjs.org/package/kuu-tools)
[![Build Status](https://travis-ci.org/kuuland/kuu-tools.svg?branch=master)](https://travis-ci.org/kuuland/kuu-tools)
[![NPM downloads](http://img.shields.io/npm/dm/kuu-tools.svg?style=flat)](https://npmjs.org/package/kuu-tools)
[![Dependencies](https://david-dm.org/yinfxs/kuu-tools.svg)](https://david-dm.org/yinfxs/kuu-tools)

Kuu front-end tools

## Install

```sh
npm i kuu-tools
```

## Request utils

### GET

```js
import { get } from 'kuu-tools'

const data = await get('/member/get?foo=1&bar=2')
```

### POST

```js
import { post } from 'kuu-tools'

const data = await post('/member/signup', { user: 'foo', name: 'bar' })
```

### PUT

```js
import { put } from 'kuu-tools'

const data = await put('/member/signup?foo=1&bar=2', { user: 'foo', name: 'bar' })
```

### DELETE

```js
import { del } from 'kuu-tools'

const data = await del('/member/signup?foo=1&bar=2', { user: 'foo', name: 'bar' })
```

## Model SDK

### Create

> https://github.com/kuuland/kuu#create-record

```js
import { create } from 'kuu-tools'

// create a role
const data = await create('Role', { Code: 'foo', Name: 'bar' })

// batch create roles
const data = await create('Role', [{ Code: 'foo1', Name: 'bar1' }, { Code: 'foo2', Name: 'bar2' }])
```

### Update

> https://github.com/kuuland/kuu#update-fields

```js
import { update } from 'kuu-tools'

// update a param
const data = await update('param', { ID: 5 }, { Value: 'new value', Name: 'foobar' })

// batch updates
const data = await update('param', { ID: { $in: [5, 10, 11] } }, { Value: 'new value' }, true)
```

### Delete

> https://github.com/kuuland/kuu#delete-record

```js
import { remove } from 'kuu-tools'

// delete a param
const data = await remove('param', { ID: 5 })

// batch delete
const data = await remove('param', { ID: { $in: [5, 10, 11] } }, true)

// batch and unsoft delete
const data = await remove('param', { ID: { $in: [5, 10, 11] } }, true, true)
```

### Query

> https://github.com/kuuland/kuu#query

```js
import { list, one, id } from 'kuu-tools'

// list query
const data = await list('param', { cond: { ID: { $in: [5, 10, 11] } }, page: 3, sort: '-CreatedAt' })

// query only one record
const data = await one('param', { cond: { Name: 'foo' } })

// query by id
const data = await id('param', 11)

```

## i18n

```json
{
     "hello": "你好",
     "welcome": "欢迎 {{name}}"
}
```
```js
import { withLocale } from 'kuu-tools'

class Param extends React.Component {
  render () {
    return (
      <div>
        <div>{this.props.L('hello', 'Hello')}</div>                         /* => 你好 */
        <div>{this.props.L('not_found', 'Not found')}</div>                 /* => Not found */
        <div>{this.props.L('welcome', 'Welcome Kuu', { name: 'Kuu' }}</div> /* => 欢迎 Kuu */
      </div>
    )
  }
}

export default withLocale(Param)
```

Notes:
 
1. `this.props.L` can only be used in `render`, otherwise it will not respond to language updates in real time.
1. `withLocale(Param)`
1. `withLocale(withRouter(Param))`
1. `withLocale(connect(mapStateToProps)(withRouter(Param)))`

> Message supports the [mustache](https://github.com/janl/mustache.js) syntax.

---
_Source: https://npm.io/package/kuu-tools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
