@uploadista/core 0.0.10 → 0.0.12

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.
Files changed (35) hide show
  1. package/dist/flow/index.cjs +1 -1
  2. package/dist/flow/index.d.cts +2 -2
  3. package/dist/flow/index.d.mts +2 -2
  4. package/dist/flow/index.mjs +1 -1
  5. package/dist/{flow-DEohelFR.mjs → flow-CpDQ8dgf.mjs} +2 -2
  6. package/dist/flow-CpDQ8dgf.mjs.map +1 -0
  7. package/dist/{flow-C_doYlGf.cjs → flow-wZzF8vml.cjs} +1 -1
  8. package/dist/{index-Bg1HsPC1.d.cts → index-DHOYyzYt.d.cts} +760 -104
  9. package/dist/index-DHOYyzYt.d.cts.map +1 -0
  10. package/dist/{index-BQ8Ns-NS.d.mts → index-DdT18SQi.d.mts} +760 -104
  11. package/dist/index-DdT18SQi.d.mts.map +1 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +2 -2
  14. package/dist/index.d.mts +2 -2
  15. package/dist/index.mjs +1 -1
  16. package/dist/types/index.d.cts +1 -1
  17. package/dist/types/index.d.mts +1 -1
  18. package/dist/upload/index.d.cts +1 -1
  19. package/dist/upload/index.d.mts +1 -1
  20. package/package.json +3 -3
  21. package/src/flow/index.ts +2 -0
  22. package/src/flow/plugins/credential-provider.ts +7 -1
  23. package/src/flow/plugins/image-ai-plugin.ts +5 -3
  24. package/src/flow/plugins/image-plugin.ts +46 -4
  25. package/src/flow/plugins/plugins.ts +19 -0
  26. package/src/flow/plugins/types/index.ts +1 -0
  27. package/src/flow/plugins/types/transform-image-node.ts +283 -0
  28. package/src/flow/plugins/zip-plugin.ts +4 -2
  29. package/src/flow/typed-flow.ts +199 -60
  30. package/src/flow/types/index.ts +3 -0
  31. package/src/flow/types/type-utils.ts +166 -0
  32. package/type-tests/type-utils.test-d.ts +235 -0
  33. package/dist/flow-DEohelFR.mjs.map +0 -1
  34. package/dist/index-BQ8Ns-NS.d.mts.map +0 -1
  35. package/dist/index-Bg1HsPC1.d.cts.map +0 -1
@@ -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
  /**
@@ -2669,7 +2669,7 @@ declare function createUploadServer(): Effect.Effect<{
2669
2669
  getCapabilities: (storageId: string, clientId: string | null) => Effect.Effect<DataStoreCapabilities, UploadistaError$1, never>;
2670
2670
  subscribeToUploadEvents: (uploadId: string, connection: WebSocketConnection) => Effect.Effect<void, UploadistaError$1, never>;
2671
2671
  unsubscribeFromUploadEvents: (uploadId: string) => Effect.Effect<void, UploadistaError$1, never>;
2672
- }, never, UploadFileDataStores | UploadFileKVStore | UploadEventEmitter | GenerateId>;
2672
+ }, never, GenerateId | UploadFileDataStores | UploadFileKVStore | UploadEventEmitter>;
2673
2673
  /**
2674
2674
  * Pre-built UploadServer Effect Layer.
2675
2675
  *
@@ -2700,7 +2700,7 @@ declare function createUploadServer(): Effect.Effect<{
2700
2700
  * }).pipe(Effect.provide(fullUploadSystem));
2701
2701
  * ```
2702
2702
  */
2703
- declare const uploadServer: Layer.Layer<UploadServer, never, UploadFileDataStores | UploadFileKVStore | UploadEventEmitter | GenerateId>;
2703
+ declare const uploadServer: Layer.Layer<UploadServer, never, GenerateId | UploadFileDataStores | UploadFileKVStore | UploadEventEmitter>;
2704
2704
  //#endregion
2705
2705
  //#region src/upload/upload-strategy-negotiator.d.ts
2706
2706
  /**
@@ -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 | FlowEventEmitter | FlowJobKVStore | FlowProvider>;
3255
- declare const flowServer: Layer.Layer<FlowServer, never, UploadServer | FlowEventEmitter | FlowJobKVStore | FlowProvider>;
3254
+ }, never, UploadServer | FlowProvider | FlowJobKVStore | FlowEventEmitter>;
3255
+ declare const flowServer: Layer.Layer<FlowServer, never, UploadServer | FlowProvider | FlowJobKVStore | FlowEventEmitter>;
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
  /**
@@ -3777,6 +3779,337 @@ declare const resizeParamsSchema: z.ZodObject<{
3777
3779
  */
3778
3780
  type ResizeParams = z.infer<typeof resizeParamsSchema>;
3779
3781
  //#endregion
3782
+ //#region src/flow/plugins/types/transform-image-node.d.ts
3783
+ /**
3784
+ * Type of transformation to apply to an image.
3785
+ */
3786
+ type TransformationType = "resize" | "blur" | "rotate" | "flip" | "grayscale" | "sepia" | "brightness" | "contrast" | "sharpen" | "watermark" | "logo" | "text";
3787
+ /**
3788
+ * Resize transformation parameters.
3789
+ * Resizes the image to the specified dimensions with the given fit mode.
3790
+ */
3791
+ declare const resizeTransformSchema: z.ZodObject<{
3792
+ type: z.ZodLiteral<"resize">;
3793
+ width: z.ZodOptional<z.ZodNumber>;
3794
+ height: z.ZodOptional<z.ZodNumber>;
3795
+ fit: z.ZodEnum<{
3796
+ fill: "fill";
3797
+ contain: "contain";
3798
+ cover: "cover";
3799
+ }>;
3800
+ }, z.core.$strip>;
3801
+ type ResizeTransform = z.infer<typeof resizeTransformSchema>;
3802
+ /**
3803
+ * Blur transformation parameters.
3804
+ * Applies Gaussian blur to the image.
3805
+ */
3806
+ declare const blurTransformSchema: z.ZodObject<{
3807
+ type: z.ZodLiteral<"blur">;
3808
+ sigma: z.ZodNumber;
3809
+ }, z.core.$strip>;
3810
+ type BlurTransform = z.infer<typeof blurTransformSchema>;
3811
+ /**
3812
+ * Rotate transformation parameters.
3813
+ * Rotates the image by the specified angle.
3814
+ */
3815
+ declare const rotateTransformSchema: z.ZodObject<{
3816
+ type: z.ZodLiteral<"rotate">;
3817
+ angle: z.ZodNumber;
3818
+ background: z.ZodOptional<z.ZodString>;
3819
+ }, z.core.$strip>;
3820
+ type RotateTransform = z.infer<typeof rotateTransformSchema>;
3821
+ /**
3822
+ * Flip transformation parameters.
3823
+ * Flips the image horizontally or vertically.
3824
+ */
3825
+ declare const flipTransformSchema: z.ZodObject<{
3826
+ type: z.ZodLiteral<"flip">;
3827
+ direction: z.ZodEnum<{
3828
+ horizontal: "horizontal";
3829
+ vertical: "vertical";
3830
+ }>;
3831
+ }, z.core.$strip>;
3832
+ type FlipTransform = z.infer<typeof flipTransformSchema>;
3833
+ /**
3834
+ * Grayscale transformation parameters.
3835
+ * Converts the image to grayscale.
3836
+ */
3837
+ declare const grayscaleTransformSchema: z.ZodObject<{
3838
+ type: z.ZodLiteral<"grayscale">;
3839
+ }, z.core.$strip>;
3840
+ type GrayscaleTransform = z.infer<typeof grayscaleTransformSchema>;
3841
+ /**
3842
+ * Sepia transformation parameters.
3843
+ * Applies a sepia tone effect to the image.
3844
+ */
3845
+ declare const sepiaTransformSchema: z.ZodObject<{
3846
+ type: z.ZodLiteral<"sepia">;
3847
+ }, z.core.$strip>;
3848
+ type SepiaTransform = z.infer<typeof sepiaTransformSchema>;
3849
+ /**
3850
+ * Brightness transformation parameters.
3851
+ * Adjusts the brightness of the image.
3852
+ */
3853
+ declare const brightnessTransformSchema: z.ZodObject<{
3854
+ type: z.ZodLiteral<"brightness">;
3855
+ value: z.ZodNumber;
3856
+ }, z.core.$strip>;
3857
+ type BrightnessTransform = z.infer<typeof brightnessTransformSchema>;
3858
+ /**
3859
+ * Contrast transformation parameters.
3860
+ * Adjusts the contrast of the image.
3861
+ */
3862
+ declare const contrastTransformSchema: z.ZodObject<{
3863
+ type: z.ZodLiteral<"contrast">;
3864
+ value: z.ZodNumber;
3865
+ }, z.core.$strip>;
3866
+ type ContrastTransform = z.infer<typeof contrastTransformSchema>;
3867
+ /**
3868
+ * Sharpen transformation parameters.
3869
+ * Applies sharpening to the image.
3870
+ */
3871
+ declare const sharpenTransformSchema: z.ZodObject<{
3872
+ type: z.ZodLiteral<"sharpen">;
3873
+ sigma: z.ZodOptional<z.ZodNumber>;
3874
+ }, z.core.$strip>;
3875
+ type SharpenTransform = z.infer<typeof sharpenTransformSchema>;
3876
+ /**
3877
+ * Position for overlays (watermarks, logos, text).
3878
+ */
3879
+ type OverlayPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
3880
+ /**
3881
+ * Watermark transformation parameters.
3882
+ * Overlays a watermark image on the main image.
3883
+ */
3884
+ declare const watermarkTransformSchema: z.ZodObject<{
3885
+ type: z.ZodLiteral<"watermark">;
3886
+ imagePath: z.ZodString;
3887
+ position: z.ZodEnum<{
3888
+ "top-left": "top-left";
3889
+ "top-right": "top-right";
3890
+ "bottom-left": "bottom-left";
3891
+ "bottom-right": "bottom-right";
3892
+ center: "center";
3893
+ }>;
3894
+ opacity: z.ZodNumber;
3895
+ offsetX: z.ZodOptional<z.ZodNumber>;
3896
+ offsetY: z.ZodOptional<z.ZodNumber>;
3897
+ }, z.core.$strip>;
3898
+ type WatermarkTransform = z.infer<typeof watermarkTransformSchema>;
3899
+ /**
3900
+ * Logo transformation parameters.
3901
+ * Overlays a logo image on the main image with scaling.
3902
+ */
3903
+ declare const logoTransformSchema: z.ZodObject<{
3904
+ type: z.ZodLiteral<"logo">;
3905
+ imagePath: z.ZodString;
3906
+ position: z.ZodEnum<{
3907
+ "top-left": "top-left";
3908
+ "top-right": "top-right";
3909
+ "bottom-left": "bottom-left";
3910
+ "bottom-right": "bottom-right";
3911
+ center: "center";
3912
+ }>;
3913
+ scale: z.ZodNumber;
3914
+ offsetX: z.ZodOptional<z.ZodNumber>;
3915
+ offsetY: z.ZodOptional<z.ZodNumber>;
3916
+ }, z.core.$strip>;
3917
+ type LogoTransform = z.infer<typeof logoTransformSchema>;
3918
+ /**
3919
+ * Text transformation parameters.
3920
+ * Overlays text on the image.
3921
+ */
3922
+ declare const textTransformSchema: z.ZodObject<{
3923
+ type: z.ZodLiteral<"text">;
3924
+ text: z.ZodString;
3925
+ position: z.ZodEnum<{
3926
+ "top-left": "top-left";
3927
+ "top-right": "top-right";
3928
+ "bottom-left": "bottom-left";
3929
+ "bottom-right": "bottom-right";
3930
+ center: "center";
3931
+ }>;
3932
+ fontSize: z.ZodNumber;
3933
+ color: z.ZodString;
3934
+ fontFamily: z.ZodOptional<z.ZodString>;
3935
+ offsetX: z.ZodOptional<z.ZodNumber>;
3936
+ offsetY: z.ZodOptional<z.ZodNumber>;
3937
+ }, z.core.$strip>;
3938
+ type TextTransform = z.infer<typeof textTransformSchema>;
3939
+ /**
3940
+ * Schema for validating any transformation type.
3941
+ * This is a discriminated union of all transformation schemas.
3942
+ */
3943
+ declare const transformationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3944
+ type: z.ZodLiteral<"resize">;
3945
+ width: z.ZodOptional<z.ZodNumber>;
3946
+ height: z.ZodOptional<z.ZodNumber>;
3947
+ fit: z.ZodEnum<{
3948
+ fill: "fill";
3949
+ contain: "contain";
3950
+ cover: "cover";
3951
+ }>;
3952
+ }, z.core.$strip>, z.ZodObject<{
3953
+ type: z.ZodLiteral<"blur">;
3954
+ sigma: z.ZodNumber;
3955
+ }, z.core.$strip>, z.ZodObject<{
3956
+ type: z.ZodLiteral<"rotate">;
3957
+ angle: z.ZodNumber;
3958
+ background: z.ZodOptional<z.ZodString>;
3959
+ }, z.core.$strip>, z.ZodObject<{
3960
+ type: z.ZodLiteral<"flip">;
3961
+ direction: z.ZodEnum<{
3962
+ horizontal: "horizontal";
3963
+ vertical: "vertical";
3964
+ }>;
3965
+ }, z.core.$strip>, z.ZodObject<{
3966
+ type: z.ZodLiteral<"grayscale">;
3967
+ }, z.core.$strip>, z.ZodObject<{
3968
+ type: z.ZodLiteral<"sepia">;
3969
+ }, z.core.$strip>, z.ZodObject<{
3970
+ type: z.ZodLiteral<"brightness">;
3971
+ value: z.ZodNumber;
3972
+ }, z.core.$strip>, z.ZodObject<{
3973
+ type: z.ZodLiteral<"contrast">;
3974
+ value: z.ZodNumber;
3975
+ }, z.core.$strip>, z.ZodObject<{
3976
+ type: z.ZodLiteral<"sharpen">;
3977
+ sigma: z.ZodOptional<z.ZodNumber>;
3978
+ }, z.core.$strip>, z.ZodObject<{
3979
+ type: z.ZodLiteral<"watermark">;
3980
+ imagePath: z.ZodString;
3981
+ position: z.ZodEnum<{
3982
+ "top-left": "top-left";
3983
+ "top-right": "top-right";
3984
+ "bottom-left": "bottom-left";
3985
+ "bottom-right": "bottom-right";
3986
+ center: "center";
3987
+ }>;
3988
+ opacity: z.ZodNumber;
3989
+ offsetX: z.ZodOptional<z.ZodNumber>;
3990
+ offsetY: z.ZodOptional<z.ZodNumber>;
3991
+ }, z.core.$strip>, z.ZodObject<{
3992
+ type: z.ZodLiteral<"logo">;
3993
+ imagePath: z.ZodString;
3994
+ position: z.ZodEnum<{
3995
+ "top-left": "top-left";
3996
+ "top-right": "top-right";
3997
+ "bottom-left": "bottom-left";
3998
+ "bottom-right": "bottom-right";
3999
+ center: "center";
4000
+ }>;
4001
+ scale: z.ZodNumber;
4002
+ offsetX: z.ZodOptional<z.ZodNumber>;
4003
+ offsetY: z.ZodOptional<z.ZodNumber>;
4004
+ }, z.core.$strip>, z.ZodObject<{
4005
+ type: z.ZodLiteral<"text">;
4006
+ text: z.ZodString;
4007
+ position: z.ZodEnum<{
4008
+ "top-left": "top-left";
4009
+ "top-right": "top-right";
4010
+ "bottom-left": "bottom-left";
4011
+ "bottom-right": "bottom-right";
4012
+ center: "center";
4013
+ }>;
4014
+ fontSize: z.ZodNumber;
4015
+ color: z.ZodString;
4016
+ fontFamily: z.ZodOptional<z.ZodString>;
4017
+ offsetX: z.ZodOptional<z.ZodNumber>;
4018
+ offsetY: z.ZodOptional<z.ZodNumber>;
4019
+ }, z.core.$strip>], "type">;
4020
+ /**
4021
+ * A single image transformation operation.
4022
+ * This is a discriminated union type that can represent any transformation.
4023
+ */
4024
+ type Transformation = z.infer<typeof transformationSchema>;
4025
+ /**
4026
+ * Parameters for the transform image node.
4027
+ * Contains an ordered array of transformations to apply sequentially.
4028
+ */
4029
+ declare const transformImageParamsSchema: z.ZodObject<{
4030
+ transformations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
4031
+ type: z.ZodLiteral<"resize">;
4032
+ width: z.ZodOptional<z.ZodNumber>;
4033
+ height: z.ZodOptional<z.ZodNumber>;
4034
+ fit: z.ZodEnum<{
4035
+ fill: "fill";
4036
+ contain: "contain";
4037
+ cover: "cover";
4038
+ }>;
4039
+ }, z.core.$strip>, z.ZodObject<{
4040
+ type: z.ZodLiteral<"blur">;
4041
+ sigma: z.ZodNumber;
4042
+ }, z.core.$strip>, z.ZodObject<{
4043
+ type: z.ZodLiteral<"rotate">;
4044
+ angle: z.ZodNumber;
4045
+ background: z.ZodOptional<z.ZodString>;
4046
+ }, z.core.$strip>, z.ZodObject<{
4047
+ type: z.ZodLiteral<"flip">;
4048
+ direction: z.ZodEnum<{
4049
+ horizontal: "horizontal";
4050
+ vertical: "vertical";
4051
+ }>;
4052
+ }, z.core.$strip>, z.ZodObject<{
4053
+ type: z.ZodLiteral<"grayscale">;
4054
+ }, z.core.$strip>, z.ZodObject<{
4055
+ type: z.ZodLiteral<"sepia">;
4056
+ }, z.core.$strip>, z.ZodObject<{
4057
+ type: z.ZodLiteral<"brightness">;
4058
+ value: z.ZodNumber;
4059
+ }, z.core.$strip>, z.ZodObject<{
4060
+ type: z.ZodLiteral<"contrast">;
4061
+ value: z.ZodNumber;
4062
+ }, z.core.$strip>, z.ZodObject<{
4063
+ type: z.ZodLiteral<"sharpen">;
4064
+ sigma: z.ZodOptional<z.ZodNumber>;
4065
+ }, z.core.$strip>, z.ZodObject<{
4066
+ type: z.ZodLiteral<"watermark">;
4067
+ imagePath: z.ZodString;
4068
+ position: z.ZodEnum<{
4069
+ "top-left": "top-left";
4070
+ "top-right": "top-right";
4071
+ "bottom-left": "bottom-left";
4072
+ "bottom-right": "bottom-right";
4073
+ center: "center";
4074
+ }>;
4075
+ opacity: z.ZodNumber;
4076
+ offsetX: z.ZodOptional<z.ZodNumber>;
4077
+ offsetY: z.ZodOptional<z.ZodNumber>;
4078
+ }, z.core.$strip>, z.ZodObject<{
4079
+ type: z.ZodLiteral<"logo">;
4080
+ imagePath: z.ZodString;
4081
+ position: z.ZodEnum<{
4082
+ "top-left": "top-left";
4083
+ "top-right": "top-right";
4084
+ "bottom-left": "bottom-left";
4085
+ "bottom-right": "bottom-right";
4086
+ center: "center";
4087
+ }>;
4088
+ scale: z.ZodNumber;
4089
+ offsetX: z.ZodOptional<z.ZodNumber>;
4090
+ offsetY: z.ZodOptional<z.ZodNumber>;
4091
+ }, z.core.$strip>, z.ZodObject<{
4092
+ type: z.ZodLiteral<"text">;
4093
+ text: z.ZodString;
4094
+ position: z.ZodEnum<{
4095
+ "top-left": "top-left";
4096
+ "top-right": "top-right";
4097
+ "bottom-left": "bottom-left";
4098
+ "bottom-right": "bottom-right";
4099
+ center: "center";
4100
+ }>;
4101
+ fontSize: z.ZodNumber;
4102
+ color: z.ZodString;
4103
+ fontFamily: z.ZodOptional<z.ZodString>;
4104
+ offsetX: z.ZodOptional<z.ZodNumber>;
4105
+ offsetY: z.ZodOptional<z.ZodNumber>;
4106
+ }, z.core.$strip>], "type">>;
4107
+ }, z.core.$strip>;
4108
+ /**
4109
+ * Parameters for the transform image node.
4110
+ */
4111
+ type TransformImageParams = z.infer<typeof transformImageParamsSchema>;
4112
+ //#endregion
3780
4113
  //#region src/flow/plugins/image-plugin.d.ts
3781
4114
  /**
3782
4115
  * Shape definition for the Image Plugin interface.
@@ -3801,6 +4134,41 @@ type ImagePluginShape = {
3801
4134
  * @throws {UploadistaError} When image resizing fails
3802
4135
  */
3803
4136
  resize: (input: Uint8Array, options: ResizeParams) => Effect.Effect<Uint8Array, UploadistaError>;
4137
+ /**
4138
+ * Applies a single transformation to an image.
4139
+ *
4140
+ * This method is used by the transform image node to apply individual transformations
4141
+ * in a chain. Each transformation receives the output of the previous transformation.
4142
+ *
4143
+ * @param input - The input image as a Uint8Array
4144
+ * @param transformation - The transformation to apply (discriminated union)
4145
+ * @returns An Effect that resolves to the transformed image as a Uint8Array
4146
+ * @throws {UploadistaError} When transformation fails or is unsupported by the plugin
4147
+ *
4148
+ * @example
4149
+ * ```typescript
4150
+ * const program = Effect.gen(function* () {
4151
+ * const imagePlugin = yield* ImagePlugin;
4152
+ *
4153
+ * // Apply a single transformation
4154
+ * const blurred = yield* imagePlugin.transform(imageData, {
4155
+ * type: 'blur',
4156
+ * sigma: 5.0
4157
+ * });
4158
+ *
4159
+ * // Chain multiple transformations
4160
+ * const resized = yield* imagePlugin.transform(blurred, {
4161
+ * type: 'resize',
4162
+ * width: 800,
4163
+ * height: 600,
4164
+ * fit: 'cover'
4165
+ * });
4166
+ *
4167
+ * return resized;
4168
+ * });
4169
+ * ```
4170
+ */
4171
+ transform: (input: Uint8Array, transformation: Transformation) => Effect.Effect<Uint8Array, UploadistaError>;
3804
4172
  };
3805
4173
  declare const ImagePlugin_base: Context.TagClass<ImagePlugin, "ImagePlugin", ImagePluginShape>;
3806
4174
  /**
@@ -3823,38 +4191,7 @@ declare const ImagePlugin_base: Context.TagClass<ImagePlugin, "ImagePlugin", Ima
3823
4191
  * ```
3824
4192
  */
3825
4193
  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>;
4194
+ type ImagePluginLayer = Layer.Layer<ImagePlugin, never, never>;
3858
4195
  //#endregion
3859
4196
  //#region src/flow/plugins/zip-plugin.d.ts
3860
4197
  /**
@@ -3913,17 +4250,348 @@ declare const ZipPlugin_base: Context.TagClass<ZipPlugin, "ZipPlugin", ZipPlugin
3913
4250
  * ```
3914
4251
  */
3915
4252
  declare class ZipPlugin extends ZipPlugin_base {}
4253
+ type ZipPluginLayer = Layer.Layer<ZipPlugin, never, never>;
4254
+ //#endregion
4255
+ //#region src/flow/plugins/plugins.d.ts
4256
+ type Plugin = ImagePlugin | ImageAiPlugin | CredentialProvider | ZipPlugin;
4257
+ type PluginLayer = ImagePluginLayer | ImageAiPluginLayer | CredentialProviderLayer | ZipPluginLayer;
4258
+ //#endregion
4259
+ //#region src/flow/plugins/types/describe-image-node.d.ts
4260
+ /**
4261
+ * Zod schema for validating describe image node parameters.
4262
+ * Defines the structure and validation rules for image description requests.
4263
+ */
4264
+ declare const describeImageParamsSchema: z.ZodObject<{
4265
+ serviceType: z.ZodOptional<z.ZodEnum<{
4266
+ replicate: "replicate";
4267
+ }>>;
4268
+ }, z.core.$strip>;
4269
+ /**
4270
+ * Parameters for the describe image node.
4271
+ * Controls which AI service to use for generating image descriptions.
4272
+ */
4273
+ type DescribeImageParams = z.infer<typeof describeImageParamsSchema>;
4274
+ //#endregion
4275
+ //#region src/flow/plugins/types/remove-background-node.d.ts
4276
+ /**
4277
+ * Zod schema for validating remove background node parameters.
4278
+ * Defines the structure and validation rules for background removal requests.
4279
+ */
4280
+ declare const removeBackgroundParamsSchema: z.ZodObject<{
4281
+ serviceType: z.ZodOptional<z.ZodEnum<{
4282
+ replicate: "replicate";
4283
+ }>>;
4284
+ }, z.core.$strip>;
4285
+ /**
4286
+ * Parameters for the remove background node.
4287
+ * Controls which AI service to use for background removal processing.
4288
+ */
4289
+ type RemoveBackgroundParams = z.infer<typeof removeBackgroundParamsSchema>;
4290
+ //#endregion
4291
+ //#region src/flow/types/flow-file.d.ts
4292
+ /**
4293
+ * Conditional execution rules for flow nodes.
4294
+ *
4295
+ * Conditions allow nodes to execute conditionally based on file properties or metadata.
4296
+ * They are evaluated before node execution and can skip nodes that don't match.
4297
+ *
4298
+ * @module flow/types/flow-file
4299
+ * @see {@link FlowNode} for how conditions are used in nodes
4300
+ *
4301
+ * @example
4302
+ * ```typescript
4303
+ * // Only process images larger than 1MB
4304
+ * const condition: FlowCondition = {
4305
+ * field: "size",
4306
+ * operator: "greaterThan",
4307
+ * value: 1024 * 1024
4308
+ * };
4309
+ *
4310
+ * // Only process JPEG images
4311
+ * const jpegCondition: FlowCondition = {
4312
+ * field: "mimeType",
4313
+ * operator: "startsWith",
4314
+ * value: "image/jpeg"
4315
+ * };
4316
+ * ```
4317
+ */
4318
+ /**
4319
+ * Represents a conditional rule for node execution.
4320
+ *
4321
+ * @property field - The file property to check
4322
+ * @property operator - The comparison operator to apply
4323
+ * @property value - The value to compare against
4324
+ *
4325
+ * @remarks
4326
+ * - Fields can check file metadata (mimeType, size) or image properties (width, height)
4327
+ * - String operators (contains, startsWith) work with string values
4328
+ * - Numeric operators (greaterThan, lessThan) work with numeric values
4329
+ * - The extension field checks the file extension without the dot
4330
+ */
4331
+ type FlowCondition = {
4332
+ field: "mimeType" | "size" | "width" | "height" | "extension";
4333
+ operator: "equals" | "notEquals" | "greaterThan" | "lessThan" | "contains" | "startsWith";
4334
+ value: string | number;
4335
+ };
4336
+ //#endregion
4337
+ //#region src/flow/types/type-utils.d.ts
4338
+ /**
4339
+ * Extracts the service type from an Effect Layer.
4340
+ *
4341
+ * Given a Layer that provides a service, this type utility extracts
4342
+ * the service type from the Layer's type signature.
4343
+ *
4344
+ * @template T - The Layer type to extract from
4345
+ * @returns The service type provided by the layer, or never if T is not a Layer
4346
+ *
4347
+ * @example
4348
+ * ```typescript
4349
+ * type MyLayer = Layer.Layer<ServiceA, never, never>;
4350
+ * type Service = ExtractLayerService<MyLayer>;
4351
+ * // Service = ServiceA
4352
+ * ```
4353
+ *
4354
+ * @example
4355
+ * ```typescript
4356
+ * import { ImagePluginLayer } from '@uploadista/core';
4357
+ *
4358
+ * type ImageService = ExtractLayerService<ImagePluginLayer>;
4359
+ * // ImageService = ImagePlugin
4360
+ * ```
4361
+ */
4362
+ type ExtractLayerService<T, TError$1 = never, TRequirements = never> = T extends Layer.Layer<infer S, TError$1, TRequirements> ? S : never;
4363
+ /**
4364
+ * Extracts all service types from a tuple of layers and returns them as a union.
4365
+ *
4366
+ * This type recursively processes a tuple of Layer types and extracts all
4367
+ * the services they provide, combining them into a single union type.
4368
+ *
4369
+ * @template T - A readonly tuple of Layer types
4370
+ * @returns A union of all service types provided by the layers
4371
+ *
4372
+ * @example
4373
+ * ```typescript
4374
+ * type Layers = [
4375
+ * Layer.Layer<ServiceA, never, never>,
4376
+ * Layer.Layer<ServiceB, never, never>,
4377
+ * Layer.Layer<ServiceC, never, never>
4378
+ * ];
4379
+ * type Services = ExtractLayerServices<Layers>;
4380
+ * // Services = ServiceA | ServiceB | ServiceC
4381
+ * ```
4382
+ *
4383
+ * @example
4384
+ * ```typescript
4385
+ * import { ImagePluginLayer, ZipPluginLayer } from '@uploadista/core';
4386
+ *
4387
+ * type PluginLayers = [ImagePluginLayer, ZipPluginLayer];
4388
+ * type AllServices = ExtractLayerServices<PluginLayers>;
4389
+ * // AllServices = ImagePlugin | ZipPlugin
4390
+ * ```
4391
+ */
4392
+ type ExtractLayerServices<T extends readonly Layer.Layer<any, any, any>[]> = T[number] extends Layer.Layer<infer S, any, any> ? S : never;
4393
+ /**
4394
+ * Unwraps an Effect type to extract its success value type.
4395
+ *
4396
+ * If the input type is an Effect, this extracts the success type (first type parameter).
4397
+ * If the input is not an Effect, it returns the type unchanged.
4398
+ *
4399
+ * @template T - The type to resolve, potentially an Effect
4400
+ * @returns The success type if T is an Effect, otherwise T
4401
+ *
4402
+ * @example
4403
+ * ```typescript
4404
+ * type MyEffect = Effect.Effect<string, Error, never>;
4405
+ * type Result = ResolveEffect<MyEffect>;
4406
+ * // Result = string
4407
+ * ```
4408
+ *
4409
+ * @example
4410
+ * ```typescript
4411
+ * type NonEffect = { data: string };
4412
+ * type Result = ResolveEffect<NonEffect>;
4413
+ * // Result = { data: string }
4414
+ * ```
4415
+ */
4416
+ type ResolveEffect<T> = T extends Effect.Effect<infer S, any, any> ? S : T;
4417
+ /**
4418
+ * Extracts the error type from an Effect.
4419
+ *
4420
+ * Given an Effect type, this utility extracts the error type
4421
+ * (second type parameter) from the Effect's type signature.
4422
+ *
4423
+ * @template T - The Effect type to extract from
4424
+ * @returns The error type of the Effect, or never if T is not an Effect
4425
+ *
4426
+ * @example
4427
+ * ```typescript
4428
+ * type MyEffect = Effect.Effect<string, ValidationError, never>;
4429
+ * type ErrorType = ExtractEffectError<MyEffect>;
4430
+ * // ErrorType = ValidationError
4431
+ * ```
4432
+ *
4433
+ * @example
4434
+ * ```typescript
4435
+ * type SafeEffect = Effect.Effect<number, never, SomeService>;
4436
+ * type ErrorType = ExtractEffectError<SafeEffect>;
4437
+ * // ErrorType = never (no errors possible)
4438
+ * ```
4439
+ */
4440
+ type ExtractEffectError<T> = T extends Effect.Effect<any, infer E, any> ? E : never;
4441
+ /**
4442
+ * Extracts the requirements (context) type from an Effect.
4443
+ *
4444
+ * Given an Effect type, this utility extracts the requirements type
4445
+ * (third type parameter) from the Effect's type signature. This represents
4446
+ * the services that must be provided for the Effect to run.
4447
+ *
4448
+ * @template T - The Effect type to extract from
4449
+ * @returns The requirements type of the Effect, or never if T is not an Effect
4450
+ *
4451
+ * @example
4452
+ * ```typescript
4453
+ * type MyEffect = Effect.Effect<string, Error, Database | Logger>;
4454
+ * type Requirements = ExtractEffectRequirements<MyEffect>;
4455
+ * // Requirements = Database | Logger
4456
+ * ```
4457
+ *
4458
+ * @example
4459
+ * ```typescript
4460
+ * import { ImagePlugin, ZipPlugin } from '@uploadista/core';
4461
+ *
4462
+ * type ProcessEffect = Effect.Effect<
4463
+ * ProcessedImage,
4464
+ * ProcessError,
4465
+ * ImagePlugin | ZipPlugin
4466
+ * >;
4467
+ * type Needed = ExtractEffectRequirements<ProcessEffect>;
4468
+ * // Needed = ImagePlugin | ZipPlugin
4469
+ * ```
4470
+ */
4471
+ type ExtractEffectRequirements<T> = T extends Effect.Effect<any, any, infer R> ? R : never;
3916
4472
  //#endregion
3917
4473
  //#region src/flow/typed-flow.d.ts
4474
+ /**
4475
+ * Defines a node that can be used in a typed flow.
4476
+ *
4477
+ * A node definition can be either:
4478
+ * - A plain FlowNode object
4479
+ * - An Effect that resolves to a FlowNode (for nodes requiring dependencies)
4480
+ *
4481
+ * @template TNodeError - The error types that the node can produce
4482
+ * @template TNodeRequirements - The services/dependencies the node requires
4483
+ */
3918
4484
  type NodeDefinition<TNodeError = never, TNodeRequirements = never> = FlowNode<any, any, UploadistaError$1> | Effect.Effect<FlowNode<any, any, UploadistaError$1>, TNodeError, TNodeRequirements>;
4485
+ /**
4486
+ * A record mapping node IDs to their definitions.
4487
+ *
4488
+ * This is the primary type used for defining the nodes in a typed flow,
4489
+ * allowing TypeScript to infer input/output schemas and requirements.
4490
+ *
4491
+ * @example
4492
+ * ```typescript
4493
+ * const nodes = {
4494
+ * input: fileInputNode,
4495
+ * resize: Effect.succeed(imageResizeNode),
4496
+ * output: s3OutputNode
4497
+ * } satisfies NodeDefinitionsRecord;
4498
+ * ```
4499
+ */
3919
4500
  type NodeDefinitionsRecord = Record<string, NodeDefinition<any, any>>;
4501
+ /**
4502
+ * Extracts the error type from a NodeDefinition.
4503
+ *
4504
+ * If the node is an Effect, extracts its error type.
4505
+ * If the node is a plain FlowNode, returns never (no errors).
4506
+ */
3920
4507
  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;
4508
+ /**
4509
+ * Extracts the requirements (dependencies) from a NodeDefinition.
4510
+ *
4511
+ * Uses the shared ExtractEffectRequirements utility for consistency.
4512
+ */
4513
+ type NodeDefinitionRequirements<T> = ExtractEffectRequirements<T>;
4514
+ /**
4515
+ * Extracts all possible errors from all nodes in a flow as a union.
4516
+ *
4517
+ * This iterates through all nodes in the record and combines their
4518
+ * error types into a single union type.
4519
+ */
3922
4520
  type NodesErrorUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionError<TNodes[K]> }[keyof TNodes];
4521
+ /**
4522
+ * Extracts all service requirements from all nodes in a flow as a union.
4523
+ *
4524
+ * This iterates through all nodes in the record and combines their
4525
+ * requirement types into a single union type representing all services
4526
+ * needed by the flow.
4527
+ *
4528
+ * @template TNodes - The record of node definitions
4529
+ *
4530
+ * @example
4531
+ * ```typescript
4532
+ * const nodes = {
4533
+ * resize: imageResizeNode, // requires ImagePlugin
4534
+ * zip: zipNode, // requires ZipPlugin
4535
+ * };
4536
+ * type Requirements = NodesRequirementsUnion<typeof nodes>;
4537
+ * // Requirements = ImagePlugin | ZipPlugin
4538
+ * ```
4539
+ */
3923
4540
  type NodesRequirementsUnion<TNodes extends NodeDefinitionsRecord> = { [K in keyof TNodes]: NodeDefinitionRequirements<TNodes[K]> }[keyof TNodes];
4541
+ /**
4542
+ * Extracts all service requirements from a flow's nodes.
4543
+ *
4544
+ * This includes all services required by any node in the flow,
4545
+ * including UploadServer (which is provided by the runtime).
4546
+ *
4547
+ * @template TNodes - The record of node definitions
4548
+ *
4549
+ * @example
4550
+ * ```typescript
4551
+ * const myFlow = createFlow({
4552
+ * nodes: {
4553
+ * input: fileInputNode,
4554
+ * process: imageProcessNode, // requires ImagePlugin
4555
+ * },
4556
+ * edges: [...]
4557
+ * });
4558
+ * type AllRequirements = FlowRequirements<typeof myFlow.nodes>;
4559
+ * // AllRequirements = ImagePlugin | UploadServer
4560
+ * ```
4561
+ */
3924
4562
  type FlowRequirements<TNodes extends NodeDefinitionsRecord> = NodesRequirementsUnion<TNodes>;
4563
+ /**
4564
+ * Extracts plugin service requirements from a flow, excluding UploadServer.
4565
+ *
4566
+ * This type is useful for determining which plugin layers need to be
4567
+ * provided when creating a server, as UploadServer is automatically
4568
+ * provided by the runtime.
4569
+ *
4570
+ * @template TNodes - The record of node definitions
4571
+ *
4572
+ * @example
4573
+ * ```typescript
4574
+ * const myFlow = createFlow({
4575
+ * nodes: {
4576
+ * resize: imageResizeNode, // requires ImagePlugin
4577
+ * upload: s3OutputNode, // requires UploadServer
4578
+ * },
4579
+ * edges: [...]
4580
+ * });
4581
+ * type PluginRequirements = FlowPluginRequirements<typeof myFlow.nodes>;
4582
+ * // PluginRequirements = ImagePlugin (UploadServer excluded)
4583
+ * ```
4584
+ */
3925
4585
  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;
4586
+ /**
4587
+ * Infers the concrete FlowNode type from a NodeDefinition.
4588
+ *
4589
+ * If the definition is already a FlowNode, returns it as-is.
4590
+ * If the definition is an Effect, extracts the FlowNode from the Effect's success type.
4591
+ *
4592
+ * Uses the shared ResolveEffect utility for consistency.
4593
+ */
4594
+ type InferNode<T> = T extends FlowNode<any, any, UploadistaError$1> ? T : ResolveEffect<T> extends FlowNode<any, any, UploadistaError$1> ? ResolveEffect<T> : never;
3927
4595
  type ExtractKeysByNodeType<TNodes extends NodeDefinitionsRecord, TType extends NodeType> = { [K in keyof TNodes]: InferNode<TNodes[K]>["type"] extends TType ? K : never }[keyof TNodes];
3928
4596
  type SchemaInfer<T> = T extends z.ZodTypeAny ? z.infer<T> : never;
3929
4597
  type FlowInputMap<TNodes extends NodeDefinitionsRecord> = { [K in Extract<ExtractKeysByNodeType<TNodes, NodeType.input>, string>]: SchemaInfer<InferNode<TNodes[K]>["inputSchema"]> };
@@ -3956,6 +4624,40 @@ type TypedFlowConfig<TNodes extends NodeDefinitionsRecord> = {
3956
4624
  declare const typedFlowInputsSymbol: unique symbol;
3957
4625
  declare const typedFlowOutputsSymbol: unique symbol;
3958
4626
  declare const typedFlowPluginsSymbol: unique symbol;
4627
+ /**
4628
+ * A type-safe Flow that infers input/output types and requirements from its nodes.
4629
+ *
4630
+ * TypedFlow extends the base Flow type with additional type information that
4631
+ * allows TypeScript to verify inputs, outputs, and plugin requirements at compile time.
4632
+ *
4633
+ * The phantom type properties (using unique symbols) enable type-level metadata
4634
+ * without affecting runtime behavior, allowing other type utilities to extract
4635
+ * this information for validation purposes.
4636
+ *
4637
+ * @template TNodes - Record of node definitions used in the flow
4638
+ * @template TInputSchema - Zod schema for flow inputs (inferred from input nodes)
4639
+ * @template TOutputSchema - Zod schema for flow outputs (inferred from output nodes)
4640
+ *
4641
+ * @example
4642
+ * ```typescript
4643
+ * const myFlow = createFlow({
4644
+ * nodes: {
4645
+ * input: fileInputNode,
4646
+ * resize: imageResizeNode,
4647
+ * output: s3OutputNode
4648
+ * },
4649
+ * edges: [
4650
+ * { source: 'input', target: 'resize' },
4651
+ * { source: 'resize', target: 'output' }
4652
+ * ]
4653
+ * });
4654
+ *
4655
+ * // TypeScript infers:
4656
+ * // - Input types from fileInputNode.inputSchema
4657
+ * // - Output types from s3OutputNode.outputSchema
4658
+ * // - Requirements: ImagePlugin (from resize node)
4659
+ * ```
4660
+ */
3959
4661
  type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny> = Flow<TInputSchema, TOutputSchema, FlowRequirements<TNodes>> & {
3960
4662
  run: (args: {
3961
4663
  inputs?: Partial<FlowInputMap<TNodes>>;
@@ -3978,52 +4680,6 @@ type TypedFlow<TNodes extends NodeDefinitionsRecord, TInputSchema extends z.ZodT
3978
4680
  };
3979
4681
  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
4682
  //#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
4683
  //#region src/flow/types/run-args.d.ts
4028
4684
  /**
4029
4685
  * Zod schema for validating flow run arguments.
@@ -4064,5 +4720,5 @@ type ResolvedUploadMetadata = {
4064
4720
  };
4065
4721
  declare function resolveUploadMetadata(metadata: FileMetadata): ResolvedUploadMetadata;
4066
4722
  //#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-BQ8Ns-NS.d.mts.map
4723
+ export { contrastTransformSchema as $, FlowExecutionResult as $n, UploadServerOptions as $t, ZipPluginLayer as A, DataStore as An, ConditionValue as Ar, InputData as At, LogoTransform as B, BaseKvStore as Bn, FlowServerShape as Bt, DescribeImageParams as C, webSocketMessageSchema as Cn, FlowEventNodeError as Cr, ParallelScheduler as Ct, ZipInput as D, EventBroadcaster as Dn, FlowEventNodeStart as Dr, StorageParams as Dt, PluginLayer as E, uploadEventSchema as En, FlowEventNodeResume as Er, createTransformNode as Et, BlurTransform as F, UploadFileDataStores as Fn, FlowProvider as Ft, SharpenTransform as G, UploadFileKVStore as Gn, FlowJob as Gt, ResizeTransform as H, FlowJobKVStore as Hn, WaitUntilCallback as Ht, BrightnessTransform as I, UploadFileDataStoresShape as In, FlowProviderShape as It, Transformation as J, uploadFileKvStore as Jn, FlowJobTaskStatus as Jt, TextTransform as K, flowJobKvStore as Kn, FlowJobStatus as Kt, ContrastTransform as L, UploadStrategy as Ln, FlowServer as Lt, ImagePlugin as M, DataStoreConfig as Mn, createFlowNode as Mr, createInputNode as Mt, ImagePluginLayer as N, DataStoreWriteOptions as Nn, getNodeData as Nr, inputDataSchema as Nt, ZipParams as O, EventBroadcasterService as On, ConditionField as Or, createStorageNode as Ot, ImagePluginShape as P, UploadFileDataStore as Pn, inputNodeParamsSchema as Pt, brightnessTransformSchema as Q, FlowData as Qn, UploadServer as Qt, FlipTransform as R, createDataStoreLayer as Rn, FlowServerLayer as Rt, removeBackgroundParamsSchema as S, WebSocketMessage as Sn, FlowEventNodeEnd as Sr, ExecutionLevel as St, Plugin as T, UploadEventType as Tn, FlowEventNodeResponse as Tr, TransformNodeConfig as Tt, RotateTransform as U, KvStore as Un, createFlowServer as Ut, OverlayPosition as V, BaseKvStoreService as Vn, FlowWaitUntil as Vt, SepiaTransform as W, TypedKvStore as Wn, flowServer as Wt, WatermarkTransform as X, uploadFileSchema as Xn, UploadStrategyNegotiator as Xt, TransformationType as Y, UploadFile as Yn, NegotiatedStrategy as Yt, blurTransformSchema as Z, Flow as Zn, UploadStrategyOptions as Zt, ExtractLayerService as _, UploadEventEmitter as _n, FlowEventFlowError as _r, ImageAiPluginLayer as _t, FlowInputMap as a, Middleware as an, FlowNode as ar, sepiaTransformSchema as at, FlowCondition as b, uploadEventEmitter as bn, FlowEventJobEnd as br, CredentialProviderLayer as bt, FlowRequirements as c, MiddlewareService as cn, NodeExecutionResult as cr, transformImageParamsSchema as ct, TypedFlow as d, inputFileSchema as dn, completeNodeExecution as dr, ResizeParams as dt, UploadServerShape as en, createFlowWithSchema as er, flipTransformSchema as et, TypedFlowConfig as f, BaseEventEmitter as fn, waitingNodeExecution as fr, resizeParamsSchema as ft, ExtractEffectRequirements as g, TypedEventEmitter as gn, FlowEventFlowEnd as gr, ImageAiPlugin as gt, ExtractEffectError as h, FlowEventEmitter as hn, FlowEventFlowCancel as hr, ImageAiContext as ht, runArgsSchema as i, detectMimeType as in, FlowConfig as ir, rotateTransformSchema as it, ZipPluginShape as j, DataStoreCapabilities as jn, NodeType as jr, InputNodeParams as jt, ZipPlugin as k, BufferedUploadFileDataStore as kn, ConditionOperator as kr, storageParamsSchema as kt, NodeDefinition as l, MiddlewareServiceLive as ln, NodeTypeMap as lr, transformationSchema as lt, createFlow as m, EventEmitter as mn, FlowEvent as mr, optimizeParamsSchema as mt, resolveUploadMetadata as n, uploadServer as nn, FlowEdge as nr, logoTransformSchema as nt, FlowOutputMap as o, MiddlewareContext as on, FlowNodeData as or, sharpenTransformSchema as ot, TypedFlowEdge as p, BaseEventEmitterService as pn, EventType as pr, OptimizeParams as pt, TransformImageParams as q, jsonSerializer as qn, FlowJobTask as qt, RunArgs as r, compareMimeTypes as rn, createFlowEdge as rr, resizeTransformSchema as rt, FlowPluginRequirements as s, MiddlewareNext as sn, NodeConnectionValidator as sr, textTransformSchema as st, ResolvedUploadMetadata as t, createUploadServer as tn, getFlowData as tr, grayscaleTransformSchema as tt, NodeDefinitionsRecord as u, InputFile as un, TypeCompatibilityChecker as ur, watermarkTransformSchema as ut, ExtractLayerServices as v, eventToMessageSerializer as vn, FlowEventFlowPause as vr, ImageAiPluginShape as vt, describeImageParamsSchema as w, UploadEvent as wn, FlowEventNodePause as wr, ParallelSchedulerConfig as wt, RemoveBackgroundParams as x, WebSocketConnection as xn, FlowEventJobStart as xr, CredentialProviderShape as xt, ResolveEffect as y, flowEventEmitter as yn, FlowEventFlowStart as yr, CredentialProvider as yt, GrayscaleTransform as z, isDataStore as zn, FlowServerOptions as zt };
4724
+ //# sourceMappingURL=index-DdT18SQi.d.mts.map