@motiadev/stream-client-node 0.5.2-beta.104-330172 → 0.5.3-beta.105

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/README.md CHANGED
@@ -27,9 +27,7 @@ npm install @motiadev/stream-client-node
27
27
  ```typescript
28
28
  import { Stream } from '@motiadev/stream-client-node'
29
29
 
30
- const stream = new Stream('wss://your-stream-server', () => {
31
- console.log('WebSocket connection established!')
32
- })
30
+ const stream = new Stream('wss://your-stream-server')
33
31
  ```
34
32
 
35
33
  ### 2. Subscribing to an Item Stream
@@ -163,18 +161,17 @@ All types are exported from `stream.types.ts` for advanced usage and type safety
163
161
  ```typescript
164
162
  import { Stream } from '@motiadev/stream-client-node'
165
163
 
166
- const stream = new Stream('wss://example.com', () => {
167
- const userSub = stream.subscribeItem<{ id: string; name: string }>('users', 'user-1')
164
+ const stream = new Stream('wss://example.com')
165
+ const userSub = stream.subscribeItem<{ id: string; name: string }>('users', 'user-1')
168
166
 
169
- userSub.addChangeListener((user) => {
170
- // React to user changes
171
- })
167
+ userSub.addChangeListener((user) => {
168
+ // React to user changes
169
+ })
172
170
 
173
- const groupSub = stream.subscribeGroup<{ id: string; name: string }>('users', 'group-1')
171
+ const groupSub = stream.subscribeGroup<{ id: string; name: string }>('users', 'group-1')
174
172
 
175
- groupSub.addChangeListener((users) => {
176
- // React to group changes
177
- })
173
+ groupSub.addChangeListener((users) => {
174
+ // React to group changes
178
175
  })
179
176
  ```
180
177
 
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamSubscription = exports.StreamGroupSubscription = exports.StreamItemSubscription = exports.Stream = void 0;
4
+ var stream_1 = require("./src/stream");
5
+ Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return stream_1.Stream; } });
6
+ var stream_client_1 = require("@motiadev/stream-client");
7
+ Object.defineProperty(exports, "StreamItemSubscription", { enumerable: true, get: function () { return stream_client_1.StreamItemSubscription; } });
8
+ Object.defineProperty(exports, "StreamGroupSubscription", { enumerable: true, get: function () { return stream_client_1.StreamGroupSubscription; } });
9
+ Object.defineProperty(exports, "StreamSubscription", { enumerable: true, get: function () { return stream_client_1.StreamSubscription; } });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamSocketAdapter = void 0;
4
+ const ws_1 = require("ws");
5
+ class StreamSocketAdapter {
6
+ constructor(address) {
7
+ this.address = address;
8
+ this.ws = new ws_1.WebSocket(this.address);
9
+ }
10
+ connect() { }
11
+ send(message) {
12
+ this.ws.send(message);
13
+ }
14
+ onMessage(callback) {
15
+ const listener = (message) => callback(message.data.toString());
16
+ this.ws.addEventListener('message', listener);
17
+ }
18
+ onOpen(callback) {
19
+ this.ws.addEventListener('open', callback);
20
+ }
21
+ onClose(callback) {
22
+ this.ws.addEventListener('close', callback);
23
+ }
24
+ close() {
25
+ this.ws.close();
26
+ this.ws.removeAllListeners();
27
+ }
28
+ isOpen() {
29
+ return this.ws.readyState === ws_1.WebSocket.OPEN;
30
+ }
31
+ }
32
+ exports.StreamSocketAdapter = StreamSocketAdapter;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stream = void 0;
4
+ const stream_client_1 = require("@motiadev/stream-client");
5
+ const stream_adapter_1 = require("./stream-adapter");
6
+ class Stream extends stream_client_1.Stream {
7
+ constructor(address) {
8
+ super(() => new stream_adapter_1.StreamSocketAdapter(address));
9
+ }
10
+ }
11
+ exports.Stream = Stream;
@@ -0,0 +1,2 @@
1
+ export { Stream } from './src/stream';
2
+ export { StreamItemSubscription, StreamGroupSubscription, StreamSubscription } from '@motiadev/stream-client';
@@ -0,0 +1,13 @@
1
+ import type { SocketAdapter } from '@motiadev/stream-client';
2
+ export declare class StreamSocketAdapter implements SocketAdapter {
3
+ private address;
4
+ private ws;
5
+ constructor(address: string);
6
+ connect(): void;
7
+ send(message: string): void;
8
+ onMessage(callback: (message: string) => void): void;
9
+ onOpen(callback: () => void): void;
10
+ onClose(callback: () => void): void;
11
+ close(): void;
12
+ isOpen(): boolean;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { Stream as StreamClient } from '@motiadev/stream-client';
2
+ export declare class Stream extends StreamClient {
3
+ constructor(address: string);
4
+ }
@@ -0,0 +1,2 @@
1
+ export { Stream } from './src/stream';
2
+ export { StreamItemSubscription, StreamGroupSubscription, StreamSubscription } from '@motiadev/stream-client';
@@ -0,0 +1,13 @@
1
+ import type { SocketAdapter } from '@motiadev/stream-client';
2
+ export declare class StreamSocketAdapter implements SocketAdapter {
3
+ private address;
4
+ private ws;
5
+ constructor(address: string);
6
+ connect(): void;
7
+ send(message: string): void;
8
+ onMessage(callback: (message: string) => void): void;
9
+ onOpen(callback: () => void): void;
10
+ onClose(callback: () => void): void;
11
+ close(): void;
12
+ isOpen(): boolean;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { Stream as StreamClient } from '@motiadev/stream-client';
2
+ export declare class Stream extends StreamClient {
3
+ constructor(address: string);
4
+ }
package/package.json CHANGED
@@ -1,14 +1,27 @@
1
1
  {
2
2
  "name": "@motiadev/stream-client-node",
3
3
  "description": "Motia Stream Client Package – Responsible for managing streams of data.",
4
- "version": "0.5.2-beta.104-330172",
4
+ "version": "0.5.3-beta.105",
5
5
  "license": "MIT",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
6
+ "main": "dist/cjs/index.js",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "require": "./dist/cjs/index.js",
12
+ "import": "./dist/esm/index.js",
13
+ "types": "./dist/types/index.d.ts"
14
+ },
15
+ "./workbench": {
16
+ "require": "./dist/cjs/workbench.js",
17
+ "import": "./dist/esm/workbench.js",
18
+ "types": "./dist/types/workbench.d.ts"
19
+ }
20
+ },
8
21
  "dependencies": {
9
22
  "uuid": "^11.1.0",
10
23
  "ws": "^8.18.2",
11
- "@motiadev/stream-client": "0.5.2-beta.104-330172"
24
+ "@motiadev/stream-client": "0.5.3-beta.105"
12
25
  },
13
26
  "devDependencies": {
14
27
  "@types/jest": "^29.5.14",
@@ -18,7 +31,7 @@
18
31
  "typescript": "^5.7.2"
19
32
  },
20
33
  "scripts": {
21
- "build": "rm -rf dist && tsc",
34
+ "build": "sh scripts/build.sh",
22
35
  "lint": "eslint --config ../../eslint.config.js"
23
36
  }
24
37
  }
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+
3
+ rm -rf dist
4
+
5
+ echo "Building CommonJS version..."
6
+ npx tsc --project tsconfig.json --outDir dist/cjs --module CommonJS
7
+
8
+ echo "Building ESM version..."
9
+ npx tsc --project tsconfig.json --outDir dist/esm --module ES2020
10
+
11
+ echo "Building type declarations..."
12
+ npx tsc --emitDeclarationOnly --declaration --outDir dist/types
13
+
14
+ echo "Build completed successfully!"
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { Stream } from './src/stream'
2
- export { StreamItemSubscription, StreamGroupSubscription, StreamSubscription } from '@motiadev/stream-client'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes