@motiadev/adapter-redis-streams 0.11.2-beta.157-173781 → 0.12.0-beta.157

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.
@@ -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;AACtE,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAA;AAC1D,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,CAAC,CAAiB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,aAAa,CAAiF;gBAE1F,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE,YAAY,EAAE,eAAe;IAQ/F,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAMhB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAMvE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAoB7E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAA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AC,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;IAkC1F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
@@ -26,10 +26,11 @@ class RedisStreamAdapter extends core_1.StreamAdapter {
26
26
  }
27
27
  async set(groupId, id, data) {
28
28
  const hashKey = this.makeGroupKey(groupId);
29
+ const dataWithTimestamp = data;
29
30
  const item = {
30
31
  ...data,
31
32
  id,
32
- _createdAt: data._createdAt || Date.now(),
33
+ _createdAt: dataWithTimestamp._createdAt || Date.now(),
33
34
  };
34
35
  const itemJson = JSON.stringify(item);
35
36
  const existed = await this.client.hExists(hashKey, id);
@@ -67,11 +68,12 @@ class RedisStreamAdapter extends core_1.StreamAdapter {
67
68
  const channelKey = this.makeChannelKey(channel);
68
69
  if (!this.subClient) {
69
70
  const socketConfig = this.client.options?.socket;
71
+ const keepAliveValue = socketConfig?.keepAlive;
70
72
  const clientConfig = {
71
73
  socket: {
72
74
  host: socketConfig?.host || 'localhost',
73
75
  port: socketConfig?.port || 6379,
74
- keepAlive: socketConfig?.keepAlive ?? 5000,
76
+ keepAlive: keepAliveValue,
75
77
  noDelay: true,
76
78
  },
77
79
  password: this.client.options?.password,
@@ -85,7 +87,10 @@ class RedisStreamAdapter extends core_1.StreamAdapter {
85
87
  await this.subClient.connect();
86
88
  }
87
89
  this.subscriptions.set(channelKey, handler);
88
- await this.subClient.subscribe(channelKey, async (message) => {
90
+ const subClient = this.subClient;
91
+ if (!subClient)
92
+ return;
93
+ await subClient.subscribe(channelKey, async (message) => {
89
94
  try {
90
95
  const event = JSON.parse(message);
91
96
  await handler(event);
@@ -114,16 +119,19 @@ class RedisStreamAdapter extends core_1.StreamAdapter {
114
119
  async query(groupId, filter) {
115
120
  let items = await this.getGroup(groupId);
116
121
  if (filter.where) {
122
+ const where = filter.where;
117
123
  items = items.filter((item) => {
118
- return Object.entries(filter.where).every(([key, value]) => {
119
- return item[key] === value;
124
+ return Object.entries(where).every(([key, value]) => {
125
+ const itemKey = key;
126
+ return item[itemKey] === value;
120
127
  });
121
128
  });
122
129
  }
123
130
  if (filter.orderBy) {
124
131
  items.sort((a, b) => {
125
- const aVal = a[filter.orderBy];
126
- const bVal = b[filter.orderBy];
132
+ const orderKey = filter.orderBy;
133
+ const aVal = a[orderKey];
134
+ const bVal = b[orderKey];
127
135
  const comparison = aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
128
136
  return filter.orderDirection === 'desc' ? -comparison : comparison;
129
137
  });
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.11.2-beta.157-173781",
6
+ "version": "0.12.0-beta.157",
7
7
  "dependencies": {
8
8
  "redis": "^5.9.0",
9
- "@motiadev/core": "0.11.2-beta.157-173781"
9
+ "@motiadev/core": "0.12.0-beta.157"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^22.10.2",