@uploadista/core 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -762,7 +762,7 @@ type FlowData = {
762
762
  * await db.flows.save(flowData);
763
763
  * ```
764
764
  */
765
- declare const getFlowData: <TRequirements$1>(flow: Flow<any, any, TRequirements$1>) => FlowData;
765
+ declare const getFlowData: <TRequirements>(flow: Flow<any, any, TRequirements>) => FlowData;
766
766
  /**
767
767
  * Result of a flow execution - either completed or paused.
768
768
  *
@@ -845,21 +845,21 @@ type FlowExecutionResult<TOutput> = {
845
845
  * });
846
846
  * ```
847
847
  */
848
- type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements$1> = {
848
+ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements> = {
849
849
  id: string;
850
850
  name: string;
851
851
  nodes: FlowNode<any, any, UploadistaError$1>[];
852
852
  edges: FlowEdge[];
853
853
  inputSchema: TFlowInputSchema;
854
854
  outputSchema: TFlowOutputSchema;
855
- onEvent?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements$1>["onEvent"];
856
- checkJobStatus?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements$1>["checkJobStatus"];
855
+ onEvent?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements>["onEvent"];
856
+ checkJobStatus?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements>["checkJobStatus"];
857
857
  run: (args: {
858
858
  inputs?: Record<string, z.infer<TFlowInputSchema>>;
859
859
  storageId: string;
860
860
  jobId: string;
861
861
  clientId: string | null;
862
- }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError$1, TRequirements$1>;
862
+ }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError$1, TRequirements>;
863
863
  resume: (args: {
864
864
  jobId: string;
865
865
  storageId: string;
@@ -870,7 +870,7 @@ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z
870
870
  inputs: Record<string, z.infer<TFlowInputSchema>>;
871
871
  };
872
872
  clientId: string | null;
873
- }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError$1, TRequirements$1>;
873
+ }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError$1, TRequirements>;
874
874
  validateTypes: () => {
875
875
  isValid: boolean;
876
876
  errors: string[];
@@ -952,7 +952,7 @@ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z
952
952
  * @see {@link Flow} for the returned flow type
953
953
  * @see {@link FlowConfig} for configuration options
954
954
  */
955
- declare function createFlowWithSchema<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements$1 = never, TNodeError = never, TNodeRequirements = never>(config: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TNodeError, TNodeRequirements>): Effect.Effect<Flow<TFlowInputSchema, TFlowOutputSchema, TRequirements$1>, TNodeError, TNodeRequirements>;
955
+ declare function createFlowWithSchema<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements = never, TNodeError = never, TNodeRequirements = never>(config: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TNodeError, TNodeRequirements>): Effect.Effect<Flow<TFlowInputSchema, TFlowOutputSchema, TRequirements>, TNodeError, TNodeRequirements>;
956
956
  //#endregion
957
957
  //#region src/types/upload-file.d.ts
958
958
  /**
@@ -3035,8 +3035,8 @@ declare class FlowWaitUntil extends FlowWaitUntil_base {
3035
3035
  * const flowProviderLayer = Layer.succeed(FlowProvider, dbFlowProvider);
3036
3036
  * ```
3037
3037
  */
3038
- type FlowProviderShape<TRequirements$1 = any> = {
3039
- getFlow: (flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements$1>, UploadistaError$1>;
3038
+ type FlowProviderShape<TRequirements = any> = {
3039
+ getFlow: (flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements>, UploadistaError$1>;
3040
3040
  };
3041
3041
  declare const FlowProvider_base: Context.TagClass<FlowProvider, "FlowProvider", FlowProviderShape<any>>;
3042
3042
  /**
@@ -3142,9 +3142,9 @@ declare class FlowProvider extends FlowProvider_base {}
3142
3142
  * ```
3143
3143
  */
3144
3144
  type FlowServerShape = {
3145
- getFlow: <TRequirements$1>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements$1>, UploadistaError$1>;
3145
+ getFlow: <TRequirements>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements>, UploadistaError$1>;
3146
3146
  getFlowData: (flowId: string, clientId: string | null) => Effect.Effect<FlowData, UploadistaError$1>;
3147
- runFlow: <TRequirements$1>({
3147
+ runFlow: <TRequirements>({
3148
3148
  flowId,
3149
3149
  storageId,
3150
3150
  clientId,
@@ -3154,8 +3154,8 @@ type FlowServerShape = {
3154
3154
  storageId: string;
3155
3155
  clientId: string | null;
3156
3156
  inputs: any;
3157
- }) => Effect.Effect<FlowJob, UploadistaError$1, TRequirements$1>;
3158
- resumeFlow: <TRequirements$1>({
3157
+ }) => Effect.Effect<FlowJob, UploadistaError$1, TRequirements>;
3158
+ resumeFlow: <TRequirements>({
3159
3159
  jobId,
3160
3160
  nodeId,
3161
3161
  newData,
@@ -3165,7 +3165,7 @@ type FlowServerShape = {
3165
3165
  nodeId: string;
3166
3166
  newData: unknown;
3167
3167
  clientId: string | null;
3168
- }) => Effect.Effect<FlowJob, UploadistaError$1, TRequirements$1>;
3168
+ }) => Effect.Effect<FlowJob, UploadistaError$1, TRequirements>;
3169
3169
  pauseFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError$1>;
3170
3170
  cancelFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError$1>;
3171
3171
  getJobStatus: (jobId: string) => Effect.Effect<FlowJob, UploadistaError$1>;
@@ -3212,17 +3212,17 @@ declare class FlowServer extends FlowServer_base {}
3212
3212
  * @property kvStore - KV store for flow job metadata
3213
3213
  */
3214
3214
  type FlowServerOptions = {
3215
- getFlow: <TRequirements$1>({
3215
+ getFlow: <TRequirements>({
3216
3216
  flowId,
3217
3217
  storageId
3218
3218
  }: {
3219
3219
  flowId: string;
3220
3220
  storageId: string;
3221
- }) => Promise<Flow<any, any, TRequirements$1>>;
3221
+ }) => Promise<Flow<any, any, TRequirements>>;
3222
3222
  kvStore: KvStore<FlowJob>;
3223
3223
  };
3224
3224
  declare function createFlowServer(): Effect.Effect<{
3225
- getFlow: <TRequirements$1>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, any>, UploadistaError$1, never>;
3225
+ getFlow: <TRequirements>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, any>, UploadistaError$1, never>;
3226
3226
  getFlowData: (flowId: string, clientId: string | null) => Effect.Effect<FlowData, UploadistaError$1, never>;
3227
3227
  runFlow: ({
3228
3228
  flowId,
@@ -3251,8 +3251,8 @@ declare function createFlowServer(): Effect.Effect<{
3251
3251
  cancelFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError$1, never>;
3252
3252
  subscribeToFlowEvents: (jobId: string, connection: WebSocketConnection) => Effect.Effect<void, UploadistaError$1, never>;
3253
3253
  unsubscribeFromFlowEvents: (jobId: string) => Effect.Effect<void, UploadistaError$1, never>;
3254
- }, never, UploadServer | FlowProvider | FlowJobKVStore | FlowEventEmitter>;
3255
- declare const flowServer: Layer.Layer<FlowServer, never, UploadServer | FlowProvider | FlowJobKVStore | FlowEventEmitter>;
3254
+ }, never, FlowEventEmitter | FlowJobKVStore | UploadServer | FlowProvider>;
3255
+ declare const flowServer: Layer.Layer<FlowServer, never, FlowEventEmitter | FlowJobKVStore | UploadServer | FlowProvider>;
3256
3256
  type FlowServerLayer = typeof flowServer;
3257
3257
  //#endregion
3258
3258
  //#region src/flow/nodes/input-node.d.ts
@@ -3595,7 +3595,7 @@ declare class ParallelScheduler {
3595
3595
  * // results will be in order: [result1, result2, result3]
3596
3596
  * ```
3597
3597
  */
3598
- executeNodesInParallel<T, E, R$1>(nodeExecutors: Array<() => Effect.Effect<T, E, R$1>>): Effect.Effect<T[], E, R$1>;
3598
+ executeNodesInParallel<T, E$1, R$1>(nodeExecutors: Array<() => Effect.Effect<T, E$1, R$1>>): Effect.Effect<T[], E$1, R$1>;
3599
3599
  /**
3600
3600
  * Determines if a set of nodes can be safely executed in parallel.
3601
3601
  *
@@ -3677,6 +3677,7 @@ declare const CredentialProvider_base: Context.TagClass<CredentialProvider, "Cre
3677
3677
  * ```
3678
3678
  */
3679
3679
  declare class CredentialProvider extends CredentialProvider_base {}
3680
+ type CredentialProviderLayer = Layer.Layer<CredentialProvider, never, never>;
3680
3681
  //#endregion
3681
3682
  //#region src/flow/plugins/image-ai-plugin.d.ts
3682
3683
  /**
@@ -3735,6 +3736,7 @@ declare const ImageAiPlugin_base: Context.TagClass<ImageAiPlugin, "ImageAiPlugin
3735
3736
  * ```
3736
3737
  */
3737
3738
  declare class ImageAiPlugin extends ImageAiPlugin_base {}
3739
+ type ImageAiPluginLayer = Layer.Layer<ImageAiPlugin, never, never>;
3738
3740
  //#endregion
3739
3741
  //#region src/flow/plugins/types/optimize-node.d.ts
3740
3742
  /**
@@ -3823,38 +3825,7 @@ declare const ImagePlugin_base: Context.TagClass<ImagePlugin, "ImagePlugin", Ima
3823
3825
  * ```
3824
3826
  */
3825
3827
  declare class ImagePlugin extends ImagePlugin_base {}
3826
- //#endregion
3827
- //#region src/flow/plugins/types/describe-image-node.d.ts
3828
- /**
3829
- * Zod schema for validating describe image node parameters.
3830
- * Defines the structure and validation rules for image description requests.
3831
- */
3832
- declare const describeImageParamsSchema: z.ZodObject<{
3833
- serviceType: z.ZodOptional<z.ZodEnum<{
3834
- replicate: "replicate";
3835
- }>>;
3836
- }, z.core.$strip>;
3837
- /**
3838
- * Parameters for the describe image node.
3839
- * Controls which AI service to use for generating image descriptions.
3840
- */
3841
- type DescribeImageParams = z.infer<typeof describeImageParamsSchema>;
3842
- //#endregion
3843
- //#region src/flow/plugins/types/remove-background-node.d.ts
3844
- /**
3845
- * Zod schema for validating remove background node parameters.
3846
- * Defines the structure and validation rules for background removal requests.
3847
- */
3848
- declare const removeBackgroundParamsSchema: z.ZodObject<{
3849
- serviceType: z.ZodOptional<z.ZodEnum<{
3850
- replicate: "replicate";
3851
- }>>;
3852
- }, z.core.$strip>;
3853
- /**
3854
- * Parameters for the remove background node.
3855
- * Controls which AI service to use for background removal processing.
3856
- */
3857
- type RemoveBackgroundParams = z.infer<typeof removeBackgroundParamsSchema>;
3828
+ type ImagePluginLayer = Layer.Layer<ImagePlugin, never, never>;
3858
3829
  //#endregion
3859
3830
  //#region src/flow/plugins/zip-plugin.d.ts
3860
3831
  /**
@@ -3913,17 +3884,348 @@ declare const ZipPlugin_base: Context.TagClass<ZipPlugin, "ZipPlugin", ZipPlugin
3913
3884
  * ```
3914
3885
  */
3915
3886
  declare class ZipPlugin extends ZipPlugin_base {}
3887
+ type ZipPluginLayer = Layer.Layer<ZipPlugin, never, never>;
3888
+ //#endregion
3889
+ //#region src/flow/plugins/plugins.d.ts
3890
+ type Plugin = ImagePlugin | ImageAiPlugin | CredentialProvider | ZipPlugin;
3891
+ type PluginLayer = ImagePluginLayer | ImageAiPluginLayer | CredentialProviderLayer | ZipPluginLayer;
3892
+ //#endregion
3893
+ //#region src/flow/plugins/types/describe-image-node.d.ts
3894
+ /**
3895
+ * Zod schema for validating describe image node parameters.
3896
+ * Defines the structure and validation rules for image description requests.
3897
+ */
3898
+ declare const describeImageParamsSchema: z.ZodObject<{
3899
+ serviceType: z.ZodOptional<z.ZodEnum<{
3900
+ replicate: "replicate";
3901
+ }>>;
3902
+ }, z.core.$strip>;
3903
+ /**
3904
+ * Parameters for the describe image node.
3905
+ * Controls which AI service to use for generating image descriptions.
3906
+ */
3907
+ type DescribeImageParams = z.infer<typeof describeImageParamsSchema>;
3908
+ //#endregion
3909
+ //#region src/flow/plugins/types/remove-background-node.d.ts
3910
+ /**
3911
+ * Zod schema for validating remove background node parameters.
3912
+ * Defines the structure and validation rules for background removal requests.
3913
+ */
3914
+ declare const removeBackgroundParamsSchema: z.ZodObject<{
3915
+ serviceType: z.ZodOptional<z.ZodEnum<{
3916
+ replicate: "replicate";
3917
+ }>>;
3918
+ }, z.core.$strip>;
3919
+ /**
3920
+ * Parameters for the remove background node.
3921
+ * Controls which AI service to use for background removal processing.
3922
+ */
3923
+ type RemoveBackgroundParams = z.infer<typeof removeBackgroundParamsSchema>;
3924
+ //#endregion
3925
+ //#region src/flow/types/flow-file.d.ts
3926
+ /**
3927
+ * Conditional execution rules for flow nodes.
3928
+ *
3929
+ * Conditions allow nodes to execute conditionally based on file properties or metadata.
3930
+ * They are evaluated before node execution and can skip nodes that don't match.
3931
+ *
3932
+ * @module flow/types/flow-file
3933
+ * @see {@link FlowNode} for how conditions are used in nodes
3934
+ *
3935
+ * @example
3936
+ * ```typescript
3937
+ * // Only process images larger than 1MB
3938
+ * const condition: FlowCondition = {
3939
+ * field: "size",
3940
+ * operator: "greaterThan",
3941
+ * value: 1024 * 1024
3942
+ * };
3943
+ *
3944
+ * // Only process JPEG images
3945
+ * const jpegCondition: FlowCondition = {
3946
+ * field: "mimeType",
3947
+ * operator: "startsWith",
3948
+ * value: "image/jpeg"
3949
+ * };
3950
+ * ```
3951
+ */
3952
+ /**
3953
+ * Represents a conditional rule for node execution.
3954
+ *
3955
+ * @property field - The file property to check
3956
+ * @property operator - The comparison operator to apply
3957
+ * @property value - The value to compare against
3958
+ *
3959
+ * @remarks
3960
+ * - Fields can check file metadata (mimeType, size) or image properties (width, height)
3961
+ * - String operators (contains, startsWith) work with string values
3962
+ * - Numeric operators (greaterThan, lessThan) work with numeric values
3963
+ * - The extension field checks the file extension without the dot
3964
+ */
3965
+ type FlowCondition = {
3966
+ field: "mimeType" | "size" | "width" | "height" | "extension";
3967
+ operator: "equals" | "notEquals" | "greaterThan" | "lessThan" | "contains" | "startsWith";
3968
+ value: string | number;
3969
+ };
3970
+ //#endregion
3971
+ //#region src/flow/types/type-utils.d.ts
3972
+ /**
3973
+ * Extracts the service type from an Effect Layer.
3974
+ *
3975
+ * Given a Layer that provides a service, this type utility extracts
3976
+ * the service type from the Layer's type signature.
3977
+ *
3978
+ * @template T - The Layer type to extract from
3979
+ * @returns The service type provided by the layer, or never if T is not a Layer
3980
+ *
3981
+ * @example
3982
+ * ```typescript
3983
+ * type MyLayer = Layer.Layer<ServiceA, never, never>;
3984
+ * type Service = ExtractLayerService<MyLayer>;
3985
+ * // Service = ServiceA
3986
+ * ```
3987
+ *
3988
+ * @example
3989
+ * ```typescript
3990
+ * import { ImagePluginLayer } from '@uploadista/core';
3991
+ *
3992
+ * type ImageService = ExtractLayerService<ImagePluginLayer>;
3993
+ * // ImageService = ImagePlugin
3994
+ * ```
3995
+ */
3996
+ type ExtractLayerService<T, TError$1 = never, TRequirements = never> = T extends Layer.Layer<infer S, TError$1, TRequirements> ? S : never;
3997
+ /**
3998
+ * Extracts all service types from a tuple of layers and returns them as a union.
3999
+ *
4000
+ * This type recursively processes a tuple of Layer types and extracts all
4001
+ * the services they provide, combining them into a single union type.
4002
+ *
4003
+ * @template T - A readonly tuple of Layer types
4004
+ * @returns A union of all service types provided by the layers
4005
+ *
4006
+ * @example
4007
+ * ```typescript
4008
+ * type Layers = [
4009
+ * Layer.Layer<ServiceA, never, never>,
4010
+ * Layer.Layer<ServiceB, never, never>,
4011
+ * Layer.Layer<ServiceC, never, never>
4012
+ * ];
4013
+ * type Services = ExtractLayerServices<Layers>;
4014
+ * // Services = ServiceA | ServiceB | ServiceC
4015
+ * ```
4016
+ *
4017
+ * @example
4018
+ * ```typescript
4019
+ * import { ImagePluginLayer, ZipPluginLayer } from '@uploadista/core';
4020
+ *
4021
+ * type PluginLayers = [ImagePluginLayer, ZipPluginLayer];
4022
+ * type AllServices = ExtractLayerServices<PluginLayers>;
4023
+ * // AllServices = ImagePlugin | ZipPlugin
4024
+ * ```
4025
+ */
4026
+ type ExtractLayerServices<T extends readonly Layer.Layer<any, any, any>[]> = T[number] extends Layer.Layer<infer S, any, any> ? S : never;
4027
+ /**
4028
+ * Unwraps an Effect type to extract its success value type.
4029
+ *
4030
+ * If the input type is an Effect, this extracts the success type (first type parameter).
4031
+ * If the input is not an Effect, it returns the type unchanged.
4032
+ *
4033
+ * @template T - The type to resolve, potentially an Effect
4034
+ * @returns The success type if T is an Effect, otherwise T
4035
+ *
4036
+ * @example
4037
+ * ```typescript
4038
+ * type MyEffect = Effect.Effect<string, Error, never>;
4039
+ * type Result = ResolveEffect<MyEffect>;
4040
+ * // Result = string
4041
+ * ```
4042
+ *
4043
+ * @example
4044
+ * ```typescript
4045
+ * type NonEffect = { data: string };
4046
+ * type Result = ResolveEffect<NonEffect>;
4047
+ * // Result = { data: string }
4048
+ * ```
4049
+ */
4050
+ type ResolveEffect<T> = T extends Effect.Effect<infer S, any, any> ? S : T;
4051
+ /**
4052
+ * Extracts the error type from an Effect.
4053
+ *
4054
+ * Given an Effect type, this utility extracts the error type
4055
+ * (second type parameter) from the Effect's type signature.
4056
+ *
4057
+ * @template T - The Effect type to extract from
4058
+ * @returns The error type of the Effect, or never if T is not an Effect
4059
+ *
4060
+ * @example
4061
+ * ```typescript
4062
+ * type MyEffect = Effect.Effect<string, ValidationError, never>;
4063
+ * type ErrorType = ExtractEffectError<MyEffect>;
4064
+ * // ErrorType = ValidationError
4065
+ * ```
4066
+ *
4067
+ * @example
4068
+ * ```typescript
4069
+ * type SafeEffect = Effect.Effect<number, never, SomeService>;
4070
+ * type ErrorType = ExtractEffectError<SafeEffect>;
4071
+ * // ErrorType = never (no errors possible)
4072
+ * ```
4073
+ */
4074
+ type ExtractEffectError<T> = T extends Effect.Effect<any, infer E, any> ? E : never;
4075
+ /**
4076
+ * Extracts the requirements (context) type from an Effect.
4077
+ *
4078
+ * Given an Effect type, this utility extracts the requirements type
4079
+ * (third type parameter) from the Effect's type signature. This represents
4080
+ * the services that must be provided for the Effect to run.
4081
+ *
4082
+ * @template T - The Effect type to extract from
4083
+ * @returns The requirements type of the Effect, or never if T is not an Effect
4084
+ *
4085
+ * @example
4086
+ * ```typescript
4087
+ * type MyEffect = Effect.Effect<string, Error, Database | Logger>;
4088
+ * type Requirements = ExtractEffectRequirements<MyEffect>;
4089
+ * // Requirements = Database | Logger
4090
+ * ```
4091
+ *
4092
+ * @example
4093
+ * ```typescript
4094
+ * import { ImagePlugin, ZipPlugin } from '@uploadista/core';
4095
+ *
4096
+ * type ProcessEffect = Effect.Effect<
4097
+ * ProcessedImage,
4098
+ * ProcessError,
4099
+ * ImagePlugin | ZipPlugin
4100
+ * >;
4101
+ * type Needed = ExtractEffectRequirements<ProcessEffect>;
4102
+ * // Needed = ImagePlugin | ZipPlugin
4103
+ * ```
4104
+ */
4105
+ type ExtractEffectRequirements<T> = T extends Effect.Effect<any, any, infer R> ? R : never;
3916
4106
  //#endregion
3917
4107
  //#region src/flow/typed-flow.d.ts
4108
+ /**
4109
+ * Defines a node that can be used in a typed flow.
4110
+ *
4111
+ * A node definition can be either:
4112
+ * - A plain FlowNode object
4113
+ * - An Effect that resolves to a FlowNode (for nodes requiring dependencies)
4114
+ *
4115
+ * @template TNodeError - The error types that the node can produce
4116
+ * @template TNodeRequirements - The services/dependencies the node requires
4117
+ */
3918
4118
  type NodeDefinition<TNodeError = never, TNodeRequirements = never> = FlowNode<any, any, UploadistaError$1> | Effect.Effect<FlowNode<any, any, UploadistaError$1>, TNodeError, TNodeRequirements>;
4119
+ /**
4120
+ * A record mapping node IDs to their definitions.
4121
+ *
4122
+ * This is the primary type used for defining the nodes in a typed flow,
4123
+ * allowing TypeScript to infer input/output schemas and requirements.
4124
+ *
4125
+ * @example
4126
+ * ```typescript
4127
+ * const nodes = {
4128
+ * input: fileInputNode,
4129
+ * resize: Effect.succeed(imageResizeNode),
4130
+ * output: s3OutputNode
4131
+ * } satisfies NodeDefinitionsRecord;
4132
+ * ```
4133
+ */
3919
4134
  type NodeDefinitionsRecord = Record<string, NodeDefinition<any, any>>;
4135
+ /**
4136
+ * Extracts the error type from a NodeDefinition.
4137
+ *
4138
+ * If the node is an Effect, extracts its error type.
4139
+ * If the node is a plain FlowNode, returns never (no errors).
4140
+ */
3920
4141
  type NodeDefinitionError<T> = T extends Effect.Effect<FlowNode<any, any, UploadistaError$1>, infer TError, any> ? TError : never;
3921
- type NodeDefinitionRequirements<T> = T extends Effect.Effect<FlowNode<any, any, UploadistaError$1>, any, infer TRequirements> ? TRequirements : never;
4142
+ /**
4143
+ * Extracts the requirements (dependencies) from a NodeDefinition.
4144
+ *
4145
+ * Uses the shared ExtractEffectRequirements utility for consistency.
4146
+ */
4147
+ type NodeDefinitionRequirements<T> = ExtractEffectRequirements<T>;
4148
+ /**
4149
+ * Extracts all possible errors from all nodes in a flow as a union.
4150
+ *
4151
+ * This iterates through all nodes in the record and combines their
4152
+ * error types into a single union type.
4153
+ */
3922
4154
  type NodesErrorUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionError<TNodes[K]> }[keyof TNodes];
4155
+ /**
4156
+ * Extracts all service requirements from all nodes in a flow as a union.
4157
+ *
4158
+ * This iterates through all nodes in the record and combines their
4159
+ * requirement types into a single union type representing all services
4160
+ * needed by the flow.
4161
+ *
4162
+ * @template TNodes - The record of node definitions
4163
+ *
4164
+ * @example
4165
+ * ```typescript
4166
+ * const nodes = {
4167
+ * resize: imageResizeNode, // requires ImagePlugin
4168
+ * zip: zipNode, // requires ZipPlugin
4169
+ * };
4170
+ * type Requirements = NodesRequirementsUnion<typeof nodes>;
4171
+ * // Requirements = ImagePlugin | ZipPlugin
4172
+ * ```
4173
+ */
3923
4174
  type NodesRequirementsUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionRequirements<TNodes[K]> }[keyof TNodes];
4175
+ /**
4176
+ * Extracts all service requirements from a flow's nodes.
4177
+ *
4178
+ * This includes all services required by any node in the flow,
4179
+ * including UploadServer (which is provided by the runtime).
4180
+ *
4181
+ * @template TNodes - The record of node definitions
4182
+ *
4183
+ * @example
4184
+ * ```typescript
4185
+ * const myFlow = createFlow({
4186
+ * nodes: {
4187
+ * input: fileInputNode,
4188
+ * process: imageProcessNode, // requires ImagePlugin
4189
+ * },
4190
+ * edges: [...]
4191
+ * });
4192
+ * type AllRequirements = FlowRequirements<typeof myFlow.nodes>;
4193
+ * // AllRequirements = ImagePlugin | UploadServer
4194
+ * ```
4195
+ */
3924
4196
  type FlowRequirements<TNodes extends NodeDefinitionsRecord> = NodesRequirementsUnion<TNodes>;
4197
+ /**
4198
+ * Extracts plugin service requirements from a flow, excluding UploadServer.
4199
+ *
4200
+ * This type is useful for determining which plugin layers need to be
4201
+ * provided when creating a server, as UploadServer is automatically
4202
+ * provided by the runtime.
4203
+ *
4204
+ * @template TNodes - The record of node definitions
4205
+ *
4206
+ * @example
4207
+ * ```typescript
4208
+ * const myFlow = createFlow({
4209
+ * nodes: {
4210
+ * resize: imageResizeNode, // requires ImagePlugin
4211
+ * upload: s3OutputNode, // requires UploadServer
4212
+ * },
4213
+ * edges: [...]
4214
+ * });
4215
+ * type PluginRequirements = FlowPluginRequirements<typeof myFlow.nodes>;
4216
+ * // PluginRequirements = ImagePlugin (UploadServer excluded)
4217
+ * ```
4218
+ */
3925
4219
  type FlowPluginRequirements<TNodes extends NodeDefinitionsRecord> = Exclude<FlowRequirements<TNodes>, UploadServer>;
3926
- type InferNode<T> = T extends FlowNode<any, any, UploadistaError$1> ? T : T extends Effect.Effect<infer R, any, any> ? R extends FlowNode<any, any, UploadistaError$1> ? R : never : never;
4220
+ /**
4221
+ * Infers the concrete FlowNode type from a NodeDefinition.
4222
+ *
4223
+ * If the definition is already a FlowNode, returns it as-is.
4224
+ * If the definition is an Effect, extracts the FlowNode from the Effect's success type.
4225
+ *
4226
+ * Uses the shared ResolveEffect utility for consistency.
4227
+ */
4228
+ type InferNode<T> = T extends FlowNode<any, any, UploadistaError$1> ? T : ResolveEffect<T> extends FlowNode<any, any, UploadistaError$1> ? ResolveEffect<T> : never;
3927
4229
  type ExtractKeysByNodeType<TNodes extends NodeDefinitionsRecord, TType extends NodeType> = { [K in keyof TNodes]: InferNode<TNodes[K]>["type"] extends TType ? K : never }[keyof TNodes];
3928
4230
  type SchemaInfer<T> = T extends z.ZodTypeAny ? z.infer<T> : never;
3929
4231
  type FlowInputMap<TNodes extends NodeDefinitionsRecord> = { [K in Extract<ExtractKeysByNodeType<TNodes, NodeType.input>, string>]: SchemaInfer<InferNode<TNodes[K]>["inputSchema"]> };
@@ -3956,6 +4258,40 @@ type TypedFlowConfig<TNodes extends NodeDefinitionsRecord> = {
3956
4258
  declare const typedFlowInputsSymbol: unique symbol;
3957
4259
  declare const typedFlowOutputsSymbol: unique symbol;
3958
4260
  declare const typedFlowPluginsSymbol: unique symbol;
4261
+ /**
4262
+ * A type-safe Flow that infers input/output types and requirements from its nodes.
4263
+ *
4264
+ * TypedFlow extends the base Flow type with additional type information that
4265
+ * allows TypeScript to verify inputs, outputs, and plugin requirements at compile time.
4266
+ *
4267
+ * The phantom type properties (using unique symbols) enable type-level metadata
4268
+ * without affecting runtime behavior, allowing other type utilities to extract
4269
+ * this information for validation purposes.
4270
+ *
4271
+ * @template TNodes - Record of node definitions used in the flow
4272
+ * @template TInputSchema - Zod schema for flow inputs (inferred from input nodes)
4273
+ * @template TOutputSchema - Zod schema for flow outputs (inferred from output nodes)
4274
+ *
4275
+ * @example
4276
+ * ```typescript
4277
+ * const myFlow = createFlow({
4278
+ * nodes: {
4279
+ * input: fileInputNode,
4280
+ * resize: imageResizeNode,
4281
+ * output: s3OutputNode
4282
+ * },
4283
+ * edges: [
4284
+ * { source: 'input', target: 'resize' },
4285
+ * { source: 'resize', target: 'output' }
4286
+ * ]
4287
+ * });
4288
+ *
4289
+ * // TypeScript infers:
4290
+ * // - Input types from fileInputNode.inputSchema
4291
+ * // - Output types from s3OutputNode.outputSchema
4292
+ * // - Requirements: ImagePlugin (from resize node)
4293
+ * ```
4294
+ */
3959
4295
  type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny> = Flow<TInputSchema, TOutputSchema, FlowRequirements<TNodes>> & {
3960
4296
  run: (args: {
3961
4297
  inputs?: Partial<FlowInputMap<TNodes>>;
@@ -3978,52 +4314,6 @@ type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodT
3978
4314
  };
3979
4315
  declare function createFlow<TNodes extends NodeDefinitionsRecord>(config: TypedFlowConfig<TNodes>): Effect.Effect<TypedFlow<TNodes, z.ZodType<FlowInputUnion<TNodes>>, z.ZodType<FlowOutputUnion<TNodes>>>, NodesErrorUnion<TNodes> | UploadistaError$1, FlowRequirements<TNodes>>;
3980
4316
  //#endregion
3981
- //#region src/flow/types/flow-file.d.ts
3982
- /**
3983
- * Conditional execution rules for flow nodes.
3984
- *
3985
- * Conditions allow nodes to execute conditionally based on file properties or metadata.
3986
- * They are evaluated before node execution and can skip nodes that don't match.
3987
- *
3988
- * @module flow/types/flow-file
3989
- * @see {@link FlowNode} for how conditions are used in nodes
3990
- *
3991
- * @example
3992
- * ```typescript
3993
- * // Only process images larger than 1MB
3994
- * const condition: FlowCondition = {
3995
- * field: "size",
3996
- * operator: "greaterThan",
3997
- * value: 1024 * 1024
3998
- * };
3999
- *
4000
- * // Only process JPEG images
4001
- * const jpegCondition: FlowCondition = {
4002
- * field: "mimeType",
4003
- * operator: "startsWith",
4004
- * value: "image/jpeg"
4005
- * };
4006
- * ```
4007
- */
4008
- /**
4009
- * Represents a conditional rule for node execution.
4010
- *
4011
- * @property field - The file property to check
4012
- * @property operator - The comparison operator to apply
4013
- * @property value - The value to compare against
4014
- *
4015
- * @remarks
4016
- * - Fields can check file metadata (mimeType, size) or image properties (width, height)
4017
- * - String operators (contains, startsWith) work with string values
4018
- * - Numeric operators (greaterThan, lessThan) work with numeric values
4019
- * - The extension field checks the file extension without the dot
4020
- */
4021
- type FlowCondition = {
4022
- field: "mimeType" | "size" | "width" | "height" | "extension";
4023
- operator: "equals" | "notEquals" | "greaterThan" | "lessThan" | "contains" | "startsWith";
4024
- value: string | number;
4025
- };
4026
- //#endregion
4027
4317
  //#region src/flow/types/run-args.d.ts
4028
4318
  /**
4029
4319
  * Zod schema for validating flow run arguments.
@@ -4064,5 +4354,5 @@ type ResolvedUploadMetadata = {
4064
4354
  };
4065
4355
  declare function resolveUploadMetadata(metadata: FileMetadata): ResolvedUploadMetadata;
4066
4356
  //#endregion
4067
- export { FlowServerShape as $, BaseKvStore as $t, ImageAiContext as A, FlowEventFlowError as An, UploadEventEmitter as At, StorageParams as B, FlowEventNodeStart as Bn, EventBroadcaster as Bt, describeImageParamsSchema as C, TypeCompatibilityChecker as Cn, InputFile as Ct, resizeParamsSchema as D, FlowEvent as Dn, EventEmitter as Dt, ResizeParams as E, EventType as En, BaseEventEmitterService as Et, ExecutionLevel as F, FlowEventNodeEnd as Fn, WebSocketMessage as Ft, createInputNode as G, createFlowNode as Gn, DataStoreConfig as Gt, storageParamsSchema as H, ConditionOperator as Hn, BufferedUploadFileDataStore as Ht, ParallelScheduler as I, FlowEventNodeError as In, webSocketMessageSchema as It, FlowProvider as J, UploadFileDataStores as Jt, inputDataSchema as K, getNodeData as Kn, DataStoreWriteOptions as Kt, ParallelSchedulerConfig as L, FlowEventNodePause as Ln, UploadEvent as Lt, ImageAiPluginShape as M, FlowEventFlowStart as Mn, flowEventEmitter as Mt, CredentialProvider as N, FlowEventJobEnd as Nn, uploadEventEmitter as Nt, OptimizeParams as O, FlowEventFlowCancel as On, FlowEventEmitter as Ot, CredentialProviderShape as P, FlowEventJobStart as Pn, WebSocketConnection as Pt, FlowServerOptions as Q, isDataStore as Qt, TransformNodeConfig as R, FlowEventNodeResponse as Rn, UploadEventType as Rt, DescribeImageParams as S, NodeTypeMap as Sn, MiddlewareServiceLive as St, ImagePluginShape as T, waitingNodeExecution as Tn, BaseEventEmitter as Tt, InputData as U, ConditionValue as Un, DataStore as Ut, createStorageNode as V, ConditionField as Vn, EventBroadcasterService as Vt, InputNodeParams as W, NodeType as Wn, DataStoreCapabilities as Wt, FlowServer as X, UploadStrategy as Xt, FlowProviderShape as Y, UploadFileDataStoresShape as Yt, FlowServerLayer as Z, createDataStoreLayer as Zt, ZipParams as _, FlowConfig as _n, detectMimeType as _t, FlowCondition as a, flowJobKvStore as an, FlowJobStatus as at, RemoveBackgroundParams as b, NodeConnectionValidator as bn, MiddlewareNext as bt, FlowPluginRequirements as c, UploadFile as cn, NegotiatedStrategy as ct, NodeDefinitionsRecord as d, FlowData as dn, UploadServer as dt, BaseKvStoreService as en, FlowWaitUntil as et, TypedFlow as f, FlowExecutionResult as fn, UploadServerOptions as ft, ZipInput as g, createFlowEdge as gn, compareMimeTypes as gt, createFlow as h, FlowEdge as hn, uploadServer as ht, runArgsSchema as i, UploadFileKVStore as in, FlowJob as it, ImageAiPlugin as j, FlowEventFlowPause as jn, eventToMessageSerializer as jt, optimizeParamsSchema as k, FlowEventFlowEnd as kn, TypedEventEmitter as kt, FlowRequirements as l, uploadFileSchema as ln, UploadStrategyNegotiator as lt, TypedFlowEdge as m, getFlowData as mn, createUploadServer as mt, resolveUploadMetadata as n, KvStore as nn, createFlowServer as nt, FlowInputMap as o, jsonSerializer as on, FlowJobTask as ot, TypedFlowConfig as p, createFlowWithSchema as pn, UploadServerShape as pt, inputNodeParamsSchema as q, UploadFileDataStore as qt, RunArgs as r, TypedKvStore as rn, flowServer as rt, FlowOutputMap as s, uploadFileKvStore as sn, FlowJobTaskStatus as st, ResolvedUploadMetadata as t, FlowJobKVStore as tn, WaitUntilCallback as tt, NodeDefinition as u, Flow as un, UploadStrategyOptions as ut, ZipPlugin as v, FlowNode as vn, Middleware as vt, ImagePlugin as w, completeNodeExecution as wn, inputFileSchema as wt, removeBackgroundParamsSchema as x, NodeExecutionResult as xn, MiddlewareService as xt, ZipPluginShape as y, FlowNodeData as yn, MiddlewareContext as yt, createTransformNode as z, FlowEventNodeResume as zn, uploadEventSchema as zt };
4068
- //# sourceMappingURL=index-od64jviT.d.mts.map
4357
+ export { storageParamsSchema as $, ConditionOperator as $n, BufferedUploadFileDataStore as $t, ZipPluginLayer as A, FlowNodeData as An, MiddlewareContext as At, ImageAiPlugin as B, FlowEventFlowEnd as Bn, TypedEventEmitter as Bt, DescribeImageParams as C, FlowExecutionResult as Cn, UploadServerOptions as Ct, ZipInput as D, createFlowEdge as Dn, compareMimeTypes as Dt, PluginLayer as E, FlowEdge as En, uploadServer as Et, ResizeParams as F, completeNodeExecution as Fn, inputFileSchema as Ft, CredentialProviderShape as G, FlowEventJobStart as Gn, WebSocketConnection as Gt, ImageAiPluginShape as H, FlowEventFlowPause as Hn, eventToMessageSerializer as Ht, resizeParamsSchema as I, waitingNodeExecution as In, BaseEventEmitter as It, ParallelSchedulerConfig as J, FlowEventNodePause as Jn, UploadEvent as Jt, ExecutionLevel as K, FlowEventNodeEnd as Kn, WebSocketMessage as Kt, OptimizeParams as L, EventType as Ln, BaseEventEmitterService as Lt, ImagePlugin as M, NodeExecutionResult as Mn, MiddlewareService as Mt, ImagePluginLayer as N, NodeTypeMap as Nn, MiddlewareServiceLive as Nt, ZipParams as O, FlowConfig as On, detectMimeType as Ot, ImagePluginShape as P, TypeCompatibilityChecker as Pn, InputFile as Pt, createStorageNode as Q, ConditionField as Qn, EventBroadcasterService as Qt, optimizeParamsSchema as R, FlowEvent as Rn, EventEmitter as Rt, removeBackgroundParamsSchema as S, FlowData as Sn, UploadServer as St, Plugin as T, getFlowData as Tn, createUploadServer as Tt, CredentialProvider as U, FlowEventFlowStart as Un, flowEventEmitter as Ut, ImageAiPluginLayer as V, FlowEventFlowError as Vn, UploadEventEmitter as Vt, CredentialProviderLayer as W, FlowEventJobEnd as Wn, uploadEventEmitter as Wt, createTransformNode as X, FlowEventNodeResume as Xn, uploadEventSchema as Xt, TransformNodeConfig as Y, FlowEventNodeResponse as Yn, UploadEventType as Yt, StorageParams as Z, FlowEventNodeStart as Zn, EventBroadcaster as Zt, ExtractLayerService as _, jsonSerializer as _n, FlowJobTask as _t, FlowInputMap as a, UploadFileDataStores as an, FlowProvider as at, FlowCondition as b, uploadFileSchema as bn, UploadStrategyNegotiator as bt, FlowRequirements as c, createDataStoreLayer as cn, FlowServerLayer as ct, TypedFlow as d, BaseKvStoreService as dn, FlowWaitUntil as dt, DataStore as en, ConditionValue as er, InputData as et, TypedFlowConfig as f, FlowJobKVStore as fn, WaitUntilCallback as ft, ExtractEffectRequirements as g, flowJobKvStore as gn, FlowJobStatus as gt, ExtractEffectError as h, UploadFileKVStore as hn, FlowJob as ht, runArgsSchema as i, UploadFileDataStore as in, inputNodeParamsSchema as it, ZipPluginShape as j, NodeConnectionValidator as jn, MiddlewareNext as jt, ZipPlugin as k, FlowNode as kn, Middleware as kt, NodeDefinition as l, isDataStore as ln, FlowServerOptions as lt, createFlow as m, TypedKvStore as mn, flowServer as mt, resolveUploadMetadata as n, DataStoreConfig as nn, createFlowNode as nr, createInputNode as nt, FlowOutputMap as o, UploadFileDataStoresShape as on, FlowProviderShape as ot, TypedFlowEdge as p, KvStore as pn, createFlowServer as pt, ParallelScheduler as q, FlowEventNodeError as qn, webSocketMessageSchema as qt, RunArgs as r, DataStoreWriteOptions as rn, getNodeData as rr, inputDataSchema as rt, FlowPluginRequirements as s, UploadStrategy as sn, FlowServer as st, ResolvedUploadMetadata as t, DataStoreCapabilities as tn, NodeType as tr, InputNodeParams as tt, NodeDefinitionsRecord as u, BaseKvStore as un, FlowServerShape as ut, ExtractLayerServices as v, uploadFileKvStore as vn, FlowJobTaskStatus as vt, describeImageParamsSchema as w, createFlowWithSchema as wn, UploadServerShape as wt, RemoveBackgroundParams as x, Flow as xn, UploadStrategyOptions as xt, ResolveEffect as y, UploadFile as yn, NegotiatedStrategy as yt, ImageAiContext as z, FlowEventFlowCancel as zn, FlowEventEmitter as zt };
4358
+ //# sourceMappingURL=index-CDzzqysG.d.mts.map