@corpdk/pub-sub 0.0.0-stage → 2026.10.0-alpha.13
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/LICENSE +21 -0
- package/README.md +24 -2
- package/dist/index.d.ts +16 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/memory.d.ts +2 -0
- package/dist/memory.js +5 -0
- package/dist/memory.js.map +1 -0
- package/dist/redis.d.ts +1 -0
- package/dist/redis.js +13 -0
- package/dist/redis.js.map +1 -0
- package/package.json +41 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CorpDK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @corpdk/pub-sub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Plugin-style GraphQL pub/sub factory for GraphQL Yoga: in-memory or Redis (`createAppPubSub<T>()`).
|
|
4
|
+
|
|
5
|
+
Used by DAL-automated data services for subscription topics. Redis wiring uses `@graphql-yoga/redis-event-target` and `ioredis`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @corpdk/pub-sub
|
|
11
|
+
# or
|
|
12
|
+
npm install @corpdk/pub-sub
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use the same CalVer as the rest of the DS automation npm set.
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
- [DS subscription SSE (Yoga)](https://github.com/CorpDK/coding-templates/blob/main/docs/developer/11-ds-subscription-sse.md)
|
|
20
|
+
- [Monorepo design — pub/sub](https://github.com/CorpDK/coding-templates/blob/main/docs/architecture/02-monorepo-design.md)
|
|
21
|
+
- Package source: [`libraries/pub-sub`](https://github.com/CorpDK/coding-templates/tree/main/libraries/pub-sub)
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
MIT — see the [repository LICENSE](https://github.com/CorpDK/coding-templates/blob/main/LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a type-safe pub/sub instance wired to Redis (if REDIS_URL is set)
|
|
3
|
+
* or an in-memory event target (for local dev / single-process deployments).
|
|
4
|
+
*
|
|
5
|
+
* Pass your app-specific topic map as the type parameter:
|
|
6
|
+
* const pubsub = createAppPubSub<MyTopics>();
|
|
7
|
+
*
|
|
8
|
+
* Example topic map:
|
|
9
|
+
* type MyTopics = {
|
|
10
|
+
* PING_SENT: [{ pingSent: { message: string; timestamp: string } }];
|
|
11
|
+
* ITEM_CREATED: [{ itemCreated: Item }];
|
|
12
|
+
* };
|
|
13
|
+
*/
|
|
14
|
+
export declare function createAppPubSub<T extends Record<string, [unknown]>>(): import("graphql-yoga").PubSub<T>;
|
|
15
|
+
export { createMemoryEventTarget } from "./memory.js";
|
|
16
|
+
export { createRedisEventTarget } from "./redis.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createPubSub } from "graphql-yoga";
|
|
2
|
+
import { createMemoryEventTarget } from "./memory.js";
|
|
3
|
+
import { createRedisEventTarget } from "./redis.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a type-safe pub/sub instance wired to Redis (if REDIS_URL is set)
|
|
6
|
+
* or an in-memory event target (for local dev / single-process deployments).
|
|
7
|
+
*
|
|
8
|
+
* Pass your app-specific topic map as the type parameter:
|
|
9
|
+
* const pubsub = createAppPubSub<MyTopics>();
|
|
10
|
+
*
|
|
11
|
+
* Example topic map:
|
|
12
|
+
* type MyTopics = {
|
|
13
|
+
* PING_SENT: [{ pingSent: { message: string; timestamp: string } }];
|
|
14
|
+
* ITEM_CREATED: [{ itemCreated: Item }];
|
|
15
|
+
* };
|
|
16
|
+
*/
|
|
17
|
+
export function createAppPubSub() {
|
|
18
|
+
const eventTarget = process.env.REDIS_URL
|
|
19
|
+
? createRedisEventTarget()
|
|
20
|
+
: createMemoryEventTarget();
|
|
21
|
+
return createPubSub({ eventTarget });
|
|
22
|
+
}
|
|
23
|
+
export { createMemoryEventTarget } from "./memory.js";
|
|
24
|
+
export { createRedisEventTarget } from "./redis.js";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS;QACvC,CAAC,CAAC,sBAAsB,EAAE;QAC1B,CAAC,CAAC,uBAAuB,EAAE,CAAC;IAC9B,OAAO,YAAY,CAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/memory.d.ts
ADDED
package/dist/memory.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,WAAW,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/redis.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createRedisEventTarget(): EventTarget;
|
package/dist/redis.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRedisEventTarget as createYogaRedisEventTarget } from "@graphql-yoga/redis-event-target";
|
|
2
|
+
import { Redis } from "ioredis";
|
|
3
|
+
export function createRedisEventTarget() {
|
|
4
|
+
const redisUrl = process.env.REDIS_URL ?? "";
|
|
5
|
+
const publishClient = new Redis(redisUrl);
|
|
6
|
+
const subscribeClient = new Redis(redisUrl);
|
|
7
|
+
return createYogaRedisEventTarget({
|
|
8
|
+
publishClient,
|
|
9
|
+
subscribeClient,
|
|
10
|
+
serializer: { stringify: JSON.stringify, parse: JSON.parse },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../src/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,UAAU,sBAAsB;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;IAC7C,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,0BAA0B,CAAC;QAChC,aAAa;QACb,eAAe;QACf,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;KAC7D,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corpdk/pub-sub",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2026.10.0-alpha.13",
|
|
4
|
+
"description": "Plugin-style GraphQL pub/sub factory (in-memory or Redis)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/CorpDK/coding-templates.git",
|
|
13
|
+
"directory": "libraries/pub-sub"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@graphql-yoga/redis-event-target": "^3.0.0",
|
|
28
|
+
"graphql-yoga": "^5.18.1",
|
|
29
|
+
"ioredis": "^5.10.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^24.0.0",
|
|
33
|
+
"typescript": "^6.0.2"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"lint": "eslint src/",
|
|
42
|
+
"clean": "rm -rf dist node_modules .turbo *.tsbuildinfo"
|
|
43
|
+
}
|
|
6
44
|
}
|