@uploadista/core 0.0.10 → 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.
@@ -763,7 +763,7 @@ type FlowData = {
763
763
  * await db.flows.save(flowData);
764
764
  * ```
765
765
  */
766
- declare const getFlowData: <TRequirements$1>(flow: Flow<any, any, TRequirements$1>) => FlowData;
766
+ declare const getFlowData: <TRequirements>(flow: Flow<any, any, TRequirements>) => FlowData;
767
767
  /**
768
768
  * Result of a flow execution - either completed or paused.
769
769
  *
@@ -846,21 +846,21 @@ type FlowExecutionResult<TOutput> = {
846
846
  * });
847
847
  * ```
848
848
  */
849
- type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements$1> = {
849
+ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z.ZodSchema<any>, TRequirements> = {
850
850
  id: string;
851
851
  name: string;
852
852
  nodes: FlowNode<any, any, UploadistaError>[];
853
853
  edges: FlowEdge[];
854
854
  inputSchema: TFlowInputSchema;
855
855
  outputSchema: TFlowOutputSchema;
856
- onEvent?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements$1>["onEvent"];
857
- checkJobStatus?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements$1>["checkJobStatus"];
856
+ onEvent?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements>["onEvent"];
857
+ checkJobStatus?: FlowConfig<TFlowInputSchema, TFlowOutputSchema, TRequirements>["checkJobStatus"];
858
858
  run: (args: {
859
859
  inputs?: Record<string, z.infer<TFlowInputSchema>>;
860
860
  storageId: string;
861
861
  jobId: string;
862
862
  clientId: string | null;
863
- }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError, TRequirements$1>;
863
+ }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError, TRequirements>;
864
864
  resume: (args: {
865
865
  jobId: string;
866
866
  storageId: string;
@@ -871,7 +871,7 @@ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z
871
871
  inputs: Record<string, z.infer<TFlowInputSchema>>;
872
872
  };
873
873
  clientId: string | null;
874
- }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError, TRequirements$1>;
874
+ }) => Effect.Effect<FlowExecutionResult<Record<string, z.infer<TFlowOutputSchema>>>, UploadistaError, TRequirements>;
875
875
  validateTypes: () => {
876
876
  isValid: boolean;
877
877
  errors: string[];
@@ -953,7 +953,7 @@ type Flow<TFlowInputSchema extends z.ZodSchema<any>, TFlowOutputSchema extends z
953
953
  * @see {@link Flow} for the returned flow type
954
954
  * @see {@link FlowConfig} for configuration options
955
955
  */
956
- 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>;
956
+ 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>;
957
957
  //#endregion
958
958
  //#region src/types/upload-file.d.ts
959
959
  /**
@@ -3036,8 +3036,8 @@ declare class FlowWaitUntil extends FlowWaitUntil_base {
3036
3036
  * const flowProviderLayer = Layer.succeed(FlowProvider, dbFlowProvider);
3037
3037
  * ```
3038
3038
  */
3039
- type FlowProviderShape<TRequirements$1 = any> = {
3040
- getFlow: (flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements$1>, UploadistaError>;
3039
+ type FlowProviderShape<TRequirements = any> = {
3040
+ getFlow: (flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements>, UploadistaError>;
3041
3041
  };
3042
3042
  declare const FlowProvider_base: Context.TagClass<FlowProvider, "FlowProvider", FlowProviderShape<any>>;
3043
3043
  /**
@@ -3143,9 +3143,9 @@ declare class FlowProvider extends FlowProvider_base {}
3143
3143
  * ```
3144
3144
  */
3145
3145
  type FlowServerShape = {
3146
- getFlow: <TRequirements$1>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements$1>, UploadistaError>;
3146
+ getFlow: <TRequirements>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, TRequirements>, UploadistaError>;
3147
3147
  getFlowData: (flowId: string, clientId: string | null) => Effect.Effect<FlowData, UploadistaError>;
3148
- runFlow: <TRequirements$1>({
3148
+ runFlow: <TRequirements>({
3149
3149
  flowId,
3150
3150
  storageId,
3151
3151
  clientId,
@@ -3155,8 +3155,8 @@ type FlowServerShape = {
3155
3155
  storageId: string;
3156
3156
  clientId: string | null;
3157
3157
  inputs: any;
3158
- }) => Effect.Effect<FlowJob, UploadistaError, TRequirements$1>;
3159
- resumeFlow: <TRequirements$1>({
3158
+ }) => Effect.Effect<FlowJob, UploadistaError, TRequirements>;
3159
+ resumeFlow: <TRequirements>({
3160
3160
  jobId,
3161
3161
  nodeId,
3162
3162
  newData,
@@ -3166,7 +3166,7 @@ type FlowServerShape = {
3166
3166
  nodeId: string;
3167
3167
  newData: unknown;
3168
3168
  clientId: string | null;
3169
- }) => Effect.Effect<FlowJob, UploadistaError, TRequirements$1>;
3169
+ }) => Effect.Effect<FlowJob, UploadistaError, TRequirements>;
3170
3170
  pauseFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError>;
3171
3171
  cancelFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError>;
3172
3172
  getJobStatus: (jobId: string) => Effect.Effect<FlowJob, UploadistaError>;
@@ -3213,17 +3213,17 @@ declare class FlowServer extends FlowServer_base {}
3213
3213
  * @property kvStore - KV store for flow job metadata
3214
3214
  */
3215
3215
  type FlowServerOptions = {
3216
- getFlow: <TRequirements$1>({
3216
+ getFlow: <TRequirements>({
3217
3217
  flowId,
3218
3218
  storageId
3219
3219
  }: {
3220
3220
  flowId: string;
3221
3221
  storageId: string;
3222
- }) => Promise<Flow<any, any, TRequirements$1>>;
3222
+ }) => Promise<Flow<any, any, TRequirements>>;
3223
3223
  kvStore: KvStore<FlowJob>;
3224
3224
  };
3225
3225
  declare function createFlowServer(): Effect.Effect<{
3226
- getFlow: <TRequirements$1>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, any>, UploadistaError, never>;
3226
+ getFlow: <TRequirements>(flowId: string, clientId: string | null) => Effect.Effect<Flow<any, any, any>, UploadistaError, never>;
3227
3227
  getFlowData: (flowId: string, clientId: string | null) => Effect.Effect<FlowData, UploadistaError, never>;
3228
3228
  runFlow: ({
3229
3229
  flowId,
@@ -3252,8 +3252,8 @@ declare function createFlowServer(): Effect.Effect<{
3252
3252
  cancelFlow: (jobId: string, clientId: string | null) => Effect.Effect<FlowJob, UploadistaError, never>;
3253
3253
  subscribeToFlowEvents: (jobId: string, connection: WebSocketConnection) => Effect.Effect<void, UploadistaError, never>;
3254
3254
  unsubscribeFromFlowEvents: (jobId: string) => Effect.Effect<void, UploadistaError, never>;
3255
- }, never, UploadServer | FlowEventEmitter | FlowJobKVStore | FlowProvider>;
3256
- declare const flowServer: Layer.Layer<FlowServer, never, UploadServer | FlowEventEmitter | FlowJobKVStore | FlowProvider>;
3255
+ }, never, FlowEventEmitter | FlowJobKVStore | UploadServer | FlowProvider>;
3256
+ declare const flowServer: Layer.Layer<FlowServer, never, FlowEventEmitter | FlowJobKVStore | UploadServer | FlowProvider>;
3257
3257
  type FlowServerLayer = typeof flowServer;
3258
3258
  //#endregion
3259
3259
  //#region src/flow/nodes/input-node.d.ts
@@ -3596,7 +3596,7 @@ declare class ParallelScheduler {
3596
3596
  * // results will be in order: [result1, result2, result3]
3597
3597
  * ```
3598
3598
  */
3599
- executeNodesInParallel<T, E, R$1>(nodeExecutors: Array<() => Effect.Effect<T, E, R$1>>): Effect.Effect<T[], E, R$1>;
3599
+ executeNodesInParallel<T, E$1, R$1>(nodeExecutors: Array<() => Effect.Effect<T, E$1, R$1>>): Effect.Effect<T[], E$1, R$1>;
3600
3600
  /**
3601
3601
  * Determines if a set of nodes can be safely executed in parallel.
3602
3602
  *
@@ -3678,6 +3678,7 @@ declare const CredentialProvider_base: Context.TagClass<CredentialProvider, "Cre
3678
3678
  * ```
3679
3679
  */
3680
3680
  declare class CredentialProvider extends CredentialProvider_base {}
3681
+ type CredentialProviderLayer = Layer.Layer<CredentialProvider, never, never>;
3681
3682
  //#endregion
3682
3683
  //#region dist/uploadista-error-DHajuvP1.d.mts
3683
3684
  //#region src/errors/uploadista-error.d.ts
@@ -3915,6 +3916,7 @@ declare const ImageAiPlugin_base: Context.TagClass<ImageAiPlugin, "ImageAiPlugin
3915
3916
  * ```
3916
3917
  */
3917
3918
  declare class ImageAiPlugin extends ImageAiPlugin_base {}
3919
+ type ImageAiPluginLayer = Layer.Layer<ImageAiPlugin, never, never>;
3918
3920
  //#endregion
3919
3921
  //#region src/flow/plugins/types/optimize-node.d.ts
3920
3922
  /**
@@ -4003,38 +4005,7 @@ declare const ImagePlugin_base: Context.TagClass<ImagePlugin, "ImagePlugin", Ima
4003
4005
  * ```
4004
4006
  */
4005
4007
  declare class ImagePlugin extends ImagePlugin_base {}
4006
- //#endregion
4007
- //#region src/flow/plugins/types/describe-image-node.d.ts
4008
- /**
4009
- * Zod schema for validating describe image node parameters.
4010
- * Defines the structure and validation rules for image description requests.
4011
- */
4012
- declare const describeImageParamsSchema: z.ZodObject<{
4013
- serviceType: z.ZodOptional<z.ZodEnum<{
4014
- replicate: "replicate";
4015
- }>>;
4016
- }, z.core.$strip>;
4017
- /**
4018
- * Parameters for the describe image node.
4019
- * Controls which AI service to use for generating image descriptions.
4020
- */
4021
- type DescribeImageParams = z.infer<typeof describeImageParamsSchema>;
4022
- //#endregion
4023
- //#region src/flow/plugins/types/remove-background-node.d.ts
4024
- /**
4025
- * Zod schema for validating remove background node parameters.
4026
- * Defines the structure and validation rules for background removal requests.
4027
- */
4028
- declare const removeBackgroundParamsSchema: z.ZodObject<{
4029
- serviceType: z.ZodOptional<z.ZodEnum<{
4030
- replicate: "replicate";
4031
- }>>;
4032
- }, z.core.$strip>;
4033
- /**
4034
- * Parameters for the remove background node.
4035
- * Controls which AI service to use for background removal processing.
4036
- */
4037
- type RemoveBackgroundParams = z.infer<typeof removeBackgroundParamsSchema>;
4008
+ type ImagePluginLayer = Layer.Layer<ImagePlugin, never, never>;
4038
4009
  //#endregion
4039
4010
  //#region src/flow/plugins/zip-plugin.d.ts
4040
4011
  /**
@@ -4093,17 +4064,348 @@ declare const ZipPlugin_base: Context.TagClass<ZipPlugin, "ZipPlugin", ZipPlugin
4093
4064
  * ```
4094
4065
  */
4095
4066
  declare class ZipPlugin extends ZipPlugin_base {}
4067
+ type ZipPluginLayer = Layer.Layer<ZipPlugin, never, never>;
4068
+ //#endregion
4069
+ //#region src/flow/plugins/plugins.d.ts
4070
+ type Plugin = ImagePlugin | ImageAiPlugin | CredentialProvider | ZipPlugin;
4071
+ type PluginLayer = ImagePluginLayer | ImageAiPluginLayer | CredentialProviderLayer | ZipPluginLayer;
4072
+ //#endregion
4073
+ //#region src/flow/plugins/types/describe-image-node.d.ts
4074
+ /**
4075
+ * Zod schema for validating describe image node parameters.
4076
+ * Defines the structure and validation rules for image description requests.
4077
+ */
4078
+ declare const describeImageParamsSchema: z.ZodObject<{
4079
+ serviceType: z.ZodOptional<z.ZodEnum<{
4080
+ replicate: "replicate";
4081
+ }>>;
4082
+ }, z.core.$strip>;
4083
+ /**
4084
+ * Parameters for the describe image node.
4085
+ * Controls which AI service to use for generating image descriptions.
4086
+ */
4087
+ type DescribeImageParams = z.infer<typeof describeImageParamsSchema>;
4088
+ //#endregion
4089
+ //#region src/flow/plugins/types/remove-background-node.d.ts
4090
+ /**
4091
+ * Zod schema for validating remove background node parameters.
4092
+ * Defines the structure and validation rules for background removal requests.
4093
+ */
4094
+ declare const removeBackgroundParamsSchema: z.ZodObject<{
4095
+ serviceType: z.ZodOptional<z.ZodEnum<{
4096
+ replicate: "replicate";
4097
+ }>>;
4098
+ }, z.core.$strip>;
4099
+ /**
4100
+ * Parameters for the remove background node.
4101
+ * Controls which AI service to use for background removal processing.
4102
+ */
4103
+ type RemoveBackgroundParams = z.infer<typeof removeBackgroundParamsSchema>;
4104
+ //#endregion
4105
+ //#region src/flow/types/flow-file.d.ts
4106
+ /**
4107
+ * Conditional execution rules for flow nodes.
4108
+ *
4109
+ * Conditions allow nodes to execute conditionally based on file properties or metadata.
4110
+ * They are evaluated before node execution and can skip nodes that don't match.
4111
+ *
4112
+ * @module flow/types/flow-file
4113
+ * @see {@link FlowNode} for how conditions are used in nodes
4114
+ *
4115
+ * @example
4116
+ * ```typescript
4117
+ * // Only process images larger than 1MB
4118
+ * const condition: FlowCondition = {
4119
+ * field: "size",
4120
+ * operator: "greaterThan",
4121
+ * value: 1024 * 1024
4122
+ * };
4123
+ *
4124
+ * // Only process JPEG images
4125
+ * const jpegCondition: FlowCondition = {
4126
+ * field: "mimeType",
4127
+ * operator: "startsWith",
4128
+ * value: "image/jpeg"
4129
+ * };
4130
+ * ```
4131
+ */
4132
+ /**
4133
+ * Represents a conditional rule for node execution.
4134
+ *
4135
+ * @property field - The file property to check
4136
+ * @property operator - The comparison operator to apply
4137
+ * @property value - The value to compare against
4138
+ *
4139
+ * @remarks
4140
+ * - Fields can check file metadata (mimeType, size) or image properties (width, height)
4141
+ * - String operators (contains, startsWith) work with string values
4142
+ * - Numeric operators (greaterThan, lessThan) work with numeric values
4143
+ * - The extension field checks the file extension without the dot
4144
+ */
4145
+ type FlowCondition = {
4146
+ field: "mimeType" | "size" | "width" | "height" | "extension";
4147
+ operator: "equals" | "notEquals" | "greaterThan" | "lessThan" | "contains" | "startsWith";
4148
+ value: string | number;
4149
+ };
4150
+ //#endregion
4151
+ //#region src/flow/types/type-utils.d.ts
4152
+ /**
4153
+ * Extracts the service type from an Effect Layer.
4154
+ *
4155
+ * Given a Layer that provides a service, this type utility extracts
4156
+ * the service type from the Layer's type signature.
4157
+ *
4158
+ * @template T - The Layer type to extract from
4159
+ * @returns The service type provided by the layer, or never if T is not a Layer
4160
+ *
4161
+ * @example
4162
+ * ```typescript
4163
+ * type MyLayer = Layer.Layer<ServiceA, never, never>;
4164
+ * type Service = ExtractLayerService<MyLayer>;
4165
+ * // Service = ServiceA
4166
+ * ```
4167
+ *
4168
+ * @example
4169
+ * ```typescript
4170
+ * import { ImagePluginLayer } from '@uploadista/core';
4171
+ *
4172
+ * type ImageService = ExtractLayerService<ImagePluginLayer>;
4173
+ * // ImageService = ImagePlugin
4174
+ * ```
4175
+ */
4176
+ type ExtractLayerService<T, TError$1 = never, TRequirements = never> = T extends Layer.Layer<infer S, TError$1, TRequirements> ? S : never;
4177
+ /**
4178
+ * Extracts all service types from a tuple of layers and returns them as a union.
4179
+ *
4180
+ * This type recursively processes a tuple of Layer types and extracts all
4181
+ * the services they provide, combining them into a single union type.
4182
+ *
4183
+ * @template T - A readonly tuple of Layer types
4184
+ * @returns A union of all service types provided by the layers
4185
+ *
4186
+ * @example
4187
+ * ```typescript
4188
+ * type Layers = [
4189
+ * Layer.Layer<ServiceA, never, never>,
4190
+ * Layer.Layer<ServiceB, never, never>,
4191
+ * Layer.Layer<ServiceC, never, never>
4192
+ * ];
4193
+ * type Services = ExtractLayerServices<Layers>;
4194
+ * // Services = ServiceA | ServiceB | ServiceC
4195
+ * ```
4196
+ *
4197
+ * @example
4198
+ * ```typescript
4199
+ * import { ImagePluginLayer, ZipPluginLayer } from '@uploadista/core';
4200
+ *
4201
+ * type PluginLayers = [ImagePluginLayer, ZipPluginLayer];
4202
+ * type AllServices = ExtractLayerServices<PluginLayers>;
4203
+ * // AllServices = ImagePlugin | ZipPlugin
4204
+ * ```
4205
+ */
4206
+ type ExtractLayerServices<T extends readonly Layer.Layer<any, any, any>[]> = T[number] extends Layer.Layer<infer S, any, any> ? S : never;
4207
+ /**
4208
+ * Unwraps an Effect type to extract its success value type.
4209
+ *
4210
+ * If the input type is an Effect, this extracts the success type (first type parameter).
4211
+ * If the input is not an Effect, it returns the type unchanged.
4212
+ *
4213
+ * @template T - The type to resolve, potentially an Effect
4214
+ * @returns The success type if T is an Effect, otherwise T
4215
+ *
4216
+ * @example
4217
+ * ```typescript
4218
+ * type MyEffect = Effect.Effect<string, Error, never>;
4219
+ * type Result = ResolveEffect<MyEffect>;
4220
+ * // Result = string
4221
+ * ```
4222
+ *
4223
+ * @example
4224
+ * ```typescript
4225
+ * type NonEffect = { data: string };
4226
+ * type Result = ResolveEffect<NonEffect>;
4227
+ * // Result = { data: string }
4228
+ * ```
4229
+ */
4230
+ type ResolveEffect<T> = T extends Effect.Effect<infer S, any, any> ? S : T;
4231
+ /**
4232
+ * Extracts the error type from an Effect.
4233
+ *
4234
+ * Given an Effect type, this utility extracts the error type
4235
+ * (second type parameter) from the Effect's type signature.
4236
+ *
4237
+ * @template T - The Effect type to extract from
4238
+ * @returns The error type of the Effect, or never if T is not an Effect
4239
+ *
4240
+ * @example
4241
+ * ```typescript
4242
+ * type MyEffect = Effect.Effect<string, ValidationError, never>;
4243
+ * type ErrorType = ExtractEffectError<MyEffect>;
4244
+ * // ErrorType = ValidationError
4245
+ * ```
4246
+ *
4247
+ * @example
4248
+ * ```typescript
4249
+ * type SafeEffect = Effect.Effect<number, never, SomeService>;
4250
+ * type ErrorType = ExtractEffectError<SafeEffect>;
4251
+ * // ErrorType = never (no errors possible)
4252
+ * ```
4253
+ */
4254
+ type ExtractEffectError<T> = T extends Effect.Effect<any, infer E, any> ? E : never;
4255
+ /**
4256
+ * Extracts the requirements (context) type from an Effect.
4257
+ *
4258
+ * Given an Effect type, this utility extracts the requirements type
4259
+ * (third type parameter) from the Effect's type signature. This represents
4260
+ * the services that must be provided for the Effect to run.
4261
+ *
4262
+ * @template T - The Effect type to extract from
4263
+ * @returns The requirements type of the Effect, or never if T is not an Effect
4264
+ *
4265
+ * @example
4266
+ * ```typescript
4267
+ * type MyEffect = Effect.Effect<string, Error, Database | Logger>;
4268
+ * type Requirements = ExtractEffectRequirements<MyEffect>;
4269
+ * // Requirements = Database | Logger
4270
+ * ```
4271
+ *
4272
+ * @example
4273
+ * ```typescript
4274
+ * import { ImagePlugin, ZipPlugin } from '@uploadista/core';
4275
+ *
4276
+ * type ProcessEffect = Effect.Effect<
4277
+ * ProcessedImage,
4278
+ * ProcessError,
4279
+ * ImagePlugin | ZipPlugin
4280
+ * >;
4281
+ * type Needed = ExtractEffectRequirements<ProcessEffect>;
4282
+ * // Needed = ImagePlugin | ZipPlugin
4283
+ * ```
4284
+ */
4285
+ type ExtractEffectRequirements<T> = T extends Effect.Effect<any, any, infer R> ? R : never;
4096
4286
  //#endregion
4097
4287
  //#region src/flow/typed-flow.d.ts
4288
+ /**
4289
+ * Defines a node that can be used in a typed flow.
4290
+ *
4291
+ * A node definition can be either:
4292
+ * - A plain FlowNode object
4293
+ * - An Effect that resolves to a FlowNode (for nodes requiring dependencies)
4294
+ *
4295
+ * @template TNodeError - The error types that the node can produce
4296
+ * @template TNodeRequirements - The services/dependencies the node requires
4297
+ */
4098
4298
  type NodeDefinition<TNodeError = never, TNodeRequirements = never> = FlowNode<any, any, UploadistaError> | Effect.Effect<FlowNode<any, any, UploadistaError>, TNodeError, TNodeRequirements>;
4299
+ /**
4300
+ * A record mapping node IDs to their definitions.
4301
+ *
4302
+ * This is the primary type used for defining the nodes in a typed flow,
4303
+ * allowing TypeScript to infer input/output schemas and requirements.
4304
+ *
4305
+ * @example
4306
+ * ```typescript
4307
+ * const nodes = {
4308
+ * input: fileInputNode,
4309
+ * resize: Effect.succeed(imageResizeNode),
4310
+ * output: s3OutputNode
4311
+ * } satisfies NodeDefinitionsRecord;
4312
+ * ```
4313
+ */
4099
4314
  type NodeDefinitionsRecord = Record<string, NodeDefinition<any, any>>;
4315
+ /**
4316
+ * Extracts the error type from a NodeDefinition.
4317
+ *
4318
+ * If the node is an Effect, extracts its error type.
4319
+ * If the node is a plain FlowNode, returns never (no errors).
4320
+ */
4100
4321
  type NodeDefinitionError<T> = T extends Effect.Effect<FlowNode<any, any, UploadistaError>, infer TError, any> ? TError : never;
4101
- type NodeDefinitionRequirements<T> = T extends Effect.Effect<FlowNode<any, any, UploadistaError>, any, infer TRequirements> ? TRequirements : never;
4322
+ /**
4323
+ * Extracts the requirements (dependencies) from a NodeDefinition.
4324
+ *
4325
+ * Uses the shared ExtractEffectRequirements utility for consistency.
4326
+ */
4327
+ type NodeDefinitionRequirements<T> = ExtractEffectRequirements<T>;
4328
+ /**
4329
+ * Extracts all possible errors from all nodes in a flow as a union.
4330
+ *
4331
+ * This iterates through all nodes in the record and combines their
4332
+ * error types into a single union type.
4333
+ */
4102
4334
  type NodesErrorUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionError<TNodes[K]> }[keyof TNodes];
4335
+ /**
4336
+ * Extracts all service requirements from all nodes in a flow as a union.
4337
+ *
4338
+ * This iterates through all nodes in the record and combines their
4339
+ * requirement types into a single union type representing all services
4340
+ * needed by the flow.
4341
+ *
4342
+ * @template TNodes - The record of node definitions
4343
+ *
4344
+ * @example
4345
+ * ```typescript
4346
+ * const nodes = {
4347
+ * resize: imageResizeNode, // requires ImagePlugin
4348
+ * zip: zipNode, // requires ZipPlugin
4349
+ * };
4350
+ * type Requirements = NodesRequirementsUnion<typeof nodes>;
4351
+ * // Requirements = ImagePlugin | ZipPlugin
4352
+ * ```
4353
+ */
4103
4354
  type NodesRequirementsUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionRequirements<TNodes[K]> }[keyof TNodes];
4355
+ /**
4356
+ * Extracts all service requirements from a flow's nodes.
4357
+ *
4358
+ * This includes all services required by any node in the flow,
4359
+ * including UploadServer (which is provided by the runtime).
4360
+ *
4361
+ * @template TNodes - The record of node definitions
4362
+ *
4363
+ * @example
4364
+ * ```typescript
4365
+ * const myFlow = createFlow({
4366
+ * nodes: {
4367
+ * input: fileInputNode,
4368
+ * process: imageProcessNode, // requires ImagePlugin
4369
+ * },
4370
+ * edges: [...]
4371
+ * });
4372
+ * type AllRequirements = FlowRequirements<typeof myFlow.nodes>;
4373
+ * // AllRequirements = ImagePlugin | UploadServer
4374
+ * ```
4375
+ */
4104
4376
  type FlowRequirements<TNodes extends NodeDefinitionsRecord> = NodesRequirementsUnion<TNodes>;
4377
+ /**
4378
+ * Extracts plugin service requirements from a flow, excluding UploadServer.
4379
+ *
4380
+ * This type is useful for determining which plugin layers need to be
4381
+ * provided when creating a server, as UploadServer is automatically
4382
+ * provided by the runtime.
4383
+ *
4384
+ * @template TNodes - The record of node definitions
4385
+ *
4386
+ * @example
4387
+ * ```typescript
4388
+ * const myFlow = createFlow({
4389
+ * nodes: {
4390
+ * resize: imageResizeNode, // requires ImagePlugin
4391
+ * upload: s3OutputNode, // requires UploadServer
4392
+ * },
4393
+ * edges: [...]
4394
+ * });
4395
+ * type PluginRequirements = FlowPluginRequirements<typeof myFlow.nodes>;
4396
+ * // PluginRequirements = ImagePlugin (UploadServer excluded)
4397
+ * ```
4398
+ */
4105
4399
  type FlowPluginRequirements<TNodes extends NodeDefinitionsRecord> = Exclude<FlowRequirements<TNodes>, UploadServer>;
4106
- type InferNode<T> = T extends FlowNode<any, any, UploadistaError> ? T : T extends Effect.Effect<infer R, any, any> ? R extends FlowNode<any, any, UploadistaError> ? R : never : never;
4400
+ /**
4401
+ * Infers the concrete FlowNode type from a NodeDefinition.
4402
+ *
4403
+ * If the definition is already a FlowNode, returns it as-is.
4404
+ * If the definition is an Effect, extracts the FlowNode from the Effect's success type.
4405
+ *
4406
+ * Uses the shared ResolveEffect utility for consistency.
4407
+ */
4408
+ type InferNode<T> = T extends FlowNode<any, any, UploadistaError> ? T : ResolveEffect<T> extends FlowNode<any, any, UploadistaError> ? ResolveEffect<T> : never;
4107
4409
  type ExtractKeysByNodeType<TNodes extends NodeDefinitionsRecord, TType extends NodeType> = { [K in keyof TNodes]: InferNode<TNodes[K]>["type"] extends TType ? K : never }[keyof TNodes];
4108
4410
  type SchemaInfer<T> = T extends z.ZodTypeAny ? z.infer<T> : never;
4109
4411
  type FlowInputMap<TNodes extends NodeDefinitionsRecord> = { [K in Extract<ExtractKeysByNodeType<TNodes, NodeType.input>, string>]: SchemaInfer<InferNode<TNodes[K]>["inputSchema"]> };
@@ -4136,6 +4438,40 @@ type TypedFlowConfig<TNodes extends NodeDefinitionsRecord> = {
4136
4438
  declare const typedFlowInputsSymbol: unique symbol;
4137
4439
  declare const typedFlowOutputsSymbol: unique symbol;
4138
4440
  declare const typedFlowPluginsSymbol: unique symbol;
4441
+ /**
4442
+ * A type-safe Flow that infers input/output types and requirements from its nodes.
4443
+ *
4444
+ * TypedFlow extends the base Flow type with additional type information that
4445
+ * allows TypeScript to verify inputs, outputs, and plugin requirements at compile time.
4446
+ *
4447
+ * The phantom type properties (using unique symbols) enable type-level metadata
4448
+ * without affecting runtime behavior, allowing other type utilities to extract
4449
+ * this information for validation purposes.
4450
+ *
4451
+ * @template TNodes - Record of node definitions used in the flow
4452
+ * @template TInputSchema - Zod schema for flow inputs (inferred from input nodes)
4453
+ * @template TOutputSchema - Zod schema for flow outputs (inferred from output nodes)
4454
+ *
4455
+ * @example
4456
+ * ```typescript
4457
+ * const myFlow = createFlow({
4458
+ * nodes: {
4459
+ * input: fileInputNode,
4460
+ * resize: imageResizeNode,
4461
+ * output: s3OutputNode
4462
+ * },
4463
+ * edges: [
4464
+ * { source: 'input', target: 'resize' },
4465
+ * { source: 'resize', target: 'output' }
4466
+ * ]
4467
+ * });
4468
+ *
4469
+ * // TypeScript infers:
4470
+ * // - Input types from fileInputNode.inputSchema
4471
+ * // - Output types from s3OutputNode.outputSchema
4472
+ * // - Requirements: ImagePlugin (from resize node)
4473
+ * ```
4474
+ */
4139
4475
  type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny> = Flow<TInputSchema, TOutputSchema, FlowRequirements<TNodes>> & {
4140
4476
  run: (args: {
4141
4477
  inputs?: Partial<FlowInputMap<TNodes>>;
@@ -4158,52 +4494,6 @@ type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodT
4158
4494
  };
4159
4495
  declare function createFlow<TNodes extends NodeDefinitionsRecord>(config: TypedFlowConfig<TNodes>): Effect.Effect<TypedFlow<TNodes, z.ZodType<FlowInputUnion<TNodes>>, z.ZodType<FlowOutputUnion<TNodes>>>, NodesErrorUnion<TNodes> | UploadistaError, FlowRequirements<TNodes>>;
4160
4496
  //#endregion
4161
- //#region src/flow/types/flow-file.d.ts
4162
- /**
4163
- * Conditional execution rules for flow nodes.
4164
- *
4165
- * Conditions allow nodes to execute conditionally based on file properties or metadata.
4166
- * They are evaluated before node execution and can skip nodes that don't match.
4167
- *
4168
- * @module flow/types/flow-file
4169
- * @see {@link FlowNode} for how conditions are used in nodes
4170
- *
4171
- * @example
4172
- * ```typescript
4173
- * // Only process images larger than 1MB
4174
- * const condition: FlowCondition = {
4175
- * field: "size",
4176
- * operator: "greaterThan",
4177
- * value: 1024 * 1024
4178
- * };
4179
- *
4180
- * // Only process JPEG images
4181
- * const jpegCondition: FlowCondition = {
4182
- * field: "mimeType",
4183
- * operator: "startsWith",
4184
- * value: "image/jpeg"
4185
- * };
4186
- * ```
4187
- */
4188
- /**
4189
- * Represents a conditional rule for node execution.
4190
- *
4191
- * @property field - The file property to check
4192
- * @property operator - The comparison operator to apply
4193
- * @property value - The value to compare against
4194
- *
4195
- * @remarks
4196
- * - Fields can check file metadata (mimeType, size) or image properties (width, height)
4197
- * - String operators (contains, startsWith) work with string values
4198
- * - Numeric operators (greaterThan, lessThan) work with numeric values
4199
- * - The extension field checks the file extension without the dot
4200
- */
4201
- type FlowCondition = {
4202
- field: "mimeType" | "size" | "width" | "height" | "extension";
4203
- operator: "equals" | "notEquals" | "greaterThan" | "lessThan" | "contains" | "startsWith";
4204
- value: string | number;
4205
- };
4206
- //#endregion
4207
4497
  //#region src/flow/types/run-args.d.ts
4208
4498
  /**
4209
4499
  * Zod schema for validating flow run arguments.
@@ -4244,5 +4534,5 @@ type ResolvedUploadMetadata = {
4244
4534
  };
4245
4535
  declare function resolveUploadMetadata(metadata: FileMetadata): ResolvedUploadMetadata;
4246
4536
  //#endregion
4247
- 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 };
4248
- //# sourceMappingURL=index-Bg1HsPC1.d.cts.map
4537
+ 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 };
4538
+ //# sourceMappingURL=index-DyUMSQeo.d.cts.map