@motiadev/adapter-redis-streams 0.8.2-beta.140-709523 → 0.8.2-beta.140-460356

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
@@ -18,7 +18,7 @@ import { RedisStreamAdapter } from '@motiadev/adapter-redis-streams'
18
18
 
19
19
  export default config({
20
20
  adapters: {
21
- streams: new RedisStreamAdapter({
21
+ streams: (streamName) => new RedisStreamAdapter(streamName, {
22
22
  host: process.env.REDIS_HOST || 'localhost',
23
23
  port: parseInt(process.env.REDIS_PORT || '6379'),
24
24
  password: process.env.REDIS_PASSWORD,
@@ -55,15 +55,17 @@ export default config({
55
55
  ## Key Namespacing
56
56
 
57
57
  The adapter uses the following patterns:
58
- - **Stream data**: `{keyPrefix}{groupId}:{id}`
59
- - **Events**: `motia:stream:events:{groupId}` or `motia:stream:events:{groupId}:{id}`
58
+ - **Stream data**: `{keyPrefix}{streamName}:{groupId}:{id}`
59
+ - **Events**: `motia:stream:events:{streamName}:{groupId}` or `motia:stream:events:{streamName}:{groupId}:{id}`
60
+
61
+ This ensures that different streams with the same groupId don't conflict when using shared storage.
60
62
 
61
63
  For example:
62
64
  ```
63
- motia:stream:users:user-123
64
- motia:stream:orders:order-456
65
- motia:stream:events:users
66
- motia:stream:events:users:user-123
65
+ motia:stream:users:active:user-123
66
+ motia:stream:orders:pending:order-456
67
+ motia:stream:events:users:active
68
+ motia:stream:events:users:active:user-123
67
69
  ```
68
70
 
69
71
  ## Example
@@ -71,7 +73,7 @@ motia:stream:events:users:user-123
71
73
  ```typescript
72
74
  import { RedisStreamAdapter } from '@motiadev/adapter-redis-streams'
73
75
 
74
- const adapter = new RedisStreamAdapter({
76
+ const adapter = new RedisStreamAdapter('users', {
75
77
  host: 'redis.example.com',
76
78
  port: 6379,
77
79
  password: 'your-secure-password',
@@ -8,7 +8,7 @@ export declare class RedisStreamAdapter<TData> extends StreamAdapter<TData> {
8
8
  private keyPrefix;
9
9
  private connected;
10
10
  private subscriptions;
11
- constructor(config: RedisStreamAdapterConfig);
11
+ constructor(streamName: string, config: RedisStreamAdapterConfig);
12
12
  private connect;
13
13
  private ensureConnected;
14
14
  private makeKey;
@@ -1 +1 @@
1
- {"version":3,"file":"redis-stream-adapter.d.ts","sourceRoot":"","sources":["../src/redis-stream-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAEvD,qBAAa,kBAAkB,CAAC,KAAK,CAAE,SAAQ,aAAa,CAAC,KAAK,CAAC;IACjE,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,aAAa,CAAiF;gBAE1F,MAAM,EAAE,wBAAwB;YA8C9B,OAAO;YAWP,eAAe;IAM7B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,cAAc;IAMhB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAOvE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAW7E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAW1E,QAAQ,CAAC,OAAO,EAAE,MAAM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+BlF,QAAQ;IAgBhB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAY/B"}
@@ -4,8 +4,8 @@ exports.RedisStreamAdapter = void 0;
4
4
  const core_1 = require("@motiadev/core");
5
5
  const redis_1 = require("redis");
6
6
  class RedisStreamAdapter extends core_1.StreamAdapter {
7
- constructor(config) {
8
- super();
7
+ constructor(streamName, config) {
8
+ super(streamName);
9
9
  this.connected = false;
10
10
  this.subscriptions = new Map();
11
11
  this.keyPrefix = config.keyPrefix || 'motia:stream:';
@@ -60,12 +60,14 @@ class RedisStreamAdapter extends core_1.StreamAdapter {
60
60
  }
61
61
  }
62
62
  makeKey(groupId, id) {
63
- return id ? `${this.keyPrefix}${groupId}:${id}` : `${this.keyPrefix}${groupId}`;
63
+ return id
64
+ ? `${this.keyPrefix}${this.streamName}:${groupId}:${id}`
65
+ : `${this.keyPrefix}${this.streamName}:${groupId}`;
64
66
  }
65
67
  makeChannelKey(channel) {
66
68
  return channel.id
67
- ? `motia:stream:events:${channel.groupId}:${channel.id}`
68
- : `motia:stream:events:${channel.groupId}`;
69
+ ? `motia:stream:events:${this.streamName}:${channel.groupId}:${channel.id}`
70
+ : `motia:stream:events:${this.streamName}:${channel.groupId}`;
69
71
  }
70
72
  async get(groupId, id) {
71
73
  await this.ensureConnected();
package/package.json CHANGED
@@ -3,10 +3,10 @@
3
3
  "description": "Redis streams adapter for Motia framework, enabling distributed stream management with real-time updates.",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
- "version": "0.8.2-beta.140-709523",
6
+ "version": "0.8.2-beta.140-460356",
7
7
  "dependencies": {
8
8
  "redis": "^4.7.0",
9
- "@motiadev/core": "0.8.2-beta.140-709523"
9
+ "@motiadev/core": "0.8.2-beta.140-460356"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^22.10.2",