@uploadista/event-broadcaster-redis 0.0.8 → 0.0.10

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/index.cjs CHANGED
@@ -1 +1 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@uploadista/core/errors`);c=s(c);let l=require(`@uploadista/core/types`);l=s(l);let u=require(`effect`);u=s(u);function d(e){let{redis:t,subscriberRedis:n}=e;return n.on(`error`,e=>{console.error(`[Redis] Subscriber Error:`,e)}),t.on(`error`,e=>{console.error(`[Redis] Error:`,e)}),{publish:(e,n)=>u.Effect.tryPromise({try:async()=>await t.publish(e,n),catch:t=>(console.error(`[Redis] Failed to publish to ${e}:`,t),c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:t}))}).pipe(u.Effect.asVoid),subscribe:(e,t)=>u.Effect.tryPromise({try:async()=>{await n.subscribe(e,(e,n)=>{t(e)})},catch:t=>(console.error(`[Redis] Failed to subscribe to ${e}:`,t),c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:t}))}).pipe(u.Effect.asVoid),unsubscribe:e=>u.Effect.tryPromise({try:()=>n.unsubscribe(e),catch:e=>c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})}).pipe(u.Effect.asVoid)}}const f=e=>u.Layer.succeed(l.EventBroadcasterService,d(e));exports.createRedisEventBroadcaster=d,exports.redisEventBroadcaster=f;
1
+ let e=require(`@uploadista/core/errors`),t=require(`@uploadista/core/types`),n=require(`effect`);function r(t){let{redis:r,subscriberRedis:i}=t;return i.on(`error`,e=>{console.error(`[Redis] Subscriber Error:`,e)}),r.on(`error`,e=>{console.error(`[Redis] Error:`,e)}),{publish:(t,i)=>n.Effect.tryPromise({try:async()=>await r.publish(t,i),catch:n=>(console.error(`[Redis] Failed to publish to ${t}:`,n),e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.Effect.asVoid),subscribe:(t,r)=>n.Effect.tryPromise({try:async()=>{await i.subscribe(t,(e,t)=>{r(e)})},catch:n=>(console.error(`[Redis] Failed to subscribe to ${t}:`,n),e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.Effect.asVoid),unsubscribe:t=>n.Effect.tryPromise({try:()=>i.unsubscribe(t),catch:t=>e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(n.Effect.asVoid)}}const i=e=>n.Layer.succeed(t.EventBroadcasterService,r(e));exports.createRedisEventBroadcaster=r,exports.redisEventBroadcaster=i;
@@ -30,4 +30,4 @@ declare function createRedisEventBroadcaster(config: RedisEventBroadcasterConfig
30
30
  declare const redisEventBroadcaster: (config: RedisEventBroadcasterConfig) => Layer.Layer<EventBroadcasterService, never, never>;
31
31
  //#endregion
32
32
  export { RedisEventBroadcasterConfig, createRedisEventBroadcaster, redisEventBroadcaster };
33
- //# sourceMappingURL=index.d.ts.map
33
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAiBA;AAyDa,UA1EI,2BAAA,CA2E4D;EAD/B;;;EAA2B,KAAA,EAtEhE,eAsEgE;;;;;mBAjEtD;;;;;;;iBAQH,2BAAA,SACN,8BACP;;;;cAuDU,gCAAiC,gCAA2B,KAAA,CAAA,MAAA"}
@@ -1,2 +1,2 @@
1
1
  import{UploadistaError as e}from"@uploadista/core/errors";import{EventBroadcasterService as t}from"@uploadista/core/types";import{Effect as n,Layer as r}from"effect";function i(t){let{redis:r,subscriberRedis:i}=t;return i.on(`error`,e=>{console.error(`[Redis] Subscriber Error:`,e)}),r.on(`error`,e=>{console.error(`[Redis] Error:`,e)}),{publish:(t,i)=>n.tryPromise({try:async()=>await r.publish(t,i),catch:n=>(console.error(`[Redis] Failed to publish to ${t}:`,n),e.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.asVoid),subscribe:(t,r)=>n.tryPromise({try:async()=>{await i.subscribe(t,(e,t)=>{r(e)})},catch:n=>(console.error(`[Redis] Failed to subscribe to ${t}:`,n),e.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.asVoid),unsubscribe:t=>n.tryPromise({try:()=>i.unsubscribe(t),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(n.asVoid)}}const a=e=>r.succeed(t,i(e));export{i as createRedisEventBroadcaster,a as redisEventBroadcaster};
2
- //# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":["import type { RedisClientType } from \"@redis/client\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport type { EventBroadcaster } from \"@uploadista/core/types\";\nimport { EventBroadcasterService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\n/**\n * Configuration for Redis event broadcaster\n */\nexport interface RedisEventBroadcasterConfig {\n /**\n * Redis client for publishing messages\n */\n redis: RedisClientType;\n /**\n * Separate Redis client for subscribing to messages\n * (Redis requires a dedicated connection for pub/sub)\n */\n subscriberRedis: RedisClientType;\n}\n\n/**\n * Redis-based event broadcaster for distributed deployments.\n * Uses Redis Pub/Sub to broadcast events across multiple instances.\n * Requires two separate Redis connections (one for pub, one for sub).\n */\nexport function createRedisEventBroadcaster(\n config: RedisEventBroadcasterConfig,\n): EventBroadcaster {\n const { redis, subscriberRedis } = config;\n\n subscriberRedis.on(\"error\", (error) => {\n console.error(`[Redis] Subscriber Error:`, error);\n });\n\n redis.on(\"error\", (error) => {\n console.error(`[Redis] Error:`, error);\n });\n\n return {\n publish: (channel: string, message: string) =>\n Effect.tryPromise({\n try: async () => {\n const result = await redis.publish(channel, message);\n return result;\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to publish to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n subscribe: (channel: string, handler: (message: string) => void) =>\n Effect.tryPromise({\n try: async () => {\n await subscriberRedis.subscribe(channel, (message, _channel) => {\n handler(message);\n });\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to subscribe to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n unsubscribe: (channel: string) =>\n Effect.tryPromise({\n try: () => subscriberRedis.unsubscribe(channel),\n catch: (cause) =>\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n }),\n }).pipe(Effect.asVoid),\n };\n}\n\n/**\n * Layer factory for Redis event broadcaster\n */\nexport const redisEventBroadcaster = (config: RedisEventBroadcasterConfig) =>\n Layer.succeed(EventBroadcasterService, createRedisEventBroadcaster(config));\n"],"mappings":"sKA0BA,SAAgB,EACd,EACkB,CAClB,GAAM,CAAE,QAAO,mBAAoB,EAUnC,OARA,EAAgB,GAAG,QAAU,GAAU,CACrC,QAAQ,MAAM,4BAA6B,EAAM,EACjD,CAEF,EAAM,GAAG,QAAU,GAAU,CAC3B,QAAQ,MAAM,iBAAkB,EAAM,EACtC,CAEK,CACL,SAAU,EAAiB,IACzB,EAAO,WAAW,CAChB,IAAK,SACY,MAAM,EAAM,QAAQ,EAAS,EAAQ,CAGtD,MAAQ,IACN,QAAQ,MAAM,gCAAgC,EAAQ,GAAI,EAAM,CACzD,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,WAAY,EAAiB,IAC3B,EAAO,WAAW,CAChB,IAAK,SAAY,CACf,MAAM,EAAgB,UAAU,GAAU,EAAS,IAAa,CAC9D,EAAQ,EAAQ,EAChB,EAEJ,MAAQ,IACN,QAAQ,MAAM,kCAAkC,EAAQ,GAAI,EAAM,CAC3D,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,YAAc,GACZ,EAAO,WAAW,CAChB,QAAW,EAAgB,YAAY,EAAQ,CAC/C,MAAQ,GACN,EAAgB,SAAS,gBAAiB,CACxC,QACD,CAAC,CACL,CAAC,CAAC,KAAK,EAAO,OAAO,CACzB,CAMH,MAAa,EAAyB,GACpC,EAAM,QAAQ,EAAyB,EAA4B,EAAO,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,27 @@
1
1
  {
2
2
  "name": "@uploadista/event-broadcaster-redis",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "description": "Redis event broadcaster for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
10
+ "types": "./dist/index.d.mts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs",
13
+ "default": "./dist/index.mjs"
13
14
  }
14
15
  },
15
16
  "dependencies": {
16
17
  "@redis/client": "5.9.0",
17
- "effect": "3.18.4",
18
- "@uploadista/core": "0.0.8"
18
+ "effect": "3.19.0",
19
+ "@uploadista/core": "0.0.10"
19
20
  },
20
21
  "devDependencies": {
21
- "@types/node": "24.9.1",
22
- "tsdown": "0.15.10",
23
- "@uploadista/typescript-config": "0.0.8"
22
+ "@types/node": "24.10.0",
23
+ "tsdown": "0.16.0",
24
+ "@uploadista/typescript-config": "0.0.10"
24
25
  },
25
26
  "scripts": {
26
27
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAiBA;AAyDa,UA1EI,2BAAA,CA2E4D;EAD/B;;;EAA2B,KAAA,EAtEhE,eAsEgE;;;;;mBAjEtD;;;;;;;iBAQH,2BAAA,SACN,8BACP;;;;cAuDU,gCAAiC,gCAA2B,KAAA,CAAA,MAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":["import type { RedisClientType } from \"@redis/client\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport type { EventBroadcaster } from \"@uploadista/core/types\";\nimport { EventBroadcasterService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\n/**\n * Configuration for Redis event broadcaster\n */\nexport interface RedisEventBroadcasterConfig {\n /**\n * Redis client for publishing messages\n */\n redis: RedisClientType;\n /**\n * Separate Redis client for subscribing to messages\n * (Redis requires a dedicated connection for pub/sub)\n */\n subscriberRedis: RedisClientType;\n}\n\n/**\n * Redis-based event broadcaster for distributed deployments.\n * Uses Redis Pub/Sub to broadcast events across multiple instances.\n * Requires two separate Redis connections (one for pub, one for sub).\n */\nexport function createRedisEventBroadcaster(\n config: RedisEventBroadcasterConfig,\n): EventBroadcaster {\n const { redis, subscriberRedis } = config;\n\n subscriberRedis.on(\"error\", (error) => {\n console.error(`[Redis] Subscriber Error:`, error);\n });\n\n redis.on(\"error\", (error) => {\n console.error(`[Redis] Error:`, error);\n });\n\n return {\n publish: (channel: string, message: string) =>\n Effect.tryPromise({\n try: async () => {\n const result = await redis.publish(channel, message);\n return result;\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to publish to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n subscribe: (channel: string, handler: (message: string) => void) =>\n Effect.tryPromise({\n try: async () => {\n await subscriberRedis.subscribe(channel, (message, _channel) => {\n handler(message);\n });\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to subscribe to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n unsubscribe: (channel: string) =>\n Effect.tryPromise({\n try: () => subscriberRedis.unsubscribe(channel),\n catch: (cause) =>\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n }),\n }).pipe(Effect.asVoid),\n };\n}\n\n/**\n * Layer factory for Redis event broadcaster\n */\nexport const redisEventBroadcaster = (config: RedisEventBroadcasterConfig) =>\n Layer.succeed(EventBroadcasterService, createRedisEventBroadcaster(config));\n"],"mappings":"sKA0BA,SAAgB,EACd,EACkB,CAClB,GAAM,CAAE,QAAO,mBAAoB,EAUnC,OARA,EAAgB,GAAG,QAAU,GAAU,CACrC,QAAQ,MAAM,4BAA6B,EAAM,EACjD,CAEF,EAAM,GAAG,QAAU,GAAU,CAC3B,QAAQ,MAAM,iBAAkB,EAAM,EACtC,CAEK,CACL,SAAU,EAAiB,IACzB,EAAO,WAAW,CAChB,IAAK,SACY,MAAM,EAAM,QAAQ,EAAS,EAAQ,CAGtD,MAAQ,IACN,QAAQ,MAAM,gCAAgC,EAAQ,GAAI,EAAM,CACzD,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,WAAY,EAAiB,IAC3B,EAAO,WAAW,CAChB,IAAK,SAAY,CACf,MAAM,EAAgB,UAAU,GAAU,EAAS,IAAa,CAC9D,EAAQ,EAAQ,EAChB,EAEJ,MAAQ,IACN,QAAQ,MAAM,kCAAkC,EAAQ,GAAI,EAAM,CAC3D,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,YAAc,GACZ,EAAO,WAAW,CAChB,QAAW,EAAgB,YAAY,EAAQ,CAC/C,MAAQ,GACN,EAAgB,SAAS,gBAAiB,CACxC,QACD,CAAC,CACL,CAAC,CAAC,KAAK,EAAO,OAAO,CACzB,CAMH,MAAa,EAAyB,GACpC,EAAM,QAAQ,EAAyB,EAA4B,EAAO,CAAC"}