Skip to content

Commit

Permalink
fix: ACL type defs (#346)
Browse files Browse the repository at this point in the history
* dev(examples): add ACL runnable example

* fix(typedefs): ACL type

* docs(ACL): typo in permissions key

* bump version to 6.2.1 with changelog
  • Loading branch information
DavidVujic authored Jul 4, 2024
1 parent 83c759d commit 2fa29b4
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### v 6.2.1 (2024-07-04)
* fix: ACL type, should be an array of objects. Also, fix typo in permissions key.

Pull request [346](https://github.com/yfinkelstein/node-zookeeper/pull/346) by @davidvujic

#### v 6.2.0 (2024-05-25)
* fix: build error in Node.js 22 caused by removed V8 AccessControl property

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Have a look at the code in the [examples](./examples) folder: with __master__, _
* int numChildren // number of children of this node
* long pzxid // last modified children
* acl is an array of acls objects, single acl object has following key
* int perms // permisions
* int perm // permisions
* string scheme // authorisation scheme (digest, auth)
* string auth // authorisation credentials (username:hashed_password)
* zookeeper is the ZooKeeper instance on which connect was called
Expand Down
39 changes: 39 additions & 0 deletions examples/acl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { getClient, constants } = require('./wrapper');

const logger = require('./logger');
const notifier = require('./notifier');

notifier.on('connect', (message) => logger.log('connect', message));
notifier.on('createNode', (message) => logger.log('createNode', message));

async function init() {
const client = getClient();

client.on('connect', async () => {
const path = '/acl-testing';
const data = '';
const flags = constants.ZOO_EPHEMERAL;
const version = 0;

await client.create(path, data, flags);

const before = await client.get_acl(path);

const updatedAcl = [{
perm: constants.ZOO_PERM_READ,
scheme: 'world',
auth: 'anyone',
}];

await client.set_acl(path, version, updatedAcl);

const after = await client.get_acl(path);

logger.log('before:', before[0]);
logger.log('after:', after[0]);
});
}

if (require.main === module) {
init().catch(logger.error);
}
10 changes: 7 additions & 3 deletions lib/typedeclarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,17 @@ declare module "index" {
const ZooKeeper: typeof import("zookeeper");
}
/**
* ACL
* ACL object
*/
type acl = {
perms: number;
type aclObject = {
perm: number;
scheme: string;
auth: string;
};
/**
* ACL
*/
type acl = Array<aclObject>;
/**
* stat
*/
Expand Down
11 changes: 8 additions & 3 deletions lib/typedefs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/**
* ACL
* @typedef {Object} acl
* @property {number} perms
* ACL object
* @typedef {Object} aclObject
* @property {number} perm
* @property {string} scheme
* @property {string} auth
*/

/**
* ACL
* @typedef {Array.<aclObject>} acl
*/

/**
* stat
* @typedef {Object} stat
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zookeeper",
"description": "apache zookeeper client (zookeeper async API v3.5.x - v3.8.x)",
"version": "6.2.0",
"version": "6.2.1",
"author": "Yuri Finkelstein <yurif2003@yahoo.com>",
"license": "MIT",
"contributors": [
Expand Down

0 comments on commit 2fa29b4

Please sign in to comment.