/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { DataPortSchema, DataPortSchemaNonBoolean, TypedArray, VectorFromSchema } from "@workglow/util/schema"; import type { GraphAsTaskConfig, GraphResultArray, JsonTaskItem, TaskGraphItemJson, TaskInput, TaskOutput, TaskRunContext } from "@workglow/task-graph"; import { GraphAsTask, GraphAsTaskRunner } from "@workglow/task-graph"; export declare function TypeReplicateArray(type: T, annotations?: Record): DataPortSchemaNonBoolean; /** * Removes array types from a union, leaving only non-array types. * For example, `string | string[]` becomes `string`. * Used to extract the single-value type from schemas with x-replicate annotation. * Preserves Vector types like Float64Array which also have numeric indices. */ type UnwrapArrayUnion = T extends readonly any[] ? T extends TypedArray ? T : never : number extends keyof T ? "push" extends keyof T ? never : T : T; /** * Transforms a schema by removing array variants from properties marked with x-replicate. * Properties with x-replicate use {@link TypeReplicateArray} which creates a union of * `T | T[]`, and this type extracts just `T`. */ export type DeReplicateFromSchema; }> = { [K in keyof S["properties"]]: S["properties"][K] extends { "x-replicate": true; } ? UnwrapArrayUnion> : VectorFromSchema; }; /** * ArrayTask is a compound task that either: * 1. Executes directly if all inputs are non-arrays * 2. Creates a subGraph with one task instance per array element if any input is an array * 3. Creates all combinations if multiple inputs are arrays */ export declare abstract class ArrayTask = GraphAsTaskConfig> extends GraphAsTask { static type: string; /** Make this task have results that look like an array */ static readonly compoundMerge: "PROPERTY_ARRAY"; /** Reverts GraphAsTask's override so the user-defined static schema is used. */ inputSchema(): DataPortSchema; /** Reverts GraphAsTask's override so the user-defined static schema is used. */ outputSchema(): DataPortSchema; executeMerge(_input: Input, output: Output): Output; regenerateGraph(): void; /** * Generates all possible combinations of array inputs. */ protected generateCombinations(input: Input, inputMakeArray: Array): Input[]; toJSON(): TaskGraphItemJson; toDependencyJSON(): JsonTaskItem; _runner: ArrayTaskRunner; /** * Custom runner for ArrayTask that overrides input passing behavior * as inputs were already distributed to child tasks during graph regeneration. */ get runner(): ArrayTaskRunner; } /** * Custom runner for ArrayTask that passes empty input to child tasks. * ArrayTask child tasks get their input values from their defaults (set during task creation), * not from the parent task's input. */ declare class ArrayTaskRunner = GraphAsTaskConfig> extends GraphAsTaskRunner { task: ArrayTask; /** * Pass empty input to subgraph; child tasks use defaults set during creation. */ protected executeTaskChildren(_input: Input): Promise>; /** * Pass empty input to subgraph for preview execution; child tasks use defaults set during creation. */ protected executeTaskChildrenPreview(): Promise>; executeTaskPreview(input: Input, ctx: TaskRunContext): Promise; executeTask(input: Input, ctx: TaskRunContext): Promise; } export {};