@uploadista/core 0.0.17-beta.8 → 0.0.17
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.
- package/dist/flow/index.cjs +1 -1
- package/dist/flow/index.d.cts +1 -1
- package/dist/flow/index.d.mts +1 -1
- package/dist/flow/index.mjs +1 -1
- package/dist/flow-BiUCrFTv.cjs +1 -0
- package/dist/flow-vXXjtBBv.mjs +2 -0
- package/dist/flow-vXXjtBBv.mjs.map +1 -0
- package/dist/index-BGi1r_fi.d.mts.map +1 -1
- package/dist/{index-D0mDip93.d.cts → index-BQ5luyME.d.cts} +6 -6
- package/dist/index-BQ5luyME.d.cts.map +1 -0
- package/dist/{index-decQLghO.d.mts → index-BtnCNLsH.d.mts} +6 -6
- package/dist/index-BtnCNLsH.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/upload/index.d.cts +1 -1
- package/dist/upload/index.d.mts +1 -1
- package/package.json +2 -2
- package/src/flow/node-types/index.ts +7 -2
- package/src/flow/node.ts +1 -0
- package/src/flow/nodes/input-node.ts +2 -0
- package/tests/flow/type-system.test.ts +23 -30
- package/dist/flow-D6PtUk_E.cjs +0 -1
- package/dist/flow-w1RnqI9I.mjs +0 -2
- package/dist/flow-w1RnqI9I.mjs.map +0 -1
- package/dist/index-D0mDip93.d.cts.map +0 -1
- package/dist/index-decQLghO.d.mts.map +0 -1
package/dist/flow/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../types-B5I4BioZ.cjs`),require(`../uploadista-error-DCRIscEv.cjs`),require(`../errors-CRm1FHHT.cjs`);const e=require(`../flow-
|
|
1
|
+
require(`../types-B5I4BioZ.cjs`),require(`../uploadista-error-DCRIscEv.cjs`),require(`../errors-CRm1FHHT.cjs`);const e=require(`../flow-BiUCrFTv.cjs`);require(`../upload-bBgM3QFI.cjs`),require(`../checksum-BIlVW8bD.cjs`),require(`../stream-limiter-By0fxkAh.cjs`),exports.CredentialProvider=e.N,exports.DocumentAiPlugin=e.M,exports.DocumentPlugin=e.j,exports.EventType=e.xt,exports.FlowProvider=e.F,exports.FlowServer=e.I,exports.FlowTypeRegistry=e.vt,exports.FlowWaitUntil=e.L,exports.IMAGE_DESCRIPTION_OUTPUT_TYPE_ID=e.rt,exports.ImageAiPlugin=e.A,exports.ImagePlugin=e.k,exports.NodeType=e.ht,exports.OCR_OUTPUT_TYPE_ID=e.it,exports.ParallelScheduler=e.nt,exports.STORAGE_OUTPUT_TYPE_ID=e.at,exports.STREAMING_INPUT_TYPE_ID=e.ot,exports.VideoPlugin=e.a,exports.VirusScanPlugin=e.i,exports.ZipPlugin=e.r,exports.blurTransformSchema=e.s,exports.brightnessTransformSchema=e.c,exports.completeNodeExecution=e.pt,exports.contrastTransformSchema=e.l,exports.createFlow=e.n,exports.createFlowEdge=e.St,exports.createFlowNode=e.gt,exports.createFlowServer=e.R,exports.createFlowWithSchema=e.B,exports.createInputNode=e.lt,exports.createTransformNode=e.P,exports.createTypeGuard=e.H,exports.describeImageParamsSchema=e.O,exports.describeVideoMetadataSchema=e.D,exports.extractFrameVideoParamsSchema=e.E,exports.filterOutputsByType=e.U,exports.flipTransformSchema=e.u,exports.flowServer=e.z,exports.flowTypeRegistry=e.yt,exports.getFirstOutputByType=e.W,exports.getFlowData=e.V,exports.getNodeData=e._t,exports.getOutputByNodeId=e.G,exports.getSingleOutputByType=e.K,exports.grayscaleTransformSchema=e.d,exports.hasOutputOfType=e.q,exports.imageDescriptionOutputSchema=e.st,exports.inputDataSchema=e.ut,exports.inputNodeParamsSchema=e.dt,exports.isFinalizeOperation=e.J,exports.isImageDescriptionOutput=e.Y,exports.isInitOperation=e.X,exports.isOcrOutput=e.Z,exports.isStorageOutput=e.Q,exports.isUploadFile=e.$,exports.isUploadOperation=e.et,exports.isUrlOperation=e.tt,exports.logoTransformSchema=e.f,exports.ocrOutputSchema=e.ct,exports.optimizeParamsSchema=e.T,exports.removeBackgroundParamsSchema=e.w,exports.resizeParamsSchema=e.C,exports.resizeTransformSchema=e.p,exports.resizeVideoParamsSchema=e.S,exports.resolveUploadMetadata=e.ft,exports.rotateTransformSchema=e.m,exports.runArgsSchema=e.t,exports.sepiaTransformSchema=e.h,exports.sharpenTransformSchema=e.g,exports.textTransformSchema=e._,exports.transcodeVideoParamsSchema=e.x,exports.transformImageParamsSchema=e.v,exports.transformationSchema=e.y,exports.trimVideoParamsSchema=e.o,exports.validateFlowInput=e.bt,exports.waitingNodeExecution=e.mt,exports.watermarkTransformSchema=e.b;
|
package/dist/flow/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../uploadista-error-Bb-qIIKM.cjs";
|
|
2
2
|
import "../index-_wQ5ClJU.cjs";
|
|
3
|
-
import { $ as VideoPluginShape, $t as DocumentPluginLayer, A as isOcrOutput, Ai as FlowEventNodeResponse, An as FlowServerShape, Ar as ValidationResult, At as brightnessTransformSchema, B as PluginLayer, Bt as transformImageParamsSchema, C as getFirstOutputByType, Ci as FlowEventFlowPause, Cn as inputDataSchema, Cr as STORAGE_OUTPUT_TYPE_ID, Ct as SharpenTransform, D as isFinalizeOperation, Di as FlowEventNodeEnd, Dn as FlowServer, Dr as FlowTypeRegistry, Dt as TransformationType, E as hasOutputOfType, Ei as FlowEventJobStart, En as FlowProviderShape, Er as ocrOutputSchema, Et as Transformation, F as RemoveBackgroundParams, Fi as ConditionValue, Fn as FlowJob, Fr as FlowExecutionResult, Ft as resizeTransformSchema, G as ZipPluginShape, Gt as OptimizeParams, H as ZipParams, Ht as watermarkTransformSchema, I as removeBackgroundParamsSchema, Ii as NodeType, In as FlowJobStatus, Ir as createFlowWithSchema, It as rotateTransformSchema, J as VirusScanPlugin, Jt as ImageAiPlugin, K as ScanMetadata, Kt as optimizeParamsSchema, L as DescribeImageParams, Li as createFlowNode, Ln as FlowJobTask, Lr as getFlowData, Lt as sepiaTransformSchema, M as isUploadFile, Mi as FlowEventNodeStart, Mn as WaitUntilCallback, Mr as validateFlowInput, Mt as flipTransformSchema, N as isUploadOperation, Ni as ConditionField, Nn as createFlowServer, Nr as Flow, Nt as grayscaleTransformSchema, O as isImageDescriptionOutput, Oi as FlowEventNodeError, On as FlowServerLayer, Or as NodeTypeCategory, Ot as WatermarkTransform, P as isUrlOperation, Pi as ConditionOperator, Pn as flowServer, Pr as FlowData, Pt as logoTransformSchema, Q as VideoPluginLayer, Qt as DocumentPlugin, R as describeImageParamsSchema, Ri as getNodeData, Rn as FlowJobTaskStatus, Rt as sharpenTransformSchema, S as filterOutputsByType, Si as FlowEventFlowError, Sn as createInputNode, Sr as OcrOutput, St as SepiaTransform, T as getSingleOutputByType, Ti as FlowEventJobEnd, Tn as FlowProvider, Tr as imageDescriptionOutputSchema, Tt as TransformImageParams, U as ZipPlugin, Ut as ResizeParams, V as ZipInput, Vt as transformationSchema, W as ZipPluginLayer, Wt as resizeParamsSchema, X as VirusScanPluginShape, Xt as ImageAiPluginShape, Y as VirusScanPluginLayer, Yt as ImageAiPluginLayer, Z as VideoPlugin, Zt as DocumentMetadata, _ as ExtractLayerService, _i as waitingNodeExecution, _n as ParallelSchedulerConfig, _t as GrayscaleTransform, a as FlowInputMap, ai as createFlowEdge, an as DocumentAiPlugin, at as resizeVideoParamsSchema, b as FlowCondition, bi as FlowEventFlowCancel, bn as InputData, br as ImageDescriptionOutput, bt as ResizeTransform, c as FlowRequirements, ci as FlowConfig, cn as OcrParams, ct as DescribeVideoMetadata, d as TypedFlow, di as NodeConnectionValidator, dn as OcrTaskType, dt as ImagePluginLayer, en as DocumentPluginShape, et as TrimVideoParams, f as TypedFlowConfig, fi as NodeExecutionResult, fn as CredentialProvider, ft as ImagePluginShape, g as ExtractEffectRequirements, gi as completeNodeExecution, gn as ParallelScheduler, gt as FlipTransform, h as ExtractEffectError, hi as TypedOutput, hn as ExecutionLevel, ht as ContrastTransform, i as runArgsSchema, ii as FlowEdge, in as DocumentAiContext, it as ResizeVideoParams, j as isStorageOutput, ji as FlowEventNodeResume, jn as FlowWaitUntil, jr as flowTypeRegistry, jt as contrastTransformSchema, k as isInitOperation, ki as FlowEventNodePause, kn as FlowServerOptions, kr as NodeTypeDefinition, kt as blurTransformSchema, l as NodeDefinition, li as FlowNode, ln as OcrResolution, lt as describeVideoMetadataSchema, m as createFlow, mi as TypeCompatibilityChecker, mn as CredentialProviderShape, mt as BrightnessTransform, n as resolveUploadMetadata, nn as SplitPdfParams, nt as TranscodeVideoParams, o as FlowOutputMap, oi as BuiltInTypedOutput, on as DocumentAiPluginLayer, ot as ExtractFrameVideoParams, p as TypedFlowEdge, pi as NodeTypeMap, pn as CredentialProviderLayer, pt as BlurTransform, q as ScanResult, qt as ImageAiContext, r as RunArgs, rn as SplitPdfResult, rt as transcodeVideoParamsSchema, s as FlowPluginRequirements, si as CustomTypedOutput, sn as DocumentAiPluginShape, st as extractFrameVideoParamsSchema, t as ResolvedUploadMetadata, tn as MergePdfParams, tt as trimVideoParamsSchema, u as NodeDefinitionsRecord, ui as FlowNodeData, un as OcrResult, ut as ImagePlugin, v as ExtractLayerServices, vi as EventType, vn as TransformNodeConfig, vt as LogoTransform, w as getOutputByNodeId, wi as FlowEventFlowStart, wn as inputNodeParamsSchema, wr as STREAMING_INPUT_TYPE_ID, wt as TextTransform, x as createTypeGuard, xi as FlowEventFlowEnd, xn as InputNodeParams, xr as OCR_OUTPUT_TYPE_ID, xt as RotateTransform, y as ResolveEffect, yi as FlowEvent, yn as createTransformNode, yr as IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, yt as OverlayPosition, z as Plugin, zt as textTransformSchema } from "../index-
|
|
3
|
+
import { $ as VideoPluginShape, $t as DocumentPluginLayer, A as isOcrOutput, Ai as FlowEventNodeResponse, An as FlowServerShape, Ar as ValidationResult, At as brightnessTransformSchema, B as PluginLayer, Bt as transformImageParamsSchema, C as getFirstOutputByType, Ci as FlowEventFlowPause, Cn as inputDataSchema, Cr as STORAGE_OUTPUT_TYPE_ID, Ct as SharpenTransform, D as isFinalizeOperation, Di as FlowEventNodeEnd, Dn as FlowServer, Dr as FlowTypeRegistry, Dt as TransformationType, E as hasOutputOfType, Ei as FlowEventJobStart, En as FlowProviderShape, Er as ocrOutputSchema, Et as Transformation, F as RemoveBackgroundParams, Fi as ConditionValue, Fn as FlowJob, Fr as FlowExecutionResult, Ft as resizeTransformSchema, G as ZipPluginShape, Gt as OptimizeParams, H as ZipParams, Ht as watermarkTransformSchema, I as removeBackgroundParamsSchema, Ii as NodeType, In as FlowJobStatus, Ir as createFlowWithSchema, It as rotateTransformSchema, J as VirusScanPlugin, Jt as ImageAiPlugin, K as ScanMetadata, Kt as optimizeParamsSchema, L as DescribeImageParams, Li as createFlowNode, Ln as FlowJobTask, Lr as getFlowData, Lt as sepiaTransformSchema, M as isUploadFile, Mi as FlowEventNodeStart, Mn as WaitUntilCallback, Mr as validateFlowInput, Mt as flipTransformSchema, N as isUploadOperation, Ni as ConditionField, Nn as createFlowServer, Nr as Flow, Nt as grayscaleTransformSchema, O as isImageDescriptionOutput, Oi as FlowEventNodeError, On as FlowServerLayer, Or as NodeTypeCategory, Ot as WatermarkTransform, P as isUrlOperation, Pi as ConditionOperator, Pn as flowServer, Pr as FlowData, Pt as logoTransformSchema, Q as VideoPluginLayer, Qt as DocumentPlugin, R as describeImageParamsSchema, Ri as getNodeData, Rn as FlowJobTaskStatus, Rt as sharpenTransformSchema, S as filterOutputsByType, Si as FlowEventFlowError, Sn as createInputNode, Sr as OcrOutput, St as SepiaTransform, T as getSingleOutputByType, Ti as FlowEventJobEnd, Tn as FlowProvider, Tr as imageDescriptionOutputSchema, Tt as TransformImageParams, U as ZipPlugin, Ut as ResizeParams, V as ZipInput, Vt as transformationSchema, W as ZipPluginLayer, Wt as resizeParamsSchema, X as VirusScanPluginShape, Xt as ImageAiPluginShape, Y as VirusScanPluginLayer, Yt as ImageAiPluginLayer, Z as VideoPlugin, Zt as DocumentMetadata, _ as ExtractLayerService, _i as waitingNodeExecution, _n as ParallelSchedulerConfig, _t as GrayscaleTransform, a as FlowInputMap, ai as createFlowEdge, an as DocumentAiPlugin, at as resizeVideoParamsSchema, b as FlowCondition, bi as FlowEventFlowCancel, bn as InputData, br as ImageDescriptionOutput, bt as ResizeTransform, c as FlowRequirements, ci as FlowConfig, cn as OcrParams, ct as DescribeVideoMetadata, d as TypedFlow, di as NodeConnectionValidator, dn as OcrTaskType, dt as ImagePluginLayer, en as DocumentPluginShape, et as TrimVideoParams, f as TypedFlowConfig, fi as NodeExecutionResult, fn as CredentialProvider, ft as ImagePluginShape, g as ExtractEffectRequirements, gi as completeNodeExecution, gn as ParallelScheduler, gt as FlipTransform, h as ExtractEffectError, hi as TypedOutput, hn as ExecutionLevel, ht as ContrastTransform, i as runArgsSchema, ii as FlowEdge, in as DocumentAiContext, it as ResizeVideoParams, j as isStorageOutput, ji as FlowEventNodeResume, jn as FlowWaitUntil, jr as flowTypeRegistry, jt as contrastTransformSchema, k as isInitOperation, ki as FlowEventNodePause, kn as FlowServerOptions, kr as NodeTypeDefinition, kt as blurTransformSchema, l as NodeDefinition, li as FlowNode, ln as OcrResolution, lt as describeVideoMetadataSchema, m as createFlow, mi as TypeCompatibilityChecker, mn as CredentialProviderShape, mt as BrightnessTransform, n as resolveUploadMetadata, nn as SplitPdfParams, nt as TranscodeVideoParams, o as FlowOutputMap, oi as BuiltInTypedOutput, on as DocumentAiPluginLayer, ot as ExtractFrameVideoParams, p as TypedFlowEdge, pi as NodeTypeMap, pn as CredentialProviderLayer, pt as BlurTransform, q as ScanResult, qt as ImageAiContext, r as RunArgs, rn as SplitPdfResult, rt as transcodeVideoParamsSchema, s as FlowPluginRequirements, si as CustomTypedOutput, sn as DocumentAiPluginShape, st as extractFrameVideoParamsSchema, t as ResolvedUploadMetadata, tn as MergePdfParams, tt as trimVideoParamsSchema, u as NodeDefinitionsRecord, ui as FlowNodeData, un as OcrResult, ut as ImagePlugin, v as ExtractLayerServices, vi as EventType, vn as TransformNodeConfig, vt as LogoTransform, w as getOutputByNodeId, wi as FlowEventFlowStart, wn as inputNodeParamsSchema, wr as STREAMING_INPUT_TYPE_ID, wt as TextTransform, x as createTypeGuard, xi as FlowEventFlowEnd, xn as InputNodeParams, xr as OCR_OUTPUT_TYPE_ID, xt as RotateTransform, y as ResolveEffect, yi as FlowEvent, yn as createTransformNode, yr as IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, yt as OverlayPosition, z as Plugin, zt as textTransformSchema } from "../index-BQ5luyME.cjs";
|
|
4
4
|
import "../index-B_SvQ0MU.cjs";
|
|
5
5
|
import "../index-qIN6ULCb.cjs";
|
|
6
6
|
export { BlurTransform, BrightnessTransform, BuiltInTypedOutput, ConditionField, ConditionOperator, ConditionValue, ContrastTransform, CredentialProvider, CredentialProviderLayer, CredentialProviderShape, CustomTypedOutput, DescribeImageParams, DescribeVideoMetadata, DocumentAiContext, DocumentAiPlugin, DocumentAiPluginLayer, DocumentAiPluginShape, DocumentMetadata, DocumentPlugin, DocumentPluginLayer, DocumentPluginShape, EventType, ExecutionLevel, ExtractEffectError, ExtractEffectRequirements, ExtractFrameVideoParams, ExtractLayerService, ExtractLayerServices, FlipTransform, Flow, FlowCondition, FlowConfig, FlowData, FlowEdge, FlowEvent, FlowEventFlowCancel, FlowEventFlowEnd, FlowEventFlowError, FlowEventFlowPause, FlowEventFlowStart, FlowEventJobEnd, FlowEventJobStart, FlowEventNodeEnd, FlowEventNodeError, FlowEventNodePause, FlowEventNodeResponse, FlowEventNodeResume, FlowEventNodeStart, FlowExecutionResult, FlowInputMap, FlowJob, FlowJobStatus, FlowJobTask, FlowJobTaskStatus, FlowNode, FlowNodeData, FlowOutputMap, FlowPluginRequirements, FlowProvider, FlowProviderShape, FlowRequirements, FlowServer, FlowServerLayer, FlowServerOptions, FlowServerShape, FlowTypeRegistry, FlowWaitUntil, GrayscaleTransform, IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, ImageAiContext, ImageAiPlugin, ImageAiPluginLayer, ImageAiPluginShape, ImageDescriptionOutput, ImagePlugin, ImagePluginLayer, ImagePluginShape, InputData, InputNodeParams, LogoTransform, MergePdfParams, NodeConnectionValidator, NodeDefinition, NodeDefinitionsRecord, NodeExecutionResult, NodeType, NodeTypeCategory, NodeTypeDefinition, NodeTypeMap, OCR_OUTPUT_TYPE_ID, OcrOutput, OcrParams, OcrResolution, OcrResult, OcrTaskType, OptimizeParams, OverlayPosition, ParallelScheduler, ParallelSchedulerConfig, Plugin, PluginLayer, RemoveBackgroundParams, ResizeParams, ResizeTransform, ResizeVideoParams, ResolveEffect, ResolvedUploadMetadata, RotateTransform, RunArgs, STORAGE_OUTPUT_TYPE_ID, STREAMING_INPUT_TYPE_ID, ScanMetadata, ScanResult, SepiaTransform, SharpenTransform, SplitPdfParams, SplitPdfResult, TextTransform, TranscodeVideoParams, TransformImageParams, TransformNodeConfig, Transformation, TransformationType, TrimVideoParams, TypeCompatibilityChecker, TypedFlow, TypedFlowConfig, TypedFlowEdge, TypedOutput, ValidationResult, VideoPlugin, VideoPluginLayer, VideoPluginShape, VirusScanPlugin, VirusScanPluginLayer, VirusScanPluginShape, WaitUntilCallback, WatermarkTransform, ZipInput, ZipParams, ZipPlugin, ZipPluginLayer, ZipPluginShape, blurTransformSchema, brightnessTransformSchema, completeNodeExecution, contrastTransformSchema, createFlow, createFlowEdge, createFlowNode, createFlowServer, createFlowWithSchema, createInputNode, createTransformNode, createTypeGuard, describeImageParamsSchema, describeVideoMetadataSchema, extractFrameVideoParamsSchema, filterOutputsByType, flipTransformSchema, flowServer, flowTypeRegistry, getFirstOutputByType, getFlowData, getNodeData, getOutputByNodeId, getSingleOutputByType, grayscaleTransformSchema, hasOutputOfType, imageDescriptionOutputSchema, inputDataSchema, inputNodeParamsSchema, isFinalizeOperation, isImageDescriptionOutput, isInitOperation, isOcrOutput, isStorageOutput, isUploadFile, isUploadOperation, isUrlOperation, logoTransformSchema, ocrOutputSchema, optimizeParamsSchema, removeBackgroundParamsSchema, resizeParamsSchema, resizeTransformSchema, resizeVideoParamsSchema, resolveUploadMetadata, rotateTransformSchema, runArgsSchema, sepiaTransformSchema, sharpenTransformSchema, textTransformSchema, transcodeVideoParamsSchema, transformImageParamsSchema, transformationSchema, trimVideoParamsSchema, validateFlowInput, waitingNodeExecution, watermarkTransformSchema };
|
package/dist/flow/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../uploadista-error-D7Gubrr1.mjs";
|
|
2
2
|
import "../index-C-svZlpj.mjs";
|
|
3
|
-
import { $ as VideoPluginShape, $t as DocumentPluginLayer, A as isOcrOutput, Ai as FlowEventNodeResponse, An as FlowServerShape, Ar as ValidationResult, At as brightnessTransformSchema, B as PluginLayer, Bt as transformImageParamsSchema, C as getFirstOutputByType, Ci as FlowEventFlowPause, Cn as inputDataSchema, Cr as STORAGE_OUTPUT_TYPE_ID, Ct as SharpenTransform, D as isFinalizeOperation, Di as FlowEventNodeEnd, Dn as FlowServer, Dr as FlowTypeRegistry, Dt as TransformationType, E as hasOutputOfType, Ei as FlowEventJobStart, En as FlowProviderShape, Er as ocrOutputSchema, Et as Transformation, F as RemoveBackgroundParams, Fi as ConditionValue, Fn as FlowJob, Fr as FlowExecutionResult, Ft as resizeTransformSchema, G as ZipPluginShape, Gt as OptimizeParams, H as ZipParams, Ht as watermarkTransformSchema, I as removeBackgroundParamsSchema, Ii as NodeType, In as FlowJobStatus, Ir as createFlowWithSchema, It as rotateTransformSchema, J as VirusScanPlugin, Jt as ImageAiPlugin, K as ScanMetadata, Kt as optimizeParamsSchema, L as DescribeImageParams, Li as createFlowNode, Ln as FlowJobTask, Lr as getFlowData, Lt as sepiaTransformSchema, M as isUploadFile, Mi as FlowEventNodeStart, Mn as WaitUntilCallback, Mr as validateFlowInput, Mt as flipTransformSchema, N as isUploadOperation, Ni as ConditionField, Nn as createFlowServer, Nr as Flow, Nt as grayscaleTransformSchema, O as isImageDescriptionOutput, Oi as FlowEventNodeError, On as FlowServerLayer, Or as NodeTypeCategory, Ot as WatermarkTransform, P as isUrlOperation, Pi as ConditionOperator, Pn as flowServer, Pr as FlowData, Pt as logoTransformSchema, Q as VideoPluginLayer, Qt as DocumentPlugin, R as describeImageParamsSchema, Ri as getNodeData, Rn as FlowJobTaskStatus, Rt as sharpenTransformSchema, S as filterOutputsByType, Si as FlowEventFlowError, Sn as createInputNode, Sr as OcrOutput, St as SepiaTransform, T as getSingleOutputByType, Ti as FlowEventJobEnd, Tn as FlowProvider, Tr as imageDescriptionOutputSchema, Tt as TransformImageParams, U as ZipPlugin, Ut as ResizeParams, V as ZipInput, Vt as transformationSchema, W as ZipPluginLayer, Wt as resizeParamsSchema, X as VirusScanPluginShape, Xt as ImageAiPluginShape, Y as VirusScanPluginLayer, Yt as ImageAiPluginLayer, Z as VideoPlugin, Zt as DocumentMetadata, _ as ExtractLayerService, _i as waitingNodeExecution, _n as ParallelSchedulerConfig, _t as GrayscaleTransform, a as FlowInputMap, ai as createFlowEdge, an as DocumentAiPlugin, at as resizeVideoParamsSchema, b as FlowCondition, bi as FlowEventFlowCancel, bn as InputData, br as ImageDescriptionOutput, bt as ResizeTransform, c as FlowRequirements, ci as FlowConfig, cn as OcrParams, ct as DescribeVideoMetadata, d as TypedFlow, di as NodeConnectionValidator, dn as OcrTaskType, dt as ImagePluginLayer, en as DocumentPluginShape, et as TrimVideoParams, f as TypedFlowConfig, fi as NodeExecutionResult, fn as CredentialProvider, ft as ImagePluginShape, g as ExtractEffectRequirements, gi as completeNodeExecution, gn as ParallelScheduler, gt as FlipTransform, h as ExtractEffectError, hi as TypedOutput, hn as ExecutionLevel, ht as ContrastTransform, i as runArgsSchema, ii as FlowEdge, in as DocumentAiContext, it as ResizeVideoParams, j as isStorageOutput, ji as FlowEventNodeResume, jn as FlowWaitUntil, jr as flowTypeRegistry, jt as contrastTransformSchema, k as isInitOperation, ki as FlowEventNodePause, kn as FlowServerOptions, kr as NodeTypeDefinition, kt as blurTransformSchema, l as NodeDefinition, li as FlowNode, ln as OcrResolution, lt as describeVideoMetadataSchema, m as createFlow, mi as TypeCompatibilityChecker, mn as CredentialProviderShape, mt as BrightnessTransform, n as resolveUploadMetadata, nn as SplitPdfParams, nt as TranscodeVideoParams, o as FlowOutputMap, oi as BuiltInTypedOutput, on as DocumentAiPluginLayer, ot as ExtractFrameVideoParams, p as TypedFlowEdge, pi as NodeTypeMap, pn as CredentialProviderLayer, pt as BlurTransform, q as ScanResult, qt as ImageAiContext, r as RunArgs, rn as SplitPdfResult, rt as transcodeVideoParamsSchema, s as FlowPluginRequirements, si as CustomTypedOutput, sn as DocumentAiPluginShape, st as extractFrameVideoParamsSchema, t as ResolvedUploadMetadata, tn as MergePdfParams, tt as trimVideoParamsSchema, u as NodeDefinitionsRecord, ui as FlowNodeData, un as OcrResult, ut as ImagePlugin, v as ExtractLayerServices, vi as EventType, vn as TransformNodeConfig, vt as LogoTransform, w as getOutputByNodeId, wi as FlowEventFlowStart, wn as inputNodeParamsSchema, wr as STREAMING_INPUT_TYPE_ID, wt as TextTransform, x as createTypeGuard, xi as FlowEventFlowEnd, xn as InputNodeParams, xr as OCR_OUTPUT_TYPE_ID, xt as RotateTransform, y as ResolveEffect, yi as FlowEvent, yn as createTransformNode, yr as IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, yt as OverlayPosition, z as Plugin, zt as textTransformSchema } from "../index-
|
|
3
|
+
import { $ as VideoPluginShape, $t as DocumentPluginLayer, A as isOcrOutput, Ai as FlowEventNodeResponse, An as FlowServerShape, Ar as ValidationResult, At as brightnessTransformSchema, B as PluginLayer, Bt as transformImageParamsSchema, C as getFirstOutputByType, Ci as FlowEventFlowPause, Cn as inputDataSchema, Cr as STORAGE_OUTPUT_TYPE_ID, Ct as SharpenTransform, D as isFinalizeOperation, Di as FlowEventNodeEnd, Dn as FlowServer, Dr as FlowTypeRegistry, Dt as TransformationType, E as hasOutputOfType, Ei as FlowEventJobStart, En as FlowProviderShape, Er as ocrOutputSchema, Et as Transformation, F as RemoveBackgroundParams, Fi as ConditionValue, Fn as FlowJob, Fr as FlowExecutionResult, Ft as resizeTransformSchema, G as ZipPluginShape, Gt as OptimizeParams, H as ZipParams, Ht as watermarkTransformSchema, I as removeBackgroundParamsSchema, Ii as NodeType, In as FlowJobStatus, Ir as createFlowWithSchema, It as rotateTransformSchema, J as VirusScanPlugin, Jt as ImageAiPlugin, K as ScanMetadata, Kt as optimizeParamsSchema, L as DescribeImageParams, Li as createFlowNode, Ln as FlowJobTask, Lr as getFlowData, Lt as sepiaTransformSchema, M as isUploadFile, Mi as FlowEventNodeStart, Mn as WaitUntilCallback, Mr as validateFlowInput, Mt as flipTransformSchema, N as isUploadOperation, Ni as ConditionField, Nn as createFlowServer, Nr as Flow, Nt as grayscaleTransformSchema, O as isImageDescriptionOutput, Oi as FlowEventNodeError, On as FlowServerLayer, Or as NodeTypeCategory, Ot as WatermarkTransform, P as isUrlOperation, Pi as ConditionOperator, Pn as flowServer, Pr as FlowData, Pt as logoTransformSchema, Q as VideoPluginLayer, Qt as DocumentPlugin, R as describeImageParamsSchema, Ri as getNodeData, Rn as FlowJobTaskStatus, Rt as sharpenTransformSchema, S as filterOutputsByType, Si as FlowEventFlowError, Sn as createInputNode, Sr as OcrOutput, St as SepiaTransform, T as getSingleOutputByType, Ti as FlowEventJobEnd, Tn as FlowProvider, Tr as imageDescriptionOutputSchema, Tt as TransformImageParams, U as ZipPlugin, Ut as ResizeParams, V as ZipInput, Vt as transformationSchema, W as ZipPluginLayer, Wt as resizeParamsSchema, X as VirusScanPluginShape, Xt as ImageAiPluginShape, Y as VirusScanPluginLayer, Yt as ImageAiPluginLayer, Z as VideoPlugin, Zt as DocumentMetadata, _ as ExtractLayerService, _i as waitingNodeExecution, _n as ParallelSchedulerConfig, _t as GrayscaleTransform, a as FlowInputMap, ai as createFlowEdge, an as DocumentAiPlugin, at as resizeVideoParamsSchema, b as FlowCondition, bi as FlowEventFlowCancel, bn as InputData, br as ImageDescriptionOutput, bt as ResizeTransform, c as FlowRequirements, ci as FlowConfig, cn as OcrParams, ct as DescribeVideoMetadata, d as TypedFlow, di as NodeConnectionValidator, dn as OcrTaskType, dt as ImagePluginLayer, en as DocumentPluginShape, et as TrimVideoParams, f as TypedFlowConfig, fi as NodeExecutionResult, fn as CredentialProvider, ft as ImagePluginShape, g as ExtractEffectRequirements, gi as completeNodeExecution, gn as ParallelScheduler, gt as FlipTransform, h as ExtractEffectError, hi as TypedOutput, hn as ExecutionLevel, ht as ContrastTransform, i as runArgsSchema, ii as FlowEdge, in as DocumentAiContext, it as ResizeVideoParams, j as isStorageOutput, ji as FlowEventNodeResume, jn as FlowWaitUntil, jr as flowTypeRegistry, jt as contrastTransformSchema, k as isInitOperation, ki as FlowEventNodePause, kn as FlowServerOptions, kr as NodeTypeDefinition, kt as blurTransformSchema, l as NodeDefinition, li as FlowNode, ln as OcrResolution, lt as describeVideoMetadataSchema, m as createFlow, mi as TypeCompatibilityChecker, mn as CredentialProviderShape, mt as BrightnessTransform, n as resolveUploadMetadata, nn as SplitPdfParams, nt as TranscodeVideoParams, o as FlowOutputMap, oi as BuiltInTypedOutput, on as DocumentAiPluginLayer, ot as ExtractFrameVideoParams, p as TypedFlowEdge, pi as NodeTypeMap, pn as CredentialProviderLayer, pt as BlurTransform, q as ScanResult, qt as ImageAiContext, r as RunArgs, rn as SplitPdfResult, rt as transcodeVideoParamsSchema, s as FlowPluginRequirements, si as CustomTypedOutput, sn as DocumentAiPluginShape, st as extractFrameVideoParamsSchema, t as ResolvedUploadMetadata, tn as MergePdfParams, tt as trimVideoParamsSchema, u as NodeDefinitionsRecord, ui as FlowNodeData, un as OcrResult, ut as ImagePlugin, v as ExtractLayerServices, vi as EventType, vn as TransformNodeConfig, vt as LogoTransform, w as getOutputByNodeId, wi as FlowEventFlowStart, wn as inputNodeParamsSchema, wr as STREAMING_INPUT_TYPE_ID, wt as TextTransform, x as createTypeGuard, xi as FlowEventFlowEnd, xn as InputNodeParams, xr as OCR_OUTPUT_TYPE_ID, xt as RotateTransform, y as ResolveEffect, yi as FlowEvent, yn as createTransformNode, yr as IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, yt as OverlayPosition, z as Plugin, zt as textTransformSchema } from "../index-BtnCNLsH.mjs";
|
|
4
4
|
import "../index-BGi1r_fi.mjs";
|
|
5
5
|
import "../index-DIWuZlxd.mjs";
|
|
6
6
|
export { BlurTransform, BrightnessTransform, BuiltInTypedOutput, ConditionField, ConditionOperator, ConditionValue, ContrastTransform, CredentialProvider, CredentialProviderLayer, CredentialProviderShape, CustomTypedOutput, DescribeImageParams, DescribeVideoMetadata, DocumentAiContext, DocumentAiPlugin, DocumentAiPluginLayer, DocumentAiPluginShape, DocumentMetadata, DocumentPlugin, DocumentPluginLayer, DocumentPluginShape, EventType, ExecutionLevel, ExtractEffectError, ExtractEffectRequirements, ExtractFrameVideoParams, ExtractLayerService, ExtractLayerServices, FlipTransform, Flow, FlowCondition, FlowConfig, FlowData, FlowEdge, FlowEvent, FlowEventFlowCancel, FlowEventFlowEnd, FlowEventFlowError, FlowEventFlowPause, FlowEventFlowStart, FlowEventJobEnd, FlowEventJobStart, FlowEventNodeEnd, FlowEventNodeError, FlowEventNodePause, FlowEventNodeResponse, FlowEventNodeResume, FlowEventNodeStart, FlowExecutionResult, FlowInputMap, FlowJob, FlowJobStatus, FlowJobTask, FlowJobTaskStatus, FlowNode, FlowNodeData, FlowOutputMap, FlowPluginRequirements, FlowProvider, FlowProviderShape, FlowRequirements, FlowServer, FlowServerLayer, FlowServerOptions, FlowServerShape, FlowTypeRegistry, FlowWaitUntil, GrayscaleTransform, IMAGE_DESCRIPTION_OUTPUT_TYPE_ID, ImageAiContext, ImageAiPlugin, ImageAiPluginLayer, ImageAiPluginShape, ImageDescriptionOutput, ImagePlugin, ImagePluginLayer, ImagePluginShape, InputData, InputNodeParams, LogoTransform, MergePdfParams, NodeConnectionValidator, NodeDefinition, NodeDefinitionsRecord, NodeExecutionResult, NodeType, NodeTypeCategory, NodeTypeDefinition, NodeTypeMap, OCR_OUTPUT_TYPE_ID, OcrOutput, OcrParams, OcrResolution, OcrResult, OcrTaskType, OptimizeParams, OverlayPosition, ParallelScheduler, ParallelSchedulerConfig, Plugin, PluginLayer, RemoveBackgroundParams, ResizeParams, ResizeTransform, ResizeVideoParams, ResolveEffect, ResolvedUploadMetadata, RotateTransform, RunArgs, STORAGE_OUTPUT_TYPE_ID, STREAMING_INPUT_TYPE_ID, ScanMetadata, ScanResult, SepiaTransform, SharpenTransform, SplitPdfParams, SplitPdfResult, TextTransform, TranscodeVideoParams, TransformImageParams, TransformNodeConfig, Transformation, TransformationType, TrimVideoParams, TypeCompatibilityChecker, TypedFlow, TypedFlowConfig, TypedFlowEdge, TypedOutput, ValidationResult, VideoPlugin, VideoPluginLayer, VideoPluginShape, VirusScanPlugin, VirusScanPluginLayer, VirusScanPluginShape, WaitUntilCallback, WatermarkTransform, ZipInput, ZipParams, ZipPlugin, ZipPluginLayer, ZipPluginShape, blurTransformSchema, brightnessTransformSchema, completeNodeExecution, contrastTransformSchema, createFlow, createFlowEdge, createFlowNode, createFlowServer, createFlowWithSchema, createInputNode, createTransformNode, createTypeGuard, describeImageParamsSchema, describeVideoMetadataSchema, extractFrameVideoParamsSchema, filterOutputsByType, flipTransformSchema, flowServer, flowTypeRegistry, getFirstOutputByType, getFlowData, getNodeData, getOutputByNodeId, getSingleOutputByType, grayscaleTransformSchema, hasOutputOfType, imageDescriptionOutputSchema, inputDataSchema, inputNodeParamsSchema, isFinalizeOperation, isImageDescriptionOutput, isInitOperation, isOcrOutput, isStorageOutput, isUploadFile, isUploadOperation, isUrlOperation, logoTransformSchema, ocrOutputSchema, optimizeParamsSchema, removeBackgroundParamsSchema, resizeParamsSchema, resizeTransformSchema, resizeVideoParamsSchema, resolveUploadMetadata, rotateTransformSchema, runArgsSchema, sepiaTransformSchema, sharpenTransformSchema, textTransformSchema, transcodeVideoParamsSchema, transformImageParamsSchema, transformationSchema, trimVideoParamsSchema, validateFlowInput, waitingNodeExecution, watermarkTransformSchema };
|
package/dist/flow/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../uploadista-error-djFxVTLh.mjs";import"../errors-CtPUOWNd.mjs";import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,St as b,T as x,U as S,V as C,W as w,X as T,Y as E,Z as D,_ as O,_t as k,a as A,at as j,b as M,bt as N,c as P,ct as F,d as I,dt as L,et as R,f as z,ft as B,g as V,gt as H,h as U,ht as W,i as G,it as K,j as q,k as J,l as Y,lt as X,m as Z,mt as Q,n as $,nt as ee,o as te,ot as ne,p as re,pt as ie,q as ae,r as oe,rt as se,s as ce,st as le,t as ue,tt as de,u as fe,ut as pe,v as me,vt as he,w as ge,x as _e,xt as ve,y as ye,yt as be,z as xe}from"../flow-
|
|
1
|
+
import"../uploadista-error-djFxVTLh.mjs";import"../errors-CtPUOWNd.mjs";import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,St as b,T as x,U as S,V as C,W as w,X as T,Y as E,Z as D,_ as O,_t as k,a as A,at as j,b as M,bt as N,c as P,ct as F,d as I,dt as L,et as R,f as z,ft as B,g as V,gt as H,h as U,ht as W,i as G,it as K,j as q,k as J,l as Y,lt as X,m as Z,mt as Q,n as $,nt as ee,o as te,ot as ne,p as re,pt as ie,q as ae,r as oe,rt as se,s as ce,st as le,t as ue,tt as de,u as fe,ut as pe,v as me,vt as he,w as ge,x as _e,xt as ve,y as ye,yt as be,z as xe}from"../flow-vXXjtBBv.mjs";import"../types-f6w5J3UD.mjs";import"../upload-Bq9h95w6.mjs";import"../checksum-DaCqP8Qa.mjs";import"../stream-limiter-D2Y8Z_Kv.mjs";export{m as CredentialProvider,p as DocumentAiPlugin,q as DocumentPlugin,ve as EventType,o as FlowProvider,l as FlowServer,he as FlowTypeRegistry,f as FlowWaitUntil,se as IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,t as ImageAiPlugin,J as ImagePlugin,W as NodeType,K as OCR_OUTPUT_TYPE_ID,ee as ParallelScheduler,j as STORAGE_OUTPUT_TYPE_ID,ne as STREAMING_INPUT_TYPE_ID,A as VideoPlugin,G as VirusScanPlugin,oe as ZipPlugin,ce as blurTransformSchema,P as brightnessTransformSchema,ie as completeNodeExecution,Y as contrastTransformSchema,$ as createFlow,b as createFlowEdge,H as createFlowNode,v as createFlowServer,n as createFlowWithSchema,X as createInputNode,g as createTransformNode,c as createTypeGuard,h as describeImageParamsSchema,i as describeVideoMetadataSchema,a as extractFrameVideoParamsSchema,S as filterOutputsByType,fe as flipTransformSchema,xe as flowServer,be as flowTypeRegistry,w as getFirstOutputByType,C as getFlowData,k as getNodeData,s as getOutputByNodeId,d as getSingleOutputByType,I as grayscaleTransformSchema,ae as hasOutputOfType,le as imageDescriptionOutputSchema,pe as inputDataSchema,L as inputNodeParamsSchema,u as isFinalizeOperation,E as isImageDescriptionOutput,T as isInitOperation,D as isOcrOutput,_ as isStorageOutput,e as isUploadFile,R as isUploadOperation,de as isUrlOperation,z as logoTransformSchema,F as ocrOutputSchema,x as optimizeParamsSchema,ge as removeBackgroundParamsSchema,r as resizeParamsSchema,re as resizeTransformSchema,y as resizeVideoParamsSchema,B as resolveUploadMetadata,Z as rotateTransformSchema,ue as runArgsSchema,U as sepiaTransformSchema,V as sharpenTransformSchema,O as textTransformSchema,_e as transcodeVideoParamsSchema,me as transformImageParamsSchema,ye as transformationSchema,te as trimVideoParamsSchema,N as validateFlowInput,Q as waitingNodeExecution,M as watermarkTransformSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./types-B5I4BioZ.cjs`),t=require(`./uploadista-error-DCRIscEv.cjs`),n=require(`./upload-bBgM3QFI.cjs`);let r=require(`effect`),i=require(`zod`);function a({source:e,target:t,sourcePort:n,targetPort:r}){return{source:e,target:t,sourcePort:n,targetPort:r}}let o=function(e){return e.JobStart=`job-start`,e.JobEnd=`job-end`,e.FlowStart=`flow-start`,e.FlowEnd=`flow-end`,e.FlowError=`flow-error`,e.FlowPause=`flow-pause`,e.FlowCancel=`flow-cancel`,e.NodeStart=`node-start`,e.NodeEnd=`node-end`,e.NodePause=`node-pause`,e.NodeResume=`node-resume`,e.NodeError=`node-error`,e.NodeStream=`node-stream`,e.NodeResponse=`node-response`,e}({});var s=class{types;constructor(){this.types=new Map}register(e){if(this.types.has(e.id))throw t.n.fromCode(`VALIDATION_ERROR`,{body:`Node type "${e.id}" is already registered. Types cannot be modified or re-registered.`,details:{typeId:e.id}});this.types.set(e.id,e)}get(e){return this.types.get(e)}listByCategory(e){let t=[];for(let n of this.types.values())n.category===e&&t.push(n);return t}validate(e,n){let r=this.types.get(e);if(!r)return{success:!1,error:t.n.fromCode(`VALIDATION_ERROR`,{body:`Node type "${e}" is not registered`,details:{typeId:e}})};try{return{success:!0,data:r.schema.parse(n)}}catch(n){return{success:!1,error:t.n.fromCode(`VALIDATION_ERROR`,{body:`Data validation failed for type "${e}"`,cause:n,details:{typeId:e,validationErrors:n}})}}}has(e){return this.types.has(e)}size(){return this.types.size}};const c=new s;function l(e,t){return c.validate(e,t)}let u=function(e){return e.input=`input`,e.process=`process`,e.conditional=`conditional`,e.multiplex=`multiplex`,e.merge=`merge`,e}({});function d({id:e,name:n,description:i,type:a,inputSchema:o,outputSchema:s,run:l,condition:d,multiInput:f=!1,multiOutput:p=!1,pausable:m=!1,retry:h,nodeTypeId:g,keepOutput:_=!1}){return r.Effect.gen(function*(){if(g){let n=c.get(g);if(!n)return yield*t.n.fromCode(`INVALID_NODE_TYPE`,{body:`Node type "${g}" is not registered`,details:{nodeTypeId:g,nodeId:e}}).toEffect();if(a===u.input&&n.category!==`input`)return yield*t.n.fromCode(`TYPE_CATEGORY_MISMATCH`,{body:`Node type "${g}" is registered as "${n.category}" but node "${e}" is type "${a}"`,details:{nodeTypeId:g,nodeId:e,expectedCategory:`input`,actualCategory:n.category}}).toEffect()}return{id:e,name:n,description:i,type:a,nodeTypeId:g||`${a}-node`,keepOutput:_,inputSchema:o,outputSchema:s,pausable:m,run:({data:i,jobId:a,flowId:c,storageId:u,clientId:d})=>r.Effect.gen(function*(){let f=yield*l({data:yield*r.Effect.try({try:()=>o.parse(i),catch:r=>{let i=r instanceof Error?r.message:String(r);return t.n.fromCode(`FLOW_INPUT_VALIDATION_ERROR`,{body:`Node '${n}' (${e}) input validation failed: ${i}`,cause:r})}}),jobId:a,storageId:u,flowId:c,clientId:d});return f.type===`waiting`?{type:`waiting`,partialData:f.partialData,nodeType:g,nodeId:e}:{type:`complete`,data:yield*r.Effect.try({try:()=>s.parse(f.data),catch:r=>{let i=r instanceof Error?r.message:String(r);return t.n.fromCode(`FLOW_OUTPUT_VALIDATION_ERROR`,{body:`Node '${n}' (${e}) output validation failed: ${i}`,cause:r})}}),nodeType:g,nodeId:e}}),condition:d,multiInput:f,multiOutput:p,retry:h}})}const f=e=>({id:e.id,name:e.name,description:e.description,type:e.type,nodeTypeId:e.nodeTypeId}),p=e=>({type:`complete`,data:e}),m=e=>({type:`waiting`,partialData:e}),h=(e,t)=>{if(e===t)return!0;try{return!!(e&&t&&typeof e==`object`&&typeof t==`object`)}catch{return!0}};var g=class{typeChecker;constructor(e=h){this.typeChecker=e}validateConnection(e,t,n){return this.getCompatibleTypes(e.outputSchema,t.inputSchema)}getCompatibleTypes(e,t){return this.typeChecker(e,t)}validateFlow(e,t){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(!t){n.push(`Source node ${e.source} not found`);continue}if(!i){n.push(`Target node ${e.target} not found`);continue}this.validateConnection(t,i,e)||n.push(`Schema mismatch: ${t.id} output schema incompatible with ${i.id} input schema`)}return{isValid:n.length===0,errors:n}}getExpectedInputSchemas(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i={};for(let t of n)if(t.target===e){let e=r.get(t.source);if(e){let n=t.sourcePort||t.source;i[n]=e.outputSchema}}return i}getActualOutputSchemas(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i={};for(let t of n)if(t.source===e){let e=r.get(t.target);if(e){let n=t.targetPort||t.target;i[n]=e.inputSchema}}return i}validateData(e,t){try{return t.parse(e),{isValid:!0,errors:[]}}catch(e){return e instanceof Error&&`errors`in e?{isValid:!1,errors:e.errors.map(e=>`${e.path.join(`.`)}: ${e.message}`)}:{isValid:!1,errors:[e instanceof Error?e.message:`Validation failed`]}}}};function _(e){if(!e)return{type:``,fileName:``,metadata:void 0,metadataJson:void 0};let t={...e},n=String(t.type||t.mimeType||t[`content-type`]||``);n&&(t.type||=n,t.mimeType||=n);let r=String(t.fileName||t.originalName||t.name||``);return r&&(t.fileName||=r,t.originalName||=r,t.name||=r),{type:n,fileName:r,metadata:t,metadataJson:JSON.stringify(t)}}const v=i.z.object({operation:i.z.literal(`init`),storageId:i.z.string(),metadata:i.z.record(i.z.string(),i.z.any()).optional()}),y=i.z.object({operation:i.z.literal(`finalize`),uploadId:i.z.string()}),b=i.z.object({operation:i.z.literal(`url`),url:i.z.string(),storageId:i.z.string().optional(),metadata:i.z.record(i.z.string(),i.z.any()).optional()}),x=i.z.union([v,y,b]),S=i.z.object({allowedMimeTypes:i.z.array(i.z.string()).optional(),minSize:i.z.number().positive().optional(),maxSize:i.z.number().positive().optional()});function C(e,n){return r.Effect.gen(function*(){if(n){if(n.allowedMimeTypes&&n.allowedMimeTypes.length>0&&!n.allowedMimeTypes.some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-2);return e.type.startsWith(n)}return e.type===t}))throw yield*t.n.fromCode(`VALIDATION_ERROR`,{cause:Error(`File type "${e.type}" is not allowed. Allowed types: ${n.allowedMimeTypes.join(`, `)}`)}).toEffect();if(n.minSize!==void 0&&e.size<n.minSize)throw yield*t.n.fromCode(`VALIDATION_ERROR`,{cause:Error(`File size (${e.size} bytes) is below minimum (${n.minSize} bytes)`)}).toEffect();if(n.maxSize!==void 0&&e.size>n.maxSize)throw yield*t.n.fromCode(`VALIDATION_ERROR`,{cause:Error(`File size (${e.size} bytes) exceeds maximum (${n.maxSize} bytes)`)}).toEffect()}})}function w(i,a,o){let s=o?.keepOutput??!1;return r.Effect.gen(function*(){let o=yield*n.n;return yield*d({id:i,name:`Input`,description:`Handles file input through multiple methods - streaming upload (init/finalize) or direct URL fetch`,type:u.input,inputSchema:x,outputSchema:e.D,keepOutput:s,nodeTypeId:O,run:({data:e,flowId:s,jobId:c,clientId:l})=>r.Effect.gen(function*(){switch(e.operation){case`init`:{let t={storageId:e.storageId,size:e.metadata?.size||0,type:e.metadata?.mimeType||`application/octet-stream`,fileName:e.metadata?.originalName,lastModified:e.metadata?.size?Date.now():void 0,metadata:e.metadata?JSON.stringify(e.metadata):void 0,flow:{flowId:s,nodeId:i,jobId:c}};return m(yield*o.createUpload(t,l))}case`finalize`:{let t=yield*o.getUpload(e.uploadId),{type:n}=_(t.metadata);return yield*C({type:n,size:t.size||0},a),p(t)}case`url`:{let t=yield*n.o(e.url),r=yield*n.a(t),u=e.metadata?.mimeType||t.headers.get(`content-type`)||`application/octet-stream`,d=e.metadata?.size||Number(t.headers.get(`content-length`)||0),f=e.metadata?.originalName||e.url.split(`/`).pop()||`file`;yield*C({type:u,size:d},a);let m=new ReadableStream({start(e){e.enqueue(new Uint8Array(r)),e.close()}}),h={storageId:e.storageId||`buffer`,size:d,type:u,fileName:f,lastModified:Date.now(),metadata:e.metadata?JSON.stringify(e.metadata):void 0};return p({...yield*o.upload(h,l,m),flow:{flowId:s,nodeId:i,jobId:c}})}default:throw yield*t.n.fromCode(`VALIDATION_ERROR`,{cause:Error(`Invalid operation`)}).toEffect()}})})})}const T=`storage-output-v1`,E=`ocr-output-v1`,D=`image-description-output-v1`,O=`streaming-input-v1`,k=i.z.object({extractedText:i.z.string(),format:i.z.enum([`markdown`,`plain`,`structured`]),taskType:i.z.enum([`convertToMarkdown`,`freeOcr`,`parseFigure`,`locateObject`]),confidence:i.z.number().min(0).max(1).optional()}),A=i.z.object({description:i.z.string(),confidence:i.z.number().min(0).max(1).optional(),metadata:i.z.record(i.z.string(),i.z.unknown()).optional()});c.register({id:O,category:`input`,schema:x,version:`1.0.0`,description:`Streaming file input with init/finalize/url operations for flexible file ingestion`}),c.register({id:T,category:`output`,schema:e.D,version:`1.0.0`,description:`Storage output node that saves files to configured storage backend`}),c.register({id:E,category:`output`,schema:k,version:`1.0.0`,description:`OCR output node that extracts structured text from documents using AI`}),c.register({id:D,category:`output`,schema:A,version:`1.0.0`,description:`Image description output node that generates AI-powered descriptions of images`});var j=class{maxConcurrency;constructor(e={}){this.maxConcurrency=e.maxConcurrency??4}groupNodesByExecutionLevel(e,t){let n={},r={};e.forEach(e=>{n[e.id]=[],r[e.id]=0}),t.forEach(e=>{n[e.source]?.push(e.target),r[e.target]=(r[e.target]||0)+1});let i=[],a=new Set,o=0;for(;a.size<e.length;){let e=Object.keys(r).filter(e=>r[e]===0&&!a.has(e));if(e.length===0)throw Error(`Cycle detected in flow graph - cannot execute in parallel`);i.push({level:o++,nodes:e}),e.forEach(e=>{a.add(e),delete r[e],n[e]?.forEach(e=>{r[e]!==void 0&&r[e]--})})}return i}executeNodesInParallel(e){return r.Effect.all(e.map(e=>e()),{concurrency:this.maxConcurrency})}canExecuteInParallel(e,t,n){return e.every(e=>(n[e]||[]).every(e=>t.has(e)))}getStats(){return{maxConcurrency:this.maxConcurrency}}};function M(e){return t=>{if(t.nodeType!==e)return!1;let n=c.get(e);return n?n.schema.safeParse(t.data).success:!1}}function N(t){return!t||typeof t!=`object`?!1:e.D.safeParse(t).success}const ee=M(`storage-output-v1`),te=M(E),ne=M(D);function P(e,t){return e.filter(t)}function re(e,n){return r.Effect.gen(function*(){let r=P(e,n);return r.length===0?yield*t.n.fromCode(`OUTPUT_NOT_FOUND`,{body:`No output of the specified type was found in the flow results`}).toEffect():r.length>1?yield*t.n.fromCode(`MULTIPLE_OUTPUTS_FOUND`,{body:`Found ${r.length} outputs of the specified type, expected exactly one`,details:{foundCount:r.length,nodeIds:r.map(e=>e.nodeId)}}).toEffect():r[0]})}function ie(e,t){return P(e,t)[0]}function ae(e,t){return e.find(e=>e.nodeId===t)}function oe(e,t){return e.some(t)}function se(e){return e.operation===`init`}function ce(e){return e.operation===`finalize`}function le(e){return e.operation===`url`}function ue(e){return e.operation===`init`||e.operation===`url`}const F=e=>({id:e.id,name:e.name,nodes:e.nodes.map(f),edges:e.edges});function I(n){return r.Effect.gen(function*(){let a=yield*r.Effect.all(n.nodes.map(e=>r.Effect.isEffect(e)?e:r.Effect.succeed(e))),{flowId:s,name:c,onEvent:l,checkJobStatus:u,edges:d,inputSchema:f,outputSchema:p,typeChecker:m}=n,h=a,_=new g(m),v=()=>{let e={},t={},n={};return h.forEach(r=>{e[r.id]=[],n[r.id]=[],t[r.id]=0}),d.forEach(r=>{e[r.source]?.push(r.target),n[r.target]?.push(r.source),t[r.target]=(t[r.target]||0)+1}),{graph:e,reverseGraph:n,inDegree:t}},y=()=>{let{graph:e,inDegree:t}=v(),n=[],r=[];for(Object.keys(t).forEach(e=>{t[e]===0&&n.push(e)});n.length>0;){let i=n.shift();if(!i)throw Error(`No current node found`);r.push(i),e[i]?.forEach(e=>{t[e]=(t[e]||0)-1,t[e]===0&&n.push(e)})}return r},b=(e,t)=>{if(!e.condition)return r.Effect.succeed(!0);let{field:n,operator:i,value:a}=e.condition,o=t,s=o?.metadata?.[n]||o?.[n],c=(()=>{switch(i){case`equals`:return s===a;case`notEquals`:return s!==a;case`greaterThan`:return Number(s)>Number(a);case`lessThan`:return Number(s)<Number(a);case`contains`:return String(s).includes(String(a));case`startsWith`:return String(s).startsWith(String(a));default:return!0}})();return r.Effect.succeed(c)},x=(e,t)=>{let{reverseGraph:n}=v(),r=n[e]||[],i={};return r.forEach(e=>{let n=t.get(e);n!==void 0&&(i[e]=n)}),i},S=e=>{let t=h.filter(e=>e.type===`input`),n={};return t.forEach(t=>{e&&typeof e==`object`&&t.id in e&&(n[t.id]=f.parse(e[t.id]))}),n},C=e=>!d.some(t=>t.source===e),w=e=>{let t=h.find(t=>t.id===e);return C(e)||t?.keepOutput===!0},T=e=>{let t=h.filter(e=>w(e.id)),n={};return t.forEach(t=>{let r=e.get(t.id);r!==void 0&&(n[t.id]=r)}),n},E=(e,t)=>{let n=h.filter(e=>w(e.id)),r=[];return n.forEach(n=>{let i=e.get(n.id);if(i!==void 0){let e=t.get(n.id);r.push({nodeId:n.id,nodeType:e,data:i,timestamp:new Date().toISOString()})}}),r},D=(t,n,i)=>r.Effect.gen(function*(){if(t.storage.id===n)return t;let a=yield*e.w,o=yield*a.getDataStore(t.storage.id,i),s=yield*a.getDataStore(n,i),c=yield*o.read(t.id),l=r.Stream.make(c),u={...t,storage:{id:n,type:t.storage.type}},d=yield*s.create(u);return yield*s.write({file_id:d.id,stream:l,offset:0},{}),d}),O=(e,i,a,c,d,f,p)=>r.Effect.gen(function*(){let m=d.get(e);if(!m)return yield*t.n.fromCode(`FLOW_NODE_NOT_FOUND`).toEffect();if(u){let e=yield*u(f);if(e===`paused`)return yield*t.n.fromCode(`FLOW_PAUSED`,{cause:`Flow ${s} was paused by user at job ${f}`}).toEffect();if(e===`cancelled`)return yield*t.n.fromCode(`FLOW_CANCELLED`,{cause:`Flow ${s} was cancelled by user at job ${f}`}).toEffect()}l&&(yield*l({jobId:f,flowId:s,nodeId:e,eventType:o.NodeStart,nodeName:m.name,nodeType:m.type}));let h=m.retry?.maxRetries??0,g=m.retry?.retryDelay??1e3,_=m.retry?.exponentialBackoff??!0,v=0,y=null;for(;v<=h;)try{let u,d={};if(m.type===`input`){if(u=a[e],u===void 0)return yield*r.Effect.logError(`Input node ${e} has no input data`),yield*t.n.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Input node ${e} has no input data`)}).toEffect()}else{if(d=x(e,c),Object.keys(d).length===0)return yield*r.Effect.logError(`Node ${e} has no input data`),yield*t.n.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node ${e} has no input data`)}).toEffect();if(m.multiInput)u=d;else{let n=Object.keys(d)[0];if(!n)return yield*t.n.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node ${e} has no input data`)}).toEffect();u=d[n]}}if(m.type===`conditional`&&!(yield*b(m,u)))return l&&(yield*l({jobId:f,flowId:s,nodeId:e,eventType:o.NodeEnd,nodeName:m.name})),{nodeId:e,result:u,success:!0,waiting:!1};let h=yield*m.run({data:u,inputs:d,jobId:f,flowId:s,storageId:i,clientId:p});if(h.type===`waiting`){let t=h.partialData;return l&&(yield*l({jobId:f,flowId:s,nodeId:e,eventType:o.NodePause,nodeName:m.name,partialData:t})),{nodeId:e,result:t,success:!0,waiting:!0,nodeType:h.nodeType}}let g=h.data;if(w(e)&&(N(g)&&g.storage.id!==i&&(yield*r.Effect.logDebug(`Auto-persisting output node ${e} output from ${g.storage.id} to ${i}`),g=yield*D(g,i,p)),n.hooks?.onNodeOutput)){yield*r.Effect.logDebug(`Calling onNodeOutput hook for sink node ${e}`);let t=n.hooks.onNodeOutput({output:g,nodeId:e,flowId:s,jobId:f,storageId:i,clientId:p});g=yield*r.Effect.isEffect(t)?t:r.Effect.promise(()=>t)}return l&&(yield*l({jobId:f,flowId:s,nodeId:e,eventType:o.NodeEnd,nodeName:m.name,result:g})),{nodeId:e,result:g,success:!0,waiting:!1,nodeType:h.nodeType}}catch(n){if(y=n instanceof t.n?n:t.n.fromCode(`FLOW_NODE_ERROR`,{cause:n}),v<h){v++;let t=_?g*2**(v-1):g;yield*r.Effect.logWarning(`Node ${e} (${m.name}) failed, retrying (${v}/${h}) after ${t}ms`),yield*r.Effect.sleep(t);continue}return l&&(yield*l({jobId:f,flowId:s,nodeId:e,eventType:o.NodeError,nodeName:m.name,error:y.body,retryCount:v})),yield*y.toEffect()}return y?yield*y.toEffect():yield*t.n.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Unexpected error in retry loop`)}).toEffect()}),k=({inputs:e,storageId:a,jobId:c,resumeFrom:u,clientId:f})=>r.Effect.gen(function*(){!u&&l&&(yield*l({jobId:c,eventType:o.FlowStart,flowId:s}));let m=S(e||{}),g,_,v;u?(g=u.executionOrder,_=u.nodeResults,v=u.currentIndex):(g=y(),_=new Map,v=0);let b=new Map;if(g.length!==h.length)return yield*t.n.fromCode(`FLOW_CYCLE_ERROR`).toEffect();let x=new Map(h.map(e=>[e.id,e]));if(n.parallelExecution?.enabled??!1){yield*r.Effect.logDebug(`Flow ${s}: Executing in parallel mode (maxConcurrency: ${n.parallelExecution?.maxConcurrency??4})`);let e=new j({maxConcurrency:n.parallelExecution?.maxConcurrency??4}),t=e.groupNodesByExecutionLevel(h,d);yield*r.Effect.logDebug(`Flow ${s}: Grouped nodes into ${t.length} execution levels`);let i={};h.forEach(e=>{i[e.id]=[]}),d.forEach(e=>{i[e.target]?.push(e.source)});for(let n of t){yield*r.Effect.logDebug(`Flow ${s}: Executing level ${n.level} with nodes: ${n.nodes.join(`, `)}`);let t=n.nodes.map(e=>()=>r.Effect.gen(function*(){if(u&&e===u.executionOrder[v]&&l){let t=x.get(e);t&&(yield*l({jobId:c,flowId:s,nodeId:e,eventType:o.NodeResume,nodeName:t.name,nodeType:t.type}))}return{nodeId:e,nodeResult:yield*O(e,a,m,_,x,c,f)}})),i=yield*e.executeNodesInParallel(t);for(let{nodeId:e,nodeResult:t}of i){if(t.waiting)return t.result!==void 0&&(_.set(e,t.result),t.nodeType&&b.set(e,t.nodeType)),{type:`paused`,nodeId:e,executionState:{executionOrder:g,currentIndex:g.indexOf(e),inputs:m}};t.success&&(_.set(e,t.result),t.nodeType&&b.set(e,t.nodeType))}}}else{yield*r.Effect.logDebug(`Flow ${s}: Executing in sequential mode`);for(let e=v;e<g.length;e++){let n=g[e];if(!n)return yield*t.n.fromCode(`FLOW_NODE_NOT_FOUND`).toEffect();if(u&&e===v&&l){let e=x.get(n);e&&(yield*l({jobId:c,flowId:s,nodeId:n,eventType:o.NodeResume,nodeName:e.name,nodeType:e.type}))}let r=yield*O(n,a,m,_,x,c,f);if(r.waiting)return r.result!==void 0&&(_.set(r.nodeId,r.result),r.nodeType&&b.set(r.nodeId,r.nodeType)),{type:`paused`,nodeId:r.nodeId,executionState:{executionOrder:g,currentIndex:e,inputs:m}};r.success&&(_.set(r.nodeId,r.result),r.nodeType&&b.set(r.nodeId,r.nodeType))}}let C=T(_),D=E(_,b),k=i.z.record(i.z.string(),p).safeParse(C);if(!k.success){let e=`Flow output validation failed: ${k.error.message}. Expected outputs: ${JSON.stringify(Object.keys(T(_)))}. Output nodes (sinks + keepOutput): ${h.filter(e=>w(e.id)).map(e=>e.id).join(`, `)}`;return l&&(yield*l({jobId:c,eventType:o.FlowError,flowId:s,error:e})),yield*t.n.fromCode(`FLOW_OUTPUT_VALIDATION_ERROR`,{body:e,cause:k.error}).toEffect()}let A=k.data;return l&&(yield*l({jobId:c,eventType:o.FlowEnd,flowId:s,outputs:D,result:A})),{type:`completed`,result:A,outputs:D}});return{id:s,name:c,nodes:h,edges:d,inputSchema:f,outputSchema:p,onEvent:l,checkJobStatus:u,hooks:n.hooks,run:({inputs:e,storageId:t,jobId:n,clientId:r})=>k({inputs:e,storageId:t,jobId:n,clientId:r}),resume:({jobId:e,storageId:t,nodeResults:n,executionState:r,clientId:i})=>k({inputs:r.inputs,storageId:t,jobId:e,resumeFrom:{executionOrder:r.executionOrder,nodeResults:new Map(Object.entries(n)),currentIndex:r.currentIndex},clientId:i}),validateTypes:()=>{let e=h;return _.validateFlow(e,d)},validateInputs:e=>_.validateData(e,f),validateOutputs:e=>_.validateData(e,p)}})}var L=class e extends r.Context.Tag(`FlowWaitUntil`)(){static optional=r.Effect.serviceOption(e)},R=class extends r.Context.Tag(`FlowProvider`)(){},z=class extends r.Context.Tag(`FlowServer`)(){};const B=e=>typeof e==`object`&&!!e&&`id`in e,de=e=>typeof e==`object`&&e&&`nodeId`in e&&`data`in e&&`timestamp`in e?e.data:e;function V(e,n,i){let a=t=>{let a=e=>r.Effect.gen(function*(){let n=yield*i.get(t);n&&(yield*i.set(t,{...n,...e,updatedAt:new Date}))});return s=>r.Effect.gen(function*(){switch(e.onEvent&&(yield*r.Effect.catchAll(e.onEvent(s),e=>(r.Effect.logError(`Original onEvent failed`,e),r.Effect.succeed({eventId:null})))),yield*n.emit(t,s),r.Effect.logInfo(`Updating job ${t} with event ${s.eventType}`),s.eventType){case o.FlowStart:yield*a({status:`running`});break;case o.FlowEnd:yield*r.Effect.gen(function*(){let e=yield*i.get(t);e&&s.outputs&&(yield*i.set(t,{...e,result:s.outputs,updatedAt:new Date}))});break;case o.FlowError:yield*a({status:`failed`,error:s.error});break;case o.NodeStart:yield*r.Effect.gen(function*(){let e=yield*i.get(t);if(e){let n=e.tasks.find(e=>e.nodeId===s.nodeId)?e.tasks.map(e=>e.nodeId===s.nodeId?{...e,status:`running`,updatedAt:new Date}:e):[...e.tasks,{nodeId:s.nodeId,status:`running`,createdAt:new Date,updatedAt:new Date}];yield*i.set(t,{...e,tasks:n,updatedAt:new Date})}});break;case o.NodePause:yield*r.Effect.gen(function*(){let e=yield*i.get(t);if(e){let n=e.tasks.find(e=>e.nodeId===s.nodeId)?e.tasks.map(e=>e.nodeId===s.nodeId?{...e,status:`paused`,result:s.partialData,updatedAt:new Date}:e):[...e.tasks,{nodeId:s.nodeId,status:`paused`,result:s.partialData,createdAt:new Date,updatedAt:new Date}];yield*i.set(t,{...e,tasks:n,updatedAt:new Date})}});break;case o.NodeResume:yield*r.Effect.gen(function*(){let e=yield*i.get(t);if(e){let n=e.tasks.map(e=>e.nodeId===s.nodeId?{...e,status:`running`,updatedAt:new Date}:e);yield*i.set(t,{...e,tasks:n,updatedAt:new Date})}});break;case o.NodeEnd:yield*r.Effect.gen(function*(){let n=yield*i.get(t);if(n){let a=n.tasks.map(e=>e.nodeId===s.nodeId?{...e,status:`completed`,result:s.result,updatedAt:new Date}:e),o=!e.edges.some(e=>e.source===s.nodeId),c=e.nodes.find(e=>e.id===s.nodeId)?.keepOutput===!0,l=s.result,u=de(l),d=n.intermediateFiles||[],f=o||c;f&&B(u)&&u.id?(d=d.filter(e=>e!==u.id),c&&!o&&r.Effect.logInfo(`Preserving output from node ${s.nodeId} due to keepOutput flag`)):!f&&B(u)&&u.id&&(d.includes(u.id)||d.push(u.id)),yield*i.set(t,{...n,tasks:a,intermediateFiles:d,updatedAt:new Date})}});break;case o.NodeError:yield*r.Effect.gen(function*(){let e=yield*i.get(t);if(e){let n=e.tasks.map(e=>e.nodeId===s.nodeId?{...e,status:`failed`,error:s.error,retryCount:s.retryCount,updatedAt:new Date}:e);yield*i.set(t,{...e,tasks:n,error:s.error,updatedAt:new Date})}});break}return{eventId:t}})},s=e=>e=>r.Effect.gen(function*(){let n=yield*i.get(e);return n?n.status===`paused`?`paused`:n.status===`cancelled`?`cancelled`:`running`:yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`}))});return{...e,run:t=>r.Effect.gen(function*(){let n=t.jobId||crypto.randomUUID(),r=a(n),i=s(n);return yield*(yield*I({flowId:e.id,name:e.name,nodes:e.nodes,edges:e.edges,inputSchema:e.inputSchema,outputSchema:e.outputSchema,onEvent:r,checkJobStatus:i})).run({...t,jobId:n,clientId:t.clientId})}),resume:t=>r.Effect.gen(function*(){let n=t.jobId,r=a(n),i=s(n);return yield*(yield*I({flowId:e.id,name:e.name,nodes:e.nodes,edges:e.edges,inputSchema:e.inputSchema,outputSchema:e.outputSchema,onEvent:r,checkJobStatus:i})).resume(t)})}}function H(){return r.Effect.gen(function*(){let i=yield*R,a=yield*e.h,s=yield*e.s,c=yield*n.n,l=(e,n)=>r.Effect.gen(function*(){let i=yield*s.get(e);return i?yield*s.set(e,{...i,...n}):yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`}))}),u=(e,t)=>r.Effect.gen(function*(){let n=yield*s.get(e);!n||!n.intermediateFiles||n.intermediateFiles.length===0||(yield*r.Effect.logInfo(`Cleaning up ${n.intermediateFiles.length} intermediate files for job ${e}`),yield*r.Effect.all(n.intermediateFiles.map(e=>r.Effect.gen(function*(){yield*c.delete(e,t),yield*r.Effect.logDebug(`Deleted intermediate file ${e}`)}).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logWarning(`Failed to delete intermediate file ${e}: ${t}`),r.Effect.succeed(void 0)})))),{concurrency:5}),yield*l(e,{intermediateFiles:[]}))}),d=({jobId:e,flow:n,storageId:i,clientId:c,inputs:d})=>r.Effect.gen(function*(){console.log(`[FlowServer] executeFlowInBackground started for job: ${e}`),yield*l(e,{status:`running`}),console.log(`[FlowServer] Creating flowWithEvents for job: ${e}`);let t=V(n,a,s);console.log(`[FlowServer] Running flow for job: ${e}`);let r=yield*t.run({inputs:d,storageId:i,jobId:e,clientId:c});return console.log(`[FlowServer] Flow completed for job: ${e}, result type: ${r.type}`),r.type===`paused`?yield*l(e,{status:`paused`,pausedAt:r.nodeId,executionState:r.executionState,updatedAt:new Date}):(yield*l(e,{status:`completed`,updatedAt:new Date,endedAt:new Date}),yield*u(e,c)),r}).pipe(r.Effect.catchAll(n=>r.Effect.gen(function*(){yield*r.Effect.logError(`Flow execution failed`,n);let i=n instanceof t.n?n.body:String(n);yield*r.Effect.logInfo(`Updating job ${e} to failed status with error: ${i}`),yield*l(e,{status:`failed`,error:i,updatedAt:new Date}).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to update job ${e}`,t),r.Effect.succeed(void 0)})));let d=yield*s.get(e);throw d&&(yield*a.emit(e,{jobId:e,eventType:o.FlowError,flowId:d.flowId,error:i}).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to emit FlowError event for job ${e}`,t),r.Effect.succeed(void 0)})))),yield*u(e,c).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logWarning(`Failed to cleanup intermediate files for job ${e}`,t),r.Effect.succeed(void 0)}))),n})));return{getFlow:(e,t)=>r.Effect.gen(function*(){return yield*i.getFlow(e,t)}),getFlowData:(e,t)=>r.Effect.gen(function*(){return F(yield*i.getFlow(e,t))}),runFlow:({flowId:e,storageId:n,clientId:a,inputs:o})=>r.Effect.gen(function*(){let c=yield*L.optional,l=yield*r.Effect.try({try:()=>$.parse({inputs:o}),catch:e=>t.n.fromCode(`FLOW_INPUT_VALIDATION_ERROR`,{cause:e})}),u=crypto.randomUUID(),f=new Date,p={id:u,flowId:e,storageId:n,clientId:a,status:`started`,createdAt:f,updatedAt:f,tasks:[]};yield*s.set(u,p);let m=yield*i.getFlow(e,a);console.log(`[FlowServer] About to fork flow execution for job: ${u}`);let h=d({jobId:u,flow:m,storageId:n,clientId:a,inputs:l.inputs}).pipe(r.Effect.tapErrorCause(e=>r.Effect.logError(`Flow execution failed`,e)));if(r.Option.isSome(c)){console.log(`[FlowServer] Using waitUntil for job: ${u}`);let e=yield*r.Effect.runtime(),t=r.Runtime.runPromise(e)(h);c.value(t)}else console.log(`[FlowServer] Using Effect.forkDaemon for job: ${u}`),yield*r.Effect.forkDaemon(h);return console.log(`[FlowServer] Flow execution started for job: ${u}`),p}),getJobStatus:e=>r.Effect.gen(function*(){return(yield*s.get(e))||(yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`})))}),resumeFlow:({jobId:e,nodeId:n,newData:c,clientId:d})=>r.Effect.gen(function*(){let f=yield*L.optional,p=yield*s.get(e);if(!p)return console.error(`Job not found`),yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`}));if(p.status!==`paused`)return console.error(`Job is not paused`),yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} is not paused (status: ${p.status})`}));if(p.pausedAt!==n)return console.error(`Job is not paused at the expected node`),yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} is paused at node ${p.pausedAt}, not ${n}`}));if(!p.executionState)return console.error(`Job has no execution state`),yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} has no execution state`}));let m={...p.tasks.reduce((e,t)=>(t.result!==void 0&&(e[t.nodeId]=t.result),e),{}),[n]:c},h={...p.executionState.inputs,[n]:c};yield*l(e,{status:`running`});let g=yield*i.getFlow(p.flowId,p.clientId),_=r.Effect.gen(function*(){let n=V(g,a,s);if(!p.executionState)return yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} has no execution state`}));let i=yield*n.resume({jobId:e,storageId:p.storageId,nodeResults:m,executionState:{...p.executionState,inputs:h},clientId:p.clientId});return i.type===`paused`?yield*l(e,{status:`paused`,pausedAt:i.nodeId,executionState:i.executionState,updatedAt:new Date}):(yield*l(e,{status:`completed`,pausedAt:void 0,executionState:void 0,updatedAt:new Date,endedAt:new Date}),yield*u(e,d)),i}).pipe(r.Effect.catchAll(n=>r.Effect.gen(function*(){yield*r.Effect.logError(`Flow resume failed`,n);let i=n instanceof t.n?n.body:String(n);yield*r.Effect.logInfo(`Updating job ${e} to failed status with error: ${i}`),yield*l(e,{status:`failed`,error:i,updatedAt:new Date}).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to update job ${e}`,t),r.Effect.succeed(void 0)})));let c=yield*s.get(e);throw c&&(yield*a.emit(e,{jobId:e,eventType:o.FlowError,flowId:c.flowId,error:i}).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to emit FlowError event for job ${e}`,t),r.Effect.succeed(void 0)})))),yield*u(e,d).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logWarning(`Failed to cleanup intermediate files for job ${e}`,t),r.Effect.succeed(void 0)}))),n}))).pipe(r.Effect.tapErrorCause(e=>r.Effect.logError(`Flow resume failed`,e)));if(r.Option.isSome(f)){console.log(`[FlowServer] Using waitUntil for resume job: ${e}`);let t=yield*r.Effect.runtime(),n=r.Runtime.runPromise(t)(_);f.value(n)}else console.log(`[FlowServer] Using Effect.forkDaemon for resume job: ${e}`),yield*r.Effect.forkDaemon(_);return(yield*s.get(e))||(yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found after update`})))}),pauseFlow:(e,n)=>r.Effect.gen(function*(){let i=yield*s.get(e);if(!i)return yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`}));if(n!==null&&i.clientId!==n)return yield*r.Effect.fail(t.n.fromCode(`FLOW_NOT_AUTHORIZED`,{cause:`Client ${n} is not authorized to pause job ${e}`}));if(i.status!==`running`)return yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} cannot be paused (current status: ${i.status})`}));let c=i.tasks.find(e=>e.status===`running`)?.nodeId;return yield*l(e,{status:`paused`,pausedAt:c,updatedAt:new Date}),yield*a.emit(e,{jobId:e,flowId:i.flowId,eventType:o.FlowPause,pausedAt:c}),(yield*s.get(e))||(yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found after pause`})))}),cancelFlow:(e,n)=>r.Effect.gen(function*(){let i=yield*s.get(e);return i?n!==null&&i.clientId!==n?yield*r.Effect.fail(t.n.fromCode(`FLOW_NOT_AUTHORIZED`,{cause:`Client ${n} is not authorized to cancel job ${e}`})):i.status!==`running`&&i.status!==`paused`&&i.status!==`started`?yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${e} cannot be cancelled (current status: ${i.status})`})):(yield*l(e,{status:`cancelled`,updatedAt:new Date,endedAt:new Date}),yield*a.emit(e,{jobId:e,flowId:i.flowId,eventType:o.FlowCancel}),yield*u(e,n),(yield*s.get(e))||(yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found after cancellation`})))):yield*r.Effect.fail(t.n.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${e} not found`}))}),subscribeToFlowEvents:(e,t)=>r.Effect.gen(function*(){yield*a.subscribe(e,t)}),unsubscribeFromFlowEvents:e=>r.Effect.gen(function*(){yield*a.unsubscribe(e)})}})}const fe=r.Layer.effect(z,H());function pe({id:t,name:i,description:a,nodeTypeId:o,keepOutput:s,transform:c}){return r.Effect.gen(function*(){let l=yield*n.n;return yield*d({id:t,name:i,description:a,type:u.process,nodeTypeId:o,keepOutput:s,inputSchema:e.D,outputSchema:e.D,run:({data:e,storageId:n,flowId:i,jobId:a,clientId:o})=>r.Effect.gen(function*(){let r={flowId:i,nodeId:t,jobId:a},s=yield*c(yield*l.read(e.id,o),e),u=s instanceof Uint8Array?s:s.bytes,d=s instanceof Uint8Array?void 0:s.type,f=s instanceof Uint8Array?void 0:s.fileName,m=new ReadableStream({start(e){e.enqueue(u),e.close()}}),{type:h,fileName:g,metadata:v,metadataJson:y}=_(e.metadata),b=yield*l.upload({storageId:n,size:u.byteLength,type:d??h,fileName:f??g,lastModified:0,metadata:y,flow:r},o,m),x=v?{...v,...d&&{mimeType:d,type:d,"content-type":d},...f&&{fileName:f,originalName:f,name:f,extension:f.split(`.`).pop()||v.extension}}:b.metadata;return p(x?{...b,metadata:x}:b)})})})}var me=class extends r.Context.Tag(`CredentialProvider`)(){},he=class extends r.Context.Tag(`DocumentAiPlugin`)(){},ge=class extends r.Context.Tag(`DocumentPlugin`)(){},_e=class extends r.Context.Tag(`ImageAiPlugin`)(){},ve=class extends r.Context.Tag(`ImagePlugin`)(){};const ye=i.z.object({serviceType:i.z.enum([`replicate`]).optional()}),be=i.z.object({duration:i.z.number().nonnegative(),width:i.z.number().positive(),height:i.z.number().positive(),codec:i.z.string(),format:i.z.string(),bitrate:i.z.number().nonnegative(),frameRate:i.z.number().positive(),aspectRatio:i.z.string(),hasAudio:i.z.boolean(),audioCodec:i.z.string().optional(),audioBitrate:i.z.number().nonnegative().optional(),size:i.z.number().nonnegative()}),xe=i.z.object({timestamp:i.z.number().nonnegative(),format:i.z.enum([`png`,`jpeg`]).optional(),quality:i.z.number().min(1).max(100).optional()}),Se=i.z.object({quality:i.z.number().min(0).max(100),format:i.z.enum([`jpeg`,`webp`,`png`,`avif`])}),Ce=i.z.object({serviceType:i.z.enum([`replicate`]).optional()}),we=i.z.object({width:i.z.number().positive().optional(),height:i.z.number().positive().optional(),fit:i.z.enum([`contain`,`cover`,`fill`])}).refine(e=>e.width||e.height,`Either width or height must be specified for resize`),Te=i.z.object({width:i.z.number().positive().optional(),height:i.z.number().positive().optional(),aspectRatio:i.z.enum([`keep`,`ignore`]).optional(),scaling:i.z.enum([`bicubic`,`bilinear`,`lanczos`]).optional()}).refine(e=>e.width||e.height,`Either width or height must be specified for video resize`),Ee=i.z.object({format:i.z.enum([`mp4`,`webm`,`mov`,`avi`]),codec:i.z.enum([`h264`,`h265`,`vp9`,`av1`]).optional(),videoBitrate:i.z.string().optional(),audioBitrate:i.z.string().optional(),audioCodec:i.z.enum([`aac`,`mp3`,`opus`,`vorbis`]).optional()}),U=i.z.object({type:i.z.literal(`resize`),width:i.z.number().positive().optional(),height:i.z.number().positive().optional(),fit:i.z.enum([`contain`,`cover`,`fill`])}),W=i.z.object({type:i.z.literal(`blur`),sigma:i.z.number().min(.3).max(1e3)}),G=i.z.object({type:i.z.literal(`rotate`),angle:i.z.number(),background:i.z.string().optional()}),K=i.z.object({type:i.z.literal(`flip`),direction:i.z.enum([`horizontal`,`vertical`])}),q=i.z.object({type:i.z.literal(`grayscale`)}),J=i.z.object({type:i.z.literal(`sepia`)}),Y=i.z.object({type:i.z.literal(`brightness`),value:i.z.number().min(-100).max(100)}),X=i.z.object({type:i.z.literal(`contrast`),value:i.z.number().min(-100).max(100)}),Z=i.z.object({type:i.z.literal(`sharpen`),sigma:i.z.number().positive().optional()}),Q=i.z.object({type:i.z.literal(`watermark`),imagePath:i.z.string().min(1).url(),position:i.z.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),opacity:i.z.number().min(0).max(1),offsetX:i.z.number().optional(),offsetY:i.z.number().optional()}),De=i.z.object({type:i.z.literal(`logo`),imagePath:i.z.string().min(1).url(),position:i.z.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),scale:i.z.number().min(.1).max(2),offsetX:i.z.number().optional(),offsetY:i.z.number().optional()}),Oe=i.z.object({type:i.z.literal(`text`),text:i.z.string().min(1),position:i.z.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),fontSize:i.z.number().positive(),color:i.z.string().min(1),fontFamily:i.z.string().optional(),offsetX:i.z.number().optional(),offsetY:i.z.number().optional()}),ke=i.z.discriminatedUnion(`type`,[U,W,G,K,q,J,Y,X,Z,Q,De,Oe]),Ae=i.z.object({transformations:i.z.array(ke).min(1)}),je=i.z.object({startTime:i.z.number().nonnegative(),endTime:i.z.number().positive().optional(),duration:i.z.number().positive().optional()}).refine(e=>!e.endTime||!e.duration,`Cannot specify both endTime and duration`).refine(e=>!e.endTime||e.endTime>e.startTime,`endTime must be greater than startTime`);var Me=class extends r.Context.Tag(`VideoPlugin`)(){},Ne=class extends r.Context.Tag(`VirusScanPlugin`)(){},Pe=class extends r.Context.Tag(`ZipPlugin`)(){};const Fe=(e,t)=>{if(e.length===0)return t;let[n,...r]=e;return r.reduce((e,t)=>i.z.union([e,t]),n)};function Ie(e){return r.Effect.gen(function*(){let n=Object.entries(e.nodes),a=e=>r.Effect.isEffect(e)?e:r.Effect.succeed(e),o=yield*r.Effect.forEach(n,([e,n])=>r.Effect.flatMap(a(n),n=>n.id===e?r.Effect.succeed([e,n]):r.Effect.fail(t.n.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node key ${e} does not match node id ${n.id}`)})))),s=Object.fromEntries(o),c=o.map(([,e])=>e),l=o.filter(([,e])=>e.type===u.input).map(([,e])=>e.inputSchema),d=e.edges.map(e=>({source:s[e.source]?.id??e.source,target:s[e.target]?.id??e.target,sourcePort:e.sourcePort,targetPort:e.targetPort})),f=new Set(o.map(([e])=>s[e]?.id).filter(e=>e&&!d.some(t=>t.source===e))),p=o.filter(([,e])=>f.has(e.id)).map(([,e])=>e.outputSchema),m=e.inputSchema??Fe(l,i.z.unknown()),h=e.outputSchema??Fe(p,i.z.unknown());return yield*I({flowId:e.flowId,name:e.name,nodes:c,edges:d,inputSchema:m,outputSchema:h,typeChecker:e.typeChecker,onEvent:e.onEvent,parallelExecution:e.parallelExecution,hooks:e.hooks})})}const $=i.z.object({inputs:i.z.record(i.z.string(),i.z.any())});Object.defineProperty(exports,`$`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`B`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`G`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`H`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`J`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`K`,{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`Q`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,`St`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,`U`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`V`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`W`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`X`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`Y`,{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,`Z`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,`_t`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`at`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`bt`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`ct`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`dt`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`et`,{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`ft`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`gt`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`ht`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,`it`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`lt`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`mt`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`nt`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`ot`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`pt`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`q`,{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`rt`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`st`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`tt`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`ut`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`vt`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`xt`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`yt`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`z`,{enumerable:!0,get:function(){return fe}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./uploadista-error-djFxVTLh.mjs";import{D as t,h as n,s as r,w as i}from"./types-f6w5J3UD.mjs";import{a,n as o,o as s}from"./upload-Bq9h95w6.mjs";import{Context as c,Effect as l,Layer as u,Option as d,Runtime as f,Stream as p}from"effect";import{z as m}from"zod";function h({source:e,target:t,sourcePort:n,targetPort:r}){return{source:e,target:t,sourcePort:n,targetPort:r}}let g=function(e){return e.JobStart=`job-start`,e.JobEnd=`job-end`,e.FlowStart=`flow-start`,e.FlowEnd=`flow-end`,e.FlowError=`flow-error`,e.FlowPause=`flow-pause`,e.FlowCancel=`flow-cancel`,e.NodeStart=`node-start`,e.NodeEnd=`node-end`,e.NodePause=`node-pause`,e.NodeResume=`node-resume`,e.NodeError=`node-error`,e.NodeStream=`node-stream`,e.NodeResponse=`node-response`,e}({});var _=class{types;constructor(){this.types=new Map}register(t){if(this.types.has(t.id))throw e.fromCode(`VALIDATION_ERROR`,{body:`Node type "${t.id}" is already registered. Types cannot be modified or re-registered.`,details:{typeId:t.id}});this.types.set(t.id,t)}get(e){return this.types.get(e)}listByCategory(e){let t=[];for(let n of this.types.values())n.category===e&&t.push(n);return t}validate(t,n){let r=this.types.get(t);if(!r)return{success:!1,error:e.fromCode(`VALIDATION_ERROR`,{body:`Node type "${t}" is not registered`,details:{typeId:t}})};try{return{success:!0,data:r.schema.parse(n)}}catch(n){return{success:!1,error:e.fromCode(`VALIDATION_ERROR`,{body:`Data validation failed for type "${t}"`,cause:n,details:{typeId:t,validationErrors:n}})}}}has(e){return this.types.has(e)}size(){return this.types.size}};const v=new _;function y(e,t){return v.validate(e,t)}let b=function(e){return e.input=`input`,e.process=`process`,e.conditional=`conditional`,e.multiplex=`multiplex`,e.merge=`merge`,e}({});function x({id:t,name:n,description:r,type:i,inputSchema:a,outputSchema:o,run:s,condition:c,multiInput:u=!1,multiOutput:d=!1,pausable:f=!1,retry:p,nodeTypeId:m,keepOutput:h=!1}){return l.gen(function*(){if(m){let n=v.get(m);if(!n)return yield*e.fromCode(`INVALID_NODE_TYPE`,{body:`Node type "${m}" is not registered`,details:{nodeTypeId:m,nodeId:t}}).toEffect();if(i===b.input&&n.category!==`input`)return yield*e.fromCode(`TYPE_CATEGORY_MISMATCH`,{body:`Node type "${m}" is registered as "${n.category}" but node "${t}" is type "${i}"`,details:{nodeTypeId:m,nodeId:t,expectedCategory:`input`,actualCategory:n.category}}).toEffect()}return{id:t,name:n,description:r,type:i,nodeTypeId:m||`${i}-node`,keepOutput:h,inputSchema:a,outputSchema:o,pausable:f,run:({data:r,jobId:i,flowId:c,storageId:u,clientId:d})=>l.gen(function*(){let f=yield*s({data:yield*l.try({try:()=>a.parse(r),catch:r=>{let i=r instanceof Error?r.message:String(r);return e.fromCode(`FLOW_INPUT_VALIDATION_ERROR`,{body:`Node '${n}' (${t}) input validation failed: ${i}`,cause:r})}}),jobId:i,storageId:u,flowId:c,clientId:d});return f.type===`waiting`?{type:`waiting`,partialData:f.partialData,nodeType:m,nodeId:t}:{type:`complete`,data:yield*l.try({try:()=>o.parse(f.data),catch:r=>{let i=r instanceof Error?r.message:String(r);return e.fromCode(`FLOW_OUTPUT_VALIDATION_ERROR`,{body:`Node '${n}' (${t}) output validation failed: ${i}`,cause:r})}}),nodeType:m,nodeId:t}}),condition:c,multiInput:u,multiOutput:d,retry:p}})}const S=e=>({id:e.id,name:e.name,description:e.description,type:e.type,nodeTypeId:e.nodeTypeId}),C=e=>({type:`complete`,data:e}),w=e=>({type:`waiting`,partialData:e}),T=(e,t)=>{if(e===t)return!0;try{return!!(e&&t&&typeof e==`object`&&typeof t==`object`)}catch{return!0}};var E=class{typeChecker;constructor(e=T){this.typeChecker=e}validateConnection(e,t,n){return this.getCompatibleTypes(e.outputSchema,t.inputSchema)}getCompatibleTypes(e,t){return this.typeChecker(e,t)}validateFlow(e,t){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(!t){n.push(`Source node ${e.source} not found`);continue}if(!i){n.push(`Target node ${e.target} not found`);continue}this.validateConnection(t,i,e)||n.push(`Schema mismatch: ${t.id} output schema incompatible with ${i.id} input schema`)}return{isValid:n.length===0,errors:n}}getExpectedInputSchemas(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i={};for(let t of n)if(t.target===e){let e=r.get(t.source);if(e){let n=t.sourcePort||t.source;i[n]=e.outputSchema}}return i}getActualOutputSchemas(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i={};for(let t of n)if(t.source===e){let e=r.get(t.target);if(e){let n=t.targetPort||t.target;i[n]=e.inputSchema}}return i}validateData(e,t){try{return t.parse(e),{isValid:!0,errors:[]}}catch(e){return e instanceof Error&&`errors`in e?{isValid:!1,errors:e.errors.map(e=>`${e.path.join(`.`)}: ${e.message}`)}:{isValid:!1,errors:[e instanceof Error?e.message:`Validation failed`]}}}};function D(e){if(!e)return{type:``,fileName:``,metadata:void 0,metadataJson:void 0};let t={...e},n=String(t.type||t.mimeType||t[`content-type`]||``);n&&(t.type||=n,t.mimeType||=n);let r=String(t.fileName||t.originalName||t.name||``);return r&&(t.fileName||=r,t.originalName||=r,t.name||=r),{type:n,fileName:r,metadata:t,metadataJson:JSON.stringify(t)}}const O=m.object({operation:m.literal(`init`),storageId:m.string(),metadata:m.record(m.string(),m.any()).optional()}),k=m.object({operation:m.literal(`finalize`),uploadId:m.string()}),A=m.object({operation:m.literal(`url`),url:m.string(),storageId:m.string().optional(),metadata:m.record(m.string(),m.any()).optional()}),j=m.union([O,k,A]),ee=m.object({allowedMimeTypes:m.array(m.string()).optional(),minSize:m.number().positive().optional(),maxSize:m.number().positive().optional()});function M(t,n){return l.gen(function*(){if(n){if(n.allowedMimeTypes&&n.allowedMimeTypes.length>0&&!n.allowedMimeTypes.some(e=>{if(e.endsWith(`/*`)){let n=e.slice(0,-2);return t.type.startsWith(n)}return t.type===e}))throw yield*e.fromCode(`VALIDATION_ERROR`,{cause:Error(`File type "${t.type}" is not allowed. Allowed types: ${n.allowedMimeTypes.join(`, `)}`)}).toEffect();if(n.minSize!==void 0&&t.size<n.minSize)throw yield*e.fromCode(`VALIDATION_ERROR`,{cause:Error(`File size (${t.size} bytes) is below minimum (${n.minSize} bytes)`)}).toEffect();if(n.maxSize!==void 0&&t.size>n.maxSize)throw yield*e.fromCode(`VALIDATION_ERROR`,{cause:Error(`File size (${t.size} bytes) exceeds maximum (${n.maxSize} bytes)`)}).toEffect()}})}function te(n,r,i){let c=i?.keepOutput??!1;return l.gen(function*(){let i=yield*o;return yield*x({id:n,name:`Input`,description:`Handles file input through multiple methods - streaming upload (init/finalize) or direct URL fetch`,type:b.input,inputSchema:j,outputSchema:t,keepOutput:c,nodeTypeId:I,run:({data:t,flowId:o,jobId:c,clientId:u})=>l.gen(function*(){switch(t.operation){case`init`:{let e={storageId:t.storageId,size:t.metadata?.size||0,type:t.metadata?.mimeType||`application/octet-stream`,fileName:t.metadata?.originalName,lastModified:t.metadata?.size?Date.now():void 0,metadata:t.metadata?JSON.stringify(t.metadata):void 0,flow:{flowId:o,nodeId:n,jobId:c}};return w(yield*i.createUpload(e,u))}case`finalize`:{let e=yield*i.getUpload(t.uploadId),{type:n}=D(e.metadata);return yield*M({type:n,size:e.size||0},r),C(e)}case`url`:{let e=yield*s(t.url),l=yield*a(e),d=t.metadata?.mimeType||e.headers.get(`content-type`)||`application/octet-stream`,f=t.metadata?.size||Number(e.headers.get(`content-length`)||0),p=t.metadata?.originalName||t.url.split(`/`).pop()||`file`;yield*M({type:d,size:f},r);let m=new ReadableStream({start(e){e.enqueue(new Uint8Array(l)),e.close()}}),h={storageId:t.storageId||`buffer`,size:f,type:d,fileName:p,lastModified:Date.now(),metadata:t.metadata?JSON.stringify(t.metadata):void 0};return C({...yield*i.upload(h,u,m),flow:{flowId:o,nodeId:n,jobId:c}})}default:throw yield*e.fromCode(`VALIDATION_ERROR`,{cause:Error(`Invalid operation`)}).toEffect()}})})})}const N=`storage-output-v1`,P=`ocr-output-v1`,F=`image-description-output-v1`,I=`streaming-input-v1`,ne=m.object({extractedText:m.string(),format:m.enum([`markdown`,`plain`,`structured`]),taskType:m.enum([`convertToMarkdown`,`freeOcr`,`parseFigure`,`locateObject`]),confidence:m.number().min(0).max(1).optional()}),re=m.object({description:m.string(),confidence:m.number().min(0).max(1).optional(),metadata:m.record(m.string(),m.unknown()).optional()});v.register({id:I,category:`input`,schema:j,version:`1.0.0`,description:`Streaming file input with init/finalize/url operations for flexible file ingestion`}),v.register({id:N,category:`output`,schema:t,version:`1.0.0`,description:`Storage output node that saves files to configured storage backend`}),v.register({id:P,category:`output`,schema:ne,version:`1.0.0`,description:`OCR output node that extracts structured text from documents using AI`}),v.register({id:F,category:`output`,schema:re,version:`1.0.0`,description:`Image description output node that generates AI-powered descriptions of images`});var L=class{maxConcurrency;constructor(e={}){this.maxConcurrency=e.maxConcurrency??4}groupNodesByExecutionLevel(e,t){let n={},r={};e.forEach(e=>{n[e.id]=[],r[e.id]=0}),t.forEach(e=>{n[e.source]?.push(e.target),r[e.target]=(r[e.target]||0)+1});let i=[],a=new Set,o=0;for(;a.size<e.length;){let e=Object.keys(r).filter(e=>r[e]===0&&!a.has(e));if(e.length===0)throw Error(`Cycle detected in flow graph - cannot execute in parallel`);i.push({level:o++,nodes:e}),e.forEach(e=>{a.add(e),delete r[e],n[e]?.forEach(e=>{r[e]!==void 0&&r[e]--})})}return i}executeNodesInParallel(e){return l.all(e.map(e=>e()),{concurrency:this.maxConcurrency})}canExecuteInParallel(e,t,n){return e.every(e=>(n[e]||[]).every(e=>t.has(e)))}getStats(){return{maxConcurrency:this.maxConcurrency}}};function R(e){return t=>{if(t.nodeType!==e)return!1;let n=v.get(e);return n?n.schema.safeParse(t.data).success:!1}}function z(e){return!e||typeof e!=`object`?!1:t.safeParse(e).success}const ie=R(`storage-output-v1`),ae=R(P),oe=R(F);function B(e,t){return e.filter(t)}function se(t,n){return l.gen(function*(){let r=B(t,n);return r.length===0?yield*e.fromCode(`OUTPUT_NOT_FOUND`,{body:`No output of the specified type was found in the flow results`}).toEffect():r.length>1?yield*e.fromCode(`MULTIPLE_OUTPUTS_FOUND`,{body:`Found ${r.length} outputs of the specified type, expected exactly one`,details:{foundCount:r.length,nodeIds:r.map(e=>e.nodeId)}}).toEffect():r[0]})}function ce(e,t){return B(e,t)[0]}function le(e,t){return e.find(e=>e.nodeId===t)}function ue(e,t){return e.some(t)}function de(e){return e.operation===`init`}function fe(e){return e.operation===`finalize`}function pe(e){return e.operation===`url`}function me(e){return e.operation===`init`||e.operation===`url`}const V=e=>({id:e.id,name:e.name,nodes:e.nodes.map(S),edges:e.edges});function H(t){return l.gen(function*(){let n=yield*l.all(t.nodes.map(e=>l.isEffect(e)?e:l.succeed(e))),{flowId:r,name:a,onEvent:o,checkJobStatus:s,edges:c,inputSchema:u,outputSchema:d,typeChecker:f}=t,h=n,_=new E(f),v=()=>{let e={},t={},n={};return h.forEach(r=>{e[r.id]=[],n[r.id]=[],t[r.id]=0}),c.forEach(r=>{e[r.source]?.push(r.target),n[r.target]?.push(r.source),t[r.target]=(t[r.target]||0)+1}),{graph:e,reverseGraph:n,inDegree:t}},y=()=>{let{graph:e,inDegree:t}=v(),n=[],r=[];for(Object.keys(t).forEach(e=>{t[e]===0&&n.push(e)});n.length>0;){let i=n.shift();if(!i)throw Error(`No current node found`);r.push(i),e[i]?.forEach(e=>{t[e]=(t[e]||0)-1,t[e]===0&&n.push(e)})}return r},b=(e,t)=>{if(!e.condition)return l.succeed(!0);let{field:n,operator:r,value:i}=e.condition,a=t,o=a?.metadata?.[n]||a?.[n],s=(()=>{switch(r){case`equals`:return o===i;case`notEquals`:return o!==i;case`greaterThan`:return Number(o)>Number(i);case`lessThan`:return Number(o)<Number(i);case`contains`:return String(o).includes(String(i));case`startsWith`:return String(o).startsWith(String(i));default:return!0}})();return l.succeed(s)},x=(e,t)=>{let{reverseGraph:n}=v(),r=n[e]||[],i={};return r.forEach(e=>{let n=t.get(e);n!==void 0&&(i[e]=n)}),i},S=e=>{let t=h.filter(e=>e.type===`input`),n={};return t.forEach(t=>{e&&typeof e==`object`&&t.id in e&&(n[t.id]=u.parse(e[t.id]))}),n},C=e=>!c.some(t=>t.source===e),w=e=>{let t=h.find(t=>t.id===e);return C(e)||t?.keepOutput===!0},T=e=>{let t=h.filter(e=>w(e.id)),n={};return t.forEach(t=>{let r=e.get(t.id);r!==void 0&&(n[t.id]=r)}),n},D=(e,t)=>{let n=h.filter(e=>w(e.id)),r=[];return n.forEach(n=>{let i=e.get(n.id);if(i!==void 0){let e=t.get(n.id);r.push({nodeId:n.id,nodeType:e,data:i,timestamp:new Date().toISOString()})}}),r},O=(e,t,n)=>l.gen(function*(){if(e.storage.id===t)return e;let r=yield*i,a=yield*r.getDataStore(e.storage.id,n),o=yield*r.getDataStore(t,n),s=yield*a.read(e.id),c=p.make(s),l={...e,storage:{id:t,type:e.storage.type}},u=yield*o.create(l);return yield*o.write({file_id:u.id,stream:c,offset:0},{}),u}),k=(n,i,a,c,u,d,f)=>l.gen(function*(){let p=u.get(n);if(!p)return yield*e.fromCode(`FLOW_NODE_NOT_FOUND`).toEffect();if(s){let t=yield*s(d);if(t===`paused`)return yield*e.fromCode(`FLOW_PAUSED`,{cause:`Flow ${r} was paused by user at job ${d}`}).toEffect();if(t===`cancelled`)return yield*e.fromCode(`FLOW_CANCELLED`,{cause:`Flow ${r} was cancelled by user at job ${d}`}).toEffect()}o&&(yield*o({jobId:d,flowId:r,nodeId:n,eventType:g.NodeStart,nodeName:p.name,nodeType:p.type}));let m=p.retry?.maxRetries??0,h=p.retry?.retryDelay??1e3,_=p.retry?.exponentialBackoff??!0,v=0,y=null;for(;v<=m;)try{let s,u={};if(p.type===`input`){if(s=a[n],s===void 0)return yield*l.logError(`Input node ${n} has no input data`),yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Input node ${n} has no input data`)}).toEffect()}else{if(u=x(n,c),Object.keys(u).length===0)return yield*l.logError(`Node ${n} has no input data`),yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node ${n} has no input data`)}).toEffect();if(p.multiInput)s=u;else{let t=Object.keys(u)[0];if(!t)return yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node ${n} has no input data`)}).toEffect();s=u[t]}}if(p.type===`conditional`&&!(yield*b(p,s)))return o&&(yield*o({jobId:d,flowId:r,nodeId:n,eventType:g.NodeEnd,nodeName:p.name})),{nodeId:n,result:s,success:!0,waiting:!1};let m=yield*p.run({data:s,inputs:u,jobId:d,flowId:r,storageId:i,clientId:f});if(m.type===`waiting`){let e=m.partialData;return o&&(yield*o({jobId:d,flowId:r,nodeId:n,eventType:g.NodePause,nodeName:p.name,partialData:e})),{nodeId:n,result:e,success:!0,waiting:!0,nodeType:m.nodeType}}let h=m.data;if(w(n)&&(z(h)&&h.storage.id!==i&&(yield*l.logDebug(`Auto-persisting output node ${n} output from ${h.storage.id} to ${i}`),h=yield*O(h,i,f)),t.hooks?.onNodeOutput)){yield*l.logDebug(`Calling onNodeOutput hook for sink node ${n}`);let e=t.hooks.onNodeOutput({output:h,nodeId:n,flowId:r,jobId:d,storageId:i,clientId:f});h=yield*l.isEffect(e)?e:l.promise(()=>e)}return o&&(yield*o({jobId:d,flowId:r,nodeId:n,eventType:g.NodeEnd,nodeName:p.name,result:h})),{nodeId:n,result:h,success:!0,waiting:!1,nodeType:m.nodeType}}catch(t){if(y=t instanceof e?t:e.fromCode(`FLOW_NODE_ERROR`,{cause:t}),v<m){v++;let e=_?h*2**(v-1):h;yield*l.logWarning(`Node ${n} (${p.name}) failed, retrying (${v}/${m}) after ${e}ms`),yield*l.sleep(e);continue}return o&&(yield*o({jobId:d,flowId:r,nodeId:n,eventType:g.NodeError,nodeName:p.name,error:y.body,retryCount:v})),yield*y.toEffect()}return y?yield*y.toEffect():yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Unexpected error in retry loop`)}).toEffect()}),A=({inputs:n,storageId:i,jobId:a,resumeFrom:s,clientId:u})=>l.gen(function*(){!s&&o&&(yield*o({jobId:a,eventType:g.FlowStart,flowId:r}));let f=S(n||{}),p,_,v;s?(p=s.executionOrder,_=s.nodeResults,v=s.currentIndex):(p=y(),_=new Map,v=0);let b=new Map;if(p.length!==h.length)return yield*e.fromCode(`FLOW_CYCLE_ERROR`).toEffect();let x=new Map(h.map(e=>[e.id,e]));if(t.parallelExecution?.enabled??!1){yield*l.logDebug(`Flow ${r}: Executing in parallel mode (maxConcurrency: ${t.parallelExecution?.maxConcurrency??4})`);let e=new L({maxConcurrency:t.parallelExecution?.maxConcurrency??4}),n=e.groupNodesByExecutionLevel(h,c);yield*l.logDebug(`Flow ${r}: Grouped nodes into ${n.length} execution levels`);let d={};h.forEach(e=>{d[e.id]=[]}),c.forEach(e=>{d[e.target]?.push(e.source)});for(let t of n){yield*l.logDebug(`Flow ${r}: Executing level ${t.level} with nodes: ${t.nodes.join(`, `)}`);let n=t.nodes.map(e=>()=>l.gen(function*(){if(s&&e===s.executionOrder[v]&&o){let t=x.get(e);t&&(yield*o({jobId:a,flowId:r,nodeId:e,eventType:g.NodeResume,nodeName:t.name,nodeType:t.type}))}return{nodeId:e,nodeResult:yield*k(e,i,f,_,x,a,u)}})),c=yield*e.executeNodesInParallel(n);for(let{nodeId:e,nodeResult:t}of c){if(t.waiting)return t.result!==void 0&&(_.set(e,t.result),t.nodeType&&b.set(e,t.nodeType)),{type:`paused`,nodeId:e,executionState:{executionOrder:p,currentIndex:p.indexOf(e),inputs:f}};t.success&&(_.set(e,t.result),t.nodeType&&b.set(e,t.nodeType))}}}else{yield*l.logDebug(`Flow ${r}: Executing in sequential mode`);for(let t=v;t<p.length;t++){let n=p[t];if(!n)return yield*e.fromCode(`FLOW_NODE_NOT_FOUND`).toEffect();if(s&&t===v&&o){let e=x.get(n);e&&(yield*o({jobId:a,flowId:r,nodeId:n,eventType:g.NodeResume,nodeName:e.name,nodeType:e.type}))}let c=yield*k(n,i,f,_,x,a,u);if(c.waiting)return c.result!==void 0&&(_.set(c.nodeId,c.result),c.nodeType&&b.set(c.nodeId,c.nodeType)),{type:`paused`,nodeId:c.nodeId,executionState:{executionOrder:p,currentIndex:t,inputs:f}};c.success&&(_.set(c.nodeId,c.result),c.nodeType&&b.set(c.nodeId,c.nodeType))}}let C=T(_),E=D(_,b),O=m.record(m.string(),d).safeParse(C);if(!O.success){let t=`Flow output validation failed: ${O.error.message}. Expected outputs: ${JSON.stringify(Object.keys(T(_)))}. Output nodes (sinks + keepOutput): ${h.filter(e=>w(e.id)).map(e=>e.id).join(`, `)}`;return o&&(yield*o({jobId:a,eventType:g.FlowError,flowId:r,error:t})),yield*e.fromCode(`FLOW_OUTPUT_VALIDATION_ERROR`,{body:t,cause:O.error}).toEffect()}let A=O.data;return o&&(yield*o({jobId:a,eventType:g.FlowEnd,flowId:r,outputs:E,result:A})),{type:`completed`,result:A,outputs:E}});return{id:r,name:a,nodes:h,edges:c,inputSchema:u,outputSchema:d,onEvent:o,checkJobStatus:s,hooks:t.hooks,run:({inputs:e,storageId:t,jobId:n,clientId:r})=>A({inputs:e,storageId:t,jobId:n,clientId:r}),resume:({jobId:e,storageId:t,nodeResults:n,executionState:r,clientId:i})=>A({inputs:r.inputs,storageId:t,jobId:e,resumeFrom:{executionOrder:r.executionOrder,nodeResults:new Map(Object.entries(n)),currentIndex:r.currentIndex},clientId:i}),validateTypes:()=>{let e=h;return _.validateFlow(e,c)},validateInputs:e=>_.validateData(e,u),validateOutputs:e=>_.validateData(e,d)}})}var U=class e extends c.Tag(`FlowWaitUntil`)(){static optional=l.serviceOption(e)},W=class extends c.Tag(`FlowProvider`)(){},G=class extends c.Tag(`FlowServer`)(){};const K=e=>typeof e==`object`&&!!e&&`id`in e,he=e=>typeof e==`object`&&e&&`nodeId`in e&&`data`in e&&`timestamp`in e?e.data:e;function q(t,n,r){let i=e=>{let i=t=>l.gen(function*(){let n=yield*r.get(e);n&&(yield*r.set(e,{...n,...t,updatedAt:new Date}))});return a=>l.gen(function*(){switch(t.onEvent&&(yield*l.catchAll(t.onEvent(a),e=>(l.logError(`Original onEvent failed`,e),l.succeed({eventId:null})))),yield*n.emit(e,a),l.logInfo(`Updating job ${e} with event ${a.eventType}`),a.eventType){case g.FlowStart:yield*i({status:`running`});break;case g.FlowEnd:yield*l.gen(function*(){let t=yield*r.get(e);t&&a.outputs&&(yield*r.set(e,{...t,result:a.outputs,updatedAt:new Date}))});break;case g.FlowError:yield*i({status:`failed`,error:a.error});break;case g.NodeStart:yield*l.gen(function*(){let t=yield*r.get(e);if(t){let n=t.tasks.find(e=>e.nodeId===a.nodeId)?t.tasks.map(e=>e.nodeId===a.nodeId?{...e,status:`running`,updatedAt:new Date}:e):[...t.tasks,{nodeId:a.nodeId,status:`running`,createdAt:new Date,updatedAt:new Date}];yield*r.set(e,{...t,tasks:n,updatedAt:new Date})}});break;case g.NodePause:yield*l.gen(function*(){let t=yield*r.get(e);if(t){let n=t.tasks.find(e=>e.nodeId===a.nodeId)?t.tasks.map(e=>e.nodeId===a.nodeId?{...e,status:`paused`,result:a.partialData,updatedAt:new Date}:e):[...t.tasks,{nodeId:a.nodeId,status:`paused`,result:a.partialData,createdAt:new Date,updatedAt:new Date}];yield*r.set(e,{...t,tasks:n,updatedAt:new Date})}});break;case g.NodeResume:yield*l.gen(function*(){let t=yield*r.get(e);if(t){let n=t.tasks.map(e=>e.nodeId===a.nodeId?{...e,status:`running`,updatedAt:new Date}:e);yield*r.set(e,{...t,tasks:n,updatedAt:new Date})}});break;case g.NodeEnd:yield*l.gen(function*(){let n=yield*r.get(e);if(n){let i=n.tasks.map(e=>e.nodeId===a.nodeId?{...e,status:`completed`,result:a.result,updatedAt:new Date}:e),o=!t.edges.some(e=>e.source===a.nodeId),s=t.nodes.find(e=>e.id===a.nodeId)?.keepOutput===!0,c=a.result,u=he(c),d=n.intermediateFiles||[],f=o||s;f&&K(u)&&u.id?(d=d.filter(e=>e!==u.id),s&&!o&&l.logInfo(`Preserving output from node ${a.nodeId} due to keepOutput flag`)):!f&&K(u)&&u.id&&(d.includes(u.id)||d.push(u.id)),yield*r.set(e,{...n,tasks:i,intermediateFiles:d,updatedAt:new Date})}});break;case g.NodeError:yield*l.gen(function*(){let t=yield*r.get(e);if(t){let n=t.tasks.map(e=>e.nodeId===a.nodeId?{...e,status:`failed`,error:a.error,retryCount:a.retryCount,updatedAt:new Date}:e);yield*r.set(e,{...t,tasks:n,error:a.error,updatedAt:new Date})}});break}return{eventId:e}})},a=t=>t=>l.gen(function*(){let n=yield*r.get(t);return n?n.status===`paused`?`paused`:n.status===`cancelled`?`cancelled`:`running`:yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found`}))});return{...t,run:e=>l.gen(function*(){let n=e.jobId||crypto.randomUUID(),r=i(n),o=a(n);return yield*(yield*H({flowId:t.id,name:t.name,nodes:t.nodes,edges:t.edges,inputSchema:t.inputSchema,outputSchema:t.outputSchema,onEvent:r,checkJobStatus:o})).run({...e,jobId:n,clientId:e.clientId})}),resume:e=>l.gen(function*(){let n=e.jobId,r=i(n),o=a(n);return yield*(yield*H({flowId:t.id,name:t.name,nodes:t.nodes,edges:t.edges,inputSchema:t.inputSchema,outputSchema:t.outputSchema,onEvent:r,checkJobStatus:o})).resume(e)})}}function J(){return l.gen(function*(){let t=yield*W,i=yield*n,a=yield*r,s=yield*o,c=(t,n)=>l.gen(function*(){let r=yield*a.get(t);return r?yield*a.set(t,{...r,...n}):yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found`}))}),u=(e,t)=>l.gen(function*(){let n=yield*a.get(e);!n||!n.intermediateFiles||n.intermediateFiles.length===0||(yield*l.logInfo(`Cleaning up ${n.intermediateFiles.length} intermediate files for job ${e}`),yield*l.all(n.intermediateFiles.map(e=>l.gen(function*(){yield*s.delete(e,t),yield*l.logDebug(`Deleted intermediate file ${e}`)}).pipe(l.catchAll(t=>l.gen(function*(){return yield*l.logWarning(`Failed to delete intermediate file ${e}: ${t}`),l.succeed(void 0)})))),{concurrency:5}),yield*c(e,{intermediateFiles:[]}))}),p=({jobId:t,flow:n,storageId:r,clientId:o,inputs:s})=>l.gen(function*(){console.log(`[FlowServer] executeFlowInBackground started for job: ${t}`),yield*c(t,{status:`running`}),console.log(`[FlowServer] Creating flowWithEvents for job: ${t}`);let e=q(n,i,a);console.log(`[FlowServer] Running flow for job: ${t}`);let l=yield*e.run({inputs:s,storageId:r,jobId:t,clientId:o});return console.log(`[FlowServer] Flow completed for job: ${t}, result type: ${l.type}`),l.type===`paused`?yield*c(t,{status:`paused`,pausedAt:l.nodeId,executionState:l.executionState,updatedAt:new Date}):(yield*c(t,{status:`completed`,updatedAt:new Date,endedAt:new Date}),yield*u(t,o)),l}).pipe(l.catchAll(n=>l.gen(function*(){yield*l.logError(`Flow execution failed`,n);let r=n instanceof e?n.body:String(n);yield*l.logInfo(`Updating job ${t} to failed status with error: ${r}`),yield*c(t,{status:`failed`,error:r,updatedAt:new Date}).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logError(`Failed to update job ${t}`,e),l.succeed(void 0)})));let s=yield*a.get(t);throw s&&(yield*i.emit(t,{jobId:t,eventType:g.FlowError,flowId:s.flowId,error:r}).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logError(`Failed to emit FlowError event for job ${t}`,e),l.succeed(void 0)})))),yield*u(t,o).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logWarning(`Failed to cleanup intermediate files for job ${t}`,e),l.succeed(void 0)}))),n})));return{getFlow:(e,n)=>l.gen(function*(){return yield*t.getFlow(e,n)}),getFlowData:(e,n)=>l.gen(function*(){return V(yield*t.getFlow(e,n))}),runFlow:({flowId:n,storageId:r,clientId:i,inputs:o})=>l.gen(function*(){let s=yield*U.optional,c=yield*l.try({try:()=>Ke.parse({inputs:o}),catch:t=>e.fromCode(`FLOW_INPUT_VALIDATION_ERROR`,{cause:t})}),u=crypto.randomUUID(),m=new Date,h={id:u,flowId:n,storageId:r,clientId:i,status:`started`,createdAt:m,updatedAt:m,tasks:[]};yield*a.set(u,h);let g=yield*t.getFlow(n,i);console.log(`[FlowServer] About to fork flow execution for job: ${u}`);let _=p({jobId:u,flow:g,storageId:r,clientId:i,inputs:c.inputs}).pipe(l.tapErrorCause(e=>l.logError(`Flow execution failed`,e)));if(d.isSome(s)){console.log(`[FlowServer] Using waitUntil for job: ${u}`);let e=yield*l.runtime(),t=f.runPromise(e)(_);s.value(t)}else console.log(`[FlowServer] Using Effect.forkDaemon for job: ${u}`),yield*l.forkDaemon(_);return console.log(`[FlowServer] Flow execution started for job: ${u}`),h}),getJobStatus:t=>l.gen(function*(){return(yield*a.get(t))||(yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found`})))}),resumeFlow:({jobId:n,nodeId:r,newData:o,clientId:s})=>l.gen(function*(){let p=yield*U.optional,m=yield*a.get(n);if(!m)return console.error(`Job not found`),yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${n} not found`}));if(m.status!==`paused`)return console.error(`Job is not paused`),yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${n} is not paused (status: ${m.status})`}));if(m.pausedAt!==r)return console.error(`Job is not paused at the expected node`),yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${n} is paused at node ${m.pausedAt}, not ${r}`}));if(!m.executionState)return console.error(`Job has no execution state`),yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${n} has no execution state`}));let h={...m.tasks.reduce((e,t)=>(t.result!==void 0&&(e[t.nodeId]=t.result),e),{}),[r]:o},_={...m.executionState.inputs,[r]:o};yield*c(n,{status:`running`});let v=yield*t.getFlow(m.flowId,m.clientId),y=l.gen(function*(){let t=q(v,i,a);if(!m.executionState)return yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${n} has no execution state`}));let r=yield*t.resume({jobId:n,storageId:m.storageId,nodeResults:h,executionState:{...m.executionState,inputs:_},clientId:m.clientId});return r.type===`paused`?yield*c(n,{status:`paused`,pausedAt:r.nodeId,executionState:r.executionState,updatedAt:new Date}):(yield*c(n,{status:`completed`,pausedAt:void 0,executionState:void 0,updatedAt:new Date,endedAt:new Date}),yield*u(n,s)),r}).pipe(l.catchAll(t=>l.gen(function*(){yield*l.logError(`Flow resume failed`,t);let r=t instanceof e?t.body:String(t);yield*l.logInfo(`Updating job ${n} to failed status with error: ${r}`),yield*c(n,{status:`failed`,error:r,updatedAt:new Date}).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logError(`Failed to update job ${n}`,e),l.succeed(void 0)})));let o=yield*a.get(n);throw o&&(yield*i.emit(n,{jobId:n,eventType:g.FlowError,flowId:o.flowId,error:r}).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logError(`Failed to emit FlowError event for job ${n}`,e),l.succeed(void 0)})))),yield*u(n,s).pipe(l.catchAll(e=>l.gen(function*(){return yield*l.logWarning(`Failed to cleanup intermediate files for job ${n}`,e),l.succeed(void 0)}))),t}))).pipe(l.tapErrorCause(e=>l.logError(`Flow resume failed`,e)));if(d.isSome(p)){console.log(`[FlowServer] Using waitUntil for resume job: ${n}`);let e=yield*l.runtime(),t=f.runPromise(e)(y);p.value(t)}else console.log(`[FlowServer] Using Effect.forkDaemon for resume job: ${n}`),yield*l.forkDaemon(y);return(yield*a.get(n))||(yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${n} not found after update`})))}),pauseFlow:(t,n)=>l.gen(function*(){let r=yield*a.get(t);if(!r)return yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found`}));if(n!==null&&r.clientId!==n)return yield*l.fail(e.fromCode(`FLOW_NOT_AUTHORIZED`,{cause:`Client ${n} is not authorized to pause job ${t}`}));if(r.status!==`running`)return yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${t} cannot be paused (current status: ${r.status})`}));let o=r.tasks.find(e=>e.status===`running`)?.nodeId;return yield*c(t,{status:`paused`,pausedAt:o,updatedAt:new Date}),yield*i.emit(t,{jobId:t,flowId:r.flowId,eventType:g.FlowPause,pausedAt:o}),(yield*a.get(t))||(yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found after pause`})))}),cancelFlow:(t,n)=>l.gen(function*(){let r=yield*a.get(t);return r?n!==null&&r.clientId!==n?yield*l.fail(e.fromCode(`FLOW_NOT_AUTHORIZED`,{cause:`Client ${n} is not authorized to cancel job ${t}`})):r.status!==`running`&&r.status!==`paused`&&r.status!==`started`?yield*l.fail(e.fromCode(`FLOW_JOB_ERROR`,{cause:`Job ${t} cannot be cancelled (current status: ${r.status})`})):(yield*c(t,{status:`cancelled`,updatedAt:new Date,endedAt:new Date}),yield*i.emit(t,{jobId:t,flowId:r.flowId,eventType:g.FlowCancel}),yield*u(t,n),(yield*a.get(t))||(yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found after cancellation`})))):yield*l.fail(e.fromCode(`FLOW_JOB_NOT_FOUND`,{cause:`Job ${t} not found`}))}),subscribeToFlowEvents:(e,t)=>l.gen(function*(){yield*i.subscribe(e,t)}),unsubscribeFromFlowEvents:e=>l.gen(function*(){yield*i.unsubscribe(e)})}})}const ge=u.effect(G,J());function _e({id:e,name:n,description:r,nodeTypeId:i,keepOutput:a,transform:s}){return l.gen(function*(){let c=yield*o;return yield*x({id:e,name:n,description:r,type:b.process,nodeTypeId:i,keepOutput:a,inputSchema:t,outputSchema:t,run:({data:t,storageId:n,flowId:r,jobId:i,clientId:a})=>l.gen(function*(){let o={flowId:r,nodeId:e,jobId:i},l=yield*s(yield*c.read(t.id,a),t),u=l instanceof Uint8Array?l:l.bytes,d=l instanceof Uint8Array?void 0:l.type,f=l instanceof Uint8Array?void 0:l.fileName,p=new ReadableStream({start(e){e.enqueue(u),e.close()}}),{type:m,fileName:h,metadata:g,metadataJson:_}=D(t.metadata),v=yield*c.upload({storageId:n,size:u.byteLength,type:d??m,fileName:f??h,lastModified:0,metadata:_,flow:o},a,p),y=g?{...g,...d&&{mimeType:d,type:d,"content-type":d},...f&&{fileName:f,originalName:f,name:f,extension:f.split(`.`).pop()||g.extension}}:v.metadata;return C(y?{...v,metadata:y}:v)})})})}var ve=class extends c.Tag(`CredentialProvider`)(){},ye=class extends c.Tag(`DocumentAiPlugin`)(){},be=class extends c.Tag(`DocumentPlugin`)(){},xe=class extends c.Tag(`ImageAiPlugin`)(){},Se=class extends c.Tag(`ImagePlugin`)(){};const Ce=m.object({serviceType:m.enum([`replicate`]).optional()}),we=m.object({duration:m.number().nonnegative(),width:m.number().positive(),height:m.number().positive(),codec:m.string(),format:m.string(),bitrate:m.number().nonnegative(),frameRate:m.number().positive(),aspectRatio:m.string(),hasAudio:m.boolean(),audioCodec:m.string().optional(),audioBitrate:m.number().nonnegative().optional(),size:m.number().nonnegative()}),Te=m.object({timestamp:m.number().nonnegative(),format:m.enum([`png`,`jpeg`]).optional(),quality:m.number().min(1).max(100).optional()}),Ee=m.object({quality:m.number().min(0).max(100),format:m.enum([`jpeg`,`webp`,`png`,`avif`])}),De=m.object({serviceType:m.enum([`replicate`]).optional()}),Oe=m.object({width:m.number().positive().optional(),height:m.number().positive().optional(),fit:m.enum([`contain`,`cover`,`fill`])}).refine(e=>e.width||e.height,`Either width or height must be specified for resize`),ke=m.object({width:m.number().positive().optional(),height:m.number().positive().optional(),aspectRatio:m.enum([`keep`,`ignore`]).optional(),scaling:m.enum([`bicubic`,`bilinear`,`lanczos`]).optional()}).refine(e=>e.width||e.height,`Either width or height must be specified for video resize`),Ae=m.object({format:m.enum([`mp4`,`webm`,`mov`,`avi`]),codec:m.enum([`h264`,`h265`,`vp9`,`av1`]).optional(),videoBitrate:m.string().optional(),audioBitrate:m.string().optional(),audioCodec:m.enum([`aac`,`mp3`,`opus`,`vorbis`]).optional()}),Y=m.object({type:m.literal(`resize`),width:m.number().positive().optional(),height:m.number().positive().optional(),fit:m.enum([`contain`,`cover`,`fill`])}),X=m.object({type:m.literal(`blur`),sigma:m.number().min(.3).max(1e3)}),Z=m.object({type:m.literal(`rotate`),angle:m.number(),background:m.string().optional()}),Q=m.object({type:m.literal(`flip`),direction:m.enum([`horizontal`,`vertical`])}),je=m.object({type:m.literal(`grayscale`)}),Me=m.object({type:m.literal(`sepia`)}),Ne=m.object({type:m.literal(`brightness`),value:m.number().min(-100).max(100)}),Pe=m.object({type:m.literal(`contrast`),value:m.number().min(-100).max(100)}),$=m.object({type:m.literal(`sharpen`),sigma:m.number().positive().optional()}),Fe=m.object({type:m.literal(`watermark`),imagePath:m.string().min(1).url(),position:m.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),opacity:m.number().min(0).max(1),offsetX:m.number().optional(),offsetY:m.number().optional()}),Ie=m.object({type:m.literal(`logo`),imagePath:m.string().min(1).url(),position:m.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),scale:m.number().min(.1).max(2),offsetX:m.number().optional(),offsetY:m.number().optional()}),Le=m.object({type:m.literal(`text`),text:m.string().min(1),position:m.enum([`top-left`,`top-right`,`bottom-left`,`bottom-right`,`center`]),fontSize:m.number().positive(),color:m.string().min(1),fontFamily:m.string().optional(),offsetX:m.number().optional(),offsetY:m.number().optional()}),Re=m.discriminatedUnion(`type`,[Y,X,Z,Q,je,Me,Ne,Pe,$,Fe,Ie,Le]),ze=m.object({transformations:m.array(Re).min(1)}),Be=m.object({startTime:m.number().nonnegative(),endTime:m.number().positive().optional(),duration:m.number().positive().optional()}).refine(e=>!e.endTime||!e.duration,`Cannot specify both endTime and duration`).refine(e=>!e.endTime||e.endTime>e.startTime,`endTime must be greater than startTime`);var Ve=class extends c.Tag(`VideoPlugin`)(){},He=class extends c.Tag(`VirusScanPlugin`)(){},Ue=class extends c.Tag(`ZipPlugin`)(){};const We=(e,t)=>{if(e.length===0)return t;let[n,...r]=e;return r.reduce((e,t)=>m.union([e,t]),n)};function Ge(t){return l.gen(function*(){let n=Object.entries(t.nodes),r=e=>l.isEffect(e)?e:l.succeed(e),i=yield*l.forEach(n,([t,n])=>l.flatMap(r(n),n=>n.id===t?l.succeed([t,n]):l.fail(e.fromCode(`FLOW_NODE_ERROR`,{cause:Error(`Node key ${t} does not match node id ${n.id}`)})))),a=Object.fromEntries(i),o=i.map(([,e])=>e),s=i.filter(([,e])=>e.type===b.input).map(([,e])=>e.inputSchema),c=t.edges.map(e=>({source:a[e.source]?.id??e.source,target:a[e.target]?.id??e.target,sourcePort:e.sourcePort,targetPort:e.targetPort})),u=new Set(i.map(([e])=>a[e]?.id).filter(e=>e&&!c.some(t=>t.source===e))),d=i.filter(([,e])=>u.has(e.id)).map(([,e])=>e.outputSchema),f=t.inputSchema??We(s,m.unknown()),p=t.outputSchema??We(d,m.unknown());return yield*H({flowId:t.flowId,name:t.name,nodes:o,edges:c,inputSchema:f,outputSchema:p,typeChecker:t.typeChecker,onEvent:t.onEvent,parallelExecution:t.parallelExecution,hooks:t.hooks})})}const Ke=m.object({inputs:m.record(m.string(),m.any())});export{z as $,xe as A,H as B,Oe as C,we as D,Te as E,W as F,le as G,R as H,G as I,fe as J,se as K,U as L,ye as M,ve as N,Ce as O,_e as P,ie as Q,J as R,ke as S,h as St,Ee as T,B as U,V,ce as W,de as X,oe as Y,ae as Z,Le as _,S as _t,Ve as a,N as at,Fe as b,y as bt,Ne as c,ne as ct,je as d,ee as dt,me as et,Ie as f,D as ft,$ as g,x as gt,Me as h,b as ht,He as i,P as it,be as j,Se as k,Pe as l,te as lt,Z as m,w as mt,Ge as n,L as nt,Be as o,I as ot,Y as p,C as pt,ue as q,Ue as r,F as rt,X as s,re as st,Ke as t,pe as tt,Q as u,j as ut,ze as v,_ as vt,De as w,Ae as x,g as xt,Re as y,v as yt,ge as z};
|
|
2
|
+
//# sourceMappingURL=flow-vXXjtBBv.mjs.map
|