Skip to content

Commit c9193c3

Browse files
hhoughgga-robinson
authored andcommitted
Move pipelines types to module cloudflare:pipelines
Inherit Env from WorkerEntrypoint in PipelineEntrypoint
1 parent b608e17 commit c9193c3

File tree

24 files changed

+339
-566
lines changed

24 files changed

+339
-566
lines changed

src/cloudflare/internal/pipeline-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class PipelineTransformImpl<
8282

8383
// called by the dispatcher to validate that run is properly implemented by the subclass
8484
// @ts-expect-error thinks ping is never used
85-
private _ping(): Promise<void> {
85+
private async _ping(): Promise<void> {
8686
// making sure the function was overridden by an implementing subclass
8787
if (this.run !== PipelineTransformImpl.prototype.run) {
8888
return Promise.resolve();

src/cloudflare/internal/test/pipeline-transform/transform-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// https://opensource.org/licenses/Apache-2.0
55

66
import assert from 'node:assert';
7-
import { PipelineTransformationEntrypoint } from 'cloudflare:pipeline-transform';
7+
import { PipelineTransformationEntrypoint } from 'cloudflare:pipelines';
88

99
// this is how "Pipeline" would be implemented by the user
1010
const customTransform = class MyEntrypoint extends PipelineTransformationEntrypoint {
File renamed without changes.

types/defines/pipelines.d.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
// Copyright (c) 2022-2023 Cloudflare, Inc.
22
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
33
// https://opensource.org/licenses/Apache-2.0
4+
declare module "cloudflare:pipelines" {
5+
export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = {}, O extends PipelineRecord = {}> {
6+
/**
7+
* run recieves an array of PipelineRecord which can be
8+
* mutated and returned to the pipeline
9+
* @param records Incoming records from the pipeline to be transformed
10+
* @param metadata Information about the specific pipeline calling the transformation entrypoint
11+
* @returns A promise containing the transformed PipelineRecord array
12+
*/
413

5-
export type PipelineRecord = Record<string, unknown>
14+
protected env: Env;
15+
protected ctx: ExecutionContext;
16+
constructor(ctx: ExecutionContext, env: Env);
617

7-
export type PipelineBatchMetadata = {
8-
pipelineId: string;
9-
pipelineName: string;
10-
}
11-
12-
export abstract class PipelineTransformationEntrypoint<I extends PipelineRecord, O extends PipelineRecord> {
13-
/**
14-
* run recieves an array of PipelineRecord which can be
15-
* mutated and returned to the pipeline
16-
* @param records Incoming records from the pipeline to be transformed
17-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
18-
* @returns A promise containing the transformed PipelineRecord array
19-
*/
20-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
21-
}
22-
23-
export interface Pipeline<T extends PipelineRecord> {
24-
/**
25-
* The Pipeline interface represents the type of a binding to a Pipeline
26-
*
27-
* @param records The records to send to the pipeline
28-
*/
29-
send(records: T[]): Promise<void>
18+
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
19+
}
20+
export type PipelineRecord = Record<string, unknown>
21+
export type PipelineBatchMetadata = {
22+
pipelineId: string;
23+
pipelineName: string;
24+
}
25+
export interface Pipeline<T extends PipelineRecord> {
26+
/**
27+
* The Pipeline interface represents the type of a binding to a Pipeline
28+
*
29+
* @param records The records to send to the pipeline
30+
*/
31+
send(records: T[]): Promise<void>
32+
}
3033
}

types/generated-snapshot/2021-11-03/index.d.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5730,31 +5730,37 @@ declare module "assets:*" {
57305730
// Copyright (c) 2022-2023 Cloudflare, Inc.
57315731
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
57325732
// https://opensource.org/licenses/Apache-2.0
5733-
type PipelineRecord = Record<string, unknown>;
5734-
type PipelineBatchMetadata = {
5735-
pipelineId: string;
5736-
pipelineName: string;
5737-
};
5738-
declare abstract class PipelineTransformationEntrypoint<
5739-
I extends PipelineRecord,
5740-
O extends PipelineRecord,
5741-
> {
5742-
/**
5743-
* run recieves an array of PipelineRecord which can be
5744-
* mutated and returned to the pipeline
5745-
* @param records Incoming records from the pipeline to be transformed
5746-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5747-
* @returns A promise containing the transformed PipelineRecord array
5748-
*/
5749-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5750-
}
5751-
interface Pipeline<T extends PipelineRecord> {
5752-
/**
5753-
* The Pipeline interface represents the type of a binding to a Pipeline
5754-
*
5755-
* @param records The records to send to the pipeline
5756-
*/
5757-
send(records: T[]): Promise<void>;
5733+
declare module "cloudflare:pipelines" {
5734+
export abstract class PipelineTransformationEntrypoint<
5735+
Env = unknown,
5736+
I extends PipelineRecord = {},
5737+
O extends PipelineRecord = {},
5738+
> {
5739+
/**
5740+
* run recieves an array of PipelineRecord which can be
5741+
* mutated and returned to the pipeline
5742+
* @param records Incoming records from the pipeline to be transformed
5743+
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5744+
* @returns A promise containing the transformed PipelineRecord array
5745+
*/
5746+
protected env: Env;
5747+
protected ctx: ExecutionContext;
5748+
constructor(ctx: ExecutionContext, env: Env);
5749+
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5750+
}
5751+
export type PipelineRecord = Record<string, unknown>;
5752+
export type PipelineBatchMetadata = {
5753+
pipelineId: string;
5754+
pipelineName: string;
5755+
};
5756+
export interface Pipeline<T extends PipelineRecord> {
5757+
/**
5758+
* The Pipeline interface represents the type of a binding to a Pipeline
5759+
*
5760+
* @param records The records to send to the pipeline
5761+
*/
5762+
send(records: T[]): Promise<void>;
5763+
}
57585764
}
57595765
// PubSubMessage represents an incoming PubSub message.
57605766
// The message includes metadata about the broker, the client, and the payload

types/generated-snapshot/2021-11-03/index.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5743,35 +5743,6 @@ export type PagesPluginFunction<
57435743
> = (
57445744
context: EventPluginContext<Env, Params, Data, PluginArgs>,
57455745
) => Response | Promise<Response>;
5746-
// Copyright (c) 2022-2023 Cloudflare, Inc.
5747-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
5748-
// https://opensource.org/licenses/Apache-2.0
5749-
export type PipelineRecord = Record<string, unknown>;
5750-
export type PipelineBatchMetadata = {
5751-
pipelineId: string;
5752-
pipelineName: string;
5753-
};
5754-
export declare abstract class PipelineTransformationEntrypoint<
5755-
I extends PipelineRecord,
5756-
O extends PipelineRecord,
5757-
> {
5758-
/**
5759-
* run recieves an array of PipelineRecord which can be
5760-
* mutated and returned to the pipeline
5761-
* @param records Incoming records from the pipeline to be transformed
5762-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5763-
* @returns A promise containing the transformed PipelineRecord array
5764-
*/
5765-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5766-
}
5767-
export interface Pipeline<T extends PipelineRecord> {
5768-
/**
5769-
* The Pipeline interface represents the type of a binding to a Pipeline
5770-
*
5771-
* @param records The records to send to the pipeline
5772-
*/
5773-
send(records: T[]): Promise<void>;
5774-
}
57755746
// PubSubMessage represents an incoming PubSub message.
57765747
// The message includes metadata about the broker, the client, and the payload
57775748
// itself.

types/generated-snapshot/2022-01-31/index.d.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5756,31 +5756,37 @@ declare module "assets:*" {
57565756
// Copyright (c) 2022-2023 Cloudflare, Inc.
57575757
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
57585758
// https://opensource.org/licenses/Apache-2.0
5759-
type PipelineRecord = Record<string, unknown>;
5760-
type PipelineBatchMetadata = {
5761-
pipelineId: string;
5762-
pipelineName: string;
5763-
};
5764-
declare abstract class PipelineTransformationEntrypoint<
5765-
I extends PipelineRecord,
5766-
O extends PipelineRecord,
5767-
> {
5768-
/**
5769-
* run recieves an array of PipelineRecord which can be
5770-
* mutated and returned to the pipeline
5771-
* @param records Incoming records from the pipeline to be transformed
5772-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5773-
* @returns A promise containing the transformed PipelineRecord array
5774-
*/
5775-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5776-
}
5777-
interface Pipeline<T extends PipelineRecord> {
5778-
/**
5779-
* The Pipeline interface represents the type of a binding to a Pipeline
5780-
*
5781-
* @param records The records to send to the pipeline
5782-
*/
5783-
send(records: T[]): Promise<void>;
5759+
declare module "cloudflare:pipelines" {
5760+
export abstract class PipelineTransformationEntrypoint<
5761+
Env = unknown,
5762+
I extends PipelineRecord = {},
5763+
O extends PipelineRecord = {},
5764+
> {
5765+
/**
5766+
* run recieves an array of PipelineRecord which can be
5767+
* mutated and returned to the pipeline
5768+
* @param records Incoming records from the pipeline to be transformed
5769+
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5770+
* @returns A promise containing the transformed PipelineRecord array
5771+
*/
5772+
protected env: Env;
5773+
protected ctx: ExecutionContext;
5774+
constructor(ctx: ExecutionContext, env: Env);
5775+
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5776+
}
5777+
export type PipelineRecord = Record<string, unknown>;
5778+
export type PipelineBatchMetadata = {
5779+
pipelineId: string;
5780+
pipelineName: string;
5781+
};
5782+
export interface Pipeline<T extends PipelineRecord> {
5783+
/**
5784+
* The Pipeline interface represents the type of a binding to a Pipeline
5785+
*
5786+
* @param records The records to send to the pipeline
5787+
*/
5788+
send(records: T[]): Promise<void>;
5789+
}
57845790
}
57855791
// PubSubMessage represents an incoming PubSub message.
57865792
// The message includes metadata about the broker, the client, and the payload

types/generated-snapshot/2022-01-31/index.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5769,35 +5769,6 @@ export type PagesPluginFunction<
57695769
> = (
57705770
context: EventPluginContext<Env, Params, Data, PluginArgs>,
57715771
) => Response | Promise<Response>;
5772-
// Copyright (c) 2022-2023 Cloudflare, Inc.
5773-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
5774-
// https://opensource.org/licenses/Apache-2.0
5775-
export type PipelineRecord = Record<string, unknown>;
5776-
export type PipelineBatchMetadata = {
5777-
pipelineId: string;
5778-
pipelineName: string;
5779-
};
5780-
export declare abstract class PipelineTransformationEntrypoint<
5781-
I extends PipelineRecord,
5782-
O extends PipelineRecord,
5783-
> {
5784-
/**
5785-
* run recieves an array of PipelineRecord which can be
5786-
* mutated and returned to the pipeline
5787-
* @param records Incoming records from the pipeline to be transformed
5788-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5789-
* @returns A promise containing the transformed PipelineRecord array
5790-
*/
5791-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5792-
}
5793-
export interface Pipeline<T extends PipelineRecord> {
5794-
/**
5795-
* The Pipeline interface represents the type of a binding to a Pipeline
5796-
*
5797-
* @param records The records to send to the pipeline
5798-
*/
5799-
send(records: T[]): Promise<void>;
5800-
}
58015772
// PubSubMessage represents an incoming PubSub message.
58025773
// The message includes metadata about the broker, the client, and the payload
58035774
// itself.

types/generated-snapshot/2022-03-21/index.d.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5781,31 +5781,37 @@ declare module "assets:*" {
57815781
// Copyright (c) 2022-2023 Cloudflare, Inc.
57825782
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
57835783
// https://opensource.org/licenses/Apache-2.0
5784-
type PipelineRecord = Record<string, unknown>;
5785-
type PipelineBatchMetadata = {
5786-
pipelineId: string;
5787-
pipelineName: string;
5788-
};
5789-
declare abstract class PipelineTransformationEntrypoint<
5790-
I extends PipelineRecord,
5791-
O extends PipelineRecord,
5792-
> {
5793-
/**
5794-
* run recieves an array of PipelineRecord which can be
5795-
* mutated and returned to the pipeline
5796-
* @param records Incoming records from the pipeline to be transformed
5797-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5798-
* @returns A promise containing the transformed PipelineRecord array
5799-
*/
5800-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5801-
}
5802-
interface Pipeline<T extends PipelineRecord> {
5803-
/**
5804-
* The Pipeline interface represents the type of a binding to a Pipeline
5805-
*
5806-
* @param records The records to send to the pipeline
5807-
*/
5808-
send(records: T[]): Promise<void>;
5784+
declare module "cloudflare:pipelines" {
5785+
export abstract class PipelineTransformationEntrypoint<
5786+
Env = unknown,
5787+
I extends PipelineRecord = {},
5788+
O extends PipelineRecord = {},
5789+
> {
5790+
/**
5791+
* run recieves an array of PipelineRecord which can be
5792+
* mutated and returned to the pipeline
5793+
* @param records Incoming records from the pipeline to be transformed
5794+
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5795+
* @returns A promise containing the transformed PipelineRecord array
5796+
*/
5797+
protected env: Env;
5798+
protected ctx: ExecutionContext;
5799+
constructor(ctx: ExecutionContext, env: Env);
5800+
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5801+
}
5802+
export type PipelineRecord = Record<string, unknown>;
5803+
export type PipelineBatchMetadata = {
5804+
pipelineId: string;
5805+
pipelineName: string;
5806+
};
5807+
export interface Pipeline<T extends PipelineRecord> {
5808+
/**
5809+
* The Pipeline interface represents the type of a binding to a Pipeline
5810+
*
5811+
* @param records The records to send to the pipeline
5812+
*/
5813+
send(records: T[]): Promise<void>;
5814+
}
58095815
}
58105816
// PubSubMessage represents an incoming PubSub message.
58115817
// The message includes metadata about the broker, the client, and the payload

types/generated-snapshot/2022-03-21/index.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5794,35 +5794,6 @@ export type PagesPluginFunction<
57945794
> = (
57955795
context: EventPluginContext<Env, Params, Data, PluginArgs>,
57965796
) => Response | Promise<Response>;
5797-
// Copyright (c) 2022-2023 Cloudflare, Inc.
5798-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
5799-
// https://opensource.org/licenses/Apache-2.0
5800-
export type PipelineRecord = Record<string, unknown>;
5801-
export type PipelineBatchMetadata = {
5802-
pipelineId: string;
5803-
pipelineName: string;
5804-
};
5805-
export declare abstract class PipelineTransformationEntrypoint<
5806-
I extends PipelineRecord,
5807-
O extends PipelineRecord,
5808-
> {
5809-
/**
5810-
* run recieves an array of PipelineRecord which can be
5811-
* mutated and returned to the pipeline
5812-
* @param records Incoming records from the pipeline to be transformed
5813-
* @param metadata Information about the specific pipeline calling the transformation entrypoint
5814-
* @returns A promise containing the transformed PipelineRecord array
5815-
*/
5816-
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
5817-
}
5818-
export interface Pipeline<T extends PipelineRecord> {
5819-
/**
5820-
* The Pipeline interface represents the type of a binding to a Pipeline
5821-
*
5822-
* @param records The records to send to the pipeline
5823-
*/
5824-
send(records: T[]): Promise<void>;
5825-
}
58265797
// PubSubMessage represents an incoming PubSub message.
58275798
// The message includes metadata about the broker, the client, and the payload
58285799
// itself.

0 commit comments

Comments
 (0)