Skip to content

Commit 2fa29b4

Browse files
authored
fix: ACL type defs (#346)
* dev(examples): add ACL runnable example * fix(typedefs): ACL type * docs(ACL): typo in permissions key * bump version to 6.2.1 with changelog
1 parent 83c759d commit 2fa29b4

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#### v 6.2.1 (2024-07-04)
2+
* fix: ACL type, should be an array of objects. Also, fix typo in permissions key.
3+
4+
Pull request [346](https://github.com/yfinkelstein/node-zookeeper/pull/346) by @davidvujic
5+
16
#### v 6.2.0 (2024-05-25)
27
* fix: build error in Node.js 22 caused by removed V8 AccessControl property
38

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Have a look at the code in the [examples](./examples) folder: with __master__, _
217217
* int numChildren // number of children of this node
218218
* long pzxid // last modified children
219219
* acl is an array of acls objects, single acl object has following key
220-
* int perms // permisions
220+
* int perm // permisions
221221
* string scheme // authorisation scheme (digest, auth)
222222
* string auth // authorisation credentials (username:hashed_password)
223223
* zookeeper is the ZooKeeper instance on which connect was called

examples/acl.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { getClient, constants } = require('./wrapper');
2+
3+
const logger = require('./logger');
4+
const notifier = require('./notifier');
5+
6+
notifier.on('connect', (message) => logger.log('connect', message));
7+
notifier.on('createNode', (message) => logger.log('createNode', message));
8+
9+
async function init() {
10+
const client = getClient();
11+
12+
client.on('connect', async () => {
13+
const path = '/acl-testing';
14+
const data = '';
15+
const flags = constants.ZOO_EPHEMERAL;
16+
const version = 0;
17+
18+
await client.create(path, data, flags);
19+
20+
const before = await client.get_acl(path);
21+
22+
const updatedAcl = [{
23+
perm: constants.ZOO_PERM_READ,
24+
scheme: 'world',
25+
auth: 'anyone',
26+
}];
27+
28+
await client.set_acl(path, version, updatedAcl);
29+
30+
const after = await client.get_acl(path);
31+
32+
logger.log('before:', before[0]);
33+
logger.log('after:', after[0]);
34+
});
35+
}
36+
37+
if (require.main === module) {
38+
init().catch(logger.error);
39+
}

lib/typedeclarations.d.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,17 @@ declare module "index" {
624624
const ZooKeeper: typeof import("zookeeper");
625625
}
626626
/**
627-
* ACL
627+
* ACL object
628628
*/
629-
type acl = {
630-
perms: number;
629+
type aclObject = {
630+
perm: number;
631631
scheme: string;
632632
auth: string;
633633
};
634+
/**
635+
* ACL
636+
*/
637+
type acl = Array<aclObject>;
634638
/**
635639
* stat
636640
*/

lib/typedefs.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
/**
2-
* ACL
3-
* @typedef {Object} acl
4-
* @property {number} perms
2+
* ACL object
3+
* @typedef {Object} aclObject
4+
* @property {number} perm
55
* @property {string} scheme
66
* @property {string} auth
77
*/
88

9+
/**
10+
* ACL
11+
* @typedef {Array.<aclObject>} acl
12+
*/
13+
914
/**
1015
* stat
1116
* @typedef {Object} stat

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zookeeper",
33
"description": "apache zookeeper client (zookeeper async API v3.5.x - v3.8.x)",
4-
"version": "6.2.0",
4+
"version": "6.2.1",
55
"author": "Yuri Finkelstein <[email protected]>",
66
"license": "MIT",
77
"contributors": [

0 commit comments

Comments
 (0)