@blocklet/sdk 1.7.8 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/lib/index.js +2 -0
- package/lib/logger.js +8 -0
- package/lib/service/auth.js +1 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ const userDid = 'xxxxxxxx';
|
|
|
28
28
|
const { user } = await client.getUser(userDid);
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
###
|
|
31
|
+
### API
|
|
32
32
|
|
|
33
33
|
#### client.getUser(did)
|
|
34
34
|
|
|
@@ -37,9 +37,16 @@ Get user by user did
|
|
|
37
37
|
- _@param_ **did** `string`
|
|
38
38
|
- _@return_ `{ code, user }`
|
|
39
39
|
|
|
40
|
+
#### client.getOwner()
|
|
41
|
+
|
|
42
|
+
Get owner of the app
|
|
43
|
+
|
|
44
|
+
- _@param_ **did** `string`
|
|
45
|
+
- _@return_ `{ code, user }`
|
|
46
|
+
|
|
40
47
|
#### client.getUsers()
|
|
41
48
|
|
|
42
|
-
Get all users of the
|
|
49
|
+
Get all users of the app
|
|
43
50
|
|
|
44
51
|
- _@return_ `{ code, users }`
|
|
45
52
|
|
|
@@ -52,7 +59,7 @@ Get all permissions of a role
|
|
|
52
59
|
|
|
53
60
|
#### client.getRoles()
|
|
54
61
|
|
|
55
|
-
Get all roles of the
|
|
62
|
+
Get all roles of the app
|
|
56
63
|
|
|
57
64
|
- _@return_ `{ code, roles }`
|
|
58
65
|
|
|
@@ -104,7 +111,7 @@ Full update permissions of a role
|
|
|
104
111
|
|
|
105
112
|
#### client.getPermissions()
|
|
106
113
|
|
|
107
|
-
Get all permissions of the
|
|
114
|
+
Get all permissions of the app
|
|
108
115
|
|
|
109
116
|
- _@return_ `{ code, permissions }`
|
|
110
117
|
|
|
@@ -167,7 +174,7 @@ await Notification.sendToUser([userDid, anotherUserDid], notification);
|
|
|
167
174
|
await Notification.sendToUser([userDid, anotherUserDid], [notification, anotherNotification]);
|
|
168
175
|
```
|
|
169
176
|
|
|
170
|
-
###
|
|
177
|
+
### API
|
|
171
178
|
|
|
172
179
|
#### notification.sendToUser(receiver, notification)
|
|
173
180
|
|
|
@@ -268,6 +275,26 @@ const { Database } = require('@blocklet/sdk');
|
|
|
268
275
|
})();
|
|
269
276
|
```
|
|
270
277
|
|
|
278
|
+
## Log SDK
|
|
279
|
+
|
|
280
|
+
For Blocklet to write business logs, provides a consistent write format.
|
|
281
|
+
|
|
282
|
+
### Usage
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
const { logger } = require('@blocklet/sdk');
|
|
286
|
+
|
|
287
|
+
// log
|
|
288
|
+
log = logger('demo');
|
|
289
|
+
log.info('this is demo', { id: 'test-id' });
|
|
290
|
+
log.warn('this is demo', { id: 'test-id' });
|
|
291
|
+
log.error('this is demo', { id: 'test-id' });
|
|
292
|
+
log.debug('this is demo', { id: 'test-id' });
|
|
293
|
+
|
|
294
|
+
// access log
|
|
295
|
+
app.use(morgan('combined', { stream: logger.getAccessLogStream() }));
|
|
296
|
+
```
|
|
297
|
+
|
|
271
298
|
## getWallet
|
|
272
299
|
|
|
273
300
|
### Usage
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const Database = require('./database');
|
|
|
6
6
|
const env = require('./env');
|
|
7
7
|
const middlewares = require('./middlewares');
|
|
8
8
|
const getWallet = require('./wallet');
|
|
9
|
+
const logger = require('./logger');
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
AuthService,
|
|
@@ -16,4 +17,5 @@ module.exports = {
|
|
|
16
17
|
getWallet,
|
|
17
18
|
env,
|
|
18
19
|
middlewares,
|
|
20
|
+
logger,
|
|
19
21
|
};
|
package/lib/logger.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const logger = require('@abtnode/logger');
|
|
2
|
+
|
|
3
|
+
if (!process.env.BLOCKLET_LOG_DIR) {
|
|
4
|
+
throw new Error('valid BLOCKLET_LOG_DIR env is required by logger');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
module.exports = (label) => logger(label, { logDir: process.env.BLOCKLET_LOG_DIR, filename: 'info' });
|
|
8
|
+
module.exports.getAccessLogStream = () => logger.getAccessLogStream(process.env.BLOCKLET_LOG_DIR);
|
package/lib/service/auth.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.9",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,15 +19,16 @@
|
|
|
19
19
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/client": "1.7.
|
|
23
|
-
"@abtnode/constant": "1.7.
|
|
24
|
-
"@
|
|
25
|
-
"@arcblock/
|
|
26
|
-
"@arcblock/
|
|
27
|
-
"@
|
|
22
|
+
"@abtnode/client": "1.7.9",
|
|
23
|
+
"@abtnode/constant": "1.7.9",
|
|
24
|
+
"@abtnode/logger": "1.7.9",
|
|
25
|
+
"@arcblock/did-auth": "^1.16.4",
|
|
26
|
+
"@arcblock/jwt": "^1.16.4",
|
|
27
|
+
"@arcblock/ws": "^1.16.4",
|
|
28
|
+
"@blocklet/meta": "1.7.9",
|
|
28
29
|
"@nedb/core": "^1.2.2",
|
|
29
|
-
"@ocap/mcrypto": "^1.16.
|
|
30
|
-
"@ocap/wallet": "^1.16.
|
|
30
|
+
"@ocap/mcrypto": "^1.16.4",
|
|
31
|
+
"@ocap/wallet": "^1.16.4",
|
|
31
32
|
"axios": "^0.26.1",
|
|
32
33
|
"fs-extra": "^10.0.1",
|
|
33
34
|
"joi": "^17.6.0",
|
|
@@ -39,5 +40,5 @@
|
|
|
39
40
|
"detect-port": "^1.3.0",
|
|
40
41
|
"jest": "^27.4.5"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "285f4fedd41fcb8e1814ce5d8250ac10616e67e0"
|
|
43
44
|
}
|