@pipedream/types
Advanced tools
Comparing version
@@ -267,3 +267,2 @@ /// <reference types="node" /> | ||
}; | ||
type Modify<T, R> = Omit<T, keyof R> & R; | ||
interface BaseSource<Methods, SourcePropDefinitions> { | ||
@@ -282,7 +281,10 @@ key: string; | ||
} | ||
export type DedupedSource<Methods, SourcePropDefinitions> = Modify<BaseSource<Methods, SourcePropDefinitions>, { | ||
export interface DedupedSource<Methods, SourcePropDefinitions> extends BaseSource<Methods, SourcePropDefinitions> { | ||
dedupe: "last" | "greatest" | "unique"; | ||
run: (this: PropThis<SourcePropDefinitions> & Methods & IdEmitFunction, options?: SourceRunOptions) => void | Promise<void>; | ||
}>; | ||
export type Source<Methods, SourcePropDefinitions> = DedupedSource<Methods, SourcePropDefinitions>; | ||
} | ||
export interface NonDedupedSource<Methods, SourcePropDefinitions> extends BaseSource<Methods, SourcePropDefinitions> { | ||
dedupe?: never; | ||
} | ||
export type Source<Methods, SourcePropDefinitions> = DedupedSource<Methods, SourcePropDefinitions> | NonDedupedSource<Methods, SourcePropDefinitions>; | ||
export declare function defineSource<Methods, SourcePropDefinitions>(component: Source<Methods, SourcePropDefinitions>): Source<Methods, SourcePropDefinitions>; | ||
@@ -289,0 +291,0 @@ export interface Action<Methods, ActionPropDefinitions> { |
@@ -256,2 +256,35 @@ "use strict"; | ||
}; | ||
const nonDedupedSource = { | ||
key: "source", | ||
name: "Test Source", | ||
description: "hello, world", | ||
version: "0.0.1", | ||
type: "source", | ||
async run() { | ||
this.$emit({ | ||
foo: "bar ", | ||
}, { | ||
name: "channel", | ||
summary: "Summary", | ||
ts: 123, | ||
}); | ||
}, | ||
}; | ||
const nonDedupedSourceWithId = { | ||
key: "source", | ||
name: "Test Source", | ||
description: "hello, world", | ||
version: "0.0.1", | ||
type: "source", | ||
async run() { | ||
this.$emit({ | ||
foo: "bar ", | ||
}, { | ||
id: 246, | ||
name: "channel", | ||
summary: "Summary", | ||
ts: 123, | ||
}); | ||
}, | ||
}; | ||
// Bad sources | ||
@@ -258,0 +291,0 @@ // @ts-expect-error $ExpectError - Missing key |
{ | ||
"name": "@pipedream/types", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Pipedream TypeScript types", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
26352
3.26%704
5.23%