Skip to content

Commit 0463c9d

Browse files
committed
feat(projection): export ProjectionsEvent and SinkEventType type utils
1 parent 9386990 commit 0463c9d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/projection/src/projectIntoSink.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ type ProjectionTypes<P> = {
4848
};
4949
// https://stackoverflow.com/a/50375286
5050
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
51-
type ProjectionsEvent<P extends object> = UnifiedProjectorEvent<UnionToIntersection<ProjectionTypes<P>[keyof P]>>;
51+
export type ProjectionsEvent<P extends object> = UnifiedProjectorEvent<
52+
UnionToIntersection<ProjectionTypes<P>[keyof P]>
53+
>;
5254

5355
const isIntersectionBlock = (block: Cardano.Block, intersection: Intersection) => {
5456
if (intersection.point === 'origin') {

packages/projection/src/sinks/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { Cardano } from '@cardano-sdk/core';
23
import { Observable } from 'rxjs';
34
import { ProjectionExtraProps } from '../projections';
@@ -45,7 +46,6 @@ export type ProjectionSinks<Projections> = {
4546
[k in keyof Projections]: Sink<Projections[k]>;
4647
};
4748

48-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4949
export type SinkLifecycleOperator = (evt$: Observable<any>) => Observable<any>;
5050

5151
export type Sinks<Projections> = {
@@ -54,3 +54,6 @@ export type Sinks<Projections> = {
5454
before?: SinkLifecycleOperator;
5555
after?: SinkLifecycleOperator;
5656
};
57+
58+
type InferArg<T> = T extends (arg: infer Arg) => any ? Arg : never;
59+
export type SinkEventType<S extends { sink: any }> = InferArg<S['sink']>;

0 commit comments

Comments
 (0)