@uploadista/flow-images-nodes 0.0.16 → 0.0.17-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 +24 -180
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -165
- 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/describe-image-node.ts +10 -21
- package/src/optimize-node.ts +2 -0
- package/src/remove-background-node.ts +2 -0
- package/src/resize-node.ts +2 -0
- package/src/transform-image-node.ts +2 -0
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 a(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 o(i,{credentialId:o}={}){return r.Effect.gen(function*(){let s=yield*t.ImageAiPlugin;return yield*(0,t.createFlowNode)({id:i,name:`Describe Image`,description:`Describes the image using AI`,type:t.NodeType.process,inputSchema:n.uploadFileSchema,outputSchema:
|
|
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 a(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 o(i,{credentialId:o}={}){return r.Effect.gen(function*(){let s=yield*t.ImageAiPlugin;return yield*(0,t.createFlowNode)({id:i,name:`Describe Image`,description:`Describes the image using AI`,type:t.NodeType.process,nodeTypeId:t.IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,inputSchema:n.uploadFileSchema,outputSchema:t.imageDescriptionOutputSchema,run:({data:n,flowId:c,jobId:l,clientId:u})=>r.Effect.gen(function*(){let d={flowId:c,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*a(f);let p={clientId:u,credentialId:o},m=yield*s.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 s={jpeg:`image/jpeg`,webp:`image/webp`,png:`image/png`,avif:`image/avif`},c={jpeg:`jpg`,webp:`webp`,png:`png`,avif:`avif`};function l(e,{quality:n,format:i}){return r.Effect.gen(function*(){let a=yield*t.ImagePlugin;return yield*(0,t.createTransformNode)({id:e,name:`Optimize`,description:`Optimizes an image for web delivery`,nodeTypeId:t.STORAGE_OUTPUT_TYPE_ID,transform:(e,t)=>r.Effect.map(a.optimize(e,{quality:n,format:i}),e=>{let n=s[i],r=c[i],a=t.metadata?.fileName;return{bytes:e,type:n,fileName:a&&typeof a==`string`?a.replace(/\.[^.]+$/,`.${r}`):void 0}})})})}function u(o,{credentialId:s}={}){return r.Effect.gen(function*(){let c=yield*t.ImageAiPlugin,l=yield*i.UploadServer;return yield*(0,t.createFlowNode)({id:o,name:`Remove Background`,description:`Removes the background from an image`,type:t.NodeType.process,nodeTypeId:t.STORAGE_OUTPUT_TYPE_ID,inputSchema:n.uploadFileSchema,outputSchema:n.uploadFileSchema,run:({data:n,flowId:i,jobId:u,storageId:d,clientId:f})=>r.Effect.gen(function*(){let p={flowId:i,nodeId:o,jobId:u},m=n.url;if(!m)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*a(m);let h={clientId:f,credentialId:s},{outputUrl:g}=yield*c.removeBackground(m,h).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:_,fileName:v,metadata:y,metadataJson:b}=(0,t.resolveUploadMetadata)(n.metadata);yield*r.Effect.logInfo(`Uploading processed file to storage`);let x=yield*l.uploadFromUrl({storageId:d,size:0,type:_,fileName:v,lastModified:0,metadata:b,flow:p},f,g).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()})));return yield*r.Effect.logInfo(`Successfully removed background for file ${n.id}`),(0,t.completeNodeExecution)(y?{...x,metadata:y}:x)})})})}function d(e,{width:n,height:i,fit:a}){return r.Effect.gen(function*(){let r=yield*t.ImagePlugin;return yield*(0,t.createTransformNode)({id:e,name:`Resize`,description:`Resizes an image to the specified dimensions`,nodeTypeId:t.STORAGE_OUTPUT_TYPE_ID,transform:e=>r.resize(e,{height:i,width:n,fit:a})})})}function f(e,t,n){return r.Effect.reduce(n,t,(t,n)=>e.transform(t,n))}function p(e,{transformations:n}){return r.Effect.gen(function*(){let r=yield*t.ImagePlugin;return yield*(0,t.createTransformNode)({id:e,name:`Transform Image`,description:`Apply ${n.length} transformation${n.length===1?``:`s`} to the image`,nodeTypeId:t.STORAGE_OUTPUT_TYPE_ID,transform:e=>f(r,e,n)})})}exports.createDescribeImageNode=o,exports.createOptimizeNode=l,exports.createRemoveBackgroundNode=u,exports.createResizeNode=d,exports.createTransformImageNode=p,exports.waitForUrlAvailability=a;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import * as zod0 from "zod";
|
|
|
5
5
|
import * as _uploadista_core_errors0 from "@uploadista/core/errors";
|
|
6
6
|
import { UploadistaError } from "@uploadista/core/errors";
|
|
7
7
|
import { Effect } from "effect";
|
|
8
|
-
import * as
|
|
8
|
+
import * as _uploadista_core_types0 from "@uploadista/core/types";
|
|
9
9
|
import * as _uploadista_core_upload0 from "@uploadista/core/upload";
|
|
10
10
|
import { UploadServer } from "@uploadista/core/upload";
|
|
11
11
|
|
|
@@ -71,117 +71,13 @@ declare function createDescribeImageNode(id: string, {
|
|
|
71
71
|
} | undefined;
|
|
72
72
|
}, unknown>>;
|
|
73
73
|
outputSchema: zod0.ZodType<{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id: string;
|
|
78
|
-
type: string;
|
|
79
|
-
path?: string | undefined;
|
|
80
|
-
uploadId?: string | undefined;
|
|
81
|
-
bucket?: string | undefined;
|
|
82
|
-
parts?: {
|
|
83
|
-
partNumber: number;
|
|
84
|
-
etag: string;
|
|
85
|
-
size: number;
|
|
86
|
-
}[] | undefined;
|
|
87
|
-
};
|
|
88
|
-
size?: number | undefined;
|
|
89
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
90
|
-
creationDate?: string | undefined;
|
|
91
|
-
url?: string | undefined;
|
|
92
|
-
sizeIsDeferred?: boolean | undefined;
|
|
93
|
-
checksum?: string | undefined;
|
|
94
|
-
checksumAlgorithm?: string | undefined;
|
|
95
|
-
flow?: {
|
|
96
|
-
flowId: string;
|
|
97
|
-
nodeId: string;
|
|
98
|
-
jobId: string;
|
|
99
|
-
} | undefined;
|
|
100
|
-
} | {
|
|
101
|
-
metadata: {
|
|
102
|
-
description: string;
|
|
103
|
-
};
|
|
104
|
-
flow: {
|
|
105
|
-
flowId: string;
|
|
106
|
-
nodeId: string;
|
|
107
|
-
jobId: string;
|
|
108
|
-
};
|
|
109
|
-
id: string;
|
|
110
|
-
offset: number;
|
|
111
|
-
storage: {
|
|
112
|
-
id: string;
|
|
113
|
-
type: string;
|
|
114
|
-
path?: string | undefined;
|
|
115
|
-
uploadId?: string | undefined;
|
|
116
|
-
bucket?: string | undefined;
|
|
117
|
-
parts?: {
|
|
118
|
-
partNumber: number;
|
|
119
|
-
etag: string;
|
|
120
|
-
size: number;
|
|
121
|
-
}[] | undefined;
|
|
122
|
-
};
|
|
123
|
-
size?: number | undefined;
|
|
124
|
-
creationDate?: string | undefined;
|
|
125
|
-
url?: string | undefined;
|
|
126
|
-
sizeIsDeferred?: boolean | undefined;
|
|
127
|
-
checksum?: string | undefined;
|
|
128
|
-
checksumAlgorithm?: string | undefined;
|
|
74
|
+
description: string;
|
|
75
|
+
confidence?: number | undefined;
|
|
76
|
+
metadata?: Record<string, unknown> | undefined;
|
|
129
77
|
}, unknown, zod_v4_core0.$ZodTypeInternals<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
id: string;
|
|
134
|
-
type: string;
|
|
135
|
-
path?: string | undefined;
|
|
136
|
-
uploadId?: string | undefined;
|
|
137
|
-
bucket?: string | undefined;
|
|
138
|
-
parts?: {
|
|
139
|
-
partNumber: number;
|
|
140
|
-
etag: string;
|
|
141
|
-
size: number;
|
|
142
|
-
}[] | undefined;
|
|
143
|
-
};
|
|
144
|
-
size?: number | undefined;
|
|
145
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
146
|
-
creationDate?: string | undefined;
|
|
147
|
-
url?: string | undefined;
|
|
148
|
-
sizeIsDeferred?: boolean | undefined;
|
|
149
|
-
checksum?: string | undefined;
|
|
150
|
-
checksumAlgorithm?: string | undefined;
|
|
151
|
-
flow?: {
|
|
152
|
-
flowId: string;
|
|
153
|
-
nodeId: string;
|
|
154
|
-
jobId: string;
|
|
155
|
-
} | undefined;
|
|
156
|
-
} | {
|
|
157
|
-
metadata: {
|
|
158
|
-
description: string;
|
|
159
|
-
};
|
|
160
|
-
flow: {
|
|
161
|
-
flowId: string;
|
|
162
|
-
nodeId: string;
|
|
163
|
-
jobId: string;
|
|
164
|
-
};
|
|
165
|
-
id: string;
|
|
166
|
-
offset: number;
|
|
167
|
-
storage: {
|
|
168
|
-
id: string;
|
|
169
|
-
type: string;
|
|
170
|
-
path?: string | undefined;
|
|
171
|
-
uploadId?: string | undefined;
|
|
172
|
-
bucket?: string | undefined;
|
|
173
|
-
parts?: {
|
|
174
|
-
partNumber: number;
|
|
175
|
-
etag: string;
|
|
176
|
-
size: number;
|
|
177
|
-
}[] | undefined;
|
|
178
|
-
};
|
|
179
|
-
size?: number | undefined;
|
|
180
|
-
creationDate?: string | undefined;
|
|
181
|
-
url?: string | undefined;
|
|
182
|
-
sizeIsDeferred?: boolean | undefined;
|
|
183
|
-
checksum?: string | undefined;
|
|
184
|
-
checksumAlgorithm?: string | undefined;
|
|
78
|
+
description: string;
|
|
79
|
+
confidence?: number | undefined;
|
|
80
|
+
metadata?: Record<string, unknown> | undefined;
|
|
185
81
|
}, unknown>>;
|
|
186
82
|
run: (args: {
|
|
187
83
|
data: {
|
|
@@ -218,61 +114,9 @@ declare function createDescribeImageNode(id: string, {
|
|
|
218
114
|
inputs?: Record<string, unknown>;
|
|
219
115
|
clientId: string | null;
|
|
220
116
|
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<{
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
id: string;
|
|
225
|
-
type: string;
|
|
226
|
-
path?: string | undefined;
|
|
227
|
-
uploadId?: string | undefined;
|
|
228
|
-
bucket?: string | undefined;
|
|
229
|
-
parts?: {
|
|
230
|
-
partNumber: number;
|
|
231
|
-
etag: string;
|
|
232
|
-
size: number;
|
|
233
|
-
}[] | undefined;
|
|
234
|
-
};
|
|
235
|
-
size?: number | undefined;
|
|
236
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
237
|
-
creationDate?: string | undefined;
|
|
238
|
-
url?: string | undefined;
|
|
239
|
-
sizeIsDeferred?: boolean | undefined;
|
|
240
|
-
checksum?: string | undefined;
|
|
241
|
-
checksumAlgorithm?: string | undefined;
|
|
242
|
-
flow?: {
|
|
243
|
-
flowId: string;
|
|
244
|
-
nodeId: string;
|
|
245
|
-
jobId: string;
|
|
246
|
-
} | undefined;
|
|
247
|
-
} | {
|
|
248
|
-
metadata: {
|
|
249
|
-
description: string;
|
|
250
|
-
};
|
|
251
|
-
flow: {
|
|
252
|
-
flowId: string;
|
|
253
|
-
nodeId: string;
|
|
254
|
-
jobId: string;
|
|
255
|
-
};
|
|
256
|
-
id: string;
|
|
257
|
-
offset: number;
|
|
258
|
-
storage: {
|
|
259
|
-
id: string;
|
|
260
|
-
type: string;
|
|
261
|
-
path?: string | undefined;
|
|
262
|
-
uploadId?: string | undefined;
|
|
263
|
-
bucket?: string | undefined;
|
|
264
|
-
parts?: {
|
|
265
|
-
partNumber: number;
|
|
266
|
-
etag: string;
|
|
267
|
-
size: number;
|
|
268
|
-
}[] | undefined;
|
|
269
|
-
};
|
|
270
|
-
size?: number | undefined;
|
|
271
|
-
creationDate?: string | undefined;
|
|
272
|
-
url?: string | undefined;
|
|
273
|
-
sizeIsDeferred?: boolean | undefined;
|
|
274
|
-
checksum?: string | undefined;
|
|
275
|
-
checksumAlgorithm?: string | undefined;
|
|
117
|
+
description: string;
|
|
118
|
+
confidence?: number | undefined;
|
|
119
|
+
metadata?: Record<string, unknown> | undefined;
|
|
276
120
|
}>, UploadistaError, never>;
|
|
277
121
|
condition?: {
|
|
278
122
|
field: string;
|
|
@@ -296,16 +140,16 @@ declare function createOptimizeNode(id: string, {
|
|
|
296
140
|
quality,
|
|
297
141
|
format
|
|
298
142
|
}: OptimizeParams): Effect.Effect<_uploadista_core_flow0.FlowNodeData & {
|
|
299
|
-
inputSchema: zod0.ZodType<
|
|
300
|
-
outputSchema: zod0.ZodType<
|
|
143
|
+
inputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
144
|
+
outputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
301
145
|
run: (args: {
|
|
302
|
-
data:
|
|
146
|
+
data: _uploadista_core_types0.UploadFile;
|
|
303
147
|
jobId: string;
|
|
304
148
|
storageId: string;
|
|
305
149
|
flowId: string;
|
|
306
150
|
inputs?: Record<string, unknown>;
|
|
307
151
|
clientId: string | null;
|
|
308
|
-
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<
|
|
152
|
+
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<_uploadista_core_types0.UploadFile>, _uploadista_core_errors0.UploadistaError, never>;
|
|
309
153
|
condition?: {
|
|
310
154
|
field: string;
|
|
311
155
|
operator: string;
|
|
@@ -384,7 +228,7 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
384
228
|
jobId: string;
|
|
385
229
|
} | undefined;
|
|
386
230
|
}, unknown>>;
|
|
387
|
-
outputSchema: zod0.ZodType<
|
|
231
|
+
outputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
388
232
|
run: (args: {
|
|
389
233
|
data: {
|
|
390
234
|
id: string;
|
|
@@ -419,7 +263,7 @@ declare function createRemoveBackgroundNode(id: string, {
|
|
|
419
263
|
flowId: string;
|
|
420
264
|
inputs?: Record<string, unknown>;
|
|
421
265
|
clientId: string | null;
|
|
422
|
-
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<
|
|
266
|
+
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<_uploadista_core_types0.UploadFile>, UploadistaError, never>;
|
|
423
267
|
condition?: {
|
|
424
268
|
field: string;
|
|
425
269
|
operator: string;
|
|
@@ -443,16 +287,16 @@ declare function createResizeNode(id: string, {
|
|
|
443
287
|
height,
|
|
444
288
|
fit
|
|
445
289
|
}: ResizeParams): Effect.Effect<_uploadista_core_flow0.FlowNodeData & {
|
|
446
|
-
inputSchema: zod0.ZodType<
|
|
447
|
-
outputSchema: zod0.ZodType<
|
|
290
|
+
inputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
291
|
+
outputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
448
292
|
run: (args: {
|
|
449
|
-
data:
|
|
293
|
+
data: _uploadista_core_types0.UploadFile;
|
|
450
294
|
jobId: string;
|
|
451
295
|
storageId: string;
|
|
452
296
|
flowId: string;
|
|
453
297
|
inputs?: Record<string, unknown>;
|
|
454
298
|
clientId: string | null;
|
|
455
|
-
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<
|
|
299
|
+
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<_uploadista_core_types0.UploadFile>, _uploadista_core_errors0.UploadistaError, never>;
|
|
456
300
|
condition?: {
|
|
457
301
|
field: string;
|
|
458
302
|
operator: string;
|
|
@@ -510,16 +354,16 @@ declare function createResizeNode(id: string, {
|
|
|
510
354
|
declare function createTransformImageNode(id: string, {
|
|
511
355
|
transformations
|
|
512
356
|
}: TransformImageParams): Effect.Effect<_uploadista_core_flow0.FlowNodeData & {
|
|
513
|
-
inputSchema: zod0.ZodType<
|
|
514
|
-
outputSchema: zod0.ZodType<
|
|
357
|
+
inputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
358
|
+
outputSchema: zod0.ZodType<_uploadista_core_types0.UploadFile, unknown, zod_v4_core0.$ZodTypeInternals<_uploadista_core_types0.UploadFile, unknown>>;
|
|
515
359
|
run: (args: {
|
|
516
|
-
data:
|
|
360
|
+
data: _uploadista_core_types0.UploadFile;
|
|
517
361
|
jobId: string;
|
|
518
362
|
storageId: string;
|
|
519
363
|
flowId: string;
|
|
520
364
|
inputs?: Record<string, unknown>;
|
|
521
365
|
clientId: string | null;
|
|
522
|
-
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<
|
|
366
|
+
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<_uploadista_core_types0.UploadFile>, _uploadista_core_errors0.UploadistaError, never>;
|
|
523
367
|
condition?: {
|
|
524
368
|
field: string;
|
|
525
369
|
operator: string;
|
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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,CAAA;;;;;;;;;;;;;;;;ADZrC;AAEI,iBKFY,sBAAA,CLEZ,GAAA,EAAA,MAAA,EAAA,QAAA,EAAA;EAAY,WAAA,CAAA,EAAA,MAAkC;;IKI/C,MAAA,CAAO,aAAa"}
|
package/dist/index.d.mts
CHANGED
|
@@ -71,117 +71,13 @@ declare function createDescribeImageNode(id: string, {
|
|
|
71
71
|
} | undefined;
|
|
72
72
|
}, unknown>>;
|
|
73
73
|
outputSchema: zod0.ZodType<{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id: string;
|
|
78
|
-
type: string;
|
|
79
|
-
path?: string | undefined;
|
|
80
|
-
uploadId?: string | undefined;
|
|
81
|
-
bucket?: string | undefined;
|
|
82
|
-
parts?: {
|
|
83
|
-
partNumber: number;
|
|
84
|
-
etag: string;
|
|
85
|
-
size: number;
|
|
86
|
-
}[] | undefined;
|
|
87
|
-
};
|
|
88
|
-
size?: number | undefined;
|
|
89
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
90
|
-
creationDate?: string | undefined;
|
|
91
|
-
url?: string | undefined;
|
|
92
|
-
sizeIsDeferred?: boolean | undefined;
|
|
93
|
-
checksum?: string | undefined;
|
|
94
|
-
checksumAlgorithm?: string | undefined;
|
|
95
|
-
flow?: {
|
|
96
|
-
flowId: string;
|
|
97
|
-
nodeId: string;
|
|
98
|
-
jobId: string;
|
|
99
|
-
} | undefined;
|
|
100
|
-
} | {
|
|
101
|
-
metadata: {
|
|
102
|
-
description: string;
|
|
103
|
-
};
|
|
104
|
-
flow: {
|
|
105
|
-
flowId: string;
|
|
106
|
-
nodeId: string;
|
|
107
|
-
jobId: string;
|
|
108
|
-
};
|
|
109
|
-
id: string;
|
|
110
|
-
offset: number;
|
|
111
|
-
storage: {
|
|
112
|
-
id: string;
|
|
113
|
-
type: string;
|
|
114
|
-
path?: string | undefined;
|
|
115
|
-
uploadId?: string | undefined;
|
|
116
|
-
bucket?: string | undefined;
|
|
117
|
-
parts?: {
|
|
118
|
-
partNumber: number;
|
|
119
|
-
etag: string;
|
|
120
|
-
size: number;
|
|
121
|
-
}[] | undefined;
|
|
122
|
-
};
|
|
123
|
-
size?: number | undefined;
|
|
124
|
-
creationDate?: string | undefined;
|
|
125
|
-
url?: string | undefined;
|
|
126
|
-
sizeIsDeferred?: boolean | undefined;
|
|
127
|
-
checksum?: string | undefined;
|
|
128
|
-
checksumAlgorithm?: string | undefined;
|
|
74
|
+
description: string;
|
|
75
|
+
confidence?: number | undefined;
|
|
76
|
+
metadata?: Record<string, unknown> | undefined;
|
|
129
77
|
}, unknown, zod_v4_core0.$ZodTypeInternals<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
id: string;
|
|
134
|
-
type: string;
|
|
135
|
-
path?: string | undefined;
|
|
136
|
-
uploadId?: string | undefined;
|
|
137
|
-
bucket?: string | undefined;
|
|
138
|
-
parts?: {
|
|
139
|
-
partNumber: number;
|
|
140
|
-
etag: string;
|
|
141
|
-
size: number;
|
|
142
|
-
}[] | undefined;
|
|
143
|
-
};
|
|
144
|
-
size?: number | undefined;
|
|
145
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
146
|
-
creationDate?: string | undefined;
|
|
147
|
-
url?: string | undefined;
|
|
148
|
-
sizeIsDeferred?: boolean | undefined;
|
|
149
|
-
checksum?: string | undefined;
|
|
150
|
-
checksumAlgorithm?: string | undefined;
|
|
151
|
-
flow?: {
|
|
152
|
-
flowId: string;
|
|
153
|
-
nodeId: string;
|
|
154
|
-
jobId: string;
|
|
155
|
-
} | undefined;
|
|
156
|
-
} | {
|
|
157
|
-
metadata: {
|
|
158
|
-
description: string;
|
|
159
|
-
};
|
|
160
|
-
flow: {
|
|
161
|
-
flowId: string;
|
|
162
|
-
nodeId: string;
|
|
163
|
-
jobId: string;
|
|
164
|
-
};
|
|
165
|
-
id: string;
|
|
166
|
-
offset: number;
|
|
167
|
-
storage: {
|
|
168
|
-
id: string;
|
|
169
|
-
type: string;
|
|
170
|
-
path?: string | undefined;
|
|
171
|
-
uploadId?: string | undefined;
|
|
172
|
-
bucket?: string | undefined;
|
|
173
|
-
parts?: {
|
|
174
|
-
partNumber: number;
|
|
175
|
-
etag: string;
|
|
176
|
-
size: number;
|
|
177
|
-
}[] | undefined;
|
|
178
|
-
};
|
|
179
|
-
size?: number | undefined;
|
|
180
|
-
creationDate?: string | undefined;
|
|
181
|
-
url?: string | undefined;
|
|
182
|
-
sizeIsDeferred?: boolean | undefined;
|
|
183
|
-
checksum?: string | undefined;
|
|
184
|
-
checksumAlgorithm?: string | undefined;
|
|
78
|
+
description: string;
|
|
79
|
+
confidence?: number | undefined;
|
|
80
|
+
metadata?: Record<string, unknown> | undefined;
|
|
185
81
|
}, unknown>>;
|
|
186
82
|
run: (args: {
|
|
187
83
|
data: {
|
|
@@ -218,61 +114,9 @@ declare function createDescribeImageNode(id: string, {
|
|
|
218
114
|
inputs?: Record<string, unknown>;
|
|
219
115
|
clientId: string | null;
|
|
220
116
|
}) => Effect.Effect<_uploadista_core_flow0.NodeExecutionResult<{
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
id: string;
|
|
225
|
-
type: string;
|
|
226
|
-
path?: string | undefined;
|
|
227
|
-
uploadId?: string | undefined;
|
|
228
|
-
bucket?: string | undefined;
|
|
229
|
-
parts?: {
|
|
230
|
-
partNumber: number;
|
|
231
|
-
etag: string;
|
|
232
|
-
size: number;
|
|
233
|
-
}[] | undefined;
|
|
234
|
-
};
|
|
235
|
-
size?: number | undefined;
|
|
236
|
-
metadata?: Record<string, string | number | boolean> | undefined;
|
|
237
|
-
creationDate?: string | undefined;
|
|
238
|
-
url?: string | undefined;
|
|
239
|
-
sizeIsDeferred?: boolean | undefined;
|
|
240
|
-
checksum?: string | undefined;
|
|
241
|
-
checksumAlgorithm?: string | undefined;
|
|
242
|
-
flow?: {
|
|
243
|
-
flowId: string;
|
|
244
|
-
nodeId: string;
|
|
245
|
-
jobId: string;
|
|
246
|
-
} | undefined;
|
|
247
|
-
} | {
|
|
248
|
-
metadata: {
|
|
249
|
-
description: string;
|
|
250
|
-
};
|
|
251
|
-
flow: {
|
|
252
|
-
flowId: string;
|
|
253
|
-
nodeId: string;
|
|
254
|
-
jobId: string;
|
|
255
|
-
};
|
|
256
|
-
id: string;
|
|
257
|
-
offset: number;
|
|
258
|
-
storage: {
|
|
259
|
-
id: string;
|
|
260
|
-
type: string;
|
|
261
|
-
path?: string | undefined;
|
|
262
|
-
uploadId?: string | undefined;
|
|
263
|
-
bucket?: string | undefined;
|
|
264
|
-
parts?: {
|
|
265
|
-
partNumber: number;
|
|
266
|
-
etag: string;
|
|
267
|
-
size: number;
|
|
268
|
-
}[] | undefined;
|
|
269
|
-
};
|
|
270
|
-
size?: number | undefined;
|
|
271
|
-
creationDate?: string | undefined;
|
|
272
|
-
url?: string | undefined;
|
|
273
|
-
sizeIsDeferred?: boolean | undefined;
|
|
274
|
-
checksum?: string | undefined;
|
|
275
|
-
checksumAlgorithm?: string | undefined;
|
|
117
|
+
description: string;
|
|
118
|
+
confidence?: number | undefined;
|
|
119
|
+
metadata?: Record<string, unknown> | undefined;
|
|
276
120
|
}>, UploadistaError, never>;
|
|
277
121
|
condition?: {
|
|
278
122
|
field: string;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","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.mts","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;;;;IAEkC,MAAA,CAAA,OAAlC,sBAAA,CAAkC,YAAA;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AAA,EAAA,MAAkC;;IKI/C,MAAA,CAAO,aAAa"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{UploadistaError as e}from"@uploadista/core/errors";import{
|
|
1
|
+
import{UploadistaError as e}from"@uploadista/core/errors";import{IMAGE_DESCRIPTION_OUTPUT_TYPE_ID as t,ImageAiPlugin as n,ImagePlugin as r,NodeType as i,STORAGE_OUTPUT_TYPE_ID as a,completeNodeExecution as o,createFlowNode as s,createTransformNode as c,imageDescriptionOutputSchema as l,resolveUploadMetadata as u}from"@uploadista/core/flow";import{uploadFileSchema as d}from"@uploadista/core/types";import{Effect as f}from"effect";import{UploadServer as p}from"@uploadista/core/upload";function m(t,n={}){let{maxWaitTime:r=1e4,retryDelay:i=500}=n;return f.gen(function*(){let n=Date.now();for(;Date.now()-n<r;){let e=yield*f.tryPromise(()=>fetch(t,{method:`HEAD`})).pipe(f.catchAll(()=>f.succeed(null)));if(e?.ok){yield*f.logInfo(`URL ${t} is now available`);return}e?yield*f.logDebug(`URL not ready yet (${e.status}), retrying...`):yield*f.logDebug(`URL check failed, retrying...`),yield*f.sleep(i)}return yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:`URL ${t} not available after ${r}ms`}).toEffect()})}function h(r,{credentialId:a}={}){return f.gen(function*(){let c=yield*n;return yield*s({id:r,name:`Describe Image`,description:`Describes the image using AI`,type:i.process,nodeTypeId:t,inputSchema:d,outputSchema:l,run:({data:t,flowId:n,jobId:i,clientId:s})=>f.gen(function*(){let l={flowId:n,nodeId:r,jobId:i},u=t.url;if(!u)return yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:`URL is required for describe image operation`}).toEffect();yield*f.logInfo(`Describing image for file ${t.id} at URL: ${u}`),yield*m(u);let d={clientId:s,credentialId:a},p=yield*c.describeImage(u,d).pipe(f.catchAll(t=>f.gen(function*(){return yield*f.logError(`Failed to describe image`,t),yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:t instanceof Error?t.message:`Failed to describe image`}).toEffect()})));return yield*f.logInfo(`Successfully described image for file ${t.id}`),o({description:p.description,flow:l})})})})}const g={jpeg:`image/jpeg`,webp:`image/webp`,png:`image/png`,avif:`image/avif`},_={jpeg:`jpg`,webp:`webp`,png:`png`,avif:`avif`};function v(e,{quality:t,format:n}){return f.gen(function*(){let i=yield*r;return yield*c({id:e,name:`Optimize`,description:`Optimizes an image for web delivery`,nodeTypeId:a,transform:(e,r)=>f.map(i.optimize(e,{quality:t,format:n}),e=>{let t=g[n],i=_[n],a=r.metadata?.fileName;return{bytes:e,type:t,fileName:a&&typeof a==`string`?a.replace(/\.[^.]+$/,`.${i}`):void 0}})})})}function y(t,{credentialId:r}={}){return f.gen(function*(){let c=yield*n,l=yield*p;return yield*s({id:t,name:`Remove Background`,description:`Removes the background from an image`,type:i.process,nodeTypeId:a,inputSchema:d,outputSchema:d,run:({data:n,flowId:i,jobId:a,storageId:s,clientId:d})=>f.gen(function*(){let p={flowId:i,nodeId:t,jobId:a},h=n.url;if(!h)return yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:`URL is required for remove background operation`}).toEffect();yield*f.logInfo(`Removing background for file ${n.id} at URL: ${n.url}`),yield*m(h);let g={clientId:d,credentialId:r},{outputUrl:_}=yield*c.removeBackground(h,g).pipe(f.catchAll(t=>f.gen(function*(){return yield*f.logError(`Failed to remove background`,t),yield*e.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}=u(n.metadata);yield*f.logInfo(`Uploading processed file to storage`);let S=yield*l.uploadFromUrl({storageId:s,size:0,type:v,fileName:y,lastModified:0,metadata:x,flow:p},d,_).pipe(f.catchAll(t=>f.gen(function*(){return yield*f.logError(`Failed to upload processed file`,t),yield*e.fromCode(`FLOW_NODE_ERROR`,{cause:t instanceof Error?t.message:`Failed to upload processed file`}).toEffect()})));return yield*f.logInfo(`Successfully removed background for file ${n.id}`),o(b?{...S,metadata:b}:S)})})})}function b(e,{width:t,height:n,fit:i}){return f.gen(function*(){let o=yield*r;return yield*c({id:e,name:`Resize`,description:`Resizes an image to the specified dimensions`,nodeTypeId:a,transform:e=>o.resize(e,{height:n,width:t,fit:i})})})}function x(e,t,n){return f.reduce(n,t,(t,n)=>e.transform(t,n))}function S(e,{transformations:t}){return f.gen(function*(){let n=yield*r;return yield*c({id:e,name:`Transform Image`,description:`Apply ${t.length} transformation${t.length===1?``:`s`} to the image`,nodeTypeId:a,transform:e=>x(n,e,t)})})}export{h as createDescribeImageNode,v as createOptimizeNode,y as createRemoveBackgroundNode,b as createResizeNode,S as createTransformImageNode,m as waitForUrlAvailability};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["formatToMimeType: Record<OptimizeParams[\"format\"], string>","formatToExtension: Record<OptimizeParams[\"format\"], string>"],"sources":["../src/wait-for-url.ts","../src/describe-image-node.ts","../src/optimize-node.ts","../src/remove-background-node.ts","../src/resize-node.ts","../src/transform-image-node.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { Effect } from \"effect\";\n\n/**\n * Waits for a URL to become available by periodically checking its accessibility.\n * This is useful when a file has just been uploaded and may not be immediately\n * accessible due to CDN propagation or storage consistency delays.\n *\n * @param url - The URL to check for availability\n * @param options - Configuration options\n * @param options.maxWaitTime - Maximum time to wait in milliseconds (default: 10000)\n * @param options.retryDelay - Delay between retries in milliseconds (default: 500)\n * @returns Effect that succeeds when URL is available or fails with UploadistaError\n */\nexport function waitForUrlAvailability(\n url: string,\n options: {\n maxWaitTime?: number;\n retryDelay?: number;\n } = {},\n): Effect.Effect<void, UploadistaError> {\n const { maxWaitTime = 10000, retryDelay = 500 } = options;\n\n return Effect.gen(function* () {\n const startTime = Date.now();\n\n while (Date.now() - startTime < maxWaitTime) {\n const response = yield* Effect.tryPromise(() =>\n fetch(url, { method: \"HEAD\" }),\n ).pipe(Effect.catchAll(() => Effect.succeed(null)));\n\n if (response?.ok) {\n yield* Effect.logInfo(`URL ${url} is now available`);\n return;\n }\n\n if (response) {\n yield* Effect.logDebug(\n `URL not ready yet (${response.status}), retrying...`,\n );\n } else {\n yield* Effect.logDebug(`URL check failed, retrying...`);\n }\n\n yield* Effect.sleep(retryDelay);\n }\n\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: `URL ${url} not available after ${maxWaitTime}ms`,\n }).toEffect();\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n ImageAiPlugin,\n NodeType,\n resolveUploadMetadata,\n} from \"@uploadista/core/flow\";\nimport { uploadFileSchema } from \"@uploadista/core/types\";\n\nimport { Effect } from \"effect\";\nimport { waitForUrlAvailability } from \"./wait-for-url\";\n\nexport function createDescribeImageNode(\n id: string,\n { credentialId }: { credentialId?: string } = {},\n) {\n return Effect.gen(function* () {\n const imageAiService = yield* ImageAiPlugin;\n\n return yield* createFlowNode({\n id,\n name: \"Describe Image\",\n description: \"Describes the image using AI\",\n type: NodeType.process,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n run: ({ data: file, flowId, jobId, clientId }) => {\n return Effect.gen(function* () {\n const flow = {\n flowId,\n nodeId: id,\n jobId,\n };\n\n const fileUrl = file.url;\n\n // Validate input\n if (!fileUrl) {\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: \"URL is required for describe image operation\",\n }).toEffect();\n }\n\n yield* Effect.logInfo(\n `Describing image for file ${file.id} at URL: ${fileUrl}`,\n );\n\n // Wait for URL to be available with retry mechanism\n yield* waitForUrlAvailability(fileUrl);\n\n // Build context for ImageAI plugin\n const context = {\n clientId,\n credentialId,\n };\n\n // Describe image with error handling\n const { description } = yield* imageAiService\n .describeImage(fileUrl, context)\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\"Failed to describe image\", error);\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to describe image\",\n }).toEffect();\n }),\n ),\n );\n\n const { metadata } = resolveUploadMetadata(file.metadata);\n\n // add description to metadata\n const newMetadata = {\n ...file.metadata,\n ...metadata,\n description,\n };\n\n yield* Effect.logInfo(\n `Successfully described image for file ${file.id}`,\n );\n\n return completeNodeExecution(\n newMetadata\n ? {\n ...file,\n metadata: newMetadata,\n flow,\n }\n : file,\n );\n });\n },\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n type OptimizeParams,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\n// Map image format to MIME type\nconst formatToMimeType: Record<OptimizeParams[\"format\"], string> = {\n jpeg: \"image/jpeg\",\n webp: \"image/webp\",\n png: \"image/png\",\n avif: \"image/avif\",\n};\n\n// Map image format to file extension\nconst formatToExtension: Record<OptimizeParams[\"format\"], string> = {\n jpeg: \"jpg\",\n webp: \"webp\",\n png: \"png\",\n avif: \"avif\",\n};\n\nexport function createOptimizeNode(\n id: string,\n { quality, format }: OptimizeParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Optimize\",\n description: \"Optimizes an image for web delivery\",\n transform: (inputBytes, file) =>\n Effect.map(\n imageService.optimize(inputBytes, { quality, format }),\n (optimizedBytes) => {\n // Return bytes with updated metadata if format changes\n const newType = formatToMimeType[format];\n const newExtension = formatToExtension[format];\n\n // Update file extension if format changed\n const fileName = file.metadata?.fileName;\n const newFileName =\n fileName && typeof fileName === \"string\"\n ? fileName.replace(/\\.[^.]+$/, `.${newExtension}`)\n : undefined;\n\n return {\n bytes: optimizedBytes,\n type: newType,\n fileName: newFileName,\n } as\n | Uint8Array\n | { bytes: Uint8Array; type: string; fileName?: string };\n },\n ),\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n ImageAiPlugin,\n NodeType,\n resolveUploadMetadata,\n} from \"@uploadista/core/flow\";\nimport { uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { waitForUrlAvailability } from \"./wait-for-url\";\n\nexport function createRemoveBackgroundNode(\n id: string,\n { credentialId }: { credentialId?: string } = {},\n) {\n return Effect.gen(function* () {\n const imageAiService = yield* ImageAiPlugin;\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode({\n id,\n name: \"Remove Background\",\n description: \"Removes the background from an image\",\n type: NodeType.process,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n run: ({ data: file, flowId, jobId, storageId, clientId }) => {\n return Effect.gen(function* () {\n const flow = {\n flowId,\n nodeId: id,\n jobId,\n };\n\n const fileUrl = file.url;\n\n // Validate input\n if (!fileUrl) {\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: \"URL is required for remove background operation\",\n }).toEffect();\n }\n\n yield* Effect.logInfo(\n `Removing background for file ${file.id} at URL: ${file.url}`,\n );\n\n // Wait for URL to be available with retry mechanism\n yield* waitForUrlAvailability(fileUrl);\n\n // Build context for ImageAI plugin\n const context = {\n clientId,\n credentialId,\n };\n\n // Remove background with error handling\n const backgroundRemovalResult = yield* imageAiService\n .removeBackground(fileUrl, context)\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\"Failed to remove background\", error);\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to remove background from image\",\n }).toEffect();\n }),\n ),\n );\n\n const { outputUrl } = backgroundRemovalResult;\n const { type, fileName, metadata, metadataJson } =\n resolveUploadMetadata(file.metadata);\n\n yield* Effect.logInfo(`Uploading processed file to storage`);\n\n // Upload the transformed bytes back to the upload server with error handling\n const result = yield* uploadServer\n .uploadFromUrl(\n {\n storageId,\n size: 0,\n type,\n fileName,\n lastModified: 0,\n metadata: metadataJson,\n flow,\n },\n clientId,\n outputUrl,\n )\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\n \"Failed to upload processed file\",\n error,\n );\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to upload processed file\",\n }).toEffect();\n }),\n ),\n );\n\n yield* Effect.logInfo(\n `Successfully removed background for file ${file.id}`,\n );\n\n return completeNodeExecution(\n metadata\n ? {\n ...result,\n metadata,\n }\n : result,\n );\n });\n },\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n type ResizeParams,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\nexport function createResizeNode(\n id: string,\n { width, height, fit }: ResizeParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Resize\",\n description: \"Resizes an image to the specified dimensions\",\n transform: (inputBytes) =>\n imageService.resize(inputBytes, { height, width, fit }),\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n type TransformImageParams,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\n/**\n * Apply a chain of transformations to an image by reducing over the transformations array.\n * Each transformation receives the output of the previous transformation as input.\n *\n * @param imageService - The image plugin service to use for transformations\n * @param inputBytes - The input image bytes\n * @param transformations - Array of transformations to apply in sequence\n * @returns Effect that resolves to the final transformed image bytes\n */\nfunction applyTransformationChain(\n imageService: ReturnType<typeof ImagePlugin.of>,\n inputBytes: Uint8Array,\n transformations: TransformImageParams[\"transformations\"],\n) {\n return Effect.reduce(transformations, inputBytes, (bytes, transformation) =>\n imageService.transform(bytes, transformation),\n );\n}\n\n/**\n * Creates a transform image node that applies multiple transformations sequentially.\n *\n * This node enables complex image processing workflows by chaining multiple transformations\n * together. Each transformation is applied to the output of the previous transformation,\n * allowing for powerful image manipulation pipelines.\n *\n * Supported transformations include:\n * - Basic: resize, blur, rotate, flip\n * - Filters: grayscale, sepia, brightness, contrast\n * - Effects: sharpen\n * - Advanced: watermark, logo, text\n *\n * Note: Watermark and logo transformations require imagePath to be a valid URL.\n * Images will be fetched from the provided URL during transformation.\n *\n * @param id - Unique identifier for this node\n * @param params - Parameters including the transformations array\n * @returns Effect that resolves to a transform node\n *\n * @example\n * ```typescript\n * const node = createTransformImageNode(\"transform-1\", {\n * transformations: [\n * { type: 'resize', width: 800, height: 600, fit: 'cover' },\n * { type: 'brightness', value: 20 },\n * {\n * type: 'watermark',\n * imagePath: 'https://cdn.example.com/watermark.png',\n * position: 'bottom-right',\n * opacity: 0.5\n * }\n * ]\n * });\n * ```\n */\nexport function createTransformImageNode(\n id: string,\n { transformations }: TransformImageParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Transform Image\",\n description: `Apply ${transformations.length} transformation${transformations.length === 1 ? \"\" : \"s\"} to the image`,\n transform: (inputBytes) =>\n applyTransformationChain(imageService, inputBytes, transformations),\n });\n });\n}\n"],"mappings":"mYAcA,SAAgB,EACd,EACA,EAGI,EAAE,CACgC,CACtC,GAAM,CAAE,cAAc,IAAO,aAAa,KAAQ,EAElD,OAAO,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAY,KAAK,KAAK,CAE5B,KAAO,KAAK,KAAK,CAAG,EAAY,GAAa,CAC3C,IAAM,EAAW,MAAO,EAAO,eAC7B,MAAM,EAAK,CAAE,OAAQ,OAAQ,CAAC,CAC/B,CAAC,KAAK,EAAO,aAAe,EAAO,QAAQ,KAAK,CAAC,CAAC,CAEnD,GAAI,GAAU,GAAI,CAChB,MAAO,EAAO,QAAQ,OAAO,EAAI,mBAAmB,CACpD,OAGE,EACF,MAAO,EAAO,SACZ,sBAAsB,EAAS,OAAO,gBACvC,CAED,MAAO,EAAO,SAAS,gCAAgC,CAGzD,MAAO,EAAO,MAAM,E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s","names":["formatToMimeType: Record<OptimizeParams[\"format\"], string>","formatToExtension: Record<OptimizeParams[\"format\"], string>"],"sources":["../src/wait-for-url.ts","../src/describe-image-node.ts","../src/optimize-node.ts","../src/remove-background-node.ts","../src/resize-node.ts","../src/transform-image-node.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { Effect } from \"effect\";\n\n/**\n * Waits for a URL to become available by periodically checking its accessibility.\n * This is useful when a file has just been uploaded and may not be immediately\n * accessible due to CDN propagation or storage consistency delays.\n *\n * @param url - The URL to check for availability\n * @param options - Configuration options\n * @param options.maxWaitTime - Maximum time to wait in milliseconds (default: 10000)\n * @param options.retryDelay - Delay between retries in milliseconds (default: 500)\n * @returns Effect that succeeds when URL is available or fails with UploadistaError\n */\nexport function waitForUrlAvailability(\n url: string,\n options: {\n maxWaitTime?: number;\n retryDelay?: number;\n } = {},\n): Effect.Effect<void, UploadistaError> {\n const { maxWaitTime = 10000, retryDelay = 500 } = options;\n\n return Effect.gen(function* () {\n const startTime = Date.now();\n\n while (Date.now() - startTime < maxWaitTime) {\n const response = yield* Effect.tryPromise(() =>\n fetch(url, { method: \"HEAD\" }),\n ).pipe(Effect.catchAll(() => Effect.succeed(null)));\n\n if (response?.ok) {\n yield* Effect.logInfo(`URL ${url} is now available`);\n return;\n }\n\n if (response) {\n yield* Effect.logDebug(\n `URL not ready yet (${response.status}), retrying...`,\n );\n } else {\n yield* Effect.logDebug(`URL check failed, retrying...`);\n }\n\n yield* Effect.sleep(retryDelay);\n }\n\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: `URL ${url} not available after ${maxWaitTime}ms`,\n }).toEffect();\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,\n ImageAiPlugin,\n imageDescriptionOutputSchema,\n NodeType,\n} from \"@uploadista/core/flow\";\nimport { uploadFileSchema } from \"@uploadista/core/types\";\n\nimport { Effect } from \"effect\";\nimport { waitForUrlAvailability } from \"./wait-for-url\";\n\nexport function createDescribeImageNode(\n id: string,\n { credentialId }: { credentialId?: string } = {},\n) {\n return Effect.gen(function* () {\n const imageAiService = yield* ImageAiPlugin;\n\n return yield* createFlowNode({\n id,\n name: \"Describe Image\",\n description: \"Describes the image using AI\",\n type: NodeType.process,\n nodeTypeId: IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,\n inputSchema: uploadFileSchema,\n outputSchema: imageDescriptionOutputSchema,\n run: ({ data: file, flowId, jobId, clientId }) => {\n return Effect.gen(function* () {\n const flow = {\n flowId,\n nodeId: id,\n jobId,\n };\n\n const fileUrl = file.url;\n\n // Validate input\n if (!fileUrl) {\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: \"URL is required for describe image operation\",\n }).toEffect();\n }\n\n yield* Effect.logInfo(\n `Describing image for file ${file.id} at URL: ${fileUrl}`,\n );\n\n // Wait for URL to be available with retry mechanism\n yield* waitForUrlAvailability(fileUrl);\n\n // Build context for ImageAI plugin\n const context = {\n clientId,\n credentialId,\n };\n\n // Describe image with error handling\n const result = yield* imageAiService\n .describeImage(fileUrl, context)\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\"Failed to describe image\", error);\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to describe image\",\n }).toEffect();\n }),\n ),\n );\n\n yield* Effect.logInfo(\n `Successfully described image for file ${file.id}`,\n );\n\n // Return structured image description output (not UploadFile)\n return completeNodeExecution({\n description: result.description,\n flow,\n });\n });\n },\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n type OptimizeParams,\n STORAGE_OUTPUT_TYPE_ID,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\n// Map image format to MIME type\nconst formatToMimeType: Record<OptimizeParams[\"format\"], string> = {\n jpeg: \"image/jpeg\",\n webp: \"image/webp\",\n png: \"image/png\",\n avif: \"image/avif\",\n};\n\n// Map image format to file extension\nconst formatToExtension: Record<OptimizeParams[\"format\"], string> = {\n jpeg: \"jpg\",\n webp: \"webp\",\n png: \"png\",\n avif: \"avif\",\n};\n\nexport function createOptimizeNode(\n id: string,\n { quality, format }: OptimizeParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Optimize\",\n description: \"Optimizes an image for web delivery\",\n nodeTypeId: STORAGE_OUTPUT_TYPE_ID,\n transform: (inputBytes, file) =>\n Effect.map(\n imageService.optimize(inputBytes, { quality, format }),\n (optimizedBytes) => {\n // Return bytes with updated metadata if format changes\n const newType = formatToMimeType[format];\n const newExtension = formatToExtension[format];\n\n // Update file extension if format changed\n const fileName = file.metadata?.fileName;\n const newFileName =\n fileName && typeof fileName === \"string\"\n ? fileName.replace(/\\.[^.]+$/, `.${newExtension}`)\n : undefined;\n\n return {\n bytes: optimizedBytes,\n type: newType,\n fileName: newFileName,\n } as\n | Uint8Array\n | { bytes: Uint8Array; type: string; fileName?: string };\n },\n ),\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n ImageAiPlugin,\n NodeType,\n resolveUploadMetadata,\n STORAGE_OUTPUT_TYPE_ID,\n} from \"@uploadista/core/flow\";\nimport { uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { waitForUrlAvailability } from \"./wait-for-url\";\n\nexport function createRemoveBackgroundNode(\n id: string,\n { credentialId }: { credentialId?: string } = {},\n) {\n return Effect.gen(function* () {\n const imageAiService = yield* ImageAiPlugin;\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode({\n id,\n name: \"Remove Background\",\n description: \"Removes the background from an image\",\n type: NodeType.process,\n nodeTypeId: STORAGE_OUTPUT_TYPE_ID,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n run: ({ data: file, flowId, jobId, storageId, clientId }) => {\n return Effect.gen(function* () {\n const flow = {\n flowId,\n nodeId: id,\n jobId,\n };\n\n const fileUrl = file.url;\n\n // Validate input\n if (!fileUrl) {\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause: \"URL is required for remove background operation\",\n }).toEffect();\n }\n\n yield* Effect.logInfo(\n `Removing background for file ${file.id} at URL: ${file.url}`,\n );\n\n // Wait for URL to be available with retry mechanism\n yield* waitForUrlAvailability(fileUrl);\n\n // Build context for ImageAI plugin\n const context = {\n clientId,\n credentialId,\n };\n\n // Remove background with error handling\n const backgroundRemovalResult = yield* imageAiService\n .removeBackground(fileUrl, context)\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\"Failed to remove background\", error);\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to remove background from image\",\n }).toEffect();\n }),\n ),\n );\n\n const { outputUrl } = backgroundRemovalResult;\n const { type, fileName, metadata, metadataJson } =\n resolveUploadMetadata(file.metadata);\n\n yield* Effect.logInfo(`Uploading processed file to storage`);\n\n // Upload the transformed bytes back to the upload server with error handling\n const result = yield* uploadServer\n .uploadFromUrl(\n {\n storageId,\n size: 0,\n type,\n fileName,\n lastModified: 0,\n metadata: metadataJson,\n flow,\n },\n clientId,\n outputUrl,\n )\n .pipe(\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n yield* Effect.logError(\n \"Failed to upload processed file\",\n error,\n );\n return yield* UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n cause:\n error instanceof Error\n ? error.message\n : \"Failed to upload processed file\",\n }).toEffect();\n }),\n ),\n );\n\n yield* Effect.logInfo(\n `Successfully removed background for file ${file.id}`,\n );\n\n return completeNodeExecution(\n metadata\n ? {\n ...result,\n metadata,\n }\n : result,\n );\n });\n },\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n type ResizeParams,\n STORAGE_OUTPUT_TYPE_ID,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\nexport function createResizeNode(\n id: string,\n { width, height, fit }: ResizeParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Resize\",\n description: \"Resizes an image to the specified dimensions\",\n nodeTypeId: STORAGE_OUTPUT_TYPE_ID,\n transform: (inputBytes) =>\n imageService.resize(inputBytes, { height, width, fit }),\n });\n });\n}\n","import {\n createTransformNode,\n ImagePlugin,\n STORAGE_OUTPUT_TYPE_ID,\n type TransformImageParams,\n} from \"@uploadista/core/flow\";\nimport { Effect } from \"effect\";\n\n/**\n * Apply a chain of transformations to an image by reducing over the transformations array.\n * Each transformation receives the output of the previous transformation as input.\n *\n * @param imageService - The image plugin service to use for transformations\n * @param inputBytes - The input image bytes\n * @param transformations - Array of transformations to apply in sequence\n * @returns Effect that resolves to the final transformed image bytes\n */\nfunction applyTransformationChain(\n imageService: ReturnType<typeof ImagePlugin.of>,\n inputBytes: Uint8Array,\n transformations: TransformImageParams[\"transformations\"],\n) {\n return Effect.reduce(transformations, inputBytes, (bytes, transformation) =>\n imageService.transform(bytes, transformation),\n );\n}\n\n/**\n * Creates a transform image node that applies multiple transformations sequentially.\n *\n * This node enables complex image processing workflows by chaining multiple transformations\n * together. Each transformation is applied to the output of the previous transformation,\n * allowing for powerful image manipulation pipelines.\n *\n * Supported transformations include:\n * - Basic: resize, blur, rotate, flip\n * - Filters: grayscale, sepia, brightness, contrast\n * - Effects: sharpen\n * - Advanced: watermark, logo, text\n *\n * Note: Watermark and logo transformations require imagePath to be a valid URL.\n * Images will be fetched from the provided URL during transformation.\n *\n * @param id - Unique identifier for this node\n * @param params - Parameters including the transformations array\n * @returns Effect that resolves to a transform node\n *\n * @example\n * ```typescript\n * const node = createTransformImageNode(\"transform-1\", {\n * transformations: [\n * { type: 'resize', width: 800, height: 600, fit: 'cover' },\n * { type: 'brightness', value: 20 },\n * {\n * type: 'watermark',\n * imagePath: 'https://cdn.example.com/watermark.png',\n * position: 'bottom-right',\n * opacity: 0.5\n * }\n * ]\n * });\n * ```\n */\nexport function createTransformImageNode(\n id: string,\n { transformations }: TransformImageParams,\n) {\n return Effect.gen(function* () {\n const imageService = yield* ImagePlugin;\n\n return yield* createTransformNode({\n id,\n name: \"Transform Image\",\n description: `Apply ${transformations.length} transformation${transformations.length === 1 ? \"\" : \"s\"} to the image`,\n nodeTypeId: STORAGE_OUTPUT_TYPE_ID,\n transform: (inputBytes) =>\n applyTransformationChain(imageService, inputBytes, transformations),\n });\n });\n}\n"],"mappings":"ueAcA,SAAgB,EACd,EACA,EAGI,EAAE,CACgC,CACtC,GAAM,CAAE,cAAc,IAAO,aAAa,KAAQ,EAElD,OAAO,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAY,KAAK,KAAK,CAE5B,KAAO,KAAK,KAAK,CAAG,EAAY,GAAa,CAC3C,IAAM,EAAW,MAAO,EAAO,eAC7B,MAAM,EAAK,CAAE,OAAQ,OAAQ,CAAC,CAC/B,CAAC,KAAK,EAAO,aAAe,EAAO,QAAQ,KAAK,CAAC,CAAC,CAEnD,GAAI,GAAU,GAAI,CAChB,MAAO,EAAO,QAAQ,OAAO,EAAI,mBAAmB,CACpD,OAGE,EACF,MAAO,EAAO,SACZ,sBAAsB,EAAS,OAAO,gBACvC,CAED,MAAO,EAAO,SAAS,gCAAgC,CAGzD,MAAO,EAAO,MAAM,EAAW,CAGjC,OAAO,MAAO,EAAgB,SAAS,kBAAmB,CACxD,MAAO,OAAO,EAAI,uBAAuB,EAAY,IACtD,CAAC,CAAC,UAAU,EACb,CCpCJ,SAAgB,EACd,EACA,CAAE,gBAA4C,EAAE,CAChD,CACA,OAAO,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAiB,MAAO,EAE9B,OAAO,MAAO,EAAe,CAC3B,KACA,KAAM,iBACN,YAAa,+BACb,KAAM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D,CACM,MAAO,EAAgB,SAAS,kBAAmB,CACxD,MACE,aAAiB,MACb,EAAM,QACN,kCACP,CAAC,CAAC,UAAU,EACb,CACH,CACF,CAMH,OAJA,MAAO,EAAO,QACZ,4CAA4C,EAAK,KAClD,CAEM,EACL,EACI,CACE,GAAG,EACH,WACD,CACD,EACL,EACD,CAEL,CAAC,EACF,CC1HJ,SAAgB,EACd,EACA,CAAE,QAAO,SAAQ,OACjB,CACA,OAAO,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAe,MAAO,EAE5B,OAAO,MAAO,EAAoB,CAChC,KACA,KAAM,SACN,YAAa,+CACb,WAAY,EACZ,UAAY,GACV,EAAa,OAAO,EAAY,CAAE,SAAQ,QAAO,MAAK,CAAC,CAC1D,CAAC,EACF,CCNJ,SAAS,EACP,EACA,EACA,EACA,CACA,OAAO,EAAO,OAAO,EAAiB,GAAa,EAAO,IACxD,EAAa,UAAU,EAAO,EAAe,CAC9C,CAuCH,SAAgB,EACd,EACA,CAAE,mBACF,CACA,OAAO,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAe,MAAO,EAE5B,OAAO,MAAO,EAAoB,CAChC,KACA,KAAM,kBACN,YAAa,SAAS,EAAgB,OAAO,iBAAiB,EAAgB,SAAW,EAAI,GAAK,IAAI,eACtG,WAAY,EACZ,UAAY,GACV,EAAyB,EAAc,EAAY,EAAgB,CACtE,CAAC,EACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/flow-images-nodes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17-beta.1",
|
|
5
5
|
"description": "Image processing nodes for Uploadista Flow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"effect": "3.19.4",
|
|
18
18
|
"zod": "4.1.12",
|
|
19
|
-
"@uploadista/core": "0.0.
|
|
19
|
+
"@uploadista/core": "0.0.17-beta.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@effect/vitest": "0.27.0",
|
|
23
23
|
"@types/node": "24.10.1",
|
|
24
24
|
"tsdown": "0.16.5",
|
|
25
|
-
"vitest": "4.0.
|
|
26
|
-
"@uploadista/typescript-config": "0.0.
|
|
25
|
+
"vitest": "4.0.10",
|
|
26
|
+
"@uploadista/typescript-config": "0.0.17-beta.1"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsdown",
|
|
@@ -2,9 +2,10 @@ import { UploadistaError } from "@uploadista/core/errors";
|
|
|
2
2
|
import {
|
|
3
3
|
completeNodeExecution,
|
|
4
4
|
createFlowNode,
|
|
5
|
+
IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,
|
|
5
6
|
ImageAiPlugin,
|
|
7
|
+
imageDescriptionOutputSchema,
|
|
6
8
|
NodeType,
|
|
7
|
-
resolveUploadMetadata,
|
|
8
9
|
} from "@uploadista/core/flow";
|
|
9
10
|
import { uploadFileSchema } from "@uploadista/core/types";
|
|
10
11
|
|
|
@@ -23,8 +24,9 @@ export function createDescribeImageNode(
|
|
|
23
24
|
name: "Describe Image",
|
|
24
25
|
description: "Describes the image using AI",
|
|
25
26
|
type: NodeType.process,
|
|
27
|
+
nodeTypeId: IMAGE_DESCRIPTION_OUTPUT_TYPE_ID,
|
|
26
28
|
inputSchema: uploadFileSchema,
|
|
27
|
-
outputSchema:
|
|
29
|
+
outputSchema: imageDescriptionOutputSchema,
|
|
28
30
|
run: ({ data: file, flowId, jobId, clientId }) => {
|
|
29
31
|
return Effect.gen(function* () {
|
|
30
32
|
const flow = {
|
|
@@ -56,7 +58,7 @@ export function createDescribeImageNode(
|
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
// Describe image with error handling
|
|
59
|
-
const
|
|
61
|
+
const result = yield* imageAiService
|
|
60
62
|
.describeImage(fileUrl, context)
|
|
61
63
|
.pipe(
|
|
62
64
|
Effect.catchAll((error) =>
|
|
@@ -72,28 +74,15 @@ export function createDescribeImageNode(
|
|
|
72
74
|
),
|
|
73
75
|
);
|
|
74
76
|
|
|
75
|
-
const { metadata } = resolveUploadMetadata(file.metadata);
|
|
76
|
-
|
|
77
|
-
// add description to metadata
|
|
78
|
-
const newMetadata = {
|
|
79
|
-
...file.metadata,
|
|
80
|
-
...metadata,
|
|
81
|
-
description,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
77
|
yield* Effect.logInfo(
|
|
85
78
|
`Successfully described image for file ${file.id}`,
|
|
86
79
|
);
|
|
87
80
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
flow,
|
|
94
|
-
}
|
|
95
|
-
: file,
|
|
96
|
-
);
|
|
81
|
+
// Return structured image description output (not UploadFile)
|
|
82
|
+
return completeNodeExecution({
|
|
83
|
+
description: result.description,
|
|
84
|
+
flow,
|
|
85
|
+
});
|
|
97
86
|
});
|
|
98
87
|
},
|
|
99
88
|
});
|
package/src/optimize-node.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createTransformNode,
|
|
3
3
|
ImagePlugin,
|
|
4
4
|
type OptimizeParams,
|
|
5
|
+
STORAGE_OUTPUT_TYPE_ID,
|
|
5
6
|
} from "@uploadista/core/flow";
|
|
6
7
|
import { Effect } from "effect";
|
|
7
8
|
|
|
@@ -32,6 +33,7 @@ export function createOptimizeNode(
|
|
|
32
33
|
id,
|
|
33
34
|
name: "Optimize",
|
|
34
35
|
description: "Optimizes an image for web delivery",
|
|
36
|
+
nodeTypeId: STORAGE_OUTPUT_TYPE_ID,
|
|
35
37
|
transform: (inputBytes, file) =>
|
|
36
38
|
Effect.map(
|
|
37
39
|
imageService.optimize(inputBytes, { quality, format }),
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ImageAiPlugin,
|
|
6
6
|
NodeType,
|
|
7
7
|
resolveUploadMetadata,
|
|
8
|
+
STORAGE_OUTPUT_TYPE_ID,
|
|
8
9
|
} from "@uploadista/core/flow";
|
|
9
10
|
import { uploadFileSchema } from "@uploadista/core/types";
|
|
10
11
|
import { UploadServer } from "@uploadista/core/upload";
|
|
@@ -24,6 +25,7 @@ export function createRemoveBackgroundNode(
|
|
|
24
25
|
name: "Remove Background",
|
|
25
26
|
description: "Removes the background from an image",
|
|
26
27
|
type: NodeType.process,
|
|
28
|
+
nodeTypeId: STORAGE_OUTPUT_TYPE_ID,
|
|
27
29
|
inputSchema: uploadFileSchema,
|
|
28
30
|
outputSchema: uploadFileSchema,
|
|
29
31
|
run: ({ data: file, flowId, jobId, storageId, clientId }) => {
|
package/src/resize-node.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createTransformNode,
|
|
3
3
|
ImagePlugin,
|
|
4
4
|
type ResizeParams,
|
|
5
|
+
STORAGE_OUTPUT_TYPE_ID,
|
|
5
6
|
} from "@uploadista/core/flow";
|
|
6
7
|
import { Effect } from "effect";
|
|
7
8
|
|
|
@@ -16,6 +17,7 @@ export function createResizeNode(
|
|
|
16
17
|
id,
|
|
17
18
|
name: "Resize",
|
|
18
19
|
description: "Resizes an image to the specified dimensions",
|
|
20
|
+
nodeTypeId: STORAGE_OUTPUT_TYPE_ID,
|
|
19
21
|
transform: (inputBytes) =>
|
|
20
22
|
imageService.resize(inputBytes, { height, width, fit }),
|
|
21
23
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTransformNode,
|
|
3
3
|
ImagePlugin,
|
|
4
|
+
STORAGE_OUTPUT_TYPE_ID,
|
|
4
5
|
type TransformImageParams,
|
|
5
6
|
} from "@uploadista/core/flow";
|
|
6
7
|
import { Effect } from "effect";
|
|
@@ -71,6 +72,7 @@ export function createTransformImageNode(
|
|
|
71
72
|
id,
|
|
72
73
|
name: "Transform Image",
|
|
73
74
|
description: `Apply ${transformations.length} transformation${transformations.length === 1 ? "" : "s"} to the image`,
|
|
75
|
+
nodeTypeId: STORAGE_OUTPUT_TYPE_ID,
|
|
74
76
|
transform: (inputBytes) =>
|
|
75
77
|
applyTransformationChain(imageService, inputBytes, transformations),
|
|
76
78
|
});
|