apache-iggy 0.8.0 → 0.8.1-edge.1
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/NOTICE +12 -0
- package/README.md +14 -0
- package/dist/client/client.utils.d.ts +1 -0
- package/dist/client/client.utils.js +2 -1
- package/dist/client/client.utils.test.d.ts +20 -0
- package/dist/client/client.utils.test.js +59 -0
- package/dist/wire/message/send-messages.command.js +2 -2
- package/dist/wire/message/send-messages.command.test.js +18 -0
- package/package.json +5 -3
package/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Apache Iggy (Incubating)
|
|
2
|
+
Copyright 2026 The Apache Software Foundation
|
|
3
|
+
|
|
4
|
+
This product includes software developed at
|
|
5
|
+
The Apache Software Foundation (http://www.apache.org/).
|
|
6
|
+
|
|
7
|
+
================================================================
|
|
8
|
+
|
|
9
|
+
The Iggy project code was originally created, designed, developed by Piotr Gankiewicz in April 2023.
|
|
10
|
+
It was released as an open-source project under MIT License, later converted to Apache 2.0 License,
|
|
11
|
+
and donated by LaserData, Inc. to the Apache Software Foundation (ASF) in February 2025.
|
|
12
|
+
Copyright April 2023 - February 2025 Piotr Gankiewicz, LaserData, Inc.
|
package/README.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apache/iggy/refs/heads/master/assets/logo/SVG/iggy-apache-color-darkbg.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/apache/iggy/refs/heads/master/assets/logo/SVG/iggy-apache-color-lightbg.svg">
|
|
5
|
+
<img alt="Apache Iggy" src="https://raw.githubusercontent.com/apache/iggy/refs/heads/master/assets/logo/SVG/iggy-apache-color-lightbg.svg" width="320">
|
|
6
|
+
</picture>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
1
9
|
# Apache Iggy Node.js Client
|
|
2
10
|
|
|
3
11
|
Apache Iggy Node.js client written in typescript, it currently only supports tcp & tls transports.
|
|
4
12
|
|
|
13
|
+
> Apache Iggy (Incubating) is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
|
14
|
+
>
|
|
15
|
+
> Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
|
|
16
|
+
>
|
|
17
|
+
> While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
|
|
18
|
+
|
|
5
19
|
diclaimer: although all iggy commands & basic client/stream are implemented this is still a WIP, provided as is, and has still a long way to go to be considered "battle tested".
|
|
6
20
|
|
|
7
21
|
note: This lib started as _iggy-bin_ ( [github](https://github.com/T1B0/iggy-bin) / [npm](https://www.npmjs.com/package/iggy-bin)) before migrating under iggy-rs org. package iggy-bin@v1.3.4 is equivalent to @iggy.rs/sdk@v1.0.3 and migrating again under apache iggy monorepo ( [github](https://github.com/apache/iggy/tree/master/foreign/node) and is now published on npmjs as apache-iggy
|
|
@@ -45,6 +45,7 @@ export declare const handleResponseTransform: () => Transform;
|
|
|
45
45
|
* @returns True if the response indicates success with no data
|
|
46
46
|
*/
|
|
47
47
|
export declare const deserializeVoidResponse: (r: CommandResponse) => boolean;
|
|
48
|
+
export declare const deserializeStatusResponse: (r: CommandResponse) => boolean;
|
|
48
49
|
/**
|
|
49
50
|
* Serializes a command and its payload into a buffer for sending to the server.
|
|
50
51
|
* Creates the wire format: [payload_size (4 bytes)][command (4 bytes)][payload]
|
|
@@ -31,7 +31,7 @@ export const handleResponse = (r) => {
|
|
|
31
31
|
const length = r.readUint32LE(4);
|
|
32
32
|
debug('<== handleResponse', { status, length });
|
|
33
33
|
return {
|
|
34
|
-
status, length, data: r.subarray(8)
|
|
34
|
+
status, length, data: r.subarray(8, 8 + length)
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
@@ -60,6 +60,7 @@ export const handleResponseTransform = () => new Transform({
|
|
|
60
60
|
* @returns True if the response indicates success with no data
|
|
61
61
|
*/
|
|
62
62
|
export const deserializeVoidResponse = (r) => r.status === 0 && r.data.length === 0;
|
|
63
|
+
export const deserializeStatusResponse = (r) => r.status === 0;
|
|
63
64
|
/** Length of the command code in bytes */
|
|
64
65
|
const COMMAND_LENGTH = 4;
|
|
65
66
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
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 {};
|
|
20
|
+
//# sourceMappingURL=client.utils.test.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { describe, it } from 'node:test';
|
|
20
|
+
import assert from 'node:assert/strict';
|
|
21
|
+
import { handleResponse, deserializeVoidResponse, deserializeStatusResponse } from './client.utils.js';
|
|
22
|
+
const SUCCESS = 0;
|
|
23
|
+
const ERROR = 1;
|
|
24
|
+
describe('handleResponse', () => {
|
|
25
|
+
it('bounds data to the length field, not the full buffer', () => {
|
|
26
|
+
// Server says: status=0, length=0, no payload.
|
|
27
|
+
// But the raw buffer has 4 trailing bytes (e.g. start of next response).
|
|
28
|
+
const buf = Buffer.alloc(12);
|
|
29
|
+
buf.writeUInt32LE(SUCCESS, 0); // status
|
|
30
|
+
buf.writeUInt32LE(0, 4); // length = 0 (void response)
|
|
31
|
+
buf.writeUInt32LE(42, 8); // trailing bytes — NOT part of this response
|
|
32
|
+
const r = handleResponse(buf);
|
|
33
|
+
assert.equal(r.data.length, 0);
|
|
34
|
+
});
|
|
35
|
+
it('deserializeVoidResponse returns true for a valid void response with trailing buffer bytes', () => {
|
|
36
|
+
const buf = Buffer.alloc(12);
|
|
37
|
+
buf.writeUInt32LE(SUCCESS, 0);
|
|
38
|
+
buf.writeUInt32LE(0, 4); // length = 0
|
|
39
|
+
buf.writeUInt32LE(42, 8); // trailing bytes
|
|
40
|
+
const r = handleResponse(buf);
|
|
41
|
+
assert.equal(deserializeVoidResponse(r), true);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('deserializeStatusResponse', () => {
|
|
45
|
+
it('returns true when status is SUCCESS and data is empty', () => {
|
|
46
|
+
const r = { status: SUCCESS, length: 0, data: Buffer.alloc(0) };
|
|
47
|
+
assert.equal(deserializeStatusResponse(r), true);
|
|
48
|
+
});
|
|
49
|
+
it('returns true when status is SUCCESS and data is non-empty (e.g. SendMessages server payload)', () => {
|
|
50
|
+
// Key difference from deserializeVoidResponse: non-empty data is accepted.
|
|
51
|
+
const r = { status: SUCCESS, length: 4, data: Buffer.from([1, 2, 3, 4]) };
|
|
52
|
+
assert.equal(deserializeStatusResponse(r), true);
|
|
53
|
+
});
|
|
54
|
+
it('returns false when status is an error code', () => {
|
|
55
|
+
const r = { status: ERROR, length: 0, data: Buffer.alloc(0) };
|
|
56
|
+
assert.equal(deserializeStatusResponse(r), false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=client.utils.test.js.map
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { serializeSendMessages } from './message.utils.js';
|
|
20
|
-
import {
|
|
20
|
+
import { deserializeStatusResponse } from '../../client/client.utils.js';
|
|
21
21
|
import { wrapCommand } from '../command.utils.js';
|
|
22
22
|
import { COMMAND_CODE } from '../command.code.js';
|
|
23
23
|
/**
|
|
@@ -29,7 +29,7 @@ export const SEND_MESSAGES = {
|
|
|
29
29
|
serialize: ({ streamId, topicId, messages, partition }) => {
|
|
30
30
|
return serializeSendMessages(streamId, topicId, messages, partition);
|
|
31
31
|
},
|
|
32
|
-
deserialize:
|
|
32
|
+
deserialize: deserializeStatusResponse
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Executable send messages command function.
|
|
@@ -21,6 +21,8 @@ import assert from "node:assert/strict";
|
|
|
21
21
|
import { uuidv7, uuidv4 } from "uuidv7";
|
|
22
22
|
import { SEND_MESSAGES } from "./send-messages.command.js";
|
|
23
23
|
import { HeaderValue, HeaderKeyFactory } from "./header.utils.js";
|
|
24
|
+
const SUCCESS = 0;
|
|
25
|
+
const ERROR = 1;
|
|
24
26
|
describe("SendMessages", () => {
|
|
25
27
|
describe("serialize", () => {
|
|
26
28
|
const t1 = {
|
|
@@ -148,5 +150,21 @@ describe("SendMessages", () => {
|
|
|
148
150
|
assert.doesNotThrow(() => SEND_MESSAGES.serialize(t));
|
|
149
151
|
});
|
|
150
152
|
});
|
|
153
|
+
describe('deserialize', () => {
|
|
154
|
+
it('returns true when status is SUCCESS with empty data', () => {
|
|
155
|
+
const r = { status: SUCCESS, length: 0, data: Buffer.alloc(0) };
|
|
156
|
+
assert.equal(SEND_MESSAGES.deserialize(r), true);
|
|
157
|
+
});
|
|
158
|
+
it('returns true when status is SUCCESS with non-empty server payload', () => {
|
|
159
|
+
// SendMessages server response includes data (e.g. partition/offset info).
|
|
160
|
+
// The deserializer must accept non-empty data unlike deserializeVoidResponse.
|
|
161
|
+
const r = { status: SUCCESS, length: 4, data: Buffer.from([1, 2, 3, 4]) };
|
|
162
|
+
assert.equal(SEND_MESSAGES.deserialize(r), true);
|
|
163
|
+
});
|
|
164
|
+
it('returns false when status is an error code', () => {
|
|
165
|
+
const r = { status: ERROR, length: 0, data: Buffer.alloc(0) };
|
|
166
|
+
assert.equal(SEND_MESSAGES.deserialize(r), false);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
151
169
|
});
|
|
152
170
|
//# sourceMappingURL=send-messages.command.test.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apache-iggy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.1-edge.1",
|
|
5
5
|
"description": "Official Apache Iggy NodeJS SDK",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"iggy",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"dist/**/*.d.ts",
|
|
29
29
|
"dist/index.d.ts",
|
|
30
30
|
"!dist/bdd/",
|
|
31
|
-
"!dist/examples/"
|
|
31
|
+
"!dist/examples/",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"NOTICE"
|
|
32
34
|
],
|
|
33
35
|
"types": "dist/index.d.ts",
|
|
34
36
|
"main": "dist/index.js",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@commitlint/cli": "20.1.0",
|
|
56
58
|
"@commitlint/config-conventional": "20.0.0",
|
|
57
|
-
"@cucumber/cucumber": "12.2
|
|
59
|
+
"@cucumber/cucumber": "12.8.2",
|
|
58
60
|
"@swc-node/register": "1.11.1",
|
|
59
61
|
"@types/debug": "4.1.12",
|
|
60
62
|
"@types/node": "24.10.1",
|