pulse-sdk 0.0.1 → 0.0.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.
- package/dist/proto/client.js +10 -1
- package/dist/proto/pulse.proto +64 -0
- package/package.json +2 -1
package/dist/proto/client.js
CHANGED
|
@@ -37,10 +37,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.createClient = createClient;
|
|
40
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
41
|
const path_1 = __importDefault(require("path"));
|
|
41
42
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
42
43
|
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
43
|
-
|
|
44
|
+
// Prefer the proto bundled with the package (dist/proto/pulse.proto).
|
|
45
|
+
// In development (when running from source), fall back to the repository proto.
|
|
46
|
+
const bundledProto = path_1.default.resolve(__dirname, 'pulse.proto');
|
|
47
|
+
const repoProto = path_1.default.resolve(__dirname, '../../../../internal/api/proto/pulse.proto');
|
|
48
|
+
let PROTO_PATH = bundledProto;
|
|
49
|
+
if (!fs_1.default.existsSync(bundledProto)) {
|
|
50
|
+
// fallback to repo proto for local development
|
|
51
|
+
PROTO_PATH = repoProto;
|
|
52
|
+
}
|
|
44
53
|
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
|
|
45
54
|
keepCase: true,
|
|
46
55
|
longs: String,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package pulse.v1;
|
|
4
|
+
|
|
5
|
+
option go_package = "pulse/pkg/proto";
|
|
6
|
+
|
|
7
|
+
service PulseService {
|
|
8
|
+
// Publish sends a message to a topic.
|
|
9
|
+
rpc Publish(PublishRequest) returns (PublishResponse);
|
|
10
|
+
|
|
11
|
+
// Consume reads messages from a topic as a stream.
|
|
12
|
+
rpc Consume(ConsumeRequest) returns (stream ConsumeResponse);
|
|
13
|
+
|
|
14
|
+
// CommitOffset commits the offset for a consumer group.
|
|
15
|
+
rpc CommitOffset(CommitOffsetRequest) returns (CommitOffsetResponse);
|
|
16
|
+
|
|
17
|
+
// CreateTopic creates a new topic.
|
|
18
|
+
rpc CreateTopic(CreateTopicRequest) returns (CreateTopicResponse);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message PublishRequest {
|
|
22
|
+
string topic = 1;
|
|
23
|
+
bytes payload = 2;
|
|
24
|
+
map<string, string> headers = 3;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message PublishResponse {
|
|
28
|
+
string id = 1;
|
|
29
|
+
uint64 offset = 2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
message ConsumeRequest {
|
|
33
|
+
string topic = 1;
|
|
34
|
+
string consumer_name = 2;
|
|
35
|
+
uint64 offset = 3; // Optional: start from specific offset. If 0, continues from last committed.
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message ConsumeResponse {
|
|
39
|
+
uint64 offset = 1;
|
|
40
|
+
int64 timestamp = 2;
|
|
41
|
+
bytes payload = 3;
|
|
42
|
+
map<string, string> headers = 4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message CommitOffsetRequest {
|
|
46
|
+
string topic = 1;
|
|
47
|
+
string consumer_name = 2;
|
|
48
|
+
uint64 offset = 3;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
message CommitOffsetResponse {
|
|
52
|
+
bool success = 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message CreateTopicRequest {
|
|
56
|
+
string topic = 1;
|
|
57
|
+
bool fifo = 2;
|
|
58
|
+
int64 retention_bytes = 3;
|
|
59
|
+
int64 retention_time = 4; // Nanoseconds
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message CreateTopicResponse {
|
|
63
|
+
bool success = 1;
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulse-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Pulse SDK for Node.js/TypeScript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"postbuild": "node scripts/copy-proto.js",
|
|
9
10
|
"test": "jest"
|
|
10
11
|
},
|
|
11
12
|
"author": "",
|