File
Blob: types/defines/pipelines.d.ts
| 1 | // Copyright (c) 2022-2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | declare module "cloudflare:pipelines" { |
| 5 | export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> { |
| 6 | protected env: Env; |
| 7 | protected ctx: ExecutionContext; |
| 8 | constructor(ctx: ExecutionContext, env: Env); |
| 9 | |
| 10 | /** |
| 11 | * run receives an array of PipelineRecord which can be |
| 12 | * transformed and returned to the pipeline |
| 13 | * @param records Incoming records from the pipeline to be transformed |
| 14 | * @param metadata Information about the specific pipeline calling the transformation entrypoint |
| 15 | * @returns A promise containing the transformed PipelineRecord array |
| 16 | */ |
| 17 | public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>; |
| 18 | } |
| 19 | export type PipelineRecord = Record<string, unknown> |
| 20 | export type PipelineBatchMetadata = { |
| 21 | pipelineId: string; |
| 22 | pipelineName: string; |
| 23 | } |
| 24 | export interface Pipeline<T extends PipelineRecord = PipelineRecord> { |
| 25 | /** |
| 26 | * The Pipeline interface represents the type of a binding to a Pipeline |
| 27 | * |
| 28 | * @param records The records to send to the pipeline |
| 29 | */ |
| 30 | send(records: T[]): Promise<void> |
| 31 | } |
| 32 | } |