apache-iggy 0.5.2 → 0.6.0-edge.2

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.
Files changed (75) hide show
  1. package/dist/client/client.connection.js +30 -34
  2. package/dist/client/client.socket.js +1 -1
  3. package/dist/debug-send.js +14 -16
  4. package/dist/debug.js +13 -15
  5. package/dist/e2e/tcp.cluster.e2e.d.ts +20 -0
  6. package/dist/e2e/tcp.cluster.e2e.js +55 -0
  7. package/dist/e2e/tcp.consumer-group.e2e.js +41 -29
  8. package/dist/e2e/tcp.consumer-stream.e2e.js +11 -12
  9. package/dist/e2e/tcp.send-message.e2e.js +60 -23
  10. package/dist/e2e/tcp.stream.e2e.js +5 -6
  11. package/dist/e2e/tcp.system.e2e.js +1 -1
  12. package/dist/e2e/tcp.topic.e2e.js +18 -23
  13. package/dist/e2e/tcp.user.e2e.js +5 -0
  14. package/dist/stream/consumer-stream.d.ts +2 -2
  15. package/dist/stream/consumer-stream.js +4 -14
  16. package/dist/tcp.e2e.js +2 -0
  17. package/dist/wire/client/get-client.command.d.ts +2 -2
  18. package/dist/wire/client/get-client.command.js +5 -1
  19. package/dist/wire/cluster/cluster.type.d.ts +54 -0
  20. package/dist/wire/cluster/cluster.type.js +62 -0
  21. package/dist/wire/cluster/cluster.utils.d.ts +40 -0
  22. package/dist/wire/cluster/cluster.utils.js +85 -0
  23. package/dist/wire/cluster/get-cluster-metadata.command.d.ts +27 -0
  24. package/dist/wire/cluster/get-cluster-metadata.command.js +30 -0
  25. package/dist/wire/cluster/index.d.ts +21 -0
  26. package/dist/wire/cluster/index.js +21 -0
  27. package/dist/wire/command-set.d.ts +15 -6
  28. package/dist/wire/command-set.js +14 -2
  29. package/dist/wire/command.code.d.ts +1 -0
  30. package/dist/wire/command.code.js +1 -0
  31. package/dist/wire/command.utils.js +0 -6
  32. package/dist/wire/consumer-group/create-group.command.d.ts +1 -2
  33. package/dist/wire/consumer-group/create-group.command.js +4 -4
  34. package/dist/wire/consumer-group/create-group.command.test.js +1 -2
  35. package/dist/wire/consumer-group/ensure-group.virtual.command.d.ts +23 -0
  36. package/dist/wire/consumer-group/ensure-group.virtual.command.js +33 -0
  37. package/dist/wire/consumer-group/get-group.command.d.ts +2 -2
  38. package/dist/wire/consumer-group/get-group.command.js +2 -0
  39. package/dist/wire/consumer-group/index.d.ts +1 -0
  40. package/dist/wire/consumer-group/index.js +1 -0
  41. package/dist/wire/error.utils.d.ts +4 -0
  42. package/dist/wire/error.utils.js +10 -0
  43. package/dist/wire/message/header.type.d.ts +1 -1
  44. package/dist/wire/message/poll-messages.command.d.ts +1 -1
  45. package/dist/wire/message/poll.utils.d.ts +1 -1
  46. package/dist/wire/message/poll.utils.js +1 -2
  47. package/dist/wire/offset/delete-offset.command.js +1 -1
  48. package/dist/wire/offset/get-offset.command.d.ts +7 -3
  49. package/dist/wire/offset/get-offset.command.js +3 -3
  50. package/dist/wire/offset/offset.utils.d.ts +2 -2
  51. package/dist/wire/offset/offset.utils.js +13 -4
  52. package/dist/wire/offset/store-offset.command.d.ts +1 -1
  53. package/dist/wire/stream/create-stream.command.d.ts +2 -2
  54. package/dist/wire/stream/create-stream.command.js +4 -4
  55. package/dist/wire/stream/create-stream.command.test.js +2 -3
  56. package/dist/wire/stream/ensure-stream.virtual.command.d.ts +21 -0
  57. package/dist/wire/stream/ensure-stream.virtual.command.js +26 -0
  58. package/dist/wire/stream/get-stream.command.d.ts +2 -2
  59. package/dist/wire/stream/get-stream.command.js +2 -0
  60. package/dist/wire/stream/index.d.ts +1 -0
  61. package/dist/wire/stream/index.js +1 -0
  62. package/dist/wire/system/get-stats.command.d.ts +1 -1
  63. package/dist/wire/topic/create-topic.command.d.ts +1 -2
  64. package/dist/wire/topic/create-topic.command.js +9 -9
  65. package/dist/wire/topic/create-topic.command.test.js +2 -3
  66. package/dist/wire/topic/ensure-topic.virtual.command.d.ts +22 -0
  67. package/dist/wire/topic/ensure-topic.virtual.command.js +28 -0
  68. package/dist/wire/topic/get-topic.command.d.ts +2 -2
  69. package/dist/wire/topic/get-topic.command.js +2 -0
  70. package/dist/wire/topic/index.d.ts +1 -0
  71. package/dist/wire/topic/index.js +1 -0
  72. package/dist/wire/topic/topic.utils.js +1 -1
  73. package/dist/wire/user/get-user.command.d.ts +2 -2
  74. package/dist/wire/user/get-user.command.js +5 -1
  75. package/package.json +1 -1
@@ -21,59 +21,54 @@ import assert from 'node:assert/strict';
21
21
  import { getTestClient } from './test-client.utils.js';
22
22
  describe('e2e -> topic', async () => {
23
23
  const c = getTestClient();
24
- const streamId = 111;
25
- const topicId = 123;
26
- await c.stream.create({ streamId, name: 'e2e-tcp-topic-stream' });
24
+ const streamName = 'e2e-tcp-topic-stream';
25
+ const topicName = 'e2e-tcp-topic-topic-123';
26
+ await c.stream.create({ name: streamName });
27
27
  it('e2e -> topic::create', async () => {
28
- const topic = await c.topic.create({
29
- streamId, topicId,
30
- name: 'e2e-tcp-topic',
28
+ const TOPIC = await c.topic.create({
29
+ streamId: streamName,
30
+ name: topicName,
31
31
  partitionCount: 0,
32
32
  compressionAlgorithm: 1,
33
33
  messageExpiry: 0n,
34
34
  replicationFactor: 1
35
35
  });
36
- assert.ok(topic);
36
+ assert.ok(TOPIC);
37
37
  });
38
38
  it('e2e -> topic::list', async () => {
39
- const topics = await c.topic.list({ streamId });
39
+ const topics = await c.topic.list({ streamId: streamName });
40
40
  assert.ok(topics.length > 0);
41
41
  });
42
42
  it('e2e -> topic::get', async () => {
43
- const topic = await c.topic.get({ streamId, topicId });
43
+ const topic = await c.topic.get({ streamId: streamName, topicId: topicName });
44
44
  assert.ok(topic);
45
45
  });
46
46
  it('e2e -> topic::createPartition', async () => {
47
47
  const cp = await c.partition.create({
48
- streamId, topicId,
48
+ streamId: streamName,
49
+ topicId: topicName,
49
50
  partitionCount: 22
50
51
  });
51
52
  assert.ok(cp);
52
53
  });
53
54
  it('e2e -> topic::deletePartition', async () => {
54
55
  const dp = await c.partition.delete({
55
- streamId, topicId,
56
+ streamId: streamName,
57
+ topicId: topicName,
56
58
  partitionCount: 19
57
59
  });
58
60
  assert.ok(dp);
59
61
  });
60
- it('e2e -> topic::update', async () => {
61
- const topic = await c.topic.get({ streamId, topicId });
62
- const u2 = await c.topic.update({
63
- streamId, topicId,
64
- name: topic.name,
65
- messageExpiry: 42n
66
- });
67
- assert.ok(u2);
68
- });
69
62
  it('e2e -> topic::purge', async () => {
70
- assert.ok(await c.topic.purge({ streamId, topicId }));
63
+ assert.ok(await c.topic.purge({ streamId: streamName, topicId: topicName }));
71
64
  });
72
65
  it('e2e -> topic::delete', async () => {
73
- assert.ok(await c.topic.delete({ streamId, topicId, partitionsCount: 0 }));
66
+ assert.ok(await c.topic.delete({
67
+ streamId: streamName, topicId: topicName, partitionsCount: 0
68
+ }));
74
69
  });
75
70
  it('e2e -> topic::cleanup', async () => {
76
- assert.ok(await c.stream.delete({ streamId }));
71
+ assert.ok(await c.stream.delete({ streamId: streamName }));
77
72
  assert.ok(await c.session.logout());
78
73
  });
79
74
  after(() => {
@@ -55,11 +55,13 @@ describe('e2e -> user', async () => {
55
55
  });
56
56
  it('e2e -> user::get#id', async () => {
57
57
  const u1 = await c.user.get({ userId: username });
58
+ assert.ok(u1);
58
59
  const u2 = await c.user.get({ userId: u1.id });
59
60
  assert.deepEqual(u1, u2);
60
61
  });
61
62
  it('e2e -> user::update', async () => {
62
63
  const user = await c.user.get({ userId: username });
64
+ assert.ok(user);
63
65
  const u2 = await c.user.update({
64
66
  userId: user.id,
65
67
  status: 2
@@ -68,12 +70,14 @@ describe('e2e -> user', async () => {
68
70
  });
69
71
  it('e2e -> user::changePassword', async () => {
70
72
  const user = await c.user.get({ userId: username });
73
+ assert.ok(user);
71
74
  assert.ok(await c.user.changePassword({
72
75
  userId: user.id, currentPassword: password, newPassword: 'h4x0r42'
73
76
  }));
74
77
  });
75
78
  it('e2e -> user::updatePermissions', async () => {
76
79
  const user = await c.user.get({ userId: username });
80
+ assert.ok(user);
77
81
  const perms2 = { ...permissions };
78
82
  perms2.global.ReadServers = true;
79
83
  const u2 = await c.user.updatePermissions({
@@ -83,6 +87,7 @@ describe('e2e -> user', async () => {
83
87
  });
84
88
  it('e2e -> user::delete', async () => {
85
89
  const user = await c.user.get({ userId: username });
90
+ assert.ok(user);
86
91
  assert.ok(await c.user.delete({ userId: user.id }));
87
92
  });
88
93
  it('e2e -> user::logout', async () => {
@@ -33,8 +33,8 @@ export type SingleConsumerStreamRequest = ConsumerStreamRequest & {
33
33
  partitionId: number;
34
34
  };
35
35
  export type GroupConsumerStreamRequest = ConsumerStreamRequest & {
36
- groupId: number;
36
+ groupName: string;
37
37
  };
38
38
  export declare const singleConsumerStream: (config: ClientConfig) => ({ streamId, topicId, partitionId, pollingStrategy, count, interval, autocommit, endOnLastOffset }: SingleConsumerStreamRequest) => Promise<Readable>;
39
- export declare const groupConsumerStream: (config: ClientConfig) => ({ groupId, streamId, topicId, pollingStrategy, count, interval, autocommit, endOnLastOffset }: GroupConsumerStreamRequest) => Promise<Readable>;
39
+ export declare const groupConsumerStream: (config: ClientConfig) => ({ groupName, streamId, topicId, pollingStrategy, count, interval, autocommit, endOnLastOffset }: GroupConsumerStreamRequest) => Promise<Readable>;
40
40
  //# sourceMappingURL=consumer-stream.d.ts.map
@@ -19,7 +19,6 @@
19
19
  import { Readable } from "node:stream";
20
20
  import { getClient } from "../client/client.js";
21
21
  import { Consumer } from "../wire/index.js";
22
- import { debug } from "../client/client.debug.js";
23
22
  const wait = (interval, cb) => new Promise((resolve) => {
24
23
  setTimeout(() => resolve(cb ? cb() : undefined), interval);
25
24
  });
@@ -52,23 +51,14 @@ export const singleConsumerStream = (config) => async ({ streamId, topicId, part
52
51
  const ps = Readable.from(genEagerUntilPoll(c, poll, interval, endOnLastOffset), { objectMode: true });
53
52
  return ps;
54
53
  };
55
- export const groupConsumerStream = (config) => async function groupConsumerStream({ groupId, streamId, topicId, pollingStrategy, count, interval = 1000, autocommit = true, endOnLastOffset = false }) {
54
+ export const groupConsumerStream = (config) => async function groupConsumerStream({ groupName, streamId, topicId, pollingStrategy, count, interval = 1000, autocommit = true, endOnLastOffset = false }) {
56
55
  const s = await getClient(config);
57
- try {
58
- await s.group.get({ streamId, topicId, groupId });
59
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
- }
61
- catch (err) {
62
- const ng = { streamId, topicId, groupId, name: `auto-${groupId}` };
63
- debug('group does not exist, creating it', ng);
64
- await s.group.create(ng);
65
- }
66
- await s.group.join({ streamId, topicId, groupId });
56
+ await s.group.ensureAndJoin(streamId, topicId, groupName);
67
57
  const poll = {
68
58
  streamId,
69
59
  topicId,
70
- consumer: Consumer.Group(groupId),
71
- partitionId: 0,
60
+ consumer: Consumer.Group(groupName),
61
+ partitionId: null,
72
62
  pollingStrategy,
73
63
  count,
74
64
  autocommit
package/dist/tcp.e2e.js CHANGED
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import assert from 'node:assert/strict';
19
20
  import { getRawClient } from './client/index.js';
20
21
  import { login, logout, updateStream, getStream, getStreams, updateTopic, getTopic, getTopics, createPartition, deletePartition, createTopic, deleteTopic, createStream, deleteStream, } from './wire/index.js';
21
22
  try {
@@ -66,6 +67,7 @@ try {
66
67
  // GET_TOPIC
67
68
  const t2 = await getTopic(s)({ streamId: topic1.streamId, topicId: topic1.name });
68
69
  console.log('RESPONSE_getTopic', t2);
70
+ assert.ok(t2);
69
71
  // UPDATE_TOPIC
70
72
  const r_updateTopic = await updateTopic(s)({
71
73
  streamId: topic1.streamId, topicId: topic1.topicId, name: topic1.name, messageExpiry: 42n
@@ -24,7 +24,7 @@ export type GetClient = {
24
24
  export declare const GET_CLIENT: {
25
25
  code: number;
26
26
  serialize: ({ clientId }: GetClient) => Buffer;
27
- deserialize: (r: CommandResponse) => Client;
27
+ deserialize: (r: CommandResponse) => Client | null;
28
28
  };
29
- export declare const getClient: (getClient: import("../../client/client.type.js").ClientProvider) => (arg: GetClient) => Promise<Client>;
29
+ export declare const getClient: (getClient: import("../../client/client.type.js").ClientProvider) => (arg: GetClient) => Promise<Client | null>;
30
30
  //# sourceMappingURL=get-client.command.d.ts.map
@@ -27,7 +27,11 @@ export const GET_CLIENT = {
27
27
  b.writeUInt32LE(clientId);
28
28
  return b;
29
29
  },
30
- deserialize: (r) => deserializeClient(r.data).data
30
+ deserialize: (r) => {
31
+ if (r.status === 0 && r.length === 0)
32
+ return null;
33
+ return deserializeClient(r.data).data;
34
+ }
31
35
  };
32
36
  export const getClient = wrapCommand(GET_CLIENT);
33
37
  //# sourceMappingURL=get-client.command.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { type ValueOf } from "../../type.utils.js";
20
+ export declare const ClusterNodeRole: {
21
+ readonly Leader: 0;
22
+ readonly Follower: 1;
23
+ };
24
+ export type ClusterNodeRole = typeof ClusterNodeRole;
25
+ export type ClusterNodeRoleKey = keyof ClusterNodeRole;
26
+ export type ClusterNodeRoleValue = ValueOf<ClusterNodeRole>;
27
+ export declare const ReverseClusterNodeRole: Record<0 | 1, "Leader" | "Follower">;
28
+ export declare const ClusterNodeStatus: {
29
+ readonly Healthy: 0;
30
+ readonly Starting: 1;
31
+ readonly Stopping: 2;
32
+ readonly Unreachable: 3;
33
+ readonly Maintenance: 4;
34
+ };
35
+ export type ClusterNodeStatus = typeof ClusterNodeStatus;
36
+ export type ClusterNodeStatusKey = keyof ClusterNodeStatus;
37
+ export type ClusterNodeStatusValue = ValueOf<ClusterNodeStatus>;
38
+ export declare const ReverseClusterNodeStatus: Record<0 | 1 | 2 | 4 | 3, "Healthy" | "Starting" | "Stopping" | "Unreachable" | "Maintenance">;
39
+ export declare const TransportProtocol: {
40
+ readonly TCP: 1;
41
+ readonly QUIC: 2;
42
+ readonly HTTP: 3;
43
+ };
44
+ export type TransportProtocol = typeof TransportProtocol;
45
+ export type TransportProtocolKey = keyof TransportProtocol;
46
+ export type TransportProtocolValue = ValueOf<TransportProtocol>;
47
+ export declare const ReverseTransportProtocol: Record<1 | 2 | 3, "TCP" | "QUIC" | "HTTP">;
48
+ export declare const isClusterNodeRole: (n: number) => n is ClusterNodeRoleValue;
49
+ export declare const isClusterNodeStatus: (n: number) => n is ClusterNodeStatusValue;
50
+ export declare const isTransportProtocol: (n: number) => n is TransportProtocolValue;
51
+ export declare const mapClusterNodeRole: (n: number) => ClusterNodeRoleKey;
52
+ export declare const mapClusterNodeStatus: (n: number) => ClusterNodeStatusKey;
53
+ export declare const mapTransportProtocol: (n: number) => TransportProtocolKey;
54
+ //# sourceMappingURL=cluster.type.d.ts.map
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { reverseRecord } from "../../type.utils.js";
20
+ export const ClusterNodeRole = {
21
+ Leader: 0,
22
+ Follower: 1
23
+ };
24
+ export const ReverseClusterNodeRole = reverseRecord(ClusterNodeRole);
25
+ export const ClusterNodeStatus = {
26
+ // Node is healthy and responsive
27
+ Healthy: 0,
28
+ // Node is starting up
29
+ Starting: 1,
30
+ // Node is shutting down
31
+ Stopping: 2,
32
+ // Node is unreachable
33
+ Unreachable: 3,
34
+ // Node is in maintenance mode
35
+ Maintenance: 4,
36
+ };
37
+ export const ReverseClusterNodeStatus = reverseRecord(ClusterNodeStatus);
38
+ export const TransportProtocol = {
39
+ TCP: 1,
40
+ QUIC: 2,
41
+ HTTP: 3
42
+ };
43
+ export const ReverseTransportProtocol = reverseRecord(TransportProtocol);
44
+ export const isClusterNodeRole = (n) => n in ReverseClusterNodeRole;
45
+ export const isClusterNodeStatus = (n) => n in ReverseClusterNodeStatus;
46
+ export const isTransportProtocol = (n) => n in ReverseTransportProtocol;
47
+ export const mapClusterNodeRole = (n) => {
48
+ if (!isClusterNodeRole(n))
49
+ throw new Error('Invalid ClusterNodeRole', { cause: { role: n, ClusterNodeRole } });
50
+ return ReverseClusterNodeRole[n];
51
+ };
52
+ export const mapClusterNodeStatus = (n) => {
53
+ if (!isClusterNodeStatus(n))
54
+ throw new Error('Invalid ClusterNodeStatus', { cause: { status: n, ClusterNodeStatus } });
55
+ return ReverseClusterNodeStatus[n];
56
+ };
57
+ export const mapTransportProtocol = (n) => {
58
+ if (!isTransportProtocol(n))
59
+ throw new Error('Invalid TransportProtocol', { cause: { transport: n, TransportProtocol } });
60
+ return ReverseTransportProtocol[n];
61
+ };
62
+ //# sourceMappingURL=cluster.type.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { type ClusterNodeRoleKey, type ClusterNodeStatusKey, type TransportProtocolKey } from './cluster.type.js';
20
+ export type ClusterNode = {
21
+ id: number;
22
+ name: string;
23
+ address: string;
24
+ role: ClusterNodeRoleKey;
25
+ status: ClusterNodeStatusKey;
26
+ };
27
+ type DeserializedClusterNode = {
28
+ length: number;
29
+ data: ClusterNode;
30
+ };
31
+ export declare const deserializeNode: (b: Buffer, pos?: number) => DeserializedClusterNode;
32
+ export type ClusterMetadata = {
33
+ name: string;
34
+ id: number;
35
+ transport: TransportProtocolKey;
36
+ nodes: ClusterNode[];
37
+ };
38
+ export declare const deserializeMetadata: (b: Buffer, pos?: number) => ClusterMetadata;
39
+ export {};
40
+ //# sourceMappingURL=cluster.utils.d.ts.map
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { deserializeError } from '../error.utils.js';
20
+ import { mapClusterNodeRole, mapClusterNodeStatus, mapTransportProtocol, } from './cluster.type.js';
21
+ const CLUSTER_NODE_MIN_BUFFER_SIZE = 16; // 4 + 1 + 4 + 1 + 4 + 1 + 1;
22
+ export const deserializeNode = (b, pos = 0) => {
23
+ if (b.length - pos < CLUSTER_NODE_MIN_BUFFER_SIZE)
24
+ deserializeError('cluster node', pos, b.length, CLUSTER_NODE_MIN_BUFFER_SIZE);
25
+ const id = b.readUInt32LE(pos);
26
+ pos += 4;
27
+ const nameLen = b.readUInt32LE(pos);
28
+ if (b.length - pos < 4 + nameLen)
29
+ deserializeError('cluster node', pos, b.length, 4 + nameLen, { id, nameLen });
30
+ const name = b.subarray(pos + 4, pos + 4 + nameLen).toString();
31
+ pos += nameLen + 4;
32
+ const addrLen = b.readUInt32LE(pos);
33
+ if (b.length - pos < 4 + addrLen)
34
+ deserializeError('cluster node', pos, b.length, 4 + addrLen, { id, nameLen, name, addrLen });
35
+ const address = b.subarray(pos + 4, pos + 4 + addrLen).toString();
36
+ pos += addrLen + 4;
37
+ if (b.length - pos < 2)
38
+ deserializeError('cluster node', pos, b.length, 2, { id, nameLen, name, addrLen, address });
39
+ const role = mapClusterNodeRole(b.readUInt8(pos));
40
+ pos += 1;
41
+ const status = mapClusterNodeStatus(b.readUInt8(pos));
42
+ pos += 1;
43
+ return {
44
+ length: 4 + nameLen + 4 + addrLen + 4 + 1 + 1,
45
+ data: {
46
+ id,
47
+ name,
48
+ address,
49
+ role,
50
+ status
51
+ }
52
+ };
53
+ };
54
+ // min = 4 + 1 + 4 + 1 + 1 + 4 + CLUSTER_NODE_MIN_BUFFER_SIZE;
55
+ const CLUSTER_METADATA_MIN_SIZE = 15 + CLUSTER_NODE_MIN_BUFFER_SIZE;
56
+ export const deserializeMetadata = (b, pos = 0) => {
57
+ if (b.length - pos < CLUSTER_METADATA_MIN_SIZE)
58
+ deserializeError('cluster metadata', pos, b.length, CLUSTER_METADATA_MIN_SIZE);
59
+ const nameLen = b.readUInt32LE(pos);
60
+ if (b.length - pos < 4 + nameLen)
61
+ deserializeError('cluster metadata', pos, b.length, 4 + nameLen, { nameLen });
62
+ const name = b.subarray(pos + 4, pos + 4 + nameLen).toString();
63
+ pos += nameLen + 4;
64
+ if (b.length - pos < 4 + 1 + 4)
65
+ deserializeError('cluster metadata', pos, b.length, 4 + 1 + 4, { nameLen, name });
66
+ const id = b.readUInt32LE(pos);
67
+ pos += 4;
68
+ const transport = mapTransportProtocol(b.readUInt8(pos));
69
+ pos += 1;
70
+ const nodeCount = b.readUInt32LE(pos);
71
+ pos += 4;
72
+ const nodes = [];
73
+ for (let i = 0; i < nodeCount; i++) {
74
+ const { length, data } = deserializeNode(b, pos);
75
+ nodes.push(data);
76
+ pos += length;
77
+ }
78
+ return {
79
+ name,
80
+ id,
81
+ transport,
82
+ nodes
83
+ };
84
+ };
85
+ //# sourceMappingURL=cluster.utils.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import type { CommandResponse } from '../../client/index.js';
20
+ import { type ClusterMetadata } from './cluster.utils.js';
21
+ export declare const GET_CLUSTER_METADATA: {
22
+ code: number;
23
+ serialize: () => Buffer<ArrayBuffer>;
24
+ deserialize: (r: CommandResponse) => ClusterMetadata;
25
+ };
26
+ export declare const getClusterMetadata: (getClient: import("../../client/client.type.js").ClientProvider) => (arg: void) => Promise<ClusterMetadata>;
27
+ //# sourceMappingURL=get-cluster-metadata.command.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { wrapCommand } from '../command.utils.js';
20
+ import { COMMAND_CODE } from '../command.code.js';
21
+ import { deserializeMetadata } from './cluster.utils.js';
22
+ export const GET_CLUSTER_METADATA = {
23
+ code: COMMAND_CODE.GetClusterMetadata,
24
+ serialize: () => {
25
+ return Buffer.alloc(0);
26
+ },
27
+ deserialize: (r) => deserializeMetadata(r.data)
28
+ };
29
+ export const getClusterMetadata = wrapCommand(GET_CLUSTER_METADATA);
30
+ //# sourceMappingURL=get-cluster-metadata.command.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export * from './get-cluster-metadata.command.js';
20
+ export * from './cluster.type.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export * from './get-cluster-metadata.command.js';
20
+ export * from './cluster.type.js';
21
+ //# sourceMappingURL=index.js.map
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import type { ClientProvider } from '../client/client.type.js';
20
20
  declare const userAPI: (c: ClientProvider) => {
21
- get: (arg: import("./user/get-user.command.js").GetUser) => Promise<import("./user/user.utils.js").User>;
21
+ get: (arg: import("./user/get-user.command.js").GetUser) => Promise<import("./user/user.utils.js").User | null>;
22
22
  list: (arg: void) => Promise<import("./user/user.utils.js").BaseUser[]>;
23
23
  create: (arg: import("./user/create-user.command.js").CreateUser) => Promise<import("./user/user.utils.js").User>;
24
24
  update: (arg: import("./user/update-user.command.js").UpdateUser) => Promise<boolean>;
@@ -34,7 +34,7 @@ declare const sessionAPI: (c: ClientProvider) => {
34
34
  };
35
35
  type SessionAPI = ReturnType<typeof sessionAPI>;
36
36
  declare const clientAPI: (c: ClientProvider) => {
37
- get: (arg: import("./client/get-client.command.js").GetClient) => Promise<import("./client/client.utils.js").Client>;
37
+ get: (arg: import("./client/get-client.command.js").GetClient) => Promise<import("./client/client.utils.js").Client | null>;
38
38
  getMe: (arg: void) => Promise<import("./client/client.utils.js").Client>;
39
39
  list: (arg: void) => Promise<import("./client/client.utils.js").Client[]>;
40
40
  };
@@ -46,19 +46,20 @@ declare const tokenAPI: (c: ClientProvider) => {
46
46
  };
47
47
  type TokenAPI = ReturnType<typeof tokenAPI>;
48
48
  declare const streamAPI: (c: ClientProvider) => {
49
- get: (arg: import("./stream/get-stream.command.js").GetStream) => Promise<import("./stream/stream.utils.js").Stream>;
49
+ get: (arg: import("./stream/get-stream.command.js").GetStream) => Promise<import("./stream/stream.utils.js").Stream | null>;
50
50
  list: (arg: void) => Promise<import("./stream/stream.utils.js").Stream[]>;
51
51
  create: (arg: import("./stream/create-stream.command.js").CreateStream) => Promise<import("./stream/stream.utils.js").Stream>;
52
52
  update: (arg: import("./stream/update-stream.command.js").UpdateStream) => Promise<boolean>;
53
53
  delete: (arg: import("./stream/delete-stream.command.js").DeleteStream) => Promise<boolean>;
54
54
  purge: (arg: import("./stream/purge-stream.command.js").PurgeStream) => Promise<boolean>;
55
+ ensure: (streamName: string) => Promise<import("./stream/stream.utils.js").Stream>;
55
56
  };
56
57
  type StreamAPI = ReturnType<typeof streamAPI>;
57
58
  declare const topicAPI: (c: ClientProvider) => {
58
59
  get: (arg: {
59
60
  streamId: import("./identifier.utils.js").Id;
60
61
  topicId: import("./identifier.utils.js").Id;
61
- }) => Promise<import("./topic/topic.utils.js").Topic>;
62
+ }) => Promise<import("./topic/topic.utils.js").Topic | null>;
62
63
  list: (arg: import("./topic/get-topics.command.js").GetTopics) => Promise<import("./topic/topic.utils.js").Topic[]>;
63
64
  create: (arg: import("./topic/create-topic.command.js").CreateTopic) => Promise<import("./topic/topic.utils.js").Topic>;
64
65
  update: (arg: import("./topic/update-topic.command.js").UpdateTopic) => Promise<boolean>;
@@ -68,6 +69,7 @@ declare const topicAPI: (c: ClientProvider) => {
68
69
  partitionsCount: number;
69
70
  }) => Promise<boolean>;
70
71
  purge: (arg: import("./topic/purge-topic.command.js").PurgeTopic) => Promise<boolean>;
72
+ ensure: (streamId: import("./identifier.utils.js").Id, topicName: string, partitionCount?: number, compressionAlgorithm?: number) => Promise<import("./topic/topic.utils.js").Topic>;
71
73
  };
72
74
  type TopicAPI = ReturnType<typeof topicAPI>;
73
75
  declare const partitionAPI: (c: ClientProvider) => {
@@ -80,16 +82,18 @@ declare const segmentAPI: (c: ClientProvider) => {
80
82
  };
81
83
  type SegmentAPI = ReturnType<typeof segmentAPI>;
82
84
  declare const groupAPI: (c: ClientProvider) => {
83
- get: (arg: import("./consumer-group/get-group.command.js").GetGroup) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup>;
85
+ get: (arg: import("./consumer-group/get-group.command.js").GetGroup) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup | null>;
84
86
  list: (arg: import("./consumer-group/get-groups.command.js").GetGroups) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup[]>;
85
87
  create: (arg: import("./consumer-group/create-group.command.js").CreateGroup) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup>;
86
88
  join: (arg: import("./consumer-group/join-group.command.js").JoinGroup) => Promise<boolean>;
87
89
  leave: (arg: import("./consumer-group/leave-group.command.js").LeaveGroup) => Promise<boolean>;
88
90
  delete: (arg: import("./consumer-group/delete-group.command.js").DeleteGroup) => Promise<boolean>;
91
+ ensure: (streamId: import("./identifier.utils.js").Id, topicId: import("./identifier.utils.js").Id, groupName: string) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup>;
92
+ ensureAndJoin: (streamId: import("./identifier.utils.js").Id, topicId: import("./identifier.utils.js").Id, groupName: string) => Promise<import("./consumer-group/group.utils.js").ConsumerGroup>;
89
93
  };
90
94
  type GroupAPI = ReturnType<typeof groupAPI>;
91
95
  declare const offsetAPI: (c: ClientProvider) => {
92
- get: (arg: import("./offset/get-offset.command.js").GetOffset) => Promise<import("./offset/offset.utils.js").OffsetResponse>;
96
+ get: (arg: import("./offset/get-offset.command.js").GetOffset) => Promise<import("./offset/offset.utils.js").OffsetResponse | null>;
93
97
  store: (arg: import("./offset/store-offset.command.js").StoreOffset) => Promise<boolean>;
94
98
  delete: (arg: import("./offset/get-offset.command.js").GetOffset) => Promise<boolean>;
95
99
  };
@@ -105,6 +109,10 @@ declare const systemAPI: (c: ClientProvider) => {
105
109
  getStats: (arg: void) => Promise<import("./system/get-stats.command.js").Stats>;
106
110
  };
107
111
  type SystemAPI = ReturnType<typeof systemAPI>;
112
+ declare const clusterAPI: (c: ClientProvider) => {
113
+ getClusterMetadata: (arg: void) => Promise<import("./cluster/cluster.utils.js").ClusterMetadata>;
114
+ };
115
+ type ClusterAPI = ReturnType<typeof clusterAPI>;
108
116
  export declare abstract class AbstractAPI {
109
117
  clientProvider: ClientProvider;
110
118
  constructor(getClient: ClientProvider);
@@ -122,6 +130,7 @@ export declare abstract class CommandAPI extends AbstractAPI {
122
130
  offset: OffsetAPI;
123
131
  message: MessageAPI;
124
132
  system: SystemAPI;
133
+ cluster: ClusterAPI;
125
134
  constructor(c: ClientProvider);
126
135
  }
127
136
  export {};