@graphql-yoga/subscription 2.2.1 → 2.2.3-canary-0a78c8b.0

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,5 @@
1
1
  import { Repeater } from '@repeaterjs/repeater';
2
- import { resolveGlobalConfig, } from '@graphql-yoga/typed-event-target';
2
+ import { resolveGlobalConfig } from '@graphql-yoga/typed-event-target';
3
3
  /**
4
4
  * Utility for publishing and subscribing to events.
5
5
  */
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@graphql-yoga/subscription",
3
- "version": "2.2.1",
3
+ "version": "2.2.3-canary-0a78c8b.0",
4
4
  "description": "",
5
5
  "dependencies": {
6
- "@graphql-yoga/typed-event-target": "^0.1.0",
6
+ "@graphql-yoga/typed-event-target": "0.1.1-canary-0a78c8b.0",
7
7
  "@repeaterjs/repeater": "^3.0.4",
8
8
  "tslib": "^2.3.1"
9
9
  },
@@ -30,7 +30,7 @@
30
30
  "exports": {
31
31
  ".": {
32
32
  "require": {
33
- "types": "./typings/index.d.ts",
33
+ "types": "./typings/index.d.cts",
34
34
  "default": "./cjs/index.js"
35
35
  },
36
36
  "import": {
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "./*": {
46
46
  "require": {
47
- "types": "./typings/*.d.ts",
47
+ "types": "./typings/*.d.cts",
48
48
  "default": "./cjs/*.js"
49
49
  },
50
50
  "import": {
@@ -0,0 +1,38 @@
1
+ import { Repeater } from '@repeaterjs/repeater';
2
+ import type { TypedEventTarget, EventAPI } from '@graphql-yoga/typed-event-target';
3
+ declare type PubSubPublishArgsByKey = {
4
+ [key: string]: [] | [any] | [number | string, any];
5
+ };
6
+ export declare type PubSubEvent<TPubSubPublishArgsByKey extends PubSubPublishArgsByKey, TKey extends Extract<keyof TPubSubPublishArgsByKey, string>> = Event & {
7
+ data?: TPubSubPublishArgsByKey[TKey][1] extends undefined ? TPubSubPublishArgsByKey[TKey][0] : TPubSubPublishArgsByKey[TKey][1];
8
+ };
9
+ export declare type PubSubEventTarget<TPubSubPublishArgsByKey extends PubSubPublishArgsByKey> = TypedEventTarget<PubSubEvent<TPubSubPublishArgsByKey, Extract<keyof TPubSubPublishArgsByKey, string>>>;
10
+ export declare type ChannelPubSubConfig<TPubSubPublishArgsByKey extends PubSubPublishArgsByKey> = {
11
+ /**
12
+ * The event target. If not specified an (in-memory) EventTarget will be created.
13
+ * For multiple server replica or serverless environments a distributed EventTarget is recommended.
14
+ *
15
+ * An event dispatched on the event target MUST have a `data` property.
16
+ */
17
+ eventTarget?: PubSubEventTarget<TPubSubPublishArgsByKey>;
18
+ /**
19
+ * Event and EventTarget implementation.
20
+ * Providing this is mandatory for a Node.js versions below 16.
21
+ */
22
+ event?: EventAPI;
23
+ };
24
+ export declare type PubSub<TPubSubPublishArgsByKey extends PubSubPublishArgsByKey> = {
25
+ /**
26
+ * Publish a value for a given topic.
27
+ */
28
+ publish<TKey extends Extract<keyof TPubSubPublishArgsByKey, string>>(routingKey: TKey, ...args: TPubSubPublishArgsByKey[TKey]): void;
29
+ /**
30
+ * Subscribe to a topic.
31
+ */
32
+ subscribe<TKey extends Extract<keyof TPubSubPublishArgsByKey, string>>(...[routingKey, id]: TPubSubPublishArgsByKey[TKey][1] extends undefined ? [TKey] : [TKey, TPubSubPublishArgsByKey[TKey][0]]): Repeater<TPubSubPublishArgsByKey[TKey][1] extends undefined ? TPubSubPublishArgsByKey[TKey][0] : TPubSubPublishArgsByKey[TKey][1]>;
33
+ };
34
+ /**
35
+ * Utility for publishing and subscribing to events.
36
+ */
37
+ export declare const createPubSub: <TPubSubPublishArgsByKey extends PubSubPublishArgsByKey>(config?: ChannelPubSubConfig<TPubSubPublishArgsByKey> | undefined) => PubSub<TPubSubPublishArgsByKey>;
38
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { Repeater } from '@repeaterjs/repeater';
2
- import { type TypedEventTarget, type EventAPI } from '@graphql-yoga/typed-event-target';
2
+ import type { TypedEventTarget, EventAPI } from '@graphql-yoga/typed-event-target';
3
3
  declare type PubSubPublishArgsByKey = {
4
4
  [key: string]: [] | [any] | [number | string, any];
5
5
  };
@@ -0,0 +1,6 @@
1
+ export { Repeater } from '@repeaterjs/repeater';
2
+ export { createPubSub, PubSub } from './createPubSub.cjs';
3
+ export type { PubSubEventTarget, PubSubEvent } from './createPubSub.cjs';
4
+ export { map } from './operator/map.cjs';
5
+ export { filter } from './operator/filter.cjs';
6
+ export { pipe } from './utils/pipe.cjs';
@@ -0,0 +1,6 @@
1
+ import { Repeater } from '@repeaterjs/repeater';
2
+ /**
3
+ * Utility for filtering an event stream.
4
+ */
5
+ export declare function filter<T, U extends T>(filter: (input: T) => input is U): (source: AsyncIterable<T>) => Repeater<U, void, unknown>;
6
+ export declare function filter<T>(filter: (input: T) => boolean): (source: AsyncIterable<T>) => Repeater<T, void, unknown>;
@@ -0,0 +1,5 @@
1
+ import { Repeater } from '@repeaterjs/repeater';
2
+ /**
3
+ * Utility for mapping an event stream.
4
+ */
5
+ export declare const map: <T, O>(mapper: (input: T) => O | Promise<O>) => (source: AsyncIterable<T>) => Repeater<O, any, unknown>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Pipes the value of an expression into a pipeline of functions.
3
+ *
4
+ * @source https://github.com/gcanti/fp-ts/blob/b442f0967b002b88eb2649ba38d95ec5ad2ab576/src/function.ts#L391-L682
5
+ */
6
+ export declare function pipe<A>(a: A): A;
7
+ export declare function pipe<A, B>(a: A, ab: (a: A) => B): B;
8
+ export declare function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C;
9
+ export declare function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D;
10
+ export declare function pipe<A, B, C, D, E>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E;
11
+ export declare function pipe<A, B, C, D, E, F>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): F;
12
+ export declare function pipe<A, B, C, D, E, F, G>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): G;
13
+ export declare function pipe<A, B, C, D, E, F, G, H>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): H;
14
+ export declare function pipe<A, B, C, D, E, F, G, H, I>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I): I;
15
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): J;
16
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K): K;
17
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L): L;
18
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M): M;
19
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N): N;
20
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O): O;
21
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P): P;
22
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q): Q;
23
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R): R;
24
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R, rs: (r: R) => S): S;
25
+ export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R, rs: (r: R) => S, st: (s: S) => T): T;