@uploadista/event-broadcaster-redis 0.0.3 → 0.0.4

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,5 +1,22 @@
1
1
 
2
2
  
3
- > @uploadista/event-broadcaster-redis@0.0.2 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/event-broadcasters/redis
4
- > tsc -b
3
+ > @uploadista/event-broadcaster-redis@0.0.3 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/event-broadcasters/redis
4
+ > tsdown
5
5
 
6
+ ℹ tsdown v0.15.9 powered by rolldown v1.0.0-beta.44
7
+ ℹ Using tsdown config: /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/event-broadcasters/redis/tsdown.config.ts
8
+ ℹ entry: src/index.ts
9
+ ℹ tsconfig: tsconfig.json
10
+ ℹ Build start
11
+ ℹ Cleaning 7 files
12
+ ℹ [CJS] dist/index.cjs 1.50 kB │ gzip: 0.68 kB
13
+ ℹ [CJS] 1 files, total: 1.50 kB
14
+ ℹ [ESM] dist/index.js 0.97 kB │ gzip: 0.45 kB
15
+ ℹ [ESM] dist/index.js.map 3.63 kB │ gzip: 1.19 kB
16
+ ℹ [ESM] dist/index.d.ts.map 0.28 kB │ gzip: 0.22 kB
17
+ ℹ [ESM] dist/index.d.ts 1.18 kB │ gzip: 0.50 kB
18
+ ℹ [ESM] 4 files, total: 6.07 kB
19
+ ℹ [CJS] dist/index.d.cts.map 0.28 kB │ gzip: 0.22 kB
20
+ ℹ [CJS] dist/index.d.cts 1.18 kB │ gzip: 0.50 kB
21
+ ℹ [CJS] 2 files, total: 1.46 kB
22
+ ✔ Build complete in 10888ms
package/dist/index.cjs ADDED
@@ -0,0 +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;
@@ -0,0 +1,33 @@
1
+ import { RedisClientType } from "@redis/client";
2
+ import { EventBroadcaster, EventBroadcasterService } from "@uploadista/core/types";
3
+ import { Layer } from "effect";
4
+
5
+ //#region src/redis-event-broadcaster.d.ts
6
+
7
+ /**
8
+ * Configuration for Redis event broadcaster
9
+ */
10
+ interface RedisEventBroadcasterConfig {
11
+ /**
12
+ * Redis client for publishing messages
13
+ */
14
+ redis: RedisClientType;
15
+ /**
16
+ * Separate Redis client for subscribing to messages
17
+ * (Redis requires a dedicated connection for pub/sub)
18
+ */
19
+ subscriberRedis: RedisClientType;
20
+ }
21
+ /**
22
+ * Redis-based event broadcaster for distributed deployments.
23
+ * Uses Redis Pub/Sub to broadcast events across multiple instances.
24
+ * Requires two separate Redis connections (one for pub, one for sub).
25
+ */
26
+ declare function createRedisEventBroadcaster(config: RedisEventBroadcasterConfig): EventBroadcaster;
27
+ /**
28
+ * Layer factory for Redis event broadcaster
29
+ */
30
+ declare const redisEventBroadcaster: (config: RedisEventBroadcasterConfig) => Layer.Layer<EventBroadcasterService, never, never>;
31
+ //#endregion
32
+ export { RedisEventBroadcasterConfig, createRedisEventBroadcaster, redisEventBroadcaster };
33
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","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.d.ts CHANGED
@@ -1,2 +1,33 @@
1
- export * from "./redis-event-broadcaster";
1
+ import { EventBroadcaster, EventBroadcasterService } from "@uploadista/core/types";
2
+ import { Layer } from "effect";
3
+ import { RedisClientType } from "@redis/client";
4
+
5
+ //#region src/redis-event-broadcaster.d.ts
6
+
7
+ /**
8
+ * Configuration for Redis event broadcaster
9
+ */
10
+ interface RedisEventBroadcasterConfig {
11
+ /**
12
+ * Redis client for publishing messages
13
+ */
14
+ redis: RedisClientType;
15
+ /**
16
+ * Separate Redis client for subscribing to messages
17
+ * (Redis requires a dedicated connection for pub/sub)
18
+ */
19
+ subscriberRedis: RedisClientType;
20
+ }
21
+ /**
22
+ * Redis-based event broadcaster for distributed deployments.
23
+ * Uses Redis Pub/Sub to broadcast events across multiple instances.
24
+ * Requires two separate Redis connections (one for pub, one for sub).
25
+ */
26
+ declare function createRedisEventBroadcaster(config: RedisEventBroadcasterConfig): EventBroadcaster;
27
+ /**
28
+ * Layer factory for Redis event broadcaster
29
+ */
30
+ declare const redisEventBroadcaster: (config: RedisEventBroadcasterConfig) => Layer.Layer<EventBroadcasterService, never, never>;
31
+ //#endregion
32
+ export { RedisEventBroadcasterConfig, createRedisEventBroadcaster, redisEventBroadcaster };
2
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
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 CHANGED
@@ -1 +1,2 @@
1
- export * from "./redis-event-broadcaster";
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
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/event-broadcaster-redis",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "Redis event broadcaster for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -15,14 +15,15 @@
15
15
  "dependencies": {
16
16
  "@redis/client": "5.8.3",
17
17
  "effect": "3.18.4",
18
- "@uploadista/core": "0.0.3"
18
+ "@uploadista/core": "0.0.4"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "24.8.1",
22
- "@uploadista/typescript-config": "0.0.3"
22
+ "tsdown": "0.15.9",
23
+ "@uploadista/typescript-config": "0.0.4"
23
24
  },
24
25
  "scripts": {
25
- "build": "tsc -b",
26
+ "build": "tsdown",
26
27
  "format": "biome format --write ./src",
27
28
  "lint": "biome lint --write ./src",
28
29
  "check": "biome check --write ./src"
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: "src/index.ts",
6
+ },
7
+ minify: true,
8
+ format: ["esm", "cjs"],
9
+ dts: true,
10
+ outDir: "dist",
11
+ });
@@ -1,29 +0,0 @@
1
- import type { RedisClientType } from "@redis/client";
2
- import type { EventBroadcaster } from "@uploadista/core/types";
3
- import { EventBroadcasterService } from "@uploadista/core/types";
4
- import { Layer } from "effect";
5
- /**
6
- * Configuration for Redis event broadcaster
7
- */
8
- export interface RedisEventBroadcasterConfig {
9
- /**
10
- * Redis client for publishing messages
11
- */
12
- redis: RedisClientType;
13
- /**
14
- * Separate Redis client for subscribing to messages
15
- * (Redis requires a dedicated connection for pub/sub)
16
- */
17
- subscriberRedis: RedisClientType;
18
- }
19
- /**
20
- * Redis-based event broadcaster for distributed deployments.
21
- * Uses Redis Pub/Sub to broadcast events across multiple instances.
22
- * Requires two separate Redis connections (one for pub, one for sub).
23
- */
24
- export declare function createRedisEventBroadcaster(config: RedisEventBroadcasterConfig): EventBroadcaster;
25
- /**
26
- * Layer factory for Redis event broadcaster
27
- */
28
- export declare const redisEventBroadcaster: (config: RedisEventBroadcasterConfig) => Layer.Layer<EventBroadcasterService, never, never>;
29
- //# sourceMappingURL=redis-event-broadcaster.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redis-event-broadcaster.d.ts","sourceRoot":"","sources":["../src/redis-event-broadcaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,2BAA2B,GAClC,gBAAgB,CAkDlB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,2BAA2B,uDACI,CAAC"}
@@ -1,54 +0,0 @@
1
- import { UploadistaError } from "@uploadista/core/errors";
2
- import { EventBroadcasterService } from "@uploadista/core/types";
3
- import { Effect, Layer } from "effect";
4
- /**
5
- * Redis-based event broadcaster for distributed deployments.
6
- * Uses Redis Pub/Sub to broadcast events across multiple instances.
7
- * Requires two separate Redis connections (one for pub, one for sub).
8
- */
9
- export function createRedisEventBroadcaster(config) {
10
- const { redis, subscriberRedis } = config;
11
- subscriberRedis.on("error", (error) => {
12
- console.error(`[Redis] Subscriber Error:`, error);
13
- });
14
- redis.on("error", (error) => {
15
- console.error(`[Redis] Error:`, error);
16
- });
17
- return {
18
- publish: (channel, message) => Effect.tryPromise({
19
- try: async () => {
20
- const result = await redis.publish(channel, message);
21
- return result;
22
- },
23
- catch: (cause) => {
24
- console.error(`[Redis] Failed to publish to ${channel}:`, cause);
25
- return UploadistaError.fromCode("UNKNOWN_ERROR", {
26
- cause,
27
- });
28
- },
29
- }).pipe(Effect.asVoid),
30
- subscribe: (channel, handler) => Effect.tryPromise({
31
- try: async () => {
32
- await subscriberRedis.subscribe(channel, (message, _channel) => {
33
- handler(message);
34
- });
35
- },
36
- catch: (cause) => {
37
- console.error(`[Redis] Failed to subscribe to ${channel}:`, cause);
38
- return UploadistaError.fromCode("UNKNOWN_ERROR", {
39
- cause,
40
- });
41
- },
42
- }).pipe(Effect.asVoid),
43
- unsubscribe: (channel) => Effect.tryPromise({
44
- try: () => subscriberRedis.unsubscribe(channel),
45
- catch: (cause) => UploadistaError.fromCode("UNKNOWN_ERROR", {
46
- cause,
47
- }),
48
- }).pipe(Effect.asVoid),
49
- };
50
- }
51
- /**
52
- * Layer factory for Redis event broadcaster
53
- */
54
- export const redisEventBroadcaster = (config) => Layer.succeed(EventBroadcasterService, createRedisEventBroadcaster(config));