@uploadista/flow-images-nodes 0.0.18 → 0.0.20-beta.1
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/index.cjs +1 -1
- package/dist/index.d.cts +121 -53
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +108 -40
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/optimize-node.ts +116 -38
- package/src/resize-node.ts +58 -2
- package/src/transform-image-node.ts +129 -4
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=require(`@uploadista/core/errors`),t=require(`@uploadista/core/flow`),n=require(`@uploadista/core/types`),r=require(`effect`),i=require(`@uploadista/core/upload`);function
|
|
1
|
+
let e=require(`@uploadista/core/errors`),t=require(`@uploadista/core/flow`),n=require(`@uploadista/core/types`),r=require(`effect`),i=require(`@uploadista/core`),a=require(`@uploadista/core/upload`);function o(t,n={}){let{maxWaitTime:i=1e4,retryDelay:a=500}=n;return r.Effect.gen(function*(){let n=Date.now();for(;Date.now()-n<i;){let e=yield*r.Effect.tryPromise(()=>fetch(t,{method:`HEAD`})).pipe(r.Effect.catchAll(()=>r.Effect.succeed(null)));if(e?.ok){yield*r.Effect.logInfo(`URL ${t} is now available`);return}e?yield*r.Effect.logDebug(`URL not ready yet (${e.status}), retrying...`):yield*r.Effect.logDebug(`URL check failed, retrying...`),yield*r.Effect.sleep(a)}return yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:`URL ${t} not available after ${i}ms`}).toEffect()})}function s(i,{credentialId:a,keepOutput:s}={}){return r.Effect.gen(function*(){let c=yield*t.ImageAiPlugin;return yield*(0,t.createFlowNode)({id:i,name:`Describe Image`,description:`Describes the image using AI`,type:t.NodeType.process,nodeTypeId:`describe-image`,outputTypeId:t.IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,keepOutput:s,inputSchema:n.uploadFileSchema,outputSchema:t.imageDescriptionOutputSchema,circuitBreaker:{enabled:!0,failureThreshold:5,resetTimeout:6e4,fallback:{type:`skip`,passThrough:!0}},run:({data:n,flowId:s,jobId:l,clientId:u})=>r.Effect.gen(function*(){let d={flowId:s,nodeId:i,jobId:l},f=n.url;if(!f)return yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:`URL is required for describe image operation`}).toEffect();yield*r.Effect.logInfo(`Describing image for file ${n.id} at URL: ${f}`),yield*o(f);let p={clientId:u,credentialId:a},m=yield*c.describeImage(f,p).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to describe image`,t),yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:t instanceof Error?t.message:`Failed to describe image`}).toEffect()})));return yield*r.Effect.logInfo(`Successfully described image for file ${n.id}`),(0,t.completeNodeExecution)({description:m.description,flow:d})})})})}const c={jpeg:`image/jpeg`,webp:`image/webp`,png:`image/png`,avif:`image/avif`},l={jpeg:`jpg`,webp:`webp`,png:`png`,avif:`avif`};function u(e,{quality:n,format:a},o){return r.Effect.gen(function*(){let s=yield*t.ImagePlugin,u=s.supportsStreaming??!1,d=o?.mode??`buffered`,f=d===`buffered`?`buffered`:u?d:`buffered`,p=r=>{let i=c[a],s=l[a],u=r.metadata?.fileName,d;if(u&&typeof u==`string`)if(o?.naming){let i={...o.naming,autoSuffix:o.naming.autoSuffix??(e=>e.format??a)};d=`${(0,t.getBaseName)((0,t.applyFileNaming)(r,(0,t.buildNamingContext)(r,{flowId:r.flow?.flowId??``,jobId:r.flow?.jobId??``,nodeId:e,nodeType:`optimize`},{format:a,quality:n}),i))}.${s}`}else d=u.replace(/\.[^.]+$/,`.${s}`);return{newType:i,newFileName:d}};return yield*(0,t.createTransformNode)({id:e,name:`Optimize`,description:`Optimizes an image for web delivery`,nodeTypeId:`optimize-image`,outputTypeId:t.STORAGE_OUTPUT_TYPE_ID,keepOutput:o?.keepOutput,nodeType:`optimize`,namingVars:{format:a,quality:n},mode:f,streamingConfig:o?.streamingConfig,transform:(e,t)=>r.Effect.map(s.optimize(e,{quality:n,format:a}),e=>{let{newType:n,newFileName:r}=p(t);return{bytes:e,type:n,fileName:r}}),streamingTransform:s.optimizeStream?(e,t)=>{let o=s.optimizeStream;if(!o)throw i.UploadistaError.fromCode(`UNKNOWN_ERROR`);return r.Effect.gen(function*(){let r=yield*o(e,{quality:n,format:a}),{newType:i,newFileName:s}=p(t);return{stream:r,type:i,fileName:s}})}:void 0})})}function d(i,{credentialId:s,keepOutput:c,naming:l}={}){return r.Effect.gen(function*(){let u=yield*t.ImageAiPlugin,d=yield*a.UploadServer;return yield*(0,t.createFlowNode)({id:i,name:`Remove Background`,description:`Removes the background from an image`,type:t.NodeType.process,nodeTypeId:`remove-background`,outputTypeId:t.STORAGE_OUTPUT_TYPE_ID,keepOutput:c,inputSchema:n.uploadFileSchema,outputSchema:n.uploadFileSchema,circuitBreaker:{enabled:!0,failureThreshold:5,resetTimeout:6e4,fallback:{type:`skip`,passThrough:!0}},run:({data:n,flowId:a,jobId:c,storageId:f,clientId:p})=>r.Effect.gen(function*(){let m={flowId:a,nodeId:i,jobId:c},h=n.url;if(!h)return yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:`URL is required for remove background operation`}).toEffect();yield*r.Effect.logInfo(`Removing background for file ${n.id} at URL: ${n.url}`),yield*o(h);let g={clientId:p,credentialId:s},{outputUrl:_}=yield*u.removeBackground(h,g).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to remove background`,t),yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:t instanceof Error?t.message:`Failed to remove background from image`}).toEffect()}))),{type:v,fileName:y,metadata:b,metadataJson:x}=(0,t.resolveUploadMetadata)(n.metadata),S=y;if(l){let e={...l,autoSuffix:l.autoSuffix??(()=>`nobg`)};S=(0,t.applyFileNaming)(n,(0,t.buildNamingContext)(n,{flowId:a,jobId:c,nodeId:i,nodeType:`remove-background`}),e)}yield*r.Effect.logInfo(`Uploading processed file to storage`);let C=yield*d.uploadFromUrl({storageId:f,size:0,type:v,fileName:S,lastModified:0,metadata:x,flow:m},p,_).pipe(r.Effect.catchAll(t=>r.Effect.gen(function*(){return yield*r.Effect.logError(`Failed to upload processed file`,t),yield*e.UploadistaError.fromCode(`FLOW_NODE_ERROR`,{cause:t instanceof Error?t.message:`Failed to upload processed file`}).toEffect()})));yield*r.Effect.logInfo(`Successfully removed background for file ${n.id}`);let w=b?{...b,...S!==y&&{fileName:S,originalName:S,name:S,extension:S.split(`.`).pop()||b.extension}}:C.metadata;return(0,t.completeNodeExecution)(w?{...C,metadata:w}:C)})})})}function f(e,{width:n,height:i,fit:a},o){return r.Effect.gen(function*(){let s=yield*t.ImagePlugin,c=s.supportsStreaming??!1,l=o?.mode??`auto`,u=l===`buffered`?`buffered`:c?l:`buffered`,d=o?.naming?{...o.naming,autoSuffix:o.naming.autoSuffix??(e=>`${e.width??n}x${e.height??i}`)}:void 0;return yield*(0,t.createTransformNode)({id:e,name:`Resize`,description:`Resizes an image to the specified dimensions`,nodeTypeId:`resize-image`,outputTypeId:t.STORAGE_OUTPUT_TYPE_ID,keepOutput:o?.keepOutput,naming:d,nodeType:`resize`,namingVars:{width:n,height:i},mode:u,streamingConfig:o?.streamingConfig,transform:e=>s.resize(e,{height:i,width:n,fit:a}),streamingTransform:s.resizeStream?e=>r.Effect.gen(function*(){let t=s.resizeStream;if(!t)throw Error(`resizeStream not available`);return{stream:yield*t(e,{width:n,height:i,fit:a})}}):void 0})})}function p(e,t,n){return r.Effect.reduce(n,t,(t,n)=>e.transform(t,n))}function m(e,t,n){let i=e.transformStream;return i?r.Effect.reduce(n,t,(e,t)=>r.Effect.flatMap(i(e,t),e=>r.Effect.succeed(e))):r.Effect.gen(function*(){let i=[];yield*r.Stream.runForEach(t,e=>r.Effect.sync(()=>{i.push(e)}));let a=i.reduce((e,t)=>e+t.byteLength,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.byteLength;let c=yield*p(e,o,n);return r.Stream.make(c)})}function h(e,{transformations:n},i){return r.Effect.gen(function*(){let a=yield*t.ImagePlugin,o=a.supportsStreaming??!1,s=i?.mode??`auto`,c=n.some(e=>e.type===`watermark`||e.type===`logo`||e.type===`text`),l=s===`buffered`?`buffered`:o&&!c?s:`buffered`,u=i?.naming?{...i.naming,autoSuffix:i.naming.autoSuffix??(()=>`transformed`)}:void 0;return yield*(0,t.createTransformNode)({id:e,name:`Transform Image`,description:`Apply ${n.length} transformation${n.length===1?``:`s`} to the image`,nodeTypeId:`transform-image`,outputTypeId:t.STORAGE_OUTPUT_TYPE_ID,keepOutput:i?.keepOutput,naming:u,nodeType:`transform-image`,mode:l,streamingConfig:i?.streamingConfig,transform:e=>p(a,e,n),streamingTransform:o&&!c?e=>r.Effect.gen(function*(){return{stream:yield*m(a,e,n)}}):void 0})})}exports.createDescribeImageNode=s,exports.createOptimizeNode=u,exports.createRemoveBackgroundNode=d,exports.createResizeNode=f,exports.createTransformImageNode=h,exports.waitForUrlAvailability=o;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
1
|
+
import * as _uploadista_core0 from "@uploadista/core";
|
|
2
|
+
import { UploadistaError } from "@uploadista/core";
|
|
3
|
+
import * as zod_v4_core0 from "zod/v4/core";
|
|
4
|
+
import * as zod0 from "zod";
|
|
5
|
+
import { UploadistaError as UploadistaError$1 } from "@uploadista/core/errors";
|
|
6
|
+
import { FileNamingConfig, ImageAiPlugin, ImagePlugin, NodeType, OptimizeParams, ResizeParams, StreamingConfig, TransformImageParams, TransformMode } from "@uploadista/core/flow";
|
|
7
7
|
import { Effect } from "effect";
|
|
8
|
-
import * as _uploadista_core_types0 from "@uploadista/core/types";
|
|
9
|
-
import * as _uploadista_core_upload0 from "@uploadista/core/upload";
|
|
10
8
|
import { UploadServer } from "@uploadista/core/upload";
|
|
11
9
|
|
|
12
10
|
//#region src/describe-image-node.d.ts
|
|
@@ -16,8 +14,8 @@ declare function createDescribeImageNode(id: string, {
|
|
|
16
14
|
}?: {
|
|
17
15
|
credentialId?: string;
|
|
18
16
|
keepOutput?: boolean;
|
|
19
|
-
}): Effect.Effect<
|
|
20
|
-
inputSchema:
|
|
17
|
+
}): Effect.Effect<_uploadista_core0.FlowNodeData & {
|
|
18
|
+
inputSchema: zod0.ZodType<{
|
|
21
19
|
id: string;
|
|
22
20
|
offset: number;
|
|
23
21
|
storage: {
|
|
@@ -49,7 +47,7 @@ declare function createDescribeImageNode(id: string, {
|
|
|
49
47
|
spanId: string;
|
|
50
48
|
traceFlags: number;
|
|
51
49
|
} | undefined;
|
|
52
|
-
}, unknown,
|
|
50
|
+
}, unknown, zod_v4_core0.$ZodTypeInternals<{
|
|
53
51
|
id: string;
|
|
54
52
|
offset: number;
|
|
55
53
|
storage: {
|
|
@@ -82,11 +80,11 @@ declare function createDescribeImageNode(id: string, {
|
|
|
82
80
|
traceFlags: number;
|
|
83
81
|
} | undefined;
|
|
84
82
|
}, unknown>>;
|
|
85
|
-
outputSchema:
|
|
83
|
+
outputSchema: zod0.ZodType<{
|
|
86
84
|
description: string;
|
|
87
85
|
confidence?: number | undefined;
|
|
88
86
|
metadata?: Record<string, unknown> | undefined;
|
|
89
|
-
}, unknown,
|
|
87
|
+
}, unknown, zod_v4_core0.$ZodTypeInternals<{
|
|
90
88
|
description: string;
|
|
91
89
|
confidence?: number | undefined;
|
|
92
90
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -130,11 +128,11 @@ declare function createDescribeImageNode(id: string, {
|
|
|
130
128
|
flowId: string;
|
|
131
129
|
inputs?: Record<string, unknown>;
|
|
132
130
|
clientId: string | null;
|
|
133
|
-
}) => Effect.Effect<
|
|
131
|
+
}) => Effect.Effect<_uploadista_core0.NodeExecutionResult<{
|
|
134
132
|
description: string;
|
|
135
133
|
confidence?: number | undefined;
|
|
136
134
|
metadata?: Record<string, unknown> | undefined;
|
|
137
|
-
}>, UploadistaError, never>;
|
|
135
|
+
}>, UploadistaError$1, never>;
|
|
138
136
|
condition?: {
|
|
139
137
|
field: string;
|
|
140
138
|
operator: string;
|
|
@@ -148,27 +146,46 @@ declare function createDescribeImageNode(id: string, {
|
|
|
148
146
|
retryDelay?: number;
|
|
149
147
|
exponentialBackoff?: boolean;
|
|
150
148
|
};
|
|
151
|
-
circuitBreaker?:
|
|
149
|
+
circuitBreaker?: _uploadista_core0.FlowCircuitBreakerConfig;
|
|
152
150
|
} & {
|
|
153
151
|
type: NodeType.process;
|
|
154
|
-
}, UploadistaError, ImageAiPlugin>;
|
|
152
|
+
}, UploadistaError$1, ImageAiPlugin>;
|
|
155
153
|
//#endregion
|
|
156
154
|
//#region src/optimize-node.d.ts
|
|
157
155
|
/**
|
|
158
156
|
* Creates an optimize node that optimizes images for web delivery.
|
|
159
157
|
*
|
|
158
|
+
* Supports both buffered and streaming modes for memory-efficient processing
|
|
159
|
+
* of large images. In streaming mode, the image is read and processed
|
|
160
|
+
* incrementally, reducing peak memory usage.
|
|
161
|
+
*
|
|
160
162
|
* @param id - Unique node identifier
|
|
161
163
|
* @param params - Optimize parameters (quality, format)
|
|
162
164
|
* @param options - Optional configuration
|
|
163
165
|
* @param options.keepOutput - Whether to keep output in flow results
|
|
164
166
|
* @param options.naming - File naming configuration (auto suffix: `${format}`)
|
|
167
|
+
* @param options.mode - Transform mode: "buffered" (default), "streaming", or "auto"
|
|
168
|
+
* @param options.streamingConfig - Streaming configuration (file size threshold, chunk size)
|
|
165
169
|
*
|
|
166
170
|
* @example
|
|
167
171
|
* ```typescript
|
|
168
|
-
* //
|
|
172
|
+
* // Buffered mode (default) - "photo.jpg" -> "photo-webp.webp"
|
|
169
173
|
* const optimize = yield* createOptimizeNode("opt-1", { quality: 80, format: "webp" }, {
|
|
170
174
|
* naming: { mode: "auto" }
|
|
171
175
|
* });
|
|
176
|
+
*
|
|
177
|
+
* // Streaming mode for large files
|
|
178
|
+
* const optimizeStreaming = yield* createOptimizeNode("opt-2", { quality: 80, format: "webp" }, {
|
|
179
|
+
* mode: "streaming",
|
|
180
|
+
* naming: { mode: "auto" }
|
|
181
|
+
* });
|
|
182
|
+
*
|
|
183
|
+
* // Auto mode - uses streaming for files > 1MB
|
|
184
|
+
* const optimizeAuto = yield* createOptimizeNode("opt-3", { quality: 80, format: "webp" }, {
|
|
185
|
+
* mode: "auto",
|
|
186
|
+
* streamingConfig: { fileSizeThreshold: 1_048_576 },
|
|
187
|
+
* naming: { mode: "auto" }
|
|
188
|
+
* });
|
|
172
189
|
* ```
|
|
173
190
|
*/
|
|
174
191
|
declare function createOptimizeNode(id: string, {
|
|
@@ -177,17 +194,19 @@ declare function createOptimizeNode(id: string, {
|
|
|
177
194
|
}: OptimizeParams, options?: {
|
|
178
195
|
keepOutput?: boolean;
|
|
179
196
|
naming?: FileNamingConfig;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
197
|
+
mode?: TransformMode;
|
|
198
|
+
streamingConfig?: StreamingConfig;
|
|
199
|
+
}): Effect.Effect<_uploadista_core0.FlowNodeData & {
|
|
200
|
+
inputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
201
|
+
outputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
183
202
|
run: (args: {
|
|
184
|
-
data:
|
|
203
|
+
data: _uploadista_core0.UploadFile;
|
|
185
204
|
jobId: string;
|
|
186
205
|
storageId: string;
|
|
187
206
|
flowId: string;
|
|
188
207
|
inputs?: Record<string, unknown>;
|
|
189
208
|
clientId: string | null;
|
|
190
|
-
}) => Effect.Effect<
|
|
209
|
+
}) => Effect.Effect<_uploadista_core0.NodeExecutionResult<_uploadista_core0.UploadFile>, UploadistaError, never>;
|
|
191
210
|
condition?: {
|
|
192
211
|
field: string;
|
|
193
212
|
operator: string;
|
|
@@ -201,10 +220,10 @@ declare function createOptimizeNode(id: string, {
|
|
|
201
220
|
retryDelay?: number;
|
|
202
221
|
exponentialBackoff?: boolean;
|
|
203
222
|
};
|
|
204
|
-
circuitBreaker?:
|
|
223
|
+
circuitBreaker?: _uploadista_core0.FlowCircuitBreakerConfig;
|
|
205
224
|
} & {
|
|
206
|
-
type:
|
|
207
|
-
},
|
|
225
|
+
type: _uploadista_core0.NodeType;
|
|
226
|
+
}, UploadistaError, ImagePlugin | _uploadista_core0.UploadServer>;
|
|
208
227
|
//#endregion
|
|
209
228
|
//#region src/remove-background-node.d.ts
|
|
210
229
|
/**
|
|
@@ -232,8 +251,8 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
232
251
|
credentialId?: string;
|
|
233
252
|
keepOutput?: boolean;
|
|
234
253
|
naming?: FileNamingConfig;
|
|
235
|
-
}): Effect.Effect<
|
|
236
|
-
inputSchema:
|
|
254
|
+
}): Effect.Effect<_uploadista_core0.FlowNodeData & {
|
|
255
|
+
inputSchema: zod0.ZodType<{
|
|
237
256
|
id: string;
|
|
238
257
|
offset: number;
|
|
239
258
|
storage: {
|
|
@@ -265,7 +284,7 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
265
284
|
spanId: string;
|
|
266
285
|
traceFlags: number;
|
|
267
286
|
} | undefined;
|
|
268
|
-
}, unknown,
|
|
287
|
+
}, unknown, zod_v4_core0.$ZodTypeInternals<{
|
|
269
288
|
id: string;
|
|
270
289
|
offset: number;
|
|
271
290
|
storage: {
|
|
@@ -298,7 +317,7 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
298
317
|
traceFlags: number;
|
|
299
318
|
} | undefined;
|
|
300
319
|
}, unknown>>;
|
|
301
|
-
outputSchema:
|
|
320
|
+
outputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
302
321
|
run: (args: {
|
|
303
322
|
data: {
|
|
304
323
|
id: string;
|
|
@@ -338,7 +357,7 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
338
357
|
flowId: string;
|
|
339
358
|
inputs?: Record<string, unknown>;
|
|
340
359
|
clientId: string | null;
|
|
341
|
-
}) => Effect.Effect<
|
|
360
|
+
}) => Effect.Effect<_uploadista_core0.NodeExecutionResult<_uploadista_core0.UploadFile>, UploadistaError$1, never>;
|
|
342
361
|
condition?: {
|
|
343
362
|
field: string;
|
|
344
363
|
operator: string;
|
|
@@ -352,27 +371,45 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
352
371
|
retryDelay?: number;
|
|
353
372
|
exponentialBackoff?: boolean;
|
|
354
373
|
};
|
|
355
|
-
circuitBreaker?:
|
|
374
|
+
circuitBreaker?: _uploadista_core0.FlowCircuitBreakerConfig;
|
|
356
375
|
} & {
|
|
357
376
|
type: NodeType.process;
|
|
358
|
-
}, UploadistaError, ImageAiPlugin | UploadServer>;
|
|
377
|
+
}, UploadistaError$1, ImageAiPlugin | UploadServer>;
|
|
359
378
|
//#endregion
|
|
360
379
|
//#region src/resize-node.d.ts
|
|
361
380
|
/**
|
|
362
381
|
* Creates a resize node that resizes images to specified dimensions.
|
|
363
382
|
*
|
|
383
|
+
* Supports both buffered and streaming modes for memory-efficient processing
|
|
384
|
+
* of large images. In streaming mode, the image is read and processed
|
|
385
|
+
* incrementally, reducing peak memory usage.
|
|
386
|
+
*
|
|
364
387
|
* @param id - Unique node identifier
|
|
365
388
|
* @param params - Resize parameters (width, height, fit)
|
|
366
389
|
* @param options - Optional configuration
|
|
367
390
|
* @param options.keepOutput - Whether to keep output in flow results
|
|
368
391
|
* @param options.naming - File naming configuration (auto suffix: `${width}x${height}`)
|
|
392
|
+
* @param options.mode - Transform mode: "buffered", "streaming", or "auto" (default)
|
|
393
|
+
* @param options.streamingConfig - Streaming configuration (file size threshold, chunk size)
|
|
369
394
|
*
|
|
370
395
|
* @example
|
|
371
396
|
* ```typescript
|
|
372
|
-
* //
|
|
397
|
+
* // Auto mode (default) - uses streaming for files > 1MB, otherwise buffered
|
|
373
398
|
* const resize = yield* createResizeNode("resize-1", { width: 800, height: 600 }, {
|
|
374
399
|
* naming: { mode: "auto" }
|
|
375
400
|
* });
|
|
401
|
+
*
|
|
402
|
+
* // Force buffered mode for small files
|
|
403
|
+
* const resizeBuffered = yield* createResizeNode("resize-2", { width: 800, height: 600 }, {
|
|
404
|
+
* mode: "buffered",
|
|
405
|
+
* naming: { mode: "auto" }
|
|
406
|
+
* });
|
|
407
|
+
*
|
|
408
|
+
* // Force streaming mode for memory efficiency
|
|
409
|
+
* const resizeStreaming = yield* createResizeNode("resize-3", { width: 800, height: 600 }, {
|
|
410
|
+
* mode: "streaming",
|
|
411
|
+
* naming: { mode: "auto" }
|
|
412
|
+
* });
|
|
376
413
|
* ```
|
|
377
414
|
*/
|
|
378
415
|
declare function createResizeNode(id: string, {
|
|
@@ -382,17 +419,19 @@ declare function createResizeNode(id: string, {
|
|
|
382
419
|
}: ResizeParams, options?: {
|
|
383
420
|
keepOutput?: boolean;
|
|
384
421
|
naming?: FileNamingConfig;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
422
|
+
mode?: TransformMode;
|
|
423
|
+
streamingConfig?: StreamingConfig;
|
|
424
|
+
}): Effect.Effect<_uploadista_core0.FlowNodeData & {
|
|
425
|
+
inputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
426
|
+
outputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
388
427
|
run: (args: {
|
|
389
|
-
data:
|
|
428
|
+
data: _uploadista_core0.UploadFile;
|
|
390
429
|
jobId: string;
|
|
391
430
|
storageId: string;
|
|
392
431
|
flowId: string;
|
|
393
432
|
inputs?: Record<string, unknown>;
|
|
394
433
|
clientId: string | null;
|
|
395
|
-
}) => Effect.Effect<
|
|
434
|
+
}) => Effect.Effect<_uploadista_core0.NodeExecutionResult<_uploadista_core0.UploadFile>, _uploadista_core0.UploadistaError, never>;
|
|
396
435
|
condition?: {
|
|
397
436
|
field: string;
|
|
398
437
|
operator: string;
|
|
@@ -406,10 +445,10 @@ declare function createResizeNode(id: string, {
|
|
|
406
445
|
retryDelay?: number;
|
|
407
446
|
exponentialBackoff?: boolean;
|
|
408
447
|
};
|
|
409
|
-
circuitBreaker?:
|
|
448
|
+
circuitBreaker?: _uploadista_core0.FlowCircuitBreakerConfig;
|
|
410
449
|
} & {
|
|
411
|
-
type:
|
|
412
|
-
},
|
|
450
|
+
type: _uploadista_core0.NodeType;
|
|
451
|
+
}, _uploadista_core0.UploadistaError, ImagePlugin | _uploadista_core0.UploadServer>;
|
|
413
452
|
//#endregion
|
|
414
453
|
//#region src/transform-image-node.d.ts
|
|
415
454
|
/**
|
|
@@ -419,24 +458,32 @@ declare function createResizeNode(id: string, {
|
|
|
419
458
|
* together. Each transformation is applied to the output of the previous transformation,
|
|
420
459
|
* allowing for powerful image manipulation pipelines.
|
|
421
460
|
*
|
|
461
|
+
* Supports both buffered and streaming modes for memory-efficient processing
|
|
462
|
+
* of large images. In streaming mode, each transformation is applied in sequence
|
|
463
|
+
* using streaming where supported.
|
|
464
|
+
*
|
|
422
465
|
* Supported transformations include:
|
|
423
466
|
* - Basic: resize, blur, rotate, flip
|
|
424
467
|
* - Filters: grayscale, sepia, brightness, contrast
|
|
425
468
|
* - Effects: sharpen
|
|
426
|
-
* - Advanced: watermark, logo, text
|
|
469
|
+
* - Advanced: watermark, logo, text (streaming not supported for these)
|
|
427
470
|
*
|
|
428
471
|
* Note: Watermark and logo transformations require imagePath to be a valid URL.
|
|
429
472
|
* Images will be fetched from the provided URL during transformation.
|
|
473
|
+
* Streaming mode is not supported for watermark, logo, and text transformations;
|
|
474
|
+
* these will cause fallback to buffered mode.
|
|
430
475
|
*
|
|
431
476
|
* @param id - Unique identifier for this node
|
|
432
477
|
* @param params - Parameters including the transformations array
|
|
433
478
|
* @param options - Optional configuration
|
|
434
479
|
* @param options.keepOutput - Whether to keep output in flow results
|
|
435
480
|
* @param options.naming - File naming configuration (auto suffix: `transformed`)
|
|
481
|
+
* @param options.mode - Transform mode: "buffered", "streaming", or "auto" (default)
|
|
482
|
+
* @param options.streamingConfig - Streaming configuration (file size threshold, chunk size)
|
|
436
483
|
*
|
|
437
484
|
* @example
|
|
438
485
|
* ```typescript
|
|
439
|
-
* //
|
|
486
|
+
* // Auto mode (default) - uses streaming for files > 1MB, otherwise buffered
|
|
440
487
|
* const node = yield* createTransformImageNode("transform-1", {
|
|
441
488
|
* transformations: [
|
|
442
489
|
* { type: 'resize', width: 800, height: 600, fit: 'cover' },
|
|
@@ -445,6 +492,25 @@ declare function createResizeNode(id: string, {
|
|
|
445
492
|
* }, {
|
|
446
493
|
* naming: { mode: "auto" }
|
|
447
494
|
* });
|
|
495
|
+
*
|
|
496
|
+
* // Force buffered mode for small files
|
|
497
|
+
* const nodeBuffered = yield* createTransformImageNode("transform-2", {
|
|
498
|
+
* transformations: [
|
|
499
|
+
* { type: 'resize', width: 800, height: 600, fit: 'cover' },
|
|
500
|
+
* { type: 'blur', sigma: 5 }
|
|
501
|
+
* ]
|
|
502
|
+
* }, {
|
|
503
|
+
* mode: "buffered",
|
|
504
|
+
* naming: { mode: "auto" }
|
|
505
|
+
* });
|
|
506
|
+
*
|
|
507
|
+
* // Force streaming mode for memory efficiency
|
|
508
|
+
* const nodeStreaming = yield* createTransformImageNode("transform-3", {
|
|
509
|
+
* transformations: [{ type: 'grayscale' }]
|
|
510
|
+
* }, {
|
|
511
|
+
* mode: "streaming",
|
|
512
|
+
* naming: { mode: "auto" }
|
|
513
|
+
* });
|
|
448
514
|
* ```
|
|
449
515
|
*/
|
|
450
516
|
declare function createTransformImageNode(id: string, {
|
|
@@ -452,17 +518,19 @@ declare function createTransformImageNode(id: string, {
|
|
|
452
518
|
}: TransformImageParams, options?: {
|
|
453
519
|
keepOutput?: boolean;
|
|
454
520
|
naming?: FileNamingConfig;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
521
|
+
mode?: TransformMode;
|
|
522
|
+
streamingConfig?: StreamingConfig;
|
|
523
|
+
}): Effect.Effect<_uploadista_core0.FlowNodeData & {
|
|
524
|
+
inputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
525
|
+
outputSchema: zod0.ZodType<_uploadista_core0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core0.UploadFile, unknown>>;
|
|
458
526
|
run: (args: {
|
|
459
|
-
data:
|
|
527
|
+
data: _uploadista_core0.UploadFile;
|
|
460
528
|
jobId: string;
|
|
461
529
|
storageId: string;
|
|
462
530
|
flowId: string;
|
|
463
531
|
inputs?: Record<string, unknown>;
|
|
464
532
|
clientId: string | null;
|
|
465
|
-
}) => Effect.Effect<
|
|
533
|
+
}) => Effect.Effect<_uploadista_core0.NodeExecutionResult<_uploadista_core0.UploadFile>, UploadistaError$1, never>;
|
|
466
534
|
condition?: {
|
|
467
535
|
field: string;
|
|
468
536
|
operator: string;
|
|
@@ -476,10 +544,10 @@ declare function createTransformImageNode(id: string, {
|
|
|
476
544
|
retryDelay?: number;
|
|
477
545
|
exponentialBackoff?: boolean;
|
|
478
546
|
};
|
|
479
|
-
circuitBreaker?:
|
|
547
|
+
circuitBreaker?: _uploadista_core0.FlowCircuitBreakerConfig;
|
|
480
548
|
} & {
|
|
481
|
-
type:
|
|
482
|
-
},
|
|
549
|
+
type: _uploadista_core0.NodeType;
|
|
550
|
+
}, UploadistaError$1, ImagePlugin | _uploadista_core0.UploadServer>;
|
|
483
551
|
//#endregion
|
|
484
552
|
//#region src/wait-for-url.d.ts
|
|
485
553
|
/**
|
|
@@ -496,7 +564,7 @@ declare function createTransformImageNode(id: string, {
|
|
|
496
564
|
declare function waitForUrlAvailability(url: string, options?: {
|
|
497
565
|
maxWaitTime?: number;
|
|
498
566
|
retryDelay?: number;
|
|
499
|
-
}): Effect.Effect<void, UploadistaError>;
|
|
567
|
+
}): Effect.Effect<void, UploadistaError$1>;
|
|
500
568
|
//#endregion
|
|
501
569
|
export { createDescribeImageNode, createOptimizeNode, createRemoveBackgroundNode, createResizeNode, createTransformImageNode, waitForUrlAvailability };
|
|
502
570
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/describe-image-node.ts","../src/optimize-node.ts","../src/remove-background-node.ts","../src/resize-node.ts","../src/transform-image-node.ts","../src/wait-for-url.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/describe-image-node.ts","../src/optimize-node.ts","../src/remove-background-node.ts","../src/resize-node.ts","../src/transform-image-node.ts","../src/wait-for-url.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;iBAcgB,uBAAA;;;;;;IAEoE,MAAA,CAAA,OAAxD,iBAAA,CAAwD,YAAA;;;;IAFpE,OAAA,EAAA;MAEZ,EAAA,EAAA,MAAA;MAAc,IAAA,EAAA,MAAA;MAAU,IAAA,CAAA,EAAwD,MAAA,GAAA,SAAA;;;;;;;;;;;;;;;;;;;MAAA,KAAA,EAAA,MAAA;IAAA,CAAA,GAAA,SAAA;;;;MCmDpE,UAAA,EAAA,MAAkB;IAE9B,CAAA,GAAA,SAAA;EAAS,CAAA,EAAA,OAAA,gCAAA,CAAA;IAAU,EAAA,EAAA,MAAA;IAGV,MAAA,EAAA,MAAA;IACF,OAAA,EAAA;MACW,EAAA,EAAA,MAAA;MAAe,IAAA,EAAA,MAClC;MAAA,IAAA,CAAA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