@uploadista/flow-utility-nodes 0.0.7 → 0.0.9
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/nodes/index.cjs +1 -1
- package/dist/nodes/index.d.cts +4 -10
- package/dist/nodes/index.d.cts.map +1 -1
- package/dist/nodes/index.d.mts +30 -0
- package/dist/nodes/index.d.mts.map +1 -0
- package/dist/nodes/{index.js → index.mjs} +1 -1
- package/dist/nodes/index.mjs.map +1 -0
- package/dist/types/index.cjs +2 -2
- package/dist/types/{index.d.ts → index.d.mts} +1 -1
- package/dist/types/{index.js → index.mjs} +1 -1
- package/dist/types/index.mjs.map +1 -0
- package/dist/{zip-node-8Vme3wB7.d.ts → zip-node-BBj1lGeU.d.mts} +1 -1
- package/dist/zip-node-BBj1lGeU.d.mts.map +1 -0
- package/package.json +6 -6
- package/dist/chunk-DjWAcSYV.cjs +0 -1
- package/dist/nodes/index.d.ts +0 -36
- package/dist/nodes/index.d.ts.map +0 -1
- package/dist/nodes/index.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/zip-node-8Vme3wB7.d.ts.map +0 -1
package/dist/nodes/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require(`@uploadista/core/flow`),t=require(`@uploadista/core/types`),n=require(`effect`),r=require(`@uploadista/core/errors`),i=require(`@uploadista/core/upload`),a=require(`zod`);function o(r,{field:i,operator:a,value:o}){return(0,e.createFlowNode)({id:r,name:`Conditional Router`,description:`Routes flow based on ${i} ${a} ${o}`,type:e.NodeType.conditional,inputSchema:t.uploadFileSchema,outputSchema:t.uploadFileSchema,condition:{field:i,operator:a,value:o},run:({data:t})=>n.Effect.succeed((0,e.completeNodeExecution)(t))})}const s=a.z.record(a.z.string(),t.uploadFileSchema),c=t.uploadFileSchema;function l(t,{strategy:a,separator:o}){return n.Effect.gen(function*(){let o=yield*i.UploadServer;return yield*(0,e.createFlowNode)({id:t,name:`Merge Files`,description:`Merges multiple files using ${a} strategy`,type:e.NodeType.merge,inputSchema:s,outputSchema:c,multiInput:!0,run:({data:t,storageId:i,clientId:s})=>n.Effect.gen(function*(){if(!t||Object.keys(t).length===0)return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`No inputs provided to merge node`}));let c=Object.values(t);if(c.length===0)return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`No files to merge`}));switch(a){case`concat`:{let t=[],n=0;for(let e of c){let r=yield*o.read(e.id,s);t.push(r),n+=r.byteLength}let r=new Uint8Array(n),a=0;for(let e of t)r.set(e,a),a+=e.byteLength;let l=new ReadableStream({start(e){e.enqueue(r),e.close()}});return(0,e.completeNodeExecution)(yield*o.upload({storageId:i,size:r.byteLength,type:`application/octet-stream`,fileName:`merged_${c.length}_files.bin`,lastModified:0,metadata:JSON.stringify({mimeType:`application/octet-stream`,originalName:`merged_${c.length}_files`,extension:`bin`})},s,l))}default:return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`Unknown merge strategy: ${a}`}))}})})})}function u(a,{outputCount:o,strategy:s}){return n.Effect.gen(function*(){let o=yield*i.UploadServer;return yield*(0,e.createFlowNode)({id:a,name:`Multiplex`,description:`Multiplexes input using ${s} strategy`,type:e.NodeType.multiplex,inputSchema:t.uploadFileSchema,outputSchema:t.uploadFileSchema,multiOutput:!0,run:({data:t,storageId:i,clientId:a})=>n.Effect.gen(function*(){let{type:c,fileName:l,metadata:u,metadataJson:d}=(0,e.resolveUploadMetadata)(t.metadata),f=u?{...t,metadata:u}:t;if(s===`copy`){let t=yield*o.read(f.id,a),n=new ReadableStream({start(e){e.enqueue(t),e.close()}}),r=yield*o.upload({storageId:i,size:t.byteLength,type:c,fileName:l,lastModified:0,metadata:d},a,n),s=(0,e.resolveUploadMetadata)(r.metadata);return(0,e.completeNodeExecution)(s.metadata?{...r,metadata:s.metadata}:r)}else if(s===`split`)return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`Split strategy is not supported with UploadFile pattern`}));return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`Unknown multiplex strategy: ${s}`}))})})})}const d=a.z.record(a.z.string(),t.uploadFileSchema),f=t.uploadFileSchema;function p(t,{zipName:a,includeMetadata:o}){return n.Effect.gen(function*(){let s=yield*i.UploadServer,c=yield*e.ZipPlugin;return yield*(0,e.createFlowNode)({id:t,name:`Zip Files`,description:`Combines multiple files into a zip archive`,type:e.NodeType.process,inputSchema:d,outputSchema:f,multiInput:!0,run:({data:t,storageId:i,clientId:l})=>n.Effect.gen(function*(){if(!t||Object.keys(t).length===0)return yield*n.Effect.fail(r.UploadistaError.fromCode(`VALIDATION_ERROR`,{body:`No inputs provided to zip node`}));let u=yield*n.Effect.forEach(Object.values(t),e=>n.Effect.gen(function*(){let t=yield*s.read(e.id,l);return{id:e.id,data:t,metadata:e.metadata}}),{concurrency:`unbounded`}),d=yield*c.zip(u,{zipName:a,includeMetadata:o}),f=new ReadableStream({start(e){e.enqueue(d),e.close()}});return(0,e.completeNodeExecution)(yield*s.upload({storageId:i,size:d.byteLength,type:`application/zip`,fileName:a,lastModified:0,metadata:JSON.stringify({mimeType:`application/zip`,type:`application/zip`,originalName:a,fileName:a,extension:`zip`})},l,f))})})})}exports.createConditionalNode=o,exports.createMergeNode=l,exports.createMultiplexNode=u,exports.createZipNode=p;
|
package/dist/nodes/index.d.cts
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
import { a as MergeParams, r as MultiplexParams, s as ConditionalParams, t as ZipParams } from "../zip-node-D-UE9ml-.cjs";
|
|
2
|
-
import * as _uploadista_core_errors0 from "@uploadista/core/errors";
|
|
3
|
-
import { UploadistaError } from "@uploadista/core/errors";
|
|
4
|
-
import * as _uploadista_core_flow0 from "@uploadista/core/flow";
|
|
5
|
-
import { ZipPlugin } from "@uploadista/core/flow";
|
|
6
|
-
import { UploadFile } from "@uploadista/core/types";
|
|
7
2
|
import { Effect } from "effect";
|
|
8
|
-
import { UploadServer } from "@uploadista/core/upload";
|
|
9
3
|
|
|
10
4
|
//#region src/nodes/conditional-node.d.ts
|
|
11
5
|
declare function createConditionalNode(id: string, {
|
|
12
6
|
field,
|
|
13
7
|
operator,
|
|
14
8
|
value
|
|
15
|
-
}: ConditionalParams):
|
|
9
|
+
}: ConditionalParams): any;
|
|
16
10
|
//#endregion
|
|
17
11
|
//#region src/nodes/merge-node.d.ts
|
|
18
12
|
declare function createMergeNode(id: string, {
|
|
19
13
|
strategy,
|
|
20
14
|
separator: _separator
|
|
21
|
-
}: MergeParams): Effect.Effect<
|
|
15
|
+
}: MergeParams): Effect.Effect<any, unknown, unknown>;
|
|
22
16
|
//#endregion
|
|
23
17
|
//#region src/nodes/multiplex-node.d.ts
|
|
24
18
|
declare function createMultiplexNode(id: string, {
|
|
25
19
|
outputCount: _outputCount,
|
|
26
20
|
strategy
|
|
27
|
-
}: MultiplexParams): Effect.Effect<
|
|
21
|
+
}: MultiplexParams): Effect.Effect<any, unknown, unknown>;
|
|
28
22
|
//#endregion
|
|
29
23
|
//#region src/nodes/zip-node.d.ts
|
|
30
24
|
declare function createZipNode(id: string, {
|
|
31
25
|
zipName,
|
|
32
26
|
includeMetadata
|
|
33
|
-
}: ZipParams): Effect.Effect<
|
|
27
|
+
}: ZipParams): Effect.Effect<any, unknown, unknown>;
|
|
34
28
|
//#endregion
|
|
35
29
|
export { createConditionalNode, createMergeNode, createMultiplexNode, createZipNode };
|
|
36
30
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":[],"mappings":";;;;iBASgB,qBAAA;;;;GAEc;;;iBCId,eAAA;;aAES;GAAc,cAAW,MAAA,CAAA;;;iBCLlC,mBAAA;eAEC;;GAA0B,kBAAe,MAAA,CAAA;;;iBCE1C,aAAA;;;GAEgB,YAAS,MAAA,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { a as MergeParams, r as MultiplexParams, s as ConditionalParams, t as ZipParams } from "../zip-node-BBj1lGeU.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/nodes/conditional-node.d.ts
|
|
5
|
+
declare function createConditionalNode(id: string, {
|
|
6
|
+
field,
|
|
7
|
+
operator,
|
|
8
|
+
value
|
|
9
|
+
}: ConditionalParams): any;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/nodes/merge-node.d.ts
|
|
12
|
+
declare function createMergeNode(id: string, {
|
|
13
|
+
strategy,
|
|
14
|
+
separator: _separator
|
|
15
|
+
}: MergeParams): Effect.Effect<any, unknown, unknown>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/nodes/multiplex-node.d.ts
|
|
18
|
+
declare function createMultiplexNode(id: string, {
|
|
19
|
+
outputCount: _outputCount,
|
|
20
|
+
strategy
|
|
21
|
+
}: MultiplexParams): Effect.Effect<any, unknown, unknown>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/nodes/zip-node.d.ts
|
|
24
|
+
declare function createZipNode(id: string, {
|
|
25
|
+
zipName,
|
|
26
|
+
includeMetadata
|
|
27
|
+
}: ZipParams): Effect.Effect<any, unknown, unknown>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { createConditionalNode, createMergeNode, createMultiplexNode, createZipNode };
|
|
30
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":[],"mappings":";;;;iBASgB,qBAAA;;;;GAEc;;;iBCId,eAAA;;aAES;GAAc,cAAW,MAAA,CAAA;;;iBCLlC,mBAAA;eAEC;;GAA0B,kBAAe,MAAA,CAAA;;;iBCE1C,aAAA;;;GAEgB,YAAS,MAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{NodeType as e,ZipPlugin as t,completeNodeExecution as n,createFlowNode as r,resolveUploadMetadata as i}from"@uploadista/core/flow";import{uploadFileSchema as a}from"@uploadista/core/types";import{Effect as o}from"effect";import{UploadistaError as s}from"@uploadista/core/errors";import{UploadServer as c}from"@uploadista/core/upload";import{z as l}from"zod";function u(t,{field:i,operator:s,value:c}){return r({id:t,name:`Conditional Router`,description:`Routes flow based on ${i} ${s} ${c}`,type:e.conditional,inputSchema:a,outputSchema:a,condition:{field:i,operator:s,value:c},run:({data:e})=>o.succeed(n(e))})}const d=l.record(l.string(),a),f=a;function p(t,{strategy:i,separator:a}){return o.gen(function*(){let a=yield*c;return yield*r({id:t,name:`Merge Files`,description:`Merges multiple files using ${i} strategy`,type:e.merge,inputSchema:d,outputSchema:f,multiInput:!0,run:({data:e,storageId:t,clientId:r})=>o.gen(function*(){if(!e||Object.keys(e).length===0)return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`No inputs provided to merge node`}));let c=Object.values(e);if(c.length===0)return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`No files to merge`}));switch(i){case`concat`:{let e=[],i=0;for(let t of c){let n=yield*a.read(t.id,r);e.push(n),i+=n.byteLength}let o=new Uint8Array(i),s=0;for(let t of e)o.set(t,s),s+=t.byteLength;let l=new ReadableStream({start(e){e.enqueue(o),e.close()}});return n(yield*a.upload({storageId:t,size:o.byteLength,type:`application/octet-stream`,fileName:`merged_${c.length}_files.bin`,lastModified:0,metadata:JSON.stringify({mimeType:`application/octet-stream`,originalName:`merged_${c.length}_files`,extension:`bin`})},r,l))}default:return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`Unknown merge strategy: ${i}`}))}})})})}function m(t,{outputCount:l,strategy:u}){return o.gen(function*(){let l=yield*c;return yield*r({id:t,name:`Multiplex`,description:`Multiplexes input using ${u} strategy`,type:e.multiplex,inputSchema:a,outputSchema:a,multiOutput:!0,run:({data:e,storageId:t,clientId:r})=>o.gen(function*(){let{type:a,fileName:c,metadata:d,metadataJson:f}=i(e.metadata),p=d?{...e,metadata:d}:e;if(u===`copy`){let e=yield*l.read(p.id,r),o=new ReadableStream({start(t){t.enqueue(e),t.close()}}),s=yield*l.upload({storageId:t,size:e.byteLength,type:a,fileName:c,lastModified:0,metadata:f},r,o),u=i(s.metadata);return n(u.metadata?{...s,metadata:u.metadata}:s)}else if(u===`split`)return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`Split strategy is not supported with UploadFile pattern`}));return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`Unknown multiplex strategy: ${u}`}))})})})}const h=l.record(l.string(),a),g=a;function _(i,{zipName:a,includeMetadata:l}){return o.gen(function*(){let u=yield*c,d=yield*t;return yield*r({id:i,name:`Zip Files`,description:`Combines multiple files into a zip archive`,type:e.process,inputSchema:h,outputSchema:g,multiInput:!0,run:({data:e,storageId:t,clientId:r})=>o.gen(function*(){if(!e||Object.keys(e).length===0)return yield*o.fail(s.fromCode(`VALIDATION_ERROR`,{body:`No inputs provided to zip node`}));let i=yield*o.forEach(Object.values(e),e=>o.gen(function*(){let t=yield*u.read(e.id,r);return{id:e.id,data:t,metadata:e.metadata}}),{concurrency:`unbounded`}),c=yield*d.zip(i,{zipName:a,includeMetadata:l}),f=new ReadableStream({start(e){e.enqueue(c),e.close()}});return n(yield*u.upload({storageId:t,size:c.byteLength,type:`application/zip`,fileName:a,lastModified:0,metadata:JSON.stringify({mimeType:`application/zip`,type:`application/zip`,originalName:a,fileName:a,extension:`zip`})},r,f))})})})}export{u as createConditionalNode,p as createMergeNode,m as createMultiplexNode,_ as createZipNode};
|
|
2
|
-
//# sourceMappingURL=index.
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["inputSchema","outputSchema","inputBytesArray: Uint8Array[]"],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":["import {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { Effect } from \"effect\";\nimport type { ConditionalParams } from \"@/types/conditional-node\";\n\nexport function createConditionalNode(\n id: string,\n { field, operator, value }: ConditionalParams,\n) {\n return createFlowNode<UploadFile, UploadFile>({\n id,\n name: \"Conditional Router\",\n description: `Routes flow based on ${field} ${operator} ${value}`,\n type: NodeType.conditional,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n condition: { field, operator, value },\n run: ({ data }) => {\n // The actual routing logic is handled by the flow engine\n // This node just passes through the data\n return Effect.succeed(completeNodeExecution(data));\n },\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { z } from \"zod\";\nimport type { MergeParams } from \"@/types/merge-node\";\n\nconst inputSchema = z.record(z.string(), uploadFileSchema);\nconst outputSchema = uploadFileSchema;\n\nexport function createMergeNode(\n id: string,\n { strategy, separator: _separator }: MergeParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode<Record<string, UploadFile>, UploadFile>({\n id,\n name: \"Merge Files\",\n description: `Merges multiple files using ${strategy} strategy`,\n type: NodeType.merge,\n inputSchema,\n outputSchema,\n multiInput: true,\n run: ({ data: inputs, storageId, clientId }) => {\n return Effect.gen(function* () {\n if (!inputs || Object.keys(inputs).length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No inputs provided to merge node\",\n }),\n );\n }\n\n const inputFiles = Object.values(inputs);\n\n if (inputFiles.length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No files to merge\",\n }),\n );\n }\n\n switch (strategy) {\n case \"concat\": {\n // Read bytes from all input files\n const inputBytesArray: Uint8Array[] = [];\n let totalSize = 0;\n\n for (const file of inputFiles) {\n const bytes = yield* uploadServer.read(file.id, clientId);\n inputBytesArray.push(bytes);\n totalSize += bytes.byteLength;\n }\n\n // Concatenate all files into one\n const mergedBytes = new Uint8Array(totalSize);\n let offset = 0;\n for (const bytes of inputBytesArray) {\n mergedBytes.set(bytes, offset);\n offset += bytes.byteLength;\n }\n\n // Create a stream from the merged bytes\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(mergedBytes);\n controller.close();\n },\n });\n\n // Upload the merged file\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: mergedBytes.byteLength,\n type: \"application/octet-stream\",\n fileName: `merged_${inputFiles.length}_files.bin`,\n lastModified: 0,\n metadata: JSON.stringify({\n mimeType: \"application/octet-stream\",\n originalName: `merged_${inputFiles.length}_files`,\n extension: \"bin\",\n }),\n },\n clientId,\n stream,\n );\n\n return completeNodeExecution(result);\n }\n default: {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: `Unknown merge strategy: ${strategy}`,\n }),\n );\n }\n }\n });\n },\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n resolveUploadMetadata,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport type { MultiplexParams } from \"@/types/multiplex-node\";\n\nexport function createMultiplexNode(\n id: string,\n { outputCount: _outputCount, strategy }: MultiplexParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode<UploadFile, UploadFile>({\n id,\n name: \"Multiplex\",\n description: `Multiplexes input using ${strategy} strategy`,\n type: NodeType.multiplex,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n multiOutput: true,\n run: ({ data: file, storageId, clientId }) => {\n return Effect.gen(function* () {\n const { type, fileName, metadata, metadataJson } =\n resolveUploadMetadata(file.metadata);\n const normalizedFile = metadata ? { ...file, metadata } : file;\n\n if (strategy === \"copy\") {\n // For copy strategy, read and re-upload the file\n const inputBytes = yield* uploadServer.read(\n normalizedFile.id,\n clientId,\n );\n\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(inputBytes);\n controller.close();\n },\n });\n\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: inputBytes.byteLength,\n type,\n fileName,\n lastModified: 0,\n metadata: metadataJson,\n },\n clientId,\n stream,\n );\n\n const resolvedResult = resolveUploadMetadata(result.metadata);\n\n return completeNodeExecution(\n resolvedResult.metadata\n ? { ...result, metadata: resolvedResult.metadata }\n : result,\n );\n } else if (strategy === \"split\") {\n // Split strategy is not supported in the new pattern\n // as it would require returning multiple UploadFiles\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"Split strategy is not supported with UploadFile pattern\",\n }),\n );\n }\n\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: `Unknown multiplex strategy: ${strategy}`,\n }),\n );\n });\n },\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n ZipPlugin,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { z } from \"zod\";\nimport type { ZipParams } from \"@/types/zip-node\";\n\nconst inputSchema = z.record(z.string(), uploadFileSchema);\nconst outputSchema = uploadFileSchema;\n\nexport function createZipNode(\n id: string,\n { zipName, includeMetadata }: ZipParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n const zipPlugin = yield* ZipPlugin;\n return yield* createFlowNode<Record<string, UploadFile>, UploadFile>({\n id,\n name: \"Zip Files\",\n description: \"Combines multiple files into a zip archive\",\n type: NodeType.process,\n inputSchema,\n outputSchema,\n multiInput: true,\n run: ({ data: inputs, storageId, clientId }) => {\n return Effect.gen(function* () {\n if (!inputs || Object.keys(inputs).length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No inputs provided to zip node\",\n }),\n );\n }\n\n\n const zipInputs = yield* Effect.forEach(\n Object.values(inputs),\n (input) =>\n Effect.gen(function* () {\n const data = yield* uploadServer.read(input.id, clientId);\n return {\n id: input.id,\n data,\n metadata: input.metadata,\n };\n }),\n { concurrency: \"unbounded\" }\n );\n\n const zipBytes = yield* zipPlugin.zip(zipInputs, { zipName, includeMetadata });\n\n // Create a stream from the zip bytes\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(zipBytes);\n controller.close();\n },\n });\n\n // Upload the zip file\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: zipBytes.byteLength,\n type: \"application/zip\",\n fileName: zipName,\n lastModified: 0,\n metadata: JSON.stringify({\n mimeType: \"application/zip\",\n type: \"application/zip\",\n originalName: zipName,\n fileName: zipName,\n extension: \"zip\",\n }),\n },\n clientId,\n stream,\n );\n\n return completeNodeExecution(result);\n });\n },\n });\n });\n}\n"],"mappings":"6WASA,SAAgB,EACd,EACA,CAAE,QAAO,WAAU,SACnB,CACA,OAAO,EAAuC,CAC5C,K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EACpC,CAEL,CAAC,EACF"}
|
package/dist/types/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`).optional(),inputCount:
|
|
1
|
+
let e=require(`zod`);const t=e.z.object({field:e.z.enum([`mimeType`,`size`,`width`,`height`,`extension`]),operator:e.z.enum([`equals`,`notEquals`,`greaterThan`,`lessThan`,`contains`,`startsWith`]),value:e.z.union([e.z.string(),e.z.number()])}),n=e.z.object({strategy:e.z.enum([`concat`,`batch`]).default(`batch`),separator:e.z.string().default(`
|
|
2
|
+
`).optional(),inputCount:e.z.number().min(2).max(10).default(2)}),r=e.z.object({outputCount:e.z.number().min(1).max(10),strategy:e.z.enum([`copy`,`split`]).default(`copy`)}),i=e.z.object({zipName:e.z.string().default(`archive.zip`),includeMetadata:e.z.boolean().default(!1),inputCount:e.z.number().min(2).max(10).default(2)});exports.conditionalParamsSchema=t,exports.mergeParamsSchema=n,exports.multiplexParamsSchema=r,exports.zipParamsSchema=i;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MergeParams, c as conditionalParamsSchema, i as multiplexParamsSchema, n as zipParamsSchema, o as mergeParamsSchema, r as MultiplexParams, s as ConditionalParams, t as ZipParams } from "../zip-node-
|
|
1
|
+
import { a as MergeParams, c as conditionalParamsSchema, i as multiplexParamsSchema, n as zipParamsSchema, o as mergeParamsSchema, r as MultiplexParams, s as ConditionalParams, t as ZipParams } from "../zip-node-BBj1lGeU.mjs";
|
|
2
2
|
export { ConditionalParams, MergeParams, MultiplexParams, ZipParams, conditionalParamsSchema, mergeParamsSchema, multiplexParamsSchema, zipParamsSchema };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{z as e}from"zod";const t=e.object({field:e.enum([`mimeType`,`size`,`width`,`height`,`extension`]),operator:e.enum([`equals`,`notEquals`,`greaterThan`,`lessThan`,`contains`,`startsWith`]),value:e.union([e.string(),e.number()])}),n=e.object({strategy:e.enum([`concat`,`batch`]).default(`batch`),separator:e.string().default(`
|
|
2
2
|
`).optional(),inputCount:e.number().min(2).max(10).default(2)}),r=e.object({outputCount:e.number().min(1).max(10),strategy:e.enum([`copy`,`split`]).default(`copy`)}),i=e.object({zipName:e.string().default(`archive.zip`),includeMetadata:e.boolean().default(!1),inputCount:e.number().min(2).max(10).default(2)});export{t as conditionalParamsSchema,n as mergeParamsSchema,r as multiplexParamsSchema,i as zipParamsSchema};
|
|
3
|
-
//# sourceMappingURL=index.
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/types/conditional-node.ts","../../src/types/merge-node.ts","../../src/types/multiplex-node.ts","../../src/types/zip-node.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const conditionalParamsSchema = z.object({\n field: z.enum([\"mimeType\", \"size\", \"width\", \"height\", \"extension\"]),\n operator: z.enum([\n \"equals\",\n \"notEquals\",\n \"greaterThan\",\n \"lessThan\",\n \"contains\",\n \"startsWith\",\n ]),\n value: z.union([z.string(), z.number()]),\n});\n\nexport type ConditionalParams = z.infer<typeof conditionalParamsSchema>;\n","import { z } from \"zod\";\n\nexport const mergeParamsSchema = z.object({\n strategy: z.enum([\"concat\", \"batch\"]).default(\"batch\"),\n separator: z.string().default(\"\\n\").optional(),\n inputCount: z.number().min(2).max(10).default(2),\n});\n\nexport type MergeParams = z.infer<typeof mergeParamsSchema>;\n","import { z } from \"zod\";\n\nexport const multiplexParamsSchema = z.object({\n outputCount: z.number().min(1).max(10),\n strategy: z.enum([\"copy\", \"split\"]).default(\"copy\"),\n});\n\nexport type MultiplexParams = z.infer<typeof multiplexParamsSchema>;\n","import { z } from \"zod\";\n\nexport const zipParamsSchema = z.object({\n zipName: z.string().default(\"archive.zip\"),\n includeMetadata: z.boolean().default(false),\n inputCount: z.number().min(2).max(10).default(2),\n});\n\nexport type ZipParams = z.infer<typeof zipParamsSchema>;\n"],"mappings":"wBAEA,MAAa,EAA0B,EAAE,OAAO,CAC9C,MAAO,EAAE,KAAK,CAAC,WAAY,OAAQ,QAAS,SAAU,YAAY,CAAC,CACnE,SAAU,EAAE,KAAK,CACf,SACA,YACA,cACA,WACA,WACA,aACD,CAAC,CACF,MAAO,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAE,EAAE,QAAQ,CAAC,CAAC,CACzC,CAAC,CCXW,EAAoB,EAAE,OAAO,CACxC,SAAU,EAAE,KAAK,CAAC,SAAU,QAAQ,CAAC,CAAC,QAAQ,QAAQ,CACtD,UAAW,EAAE,QAAQ,CAAC,QAAQ;EAAK,CAAC,UAAU,CAC9C,WAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CACjD,CAAC,CCJW,EAAwB,EAAE,OAAO,CAC5C,YAAa,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CACtC,SAAU,EAAE,KAAK,CAAC,OAAQ,QAAQ,CAAC,CAAC,QAAQ,OAAO,CACpD,CAAC,CCHW,EAAkB,EAAE,OAAO,CACtC,QAAS,EAAE,QAAQ,CAAC,QAAQ,cAAc,CAC1C,gBAAiB,EAAE,SAAS,CAAC,QAAQ,GAAM,CAC3C,WAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CACjD,CAAC"}
|
|
@@ -51,4 +51,4 @@ declare const zipParamsSchema: z.ZodObject<{
|
|
|
51
51
|
type ZipParams = z.infer<typeof zipParamsSchema>;
|
|
52
52
|
//#endregion
|
|
53
53
|
export { MergeParams as a, conditionalParamsSchema as c, multiplexParamsSchema as i, zipParamsSchema as n, mergeParamsSchema as o, MultiplexParams as r, ConditionalParams as s, ZipParams as t };
|
|
54
|
-
//# sourceMappingURL=zip-node-
|
|
54
|
+
//# sourceMappingURL=zip-node-BBj1lGeU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-node-BBj1lGeU.d.mts","names":[],"sources":["../src/types/conditional-node.ts","../src/types/merge-node.ts","../src/types/multiplex-node.ts","../src/types/zip-node.ts"],"sourcesContent":[],"mappings":";;;cAEa,yBAAuB,CAAA,CAAA;;IAAvB,QAAA,EAAA,UAAA;;;;;;;IAAuB,MAAA,EAAA,QAAA;IAAA,SAAA,EAAA,WAAA;IAaxB,WAAA,EAAA,aAAiB;;;;ECbhB,CAAA,CAAA;;;KDaD,iBAAA,GAAoB,CAAA,CAAE,aAAa;;;cCblC,mBAAiB,CAAA,CAAA;;IDAjB,MAAA,EAAA,QAAA;;;;;;KCMD,WAAA,GAAc,CAAA,CAAE,aAAa;;;cCN5B,uBAAqB,CAAA,CAAA;;EFArB,QAAA,cAAA,UAWX,CAAA;;;;;KENU,eAAA,GAAkB,CAAA,CAAE,aAAa;;;cCLhC,iBAAe,CAAA,CAAA;;EHAf,eAAA,cAWX,aAAA,CAAA;;;KGLU,SAAA,GAAY,CAAA,CAAE,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/flow-utility-nodes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"description": "Utility nodes for Uploadista Flow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"effect": "3.
|
|
21
|
+
"effect": "3.19.0",
|
|
22
22
|
"zod": "4.1.12",
|
|
23
|
-
"@uploadista/core": "0.0.
|
|
23
|
+
"@uploadista/core": "0.0.9"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "24.
|
|
27
|
-
"tsdown": "0.
|
|
28
|
-
"@uploadista/typescript-config": "0.0.
|
|
26
|
+
"@types/node": "24.10.0",
|
|
27
|
+
"tsdown": "0.16.0",
|
|
28
|
+
"@uploadista/typescript-config": "0.0.9"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsdown",
|
package/dist/chunk-DjWAcSYV.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
package/dist/nodes/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { a as MergeParams, r as MultiplexParams, s as ConditionalParams, t as ZipParams } from "../zip-node-8Vme3wB7.js";
|
|
2
|
-
import * as _uploadista_core_flow0 from "@uploadista/core/flow";
|
|
3
|
-
import { ZipPlugin } from "@uploadista/core/flow";
|
|
4
|
-
import { UploadFile } from "@uploadista/core/types";
|
|
5
|
-
import { Effect } from "effect";
|
|
6
|
-
import * as _uploadista_core_errors0 from "@uploadista/core/errors";
|
|
7
|
-
import { UploadistaError } from "@uploadista/core/errors";
|
|
8
|
-
import { UploadServer } from "@uploadista/core/upload";
|
|
9
|
-
|
|
10
|
-
//#region src/nodes/conditional-node.d.ts
|
|
11
|
-
declare function createConditionalNode(id: string, {
|
|
12
|
-
field,
|
|
13
|
-
operator,
|
|
14
|
-
value
|
|
15
|
-
}: ConditionalParams): Effect.Effect<_uploadista_core_flow0.FlowNode<UploadFile, UploadFile, _uploadista_core_errors0.UploadistaError>, never, never>;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/nodes/merge-node.d.ts
|
|
18
|
-
declare function createMergeNode(id: string, {
|
|
19
|
-
strategy,
|
|
20
|
-
separator: _separator
|
|
21
|
-
}: MergeParams): Effect.Effect<_uploadista_core_flow0.FlowNode<Record<string, UploadFile>, UploadFile, UploadistaError>, never, UploadServer>;
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/nodes/multiplex-node.d.ts
|
|
24
|
-
declare function createMultiplexNode(id: string, {
|
|
25
|
-
outputCount: _outputCount,
|
|
26
|
-
strategy
|
|
27
|
-
}: MultiplexParams): Effect.Effect<_uploadista_core_flow0.FlowNode<UploadFile, UploadFile, UploadistaError>, never, UploadServer>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/nodes/zip-node.d.ts
|
|
30
|
-
declare function createZipNode(id: string, {
|
|
31
|
-
zipName,
|
|
32
|
-
includeMetadata
|
|
33
|
-
}: ZipParams): Effect.Effect<_uploadista_core_flow0.FlowNode<Record<string, UploadFile>, UploadFile, UploadistaError>, never, UploadServer | ZipPlugin>;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { createConditionalNode, createMergeNode, createMultiplexNode, createZipNode };
|
|
36
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;iBASgB,qBAAA;;;;GAEc,oBAAiB,MAAA,CAAA,OAAA,sBAAA,CAAA,SAAA,YAAA,YAAA,wBAAA,CAAA,eAAA;;;iBCI/B,eAAA;;aAES;GAAc,cAAW,MAAA,CAAA,OAAA,sBAAA,CAAA,SAAA,eAAA,aAAA,YAAA,yBAAA;;;iBCLlC,mBAAA;eAEC;;GAA0B,kBAAe,MAAA,CAAA,OAAA,sBAAA,CAAA,SAAA,YAAA,YAAA,yBAAA;;;iBCE1C,aAAA;;;GAEgB,YAAS,MAAA,CAAA,OAAA,sBAAA,CAAA,SAAA,eAAA,aAAA,YAAA,yBAAA,eAAA"}
|
package/dist/nodes/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["inputSchema","outputSchema","inputBytesArray: Uint8Array[]"],"sources":["../../src/nodes/conditional-node.ts","../../src/nodes/merge-node.ts","../../src/nodes/multiplex-node.ts","../../src/nodes/zip-node.ts"],"sourcesContent":["import {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { Effect } from \"effect\";\nimport type { ConditionalParams } from \"@/types/conditional-node\";\n\nexport function createConditionalNode(\n id: string,\n { field, operator, value }: ConditionalParams,\n) {\n return createFlowNode<UploadFile, UploadFile>({\n id,\n name: \"Conditional Router\",\n description: `Routes flow based on ${field} ${operator} ${value}`,\n type: NodeType.conditional,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n condition: { field, operator, value },\n run: ({ data }) => {\n // The actual routing logic is handled by the flow engine\n // This node just passes through the data\n return Effect.succeed(completeNodeExecution(data));\n },\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { z } from \"zod\";\nimport type { MergeParams } from \"@/types/merge-node\";\n\nconst inputSchema = z.record(z.string(), uploadFileSchema);\nconst outputSchema = uploadFileSchema;\n\nexport function createMergeNode(\n id: string,\n { strategy, separator: _separator }: MergeParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode<Record<string, UploadFile>, UploadFile>({\n id,\n name: \"Merge Files\",\n description: `Merges multiple files using ${strategy} strategy`,\n type: NodeType.merge,\n inputSchema,\n outputSchema,\n multiInput: true,\n run: ({ data: inputs, storageId, clientId }) => {\n return Effect.gen(function* () {\n if (!inputs || Object.keys(inputs).length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No inputs provided to merge node\",\n }),\n );\n }\n\n const inputFiles = Object.values(inputs);\n\n if (inputFiles.length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No files to merge\",\n }),\n );\n }\n\n switch (strategy) {\n case \"concat\": {\n // Read bytes from all input files\n const inputBytesArray: Uint8Array[] = [];\n let totalSize = 0;\n\n for (const file of inputFiles) {\n const bytes = yield* uploadServer.read(file.id, clientId);\n inputBytesArray.push(bytes);\n totalSize += bytes.byteLength;\n }\n\n // Concatenate all files into one\n const mergedBytes = new Uint8Array(totalSize);\n let offset = 0;\n for (const bytes of inputBytesArray) {\n mergedBytes.set(bytes, offset);\n offset += bytes.byteLength;\n }\n\n // Create a stream from the merged bytes\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(mergedBytes);\n controller.close();\n },\n });\n\n // Upload the merged file\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: mergedBytes.byteLength,\n type: \"application/octet-stream\",\n fileName: `merged_${inputFiles.length}_files.bin`,\n lastModified: 0,\n metadata: JSON.stringify({\n mimeType: \"application/octet-stream\",\n originalName: `merged_${inputFiles.length}_files`,\n extension: \"bin\",\n }),\n },\n clientId,\n stream,\n );\n\n return completeNodeExecution(result);\n }\n default: {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: `Unknown merge strategy: ${strategy}`,\n }),\n );\n }\n }\n });\n },\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n resolveUploadMetadata,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport type { MultiplexParams } from \"@/types/multiplex-node\";\n\nexport function createMultiplexNode(\n id: string,\n { outputCount: _outputCount, strategy }: MultiplexParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n\n return yield* createFlowNode<UploadFile, UploadFile>({\n id,\n name: \"Multiplex\",\n description: `Multiplexes input using ${strategy} strategy`,\n type: NodeType.multiplex,\n inputSchema: uploadFileSchema,\n outputSchema: uploadFileSchema,\n multiOutput: true,\n run: ({ data: file, storageId, clientId }) => {\n return Effect.gen(function* () {\n const { type, fileName, metadata, metadataJson } =\n resolveUploadMetadata(file.metadata);\n const normalizedFile = metadata ? { ...file, metadata } : file;\n\n if (strategy === \"copy\") {\n // For copy strategy, read and re-upload the file\n const inputBytes = yield* uploadServer.read(\n normalizedFile.id,\n clientId,\n );\n\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(inputBytes);\n controller.close();\n },\n });\n\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: inputBytes.byteLength,\n type,\n fileName,\n lastModified: 0,\n metadata: metadataJson,\n },\n clientId,\n stream,\n );\n\n const resolvedResult = resolveUploadMetadata(result.metadata);\n\n return completeNodeExecution(\n resolvedResult.metadata\n ? { ...result, metadata: resolvedResult.metadata }\n : result,\n );\n } else if (strategy === \"split\") {\n // Split strategy is not supported in the new pattern\n // as it would require returning multiple UploadFiles\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"Split strategy is not supported with UploadFile pattern\",\n }),\n );\n }\n\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: `Unknown multiplex strategy: ${strategy}`,\n }),\n );\n });\n },\n });\n });\n}\n","import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n completeNodeExecution,\n createFlowNode,\n NodeType,\n ZipPlugin,\n} from \"@uploadista/core/flow\";\nimport { type UploadFile, uploadFileSchema } from \"@uploadista/core/types\";\nimport { UploadServer } from \"@uploadista/core/upload\";\nimport { Effect } from \"effect\";\nimport { z } from \"zod\";\nimport type { ZipParams } from \"@/types/zip-node\";\n\nconst inputSchema = z.record(z.string(), uploadFileSchema);\nconst outputSchema = uploadFileSchema;\n\nexport function createZipNode(\n id: string,\n { zipName, includeMetadata }: ZipParams,\n) {\n return Effect.gen(function* () {\n const uploadServer = yield* UploadServer;\n const zipPlugin = yield* ZipPlugin;\n return yield* createFlowNode<Record<string, UploadFile>, UploadFile>({\n id,\n name: \"Zip Files\",\n description: \"Combines multiple files into a zip archive\",\n type: NodeType.process,\n inputSchema,\n outputSchema,\n multiInput: true,\n run: ({ data: inputs, storageId, clientId }) => {\n return Effect.gen(function* () {\n if (!inputs || Object.keys(inputs).length === 0) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"VALIDATION_ERROR\", {\n body: \"No inputs provided to zip node\",\n }),\n );\n }\n\n\n const zipInputs = yield* Effect.forEach(\n Object.values(inputs),\n (input) =>\n Effect.gen(function* () {\n const data = yield* uploadServer.read(input.id, clientId);\n return {\n id: input.id,\n data,\n metadata: input.metadata,\n };\n }),\n { concurrency: \"unbounded\" }\n );\n\n const zipBytes = yield* zipPlugin.zip(zipInputs, { zipName, includeMetadata });\n\n // Create a stream from the zip bytes\n const stream = new ReadableStream({\n start(controller) {\n controller.enqueue(zipBytes);\n controller.close();\n },\n });\n\n // Upload the zip file\n const result = yield* uploadServer.upload(\n {\n storageId,\n size: zipBytes.byteLength,\n type: \"application/zip\",\n fileName: zipName,\n lastModified: 0,\n metadata: JSON.stringify({\n mimeType: \"application/zip\",\n type: \"application/zip\",\n originalName: zipName,\n fileName: zipName,\n extension: \"zip\",\n }),\n },\n clientId,\n stream,\n );\n\n return completeNodeExecution(result);\n });\n },\n });\n });\n}\n"],"mappings":"6WASA,SAAgB,EACd,EACA,CAAE,QAAO,WAAU,SACnB,CACA,OAAO,EAAuC,CAC5C,KAC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ACpC,CAEL,CAAC,EACF"}
|
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/conditional-node.ts","../../src/types/merge-node.ts","../../src/types/multiplex-node.ts","../../src/types/zip-node.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const conditionalParamsSchema = z.object({\n field: z.enum([\"mimeType\", \"size\", \"width\", \"height\", \"extension\"]),\n operator: z.enum([\n \"equals\",\n \"notEquals\",\n \"greaterThan\",\n \"lessThan\",\n \"contains\",\n \"startsWith\",\n ]),\n value: z.union([z.string(), z.number()]),\n});\n\nexport type ConditionalParams = z.infer<typeof conditionalParamsSchema>;\n","import { z } from \"zod\";\n\nexport const mergeParamsSchema = z.object({\n strategy: z.enum([\"concat\", \"batch\"]).default(\"batch\"),\n separator: z.string().default(\"\\n\").optional(),\n inputCount: z.number().min(2).max(10).default(2),\n});\n\nexport type MergeParams = z.infer<typeof mergeParamsSchema>;\n","import { z } from \"zod\";\n\nexport const multiplexParamsSchema = z.object({\n outputCount: z.number().min(1).max(10),\n strategy: z.enum([\"copy\", \"split\"]).default(\"copy\"),\n});\n\nexport type MultiplexParams = z.infer<typeof multiplexParamsSchema>;\n","import { z } from \"zod\";\n\nexport const zipParamsSchema = z.object({\n zipName: z.string().default(\"archive.zip\"),\n includeMetadata: z.boolean().default(false),\n inputCount: z.number().min(2).max(10).default(2),\n});\n\nexport type ZipParams = z.infer<typeof zipParamsSchema>;\n"],"mappings":"wBAEA,MAAa,EAA0B,EAAE,OAAO,CAC9C,MAAO,EAAE,KAAK,CAAC,WAAY,OAAQ,QAAS,SAAU,YAAY,CAAC,CACnE,SAAU,EAAE,KAAK,CACf,SACA,YACA,cACA,WACA,WACA,aACD,CAAC,CACF,MAAO,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAE,EAAE,QAAQ,CAAC,CAAC,CACzC,CAAC,CCXW,EAAoB,EAAE,OAAO,CACxC,SAAU,EAAE,KAAK,CAAC,SAAU,QAAQ,CAAC,CAAC,QAAQ,QAAQ,CACtD,UAAW,EAAE,QAAQ,CAAC,QAAQ;EAAK,CAAC,UAAU,CAC9C,WAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CACjD,CAAC,CCJW,EAAwB,EAAE,OAAO,CAC5C,YAAa,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CACtC,SAAU,EAAE,KAAK,CAAC,OAAQ,QAAQ,CAAC,CAAC,QAAQ,OAAO,CACpD,CAAC,CCHW,EAAkB,EAAE,OAAO,CACtC,QAAS,EAAE,QAAQ,CAAC,QAAQ,cAAc,CAC1C,gBAAiB,EAAE,SAAS,CAAC,QAAQ,GAAM,CAC3C,WAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zip-node-8Vme3wB7.d.ts","names":[],"sources":["../src/types/conditional-node.ts","../src/types/merge-node.ts","../src/types/multiplex-node.ts","../src/types/zip-node.ts"],"sourcesContent":[],"mappings":";;;cAEa,yBAAuB,CAAA,CAAA;;IAAvB,QAAA,EAAA,UAAA;;;;;;;IAAuB,MAAA,EAAA,QAAA;IAAA,SAAA,EAAA,WAAA;IAaxB,WAAA,EAAA,aAAiB;;;;ECbhB,CAAA,CAAA;;;KDaD,iBAAA,GAAoB,CAAA,CAAE,aAAa;;;cCblC,mBAAiB,CAAA,CAAA;;IDAjB,MAAA,EAAA,QAAA;;;;;;KCMD,WAAA,GAAc,CAAA,CAAE,aAAa;;;cCN5B,uBAAqB,CAAA,CAAA;;EFArB,QAAA,cAAA,UAWX,CAAA;;;;;KENU,eAAA,GAAkB,CAAA,CAAE,aAAa;;;cCLhC,iBAAe,CAAA,CAAA;;EHAf,eAAA,cAWX,aAAA,CAAA;;;KGLU,SAAA,GAAY,CAAA,CAAE,aAAa"}
|