open-index/open-npm huggingface dataset:
npm package: @saola/plugin-restfront
Description: Saola RestFront plugin
Author: Saola Development Team
Latest version: 0.4.2

# @saola/plugin-restfront

> Saola restfront plugin layerware

![Architecture](https://raw.github.com/saola-tools/saola-plugin-restfront/master/docs/modules/ROOT/assets/images/arch.png)
npm package: @saonetwork/sao-client-js
Description: sao client js sdk
Latest version: 0.0.1

# Get sao-client-js sdk

add sao-client-js dependency to your project:

```
$ npm install @saonetwork/sao-client-js
```

# Prerequisite

follow [sao client cmd tutorial](https://docs.sao.network/build-apps-on-sao-network/cli-tutorial) to prepare local sao did.

# Usage

Prepare local sao did.

* import sao-client-js package

```
import {NewSaoClientApi} from "@saonetwork/sao-client-js"
```

* initialize sao client

```
const nodeUrl = "https://gateway-beta.sao.network:443/rpc/v0"
const chainUrl = "https://rpc-beta.sao.network:443"
const keyName = "<keyName>"
const keyHome = "/home/user/.sao/keyring-test"
const groupId = "<groupId>"
const client = await NewSaoClientApi(nodeUrl, chainUrl, keyName, keyHome, groupId)
```

node url is endpoint to connect to gateway.

chain url is rpc endpoint to chain.

key name is local account key name.

#### Create Model

```
const duration = 365
const delay = 10
const name = "my profile"
const replicas = 5
const data = "your data model"
const dataId = await client.CreateModel(
    {data: data, alias: name},
    {duration: duration, replica: replicas, timeout: delay}
)

```

#### Load Model

```
console.log("load model...")
const model = await client.loadModel(dataId)
console.log(model.content)
```

#### Update Permission

```
console.log("update permissions...")
await client.updateModelPermission(
  "dataId",
  ["readonly Dids..."],
  ["readwrite Dids..."]
)

console.log("Permission Updated")

```

#### Update Model

First step is to generate change patch

```
const target = "{\"nickname\":\"new name\"}"
const dataId = await client.UpdateModel(
  {dataId: dataId,data: target}
  {duration: duration, replica: replicas, timeout: delay}
)
```