Skip to content

Commit 5e77228

Browse files
author
Adrien Maret
authored
Merge pull request #169 from kuzzleio/2-dev
# Release 2.0.0-rc1 [Creates default users and rights for payload gateways](#155) [Add measures collection and refactor data mode](#156]) [Add device provisioning with device-manager/device:create action](#166)
2 parents 351608d + 7b189a6 commit 5e77228

File tree

111 files changed

+4819
-5431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4819
-5431
lines changed

.eslintrc.json

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"env": {
3+
"node": true
4+
},
25
"root": true,
36
"parser": "@typescript-eslint/parser",
47
"plugins": [
@@ -11,6 +14,58 @@
1114
],
1215
"rules": {
1316
"@typescript-eslint/no-explicit-any": 0,
14-
"@typescript-eslint/explicit-module-boundary-types": 0
17+
"@typescript-eslint/explicit-module-boundary-types": 0,
18+
"quotes": [2, "single", "avoid-escape"],
19+
"consistent-return": 0,
20+
"curly": 2,
21+
"dot-notation": 2,
22+
"eqeqeq": 2,
23+
"func-names": ["error", "always"],
24+
"guard-for-in": 2,
25+
"indent": [2, 2, {"SwitchCase": 1}],
26+
"linebreak-style": [2, "unix"],
27+
"new-cap": 1,
28+
"no-caller": 2,
29+
"no-catch-shadow": 2,
30+
"no-console": 2,
31+
"no-else-return": 2,
32+
"no-extend-native": 2,
33+
"no-extra-bind": 2,
34+
"no-eval": 2,
35+
"no-implicit-coercion": 2,
36+
"no-implied-eval": 2,
37+
"no-invalid-this": 2,
38+
"no-irregular-whitespace": 2,
39+
"no-labels": 2,
40+
"no-lone-blocks": 2,
41+
"no-lonely-if": 1,
42+
"no-loop-func": 2,
43+
"no-multi-spaces": 1,
44+
"no-multiple-empty-lines": 1,
45+
"no-native-reassign": 2,
46+
"no-nested-ternary": 2,
47+
"no-new": 2,
48+
"no-new-func": 2,
49+
"no-new-require": 2,
50+
"no-new-wrappers": 2,
51+
"no-return-assign": 2,
52+
"no-self-compare": 2,
53+
"no-sequences": 2,
54+
"no-shadow": 2,
55+
"no-shadow-restricted-names": 2,
56+
"no-throw-literal": 2,
57+
"no-undef": 2,
58+
"no-undef-init": 1,
59+
"no-unreachable": 2,
60+
"no-unused-expressions": [2, {"allowShortCircuit": true}],
61+
"no-useless-call": 2,
62+
"no-with": 2,
63+
"require-atomic-updates": 0,
64+
"semi": [2, "always"],
65+
"space-before-blocks": 2,
66+
"strict": [2, "global"],
67+
"vars-on-top": 2,
68+
"yoda": [2, "never"],
69+
"sort-keys": ["error", "asc"]
1570
}
1671
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Install Packages
2+
description: Install necessary packages inside the CI
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- run: sudo apt remove libunwind-dev libunwind8
8+
shell: bash

.github/workflows/pull_request.workflow.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ jobs:
77
name: Lint
88
runs-on: ubuntu-18.04
99
steps:
10+
- name: Install SSH key
11+
uses: shimataro/ssh-key-action@v2
12+
with:
13+
key: ${{ secrets.SSH_KEY }}
14+
name: id_rsa
15+
known_hosts: unnecessary
1016
- uses: actions/checkout@v2
17+
- uses: ./.github/actions/remove-libs
1118
- uses: actions/setup-node@v1.4.4
1219
with:
1320
node-version: "14"
@@ -18,7 +25,14 @@ jobs:
1825
runs-on: ubuntu-18.04
1926
needs: [lint]
2027
steps:
28+
- name: Install SSH key
29+
uses: shimataro/ssh-key-action@v2
30+
with:
31+
key: ${{ secrets.SSH_KEY }}
32+
name: id_rsa
33+
known_hosts: unnecessary
2134
- uses: actions/checkout@v2
35+
- uses: ./.github/actions/remove-libs
2236
- uses: actions/setup-node@v1.4.4
2337
with:
2438
node-version: "14"

.github/workflows/push_dev.workflow.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ jobs:
1010
name: Lint
1111
runs-on: ubuntu-18.04
1212
steps:
13+
- name: Install SSH key
14+
uses: shimataro/ssh-key-action@v2
15+
with:
16+
key: ${{ secrets.SSH_KEY }}
17+
name: id_rsa
18+
known_hosts: unnecessary
1319
- uses: actions/checkout@v2
20+
- uses: ./.github/actions/remove-libs
1421
- uses: actions/setup-node@v1.4.4
1522
with:
1623
node-version: "14"
@@ -21,7 +28,14 @@ jobs:
2128
runs-on: ubuntu-18.04
2229
needs: [lint]
2330
steps:
31+
- name: Install SSH key
32+
uses: shimataro/ssh-key-action@v2
33+
with:
34+
key: ${{ secrets.SSH_KEY }}
35+
name: id_rsa
36+
known_hosts: unnecessary
2437
- uses: actions/checkout@v2
38+
- uses: ./.github/actions/remove-libs
2539
- uses: actions/setup-node@v1.4.4
2640
with:
2741
node-version: "14"

.github/workflows/push_master.workflow.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ jobs:
1010
name: Lint
1111
runs-on: ubuntu-18.04
1212
steps:
13+
- name: Install SSH key
14+
uses: shimataro/ssh-key-action@v2
15+
with:
16+
key: ${{ secrets.SSH_KEY }}
17+
name: id_rsa
18+
known_hosts: unnecessary
1319
- uses: actions/checkout@v2
20+
- uses: ./.github/actions/remove-libs
1421
- uses: actions/setup-node@v1.4.4
1522
with:
1623
node-version: "14"
@@ -22,6 +29,13 @@ jobs:
2229
needs: [lint]
2330
steps:
2431
- uses: actions/checkout@v2
32+
- name: Install SSH key
33+
uses: shimataro/ssh-key-action@v2
34+
with:
35+
key: ${{ secrets.SSH_KEY }}
36+
name: id_rsa
37+
known_hosts: unnecessary
38+
- uses: ./.github/actions/remove-libs
2539
- uses: actions/setup-node@v1.4.4
2640
with:
2741
node-version: "14"
@@ -56,6 +70,12 @@ jobs:
5670
runs-on: ubuntu-18.04
5771
needs: [functional-tests]
5872
steps:
73+
- name: Install SSH key
74+
uses: shimataro/ssh-key-action@v2
75+
with:
76+
key: ${{ secrets.SSH_KEY }}
77+
name: id_rsa
78+
known_hosts: unnecessary
5979
- uses: actions/checkout@v2
6080
- name: Cache node modules
6181
uses: actions/cache@v2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ index.js.map
2727
# Doc
2828
doc/framework
2929
frontmatter-errors.json
30+
31+
.vscode

doc/1/classes/decoder/constructor/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Decoder } from 'kuzzle-plugin-device-manager';
2626

2727
class KarakoyDecoder extends Decoder {
2828
constructor () {
29-
super('Karakoy');
29+
super("Karakoy", ["temperature"]);
3030
}
3131

3232
// This method must be implemented
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
code: true
3+
type: page
4+
title: importAssets
5+
description: Import assets using csv
6+
---
7+
8+
# importAssets
9+
10+
Import assets using csv
11+
12+
---
13+
14+
## Query Syntax
15+
16+
### HTTP
17+
18+
```http
19+
URL: http://kuzzle:7512/_/device-manager/assets/_import[?refresh=wait_for]
20+
Method: POST
21+
```
22+
23+
### Other protocols
24+
25+
```js
26+
{
27+
"controller": "device-manager/asset",
28+
"action": "importAssets",
29+
"body": {
30+
"csv": "_id,reference,model\nPERFO-imported,imported,PERFO"
31+
}
32+
}
33+
```
34+
35+
### Kourou
36+
37+
```bash
38+
kourou device-manager/asset:importAssets --body '{ "csv": require("fs").readFileSync("/absolute/path/assets.csv", "utf8") }'
39+
```
40+
---
41+
42+
## Body properties
43+
44+
- `csv`: a csv syntax compatible
45+
46+
### Optional:
47+
48+
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the documents are indexed
49+
50+
---
51+
52+
## Response
53+
54+
```js
55+
{
56+
"status": 200,
57+
"error": null,
58+
"index": "<index>",
59+
"controller": "device-manager/asset",
60+
"action": "importAssets",
61+
"requestId": "<unique request identifier>",
62+
"result": {}
63+
}
64+
```

doc/1/controllers/asset/update/index.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,35 @@ Returns information about the updated asset:
9494
}
9595
}
9696
```
97+
98+
## Events
99+
100+
Two events are triggered by this action, that can be used as follow:
101+
102+
```js
103+
app.pipe.register('device-manager:asset:update:before', async ({ asset, updates }) => {
104+
app.log.debug('before asset update triggered');
105+
106+
set(updates, 'metadata.enrichedByBeforeAssetUpdate', true);
107+
108+
return { asset, updates };
109+
})
110+
111+
app.pipe.register('device-manager:asset:update:after', async ({ asset, updates }) => {
112+
app.log.debug('after asset update triggered');
113+
114+
if (updates.metadata.enrichedByBeforeAssetUpdate) {
115+
set(updates, 'metadata.enrichedByAfterAssetUpdate', true);
116+
117+
await app.sdk.document.update(
118+
updates.metadata.index,
119+
'assets',
120+
asset._id,
121+
updates,
122+
)
123+
}
124+
125+
return { asset, updates };
126+
})
127+
128+
```
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
code: true
3+
type: page
4+
title: list
5+
description: List available registered decoders
6+
---
7+
8+
# List
9+
10+
List available registered decoders.
11+
12+
---
13+
14+
## Query Syntax
15+
16+
### HTTP
17+
18+
```http
19+
URL: http://localhost:7512/_/device-manager/decoders/_list
20+
Method: GET
21+
```
22+
23+
### Other protocols
24+
25+
```js
26+
{
27+
"controller": "device-manager/decoders",
28+
"action": "list",
29+
}
30+
```
31+
32+
### Kourou
33+
34+
```bash
35+
kourou device-manager/decoders:list
36+
```
37+
---
38+
39+
## Response
40+
41+
```js
42+
{
43+
"action": "list",
44+
"controller": "device-manager/decoders",
45+
"error": null,
46+
"node": "knode-nine-hydra-22631",
47+
"requestId": "d888a8e1-2f80-4849-99d0-86ea70fe91e4",
48+
"result": {
49+
"decoders": [
50+
{
51+
"deviceModel": "DummyTemp",
52+
"deviceMeasures": [
53+
"temperature"
54+
]
55+
},
56+
{
57+
"deviceModel": "DummyTempPosition",
58+
"deviceMeasures": [
59+
"temperature",
60+
"position"
61+
]
62+
}
63+
]
64+
},
65+
"status": 200,
66+
"volatile": null
67+
}
68+
```

0 commit comments

Comments
 (0)