@uploadista/flow-images-nodes 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/.turbo/turbo-check.log +5 -0
  3. package/LICENSE +21 -0
  4. package/README.md +117 -0
  5. package/dist/describe-image-node.d.ts +69 -0
  6. package/dist/describe-image-node.d.ts.map +1 -0
  7. package/dist/describe-image-node.js +68 -0
  8. package/dist/index.d.ts +6 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +5 -0
  11. package/dist/nodes/describe-image-node.d.ts +66 -0
  12. package/dist/nodes/describe-image-node.d.ts.map +1 -0
  13. package/dist/nodes/describe-image-node.js +43 -0
  14. package/dist/nodes/index.d.ts +5 -0
  15. package/dist/nodes/index.d.ts.map +1 -0
  16. package/dist/nodes/index.js +4 -0
  17. package/dist/nodes/optimize-node.d.ts +24 -0
  18. package/dist/nodes/optimize-node.d.ts.map +1 -0
  19. package/dist/nodes/optimize-node.js +13 -0
  20. package/dist/nodes/remove-background-node.d.ts +25 -0
  21. package/dist/nodes/remove-background-node.d.ts.map +1 -0
  22. package/dist/nodes/remove-background-node.js +48 -0
  23. package/dist/nodes/resize-node.d.ts +24 -0
  24. package/dist/nodes/resize-node.d.ts.map +1 -0
  25. package/dist/nodes/resize-node.js +13 -0
  26. package/dist/optimize-node.d.ts +24 -0
  27. package/dist/optimize-node.d.ts.map +1 -0
  28. package/dist/optimize-node.js +41 -0
  29. package/dist/remove-background-node.d.ts +28 -0
  30. package/dist/remove-background-node.d.ts.map +1 -0
  31. package/dist/remove-background-node.js +84 -0
  32. package/dist/resize-node.d.ts +24 -0
  33. package/dist/resize-node.d.ts.map +1 -0
  34. package/dist/resize-node.js +13 -0
  35. package/dist/services/idnex.d.ts +2 -0
  36. package/dist/services/idnex.d.ts.map +1 -0
  37. package/dist/services/idnex.js +1 -0
  38. package/dist/services/image-service-common.d.ts +2 -0
  39. package/dist/services/image-service-common.d.ts.map +1 -0
  40. package/dist/services/image-service-common.js +1 -0
  41. package/dist/services/image-service-node.d.ts +18 -0
  42. package/dist/services/image-service-node.d.ts.map +1 -0
  43. package/dist/services/image-service-node.js +170 -0
  44. package/dist/services/image-service-serverless.d.ts +4 -0
  45. package/dist/services/image-service-serverless.d.ts.map +1 -0
  46. package/dist/services/image-service-serverless.js +153 -0
  47. package/dist/services/image-service.d.ts +13 -0
  48. package/dist/services/image-service.d.ts.map +1 -0
  49. package/dist/services/image-service.js +3 -0
  50. package/dist/services/index.d.ts +3 -0
  51. package/dist/services/index.d.ts.map +1 -0
  52. package/dist/services/index.js +3 -0
  53. package/dist/types/index.d.ts +3 -0
  54. package/dist/types/index.d.ts.map +1 -0
  55. package/dist/types/index.js +2 -0
  56. package/dist/types/optimize-node.d.ts +9 -0
  57. package/dist/types/optimize-node.d.ts.map +1 -0
  58. package/dist/types/optimize-node.js +5 -0
  59. package/dist/types/resize-node.d.ts +12 -0
  60. package/dist/types/resize-node.d.ts.map +1 -0
  61. package/dist/types/resize-node.js +8 -0
  62. package/dist/wait-for-url.d.ts +18 -0
  63. package/dist/wait-for-url.d.ts.map +1 -0
  64. package/dist/wait-for-url.js +36 -0
  65. package/package.json +30 -0
  66. package/src/describe-image-node.ts +101 -0
  67. package/src/index.ts +5 -0
  68. package/src/optimize-node.ts +61 -0
  69. package/src/remove-background-node.ts +130 -0
  70. package/src/resize-node.ts +23 -0
  71. package/src/wait-for-url.ts +52 -0
  72. package/tsconfig.json +14 -0
  73. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,5 @@
1
+
2
+ 
3
+ > @uploadista/flow-images-nodes@0.0.2 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/images/nodes
4
+ > tsc -b
5
+
@@ -0,0 +1,5 @@
1
+
2
+ > @uploadista/flow-image-nodes@ check /Users/denislaboureyras/Documents/uploadista/dev/uploadista/packages/uploadista/flow/image-nodes
3
+ > biome check --write ./src
4
+
5
+ Checked 7 files in 26ms. No fixes applied.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 uploadista
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @uploadista/flow-images-nodes
2
+
3
+ Base image processing nodes for Uploadista flows. Provides foundational image operations.
4
+
5
+ ## Overview
6
+
7
+ Base image nodes define interfaces and common operations:
8
+
9
+ - **Image Descriptions**: Extract metadata from images
10
+ - **Optimization**: Basic compression and format conversion
11
+ - **Background Removal**: Remove image backgrounds
12
+ - **Resizing**: Scale images
13
+ - **URL Resolution**: Load images from URLs
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @uploadista/flow-images-nodes
19
+ # or
20
+ pnpm add @uploadista/flow-images-nodes
21
+ ```
22
+
23
+ ## Node Types
24
+
25
+ ### Describe Image
26
+
27
+ Extract image metadata.
28
+
29
+ ```typescript
30
+ {
31
+ type: "describe-image",
32
+ params: {}
33
+ }
34
+ ```
35
+
36
+ Output: Image metadata (dimensions, format, etc)
37
+
38
+ ### Optimize
39
+
40
+ Compress and convert images.
41
+
42
+ ```typescript
43
+ {
44
+ type: "optimize",
45
+ params: {
46
+ quality: 85, // 1-100
47
+ format: "webp" // jpeg, png, webp, avif
48
+ }
49
+ }
50
+ ```
51
+
52
+ ### Remove Background
53
+
54
+ Remove image backgrounds.
55
+
56
+ ```typescript
57
+ {
58
+ type: "remove-background",
59
+ params: {
60
+ padding: 0,
61
+ format: "png"
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Resize
67
+
68
+ Scale images to dimensions.
69
+
70
+ ```typescript
71
+ {
72
+ type: "resize",
73
+ params: {
74
+ width: 800,
75
+ height: 600,
76
+ fit: "cover" // cover, contain, fill
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### Wait for URL
82
+
83
+ Load image from URL.
84
+
85
+ ```typescript
86
+ {
87
+ type: "wait-for-url",
88
+ params: {
89
+ timeout: 30000
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Use Cases
95
+
96
+ - Extract metadata for indexing
97
+ - Normalize image formats
98
+ - Create responsive variants
99
+ - Remove backgrounds for product images
100
+ - Load external images into pipeline
101
+
102
+ ## Related Packages
103
+
104
+ - [@uploadista/flow-images-sharp](../sharp) - Sharp implementation (Node.js)
105
+ - [@uploadista/flow-images-photon](../photon) - Cloudflare Photon (edge)
106
+ - [@uploadista/flow-images-replicate](../replicate) - AI operations
107
+ - [@uploadista/server](../../servers/server) - Upload server
108
+
109
+ ## License
110
+
111
+ See [LICENSE](../../../LICENSE) in the main repository.
112
+
113
+ ## See Also
114
+
115
+ - [FLOW_NODES.md](../FLOW_NODES.md) - All available nodes
116
+ - [Sharp Node](../sharp/README.md) - Node.js image processing
117
+ - [Photon Node](../photon/README.md) - Edge image processing
@@ -0,0 +1,69 @@
1
+ import { UploadistaError } from "@uploadista/core/errors";
2
+ import { ImageAiPlugin } from "@uploadista/core/flow";
3
+ import { Effect } from "effect";
4
+ export declare function createDescribeImageNode(id: string, { credentialId }?: {
5
+ credentialId?: string;
6
+ }): Effect.Effect<import("@uploadista/core").FlowNode<{
7
+ id: string;
8
+ offset: number;
9
+ storage: {
10
+ id: string;
11
+ type: string;
12
+ path?: string | undefined;
13
+ uploadId?: string | undefined;
14
+ bucket?: string | undefined;
15
+ };
16
+ size?: number | undefined;
17
+ metadata?: Record<string, string | number | boolean> | undefined;
18
+ creationDate?: string | undefined;
19
+ url?: string | undefined;
20
+ sizeIsDeferred?: boolean | undefined;
21
+ flow?: {
22
+ flowId: string;
23
+ nodeId: string;
24
+ jobId: string;
25
+ } | undefined;
26
+ }, {
27
+ id: string;
28
+ offset: number;
29
+ storage: {
30
+ id: string;
31
+ type: string;
32
+ path?: string | undefined;
33
+ uploadId?: string | undefined;
34
+ bucket?: string | undefined;
35
+ };
36
+ size?: number | undefined;
37
+ metadata?: Record<string, string | number | boolean> | undefined;
38
+ creationDate?: string | undefined;
39
+ url?: string | undefined;
40
+ sizeIsDeferred?: boolean | undefined;
41
+ flow?: {
42
+ flowId: string;
43
+ nodeId: string;
44
+ jobId: string;
45
+ } | undefined;
46
+ } | {
47
+ metadata: {
48
+ description: string;
49
+ };
50
+ flow: {
51
+ flowId: string;
52
+ nodeId: string;
53
+ jobId: string;
54
+ };
55
+ id: string;
56
+ offset: number;
57
+ storage: {
58
+ id: string;
59
+ type: string;
60
+ path?: string | undefined;
61
+ uploadId?: string | undefined;
62
+ bucket?: string | undefined;
63
+ };
64
+ size?: number | undefined;
65
+ creationDate?: string | undefined;
66
+ url?: string | undefined;
67
+ sizeIsDeferred?: boolean | undefined;
68
+ }, UploadistaError>, never, ImageAiPlugin>;
69
+ //# sourceMappingURL=describe-image-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-image-node.d.ts","sourceRoot":"","sources":["../src/describe-image-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,EAAE,YAAY,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAqFjD"}
@@ -0,0 +1,68 @@
1
+ import { UploadistaError } from "@uploadista/core/errors";
2
+ import { completeNodeExecution, createFlowNode, ImageAiPlugin, NodeType, resolveUploadMetadata, } from "@uploadista/core/flow";
3
+ import { uploadFileSchema } from "@uploadista/core/types";
4
+ import { Effect } from "effect";
5
+ import { waitForUrlAvailability } from "./wait-for-url";
6
+ export function createDescribeImageNode(id, { credentialId } = {}) {
7
+ return Effect.gen(function* () {
8
+ const imageAiService = yield* ImageAiPlugin;
9
+ return yield* createFlowNode({
10
+ id,
11
+ name: "Describe Image",
12
+ description: "Describes the image using AI",
13
+ type: NodeType.process,
14
+ inputSchema: uploadFileSchema,
15
+ outputSchema: uploadFileSchema,
16
+ run: ({ data: file, flowId, jobId, clientId }) => {
17
+ return Effect.gen(function* () {
18
+ const flow = {
19
+ flowId,
20
+ nodeId: id,
21
+ jobId,
22
+ };
23
+ const fileUrl = file.url;
24
+ // Validate input
25
+ if (!fileUrl) {
26
+ return yield* UploadistaError.fromCode("FLOW_NODE_ERROR", {
27
+ cause: "URL is required for describe image operation",
28
+ }).toEffect();
29
+ }
30
+ yield* Effect.logInfo(`Describing image for file ${file.id} at URL: ${fileUrl}`);
31
+ // Wait for URL to be available with retry mechanism
32
+ yield* waitForUrlAvailability(fileUrl);
33
+ // Build context for ImageAI plugin
34
+ const context = {
35
+ clientId,
36
+ credentialId,
37
+ };
38
+ // Describe image with error handling
39
+ const { description } = yield* imageAiService
40
+ .describeImage(fileUrl, context)
41
+ .pipe(Effect.catchAll((error) => Effect.gen(function* () {
42
+ yield* Effect.logError("Failed to describe image", error);
43
+ return yield* UploadistaError.fromCode("FLOW_NODE_ERROR", {
44
+ cause: error instanceof Error
45
+ ? error.message
46
+ : "Failed to describe image",
47
+ }).toEffect();
48
+ })));
49
+ const { metadata } = resolveUploadMetadata(file.metadata);
50
+ // add description to metadata
51
+ const newMetadata = {
52
+ ...file.metadata,
53
+ ...metadata,
54
+ description,
55
+ };
56
+ yield* Effect.logInfo(`Successfully described image for file ${file.id}`);
57
+ return completeNodeExecution(newMetadata
58
+ ? {
59
+ ...file,
60
+ metadata: newMetadata,
61
+ flow,
62
+ }
63
+ : file);
64
+ });
65
+ },
66
+ });
67
+ });
68
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./describe-image-node";
2
+ export * from "./optimize-node";
3
+ export * from "./remove-background-node";
4
+ export * from "./resize-node";
5
+ export * from "./wait-for-url";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./describe-image-node";
2
+ export * from "./optimize-node";
3
+ export * from "./remove-background-node";
4
+ export * from "./resize-node";
5
+ export * from "./wait-for-url";
@@ -0,0 +1,66 @@
1
+ import { ImageAiPlugin } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export declare function createDescribeImageNode(id: string): Effect.Effect<import("@uploadista/core").FlowNode<{
4
+ id: string;
5
+ offset: number;
6
+ storage: {
7
+ id: string;
8
+ type: string;
9
+ path?: string | undefined;
10
+ uploadId?: string | undefined;
11
+ bucket?: string | undefined;
12
+ };
13
+ size?: number | undefined;
14
+ metadata?: Record<string, string | number | boolean> | undefined;
15
+ creationDate?: string | undefined;
16
+ url?: string | undefined;
17
+ sizeIsDeferred?: boolean | undefined;
18
+ flow?: {
19
+ flowId: string;
20
+ nodeId: string;
21
+ jobId: string;
22
+ } | undefined;
23
+ }, {
24
+ id: string;
25
+ offset: number;
26
+ storage: {
27
+ id: string;
28
+ type: string;
29
+ path?: string | undefined;
30
+ uploadId?: string | undefined;
31
+ bucket?: string | undefined;
32
+ };
33
+ size?: number | undefined;
34
+ metadata?: Record<string, string | number | boolean> | undefined;
35
+ creationDate?: string | undefined;
36
+ url?: string | undefined;
37
+ sizeIsDeferred?: boolean | undefined;
38
+ flow?: {
39
+ flowId: string;
40
+ nodeId: string;
41
+ jobId: string;
42
+ } | undefined;
43
+ } | {
44
+ metadata: {
45
+ description: string;
46
+ };
47
+ flow: {
48
+ flowId: string;
49
+ nodeId: string;
50
+ jobId: string;
51
+ };
52
+ id: string;
53
+ offset: number;
54
+ storage: {
55
+ id: string;
56
+ type: string;
57
+ path?: string | undefined;
58
+ uploadId?: string | undefined;
59
+ bucket?: string | undefined;
60
+ };
61
+ size?: number | undefined;
62
+ creationDate?: string | undefined;
63
+ url?: string | undefined;
64
+ sizeIsDeferred?: boolean | undefined;
65
+ }, import("@uploadista/core").UploadistaError>, never, ImageAiPlugin>;
66
+ //# sourceMappingURL=describe-image-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-image-node.d.ts","sourceRoot":"","sources":["../../src/nodes/describe-image-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sEA8CjD"}
@@ -0,0 +1,43 @@
1
+ import { completeNodeExecution, createFlowNode, ImageAiPlugin, NodeType, resolveUploadMetadata, } from "@uploadista/core/flow";
2
+ import { uploadFileSchema } from "@uploadista/core/types";
3
+ import { Effect } from "effect";
4
+ export function createDescribeImageNode(id) {
5
+ return Effect.gen(function* () {
6
+ const imageAiService = yield* ImageAiPlugin;
7
+ return yield* createFlowNode({
8
+ id,
9
+ name: "Describe Image",
10
+ description: "Describes the image using AI",
11
+ type: NodeType.process,
12
+ inputSchema: uploadFileSchema,
13
+ outputSchema: uploadFileSchema,
14
+ run: ({ data: file, flowId, jobId }) => {
15
+ return Effect.gen(function* () {
16
+ const flow = {
17
+ flowId,
18
+ nodeId: id,
19
+ jobId,
20
+ };
21
+ if (!file.url) {
22
+ throw new Error("URL is required");
23
+ }
24
+ const { description } = yield* imageAiService.describeImage(file.url);
25
+ const { metadata } = resolveUploadMetadata(file.metadata);
26
+ // add description to metadata
27
+ const newMetadata = {
28
+ ...file.metadata,
29
+ ...metadata,
30
+ description,
31
+ };
32
+ return completeNodeExecution(newMetadata
33
+ ? {
34
+ ...file,
35
+ metadata: newMetadata,
36
+ flow,
37
+ }
38
+ : file);
39
+ });
40
+ },
41
+ });
42
+ });
43
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./describe-image-node";
2
+ export * from "./optimize-node";
3
+ export * from "./remove-background-node";
4
+ export * from "./resize-node";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./describe-image-node";
2
+ export * from "./optimize-node";
3
+ export * from "./remove-background-node";
4
+ export * from "./resize-node";
@@ -0,0 +1,24 @@
1
+ import { ImagePlugin, type OptimizeParams } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export declare function createOptimizeNode(id: string, { quality, format }: OptimizeParams): Effect.Effect<import("@uploadista/core").FlowNode<{
4
+ id: string;
5
+ offset: number;
6
+ storage: {
7
+ id: string;
8
+ type: string;
9
+ path?: string | undefined;
10
+ uploadId?: string | undefined;
11
+ bucket?: string | undefined;
12
+ };
13
+ size?: number | undefined;
14
+ metadata?: Record<string, string | number | boolean> | undefined;
15
+ creationDate?: string | undefined;
16
+ url?: string | undefined;
17
+ sizeIsDeferred?: boolean | undefined;
18
+ flow?: {
19
+ flowId: string;
20
+ nodeId: string;
21
+ jobId: string;
22
+ } | undefined;
23
+ }, import("@uploadista/core").UploadFile, import("@uploadista/core").UploadistaError>, never, ImagePlugin | import("@uploadista/core").UploadServer>;
24
+ //# sourceMappingURL=optimize-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimize-node.d.ts","sourceRoot":"","sources":["../../src/nodes/optimize-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc;;;;;;YAc6R,CAAC;gBAAsC,CAAC;cAAoC,CAAC;;;;;;;;;;;;qJAD9Y"}
@@ -0,0 +1,13 @@
1
+ import { createTransformNode, ImagePlugin, } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export function createOptimizeNode(id, { quality, format }) {
4
+ return Effect.gen(function* () {
5
+ const imageService = yield* ImagePlugin;
6
+ return yield* createTransformNode({
7
+ id,
8
+ name: "Optimize",
9
+ description: "Optimizes an image for web delivery",
10
+ transform: (inputBytes) => imageService.optimize(inputBytes, { quality, format }),
11
+ });
12
+ });
13
+ }
@@ -0,0 +1,25 @@
1
+ import { ImageAiPlugin } from "@uploadista/core/flow";
2
+ import { UploadServer } from "@uploadista/core/upload";
3
+ import { Effect } from "effect";
4
+ export declare function createRemoveBackgroundNode(id: string): Effect.Effect<import("@uploadista/core").FlowNode<{
5
+ id: string;
6
+ offset: number;
7
+ storage: {
8
+ id: string;
9
+ type: string;
10
+ path?: string | undefined;
11
+ uploadId?: string | undefined;
12
+ bucket?: string | undefined;
13
+ };
14
+ size?: number | undefined;
15
+ metadata?: Record<string, string | number | boolean> | undefined;
16
+ creationDate?: string | undefined;
17
+ url?: string | undefined;
18
+ sizeIsDeferred?: boolean | undefined;
19
+ flow?: {
20
+ flowId: string;
21
+ nodeId: string;
22
+ jobId: string;
23
+ } | undefined;
24
+ }, import("@uploadista/core").UploadFile, import("@uploadista/core").UploadistaError>, never, ImageAiPlugin | UploadServer>;
25
+ //# sourceMappingURL=remove-background-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-background-node.d.ts","sourceRoot":"","sources":["../../src/nodes/remove-background-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;4HAuDpD"}
@@ -0,0 +1,48 @@
1
+ import { completeNodeExecution, createFlowNode, ImageAiPlugin, NodeType, resolveUploadMetadata, } from "@uploadista/core/flow";
2
+ import { uploadFileSchema } from "@uploadista/core/types";
3
+ import { UploadServer } from "@uploadista/core/upload";
4
+ import { Effect } from "effect";
5
+ export function createRemoveBackgroundNode(id) {
6
+ return Effect.gen(function* () {
7
+ const imageAiService = yield* ImageAiPlugin;
8
+ const uploadServer = yield* UploadServer;
9
+ return yield* createFlowNode({
10
+ id,
11
+ name: "Remove Background",
12
+ description: "Removes the background from an image",
13
+ type: NodeType.process,
14
+ inputSchema: uploadFileSchema,
15
+ outputSchema: uploadFileSchema,
16
+ run: ({ data: file, flowId, jobId, storageId }) => {
17
+ return Effect.gen(function* () {
18
+ const flow = {
19
+ flowId,
20
+ nodeId: id,
21
+ jobId,
22
+ };
23
+ if (!file.url) {
24
+ throw new Error("URL is required");
25
+ }
26
+ const { outputUrl } = yield* imageAiService.removeBackground(file.url);
27
+ const { type, fileName, metadata, metadataJson } = resolveUploadMetadata(file.metadata);
28
+ // Upload the transformed bytes back to the upload server
29
+ const result = yield* uploadServer.uploadFromUrl({
30
+ storageId,
31
+ size: 0,
32
+ type,
33
+ fileName,
34
+ lastModified: 0,
35
+ metadata: metadataJson,
36
+ flow,
37
+ }, outputUrl);
38
+ return completeNodeExecution(metadata
39
+ ? {
40
+ ...result,
41
+ metadata,
42
+ }
43
+ : result);
44
+ });
45
+ },
46
+ });
47
+ });
48
+ }
@@ -0,0 +1,24 @@
1
+ import { ImagePlugin, type ResizeParams } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export declare function createResizeNode(id: string, { width, height, fit }: ResizeParams): Effect.Effect<import("@uploadista/core").FlowNode<{
4
+ id: string;
5
+ offset: number;
6
+ storage: {
7
+ id: string;
8
+ type: string;
9
+ path?: string | undefined;
10
+ uploadId?: string | undefined;
11
+ bucket?: string | undefined;
12
+ };
13
+ size?: number | undefined;
14
+ metadata?: Record<string, string | number | boolean> | undefined;
15
+ creationDate?: string | undefined;
16
+ url?: string | undefined;
17
+ sizeIsDeferred?: boolean | undefined;
18
+ flow?: {
19
+ flowId: string;
20
+ nodeId: string;
21
+ jobId: string;
22
+ } | undefined;
23
+ }, import("@uploadista/core").UploadFile, import("@uploadista/core").UploadistaError>, never, ImagePlugin | import("@uploadista/core").UploadServer>;
24
+ //# sourceMappingURL=resize-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resize-node.d.ts","sourceRoot":"","sources":["../../src/nodes/resize-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,YAAY;;;;;;YAcuR,CAAC;gBAAsC,CAAC;cAAoC,CAAC;;;;;;;;;;;;qJADzY"}
@@ -0,0 +1,13 @@
1
+ import { createTransformNode, ImagePlugin, } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export function createResizeNode(id, { width, height, fit }) {
4
+ return Effect.gen(function* () {
5
+ const imageService = yield* ImagePlugin;
6
+ return yield* createTransformNode({
7
+ id,
8
+ name: "Resize",
9
+ description: "Resizes an image to the specified dimensions",
10
+ transform: (inputBytes) => imageService.resize(inputBytes, { height, width, fit }),
11
+ });
12
+ });
13
+ }
@@ -0,0 +1,24 @@
1
+ import { ImagePlugin, type OptimizeParams } from "@uploadista/core/flow";
2
+ import { Effect } from "effect";
3
+ export declare function createOptimizeNode(id: string, { quality, format }: OptimizeParams): Effect.Effect<import("@uploadista/core").FlowNode<{
4
+ id: string;
5
+ offset: number;
6
+ storage: {
7
+ id: string;
8
+ type: string;
9
+ path?: string | undefined;
10
+ uploadId?: string | undefined;
11
+ bucket?: string | undefined;
12
+ };
13
+ size?: number | undefined;
14
+ metadata?: Record<string, string | number | boolean> | undefined;
15
+ creationDate?: string | undefined;
16
+ url?: string | undefined;
17
+ sizeIsDeferred?: boolean | undefined;
18
+ flow?: {
19
+ flowId: string;
20
+ nodeId: string;
21
+ jobId: string;
22
+ } | undefined;
23
+ }, import("@uploadista/core").UploadFile, import("@uploadista/core").UploadistaError>, never, ImagePlugin | import("@uploadista/core").UploadServer>;
24
+ //# sourceMappingURL=optimize-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimize-node.d.ts","sourceRoot":"","sources":["../src/optimize-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkBhC,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc;;;;;;YAczB,CADX;gBAAsC,CAAC;cAC5B,CAAH;;;;;;;;;;;;qJAqBR"}