@uploadista/flow-utility-zipjs 0.0.20-beta.8 → 0.0.20
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 +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- 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/zip-plugin.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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));let c=require(`@uploadista/core/errors`),l=require(`@uploadista/core/flow`),u=require(`@uploadista/observability`),d=require(`effect`),f=require(`jszip`);f=s(f);const p=()=>d.Layer.succeed(l.ZipPlugin,l.ZipPlugin.of({zip:(e,t)=>d.Effect.gen(function*(){let{includeMetadata:n}=t,r=new f.default;for(let t of e){let e=t.metadata?.fileName||t.metadata?.originalName||t.id;r.file(e.toString(),t.data),n&&t.metadata&&r.file(`${e}.meta.json`,JSON.stringify(t.metadata,null,2))}let i=yield*d.Effect.tryPromise({try:()=>r.generateAsync({type:`nodebuffer`,compression:`DEFLATE`,compressionOptions:{level:6}}),catch:e=>c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{body:`Failed to generate zip file`,cause:e})});return new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}).pipe((0,u.withOperationSpan)(`zip`,`create`,{"zip.file_count":e.length,"zip.include_metadata":t.includeMetadata}))}));exports.
|
|
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));let c=require(`@uploadista/core/errors`),l=require(`@uploadista/core/flow`),u=require(`@uploadista/observability`),d=require(`effect`),f=require(`jszip`);f=s(f);const p=()=>d.Layer.succeed(l.ZipPlugin,l.ZipPlugin.of({zip:(e,t)=>d.Effect.gen(function*(){let{includeMetadata:n}=t,r=new f.default;for(let t of e){let e=t.metadata?.fileName||t.metadata?.originalName||t.id;r.file(e.toString(),t.data),n&&t.metadata&&r.file(`${e}.meta.json`,JSON.stringify(t.metadata,null,2))}let i=yield*d.Effect.tryPromise({try:()=>r.generateAsync({type:`nodebuffer`,compression:`DEFLATE`,compressionOptions:{level:6}}),catch:e=>c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{body:`Failed to generate zip file`,cause:e})});return new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}).pipe((0,u.withOperationSpan)(`zip`,`create`,{"zip.file_count":e.length,"zip.include_metadata":t.includeMetadata}))}));exports.zipPlugin=p;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { ZipPlugin } from "@uploadista/core/flow";
|
|
|
2
2
|
import { Layer } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/zip-plugin.d.ts
|
|
5
|
-
declare const
|
|
5
|
+
declare const zipPlugin: () => Layer.Layer<ZipPlugin, never, never>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export {
|
|
7
|
+
export { zipPlugin };
|
|
8
8
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,iBAAS,KAAA,CAAA,MAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ZipPlugin } from "@uploadista/core/flow";
|
|
|
2
2
|
import { Layer } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/zip-plugin.d.ts
|
|
5
|
-
declare const
|
|
5
|
+
declare const zipPlugin: () => Layer.Layer<ZipPlugin, never, never>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export {
|
|
7
|
+
export { zipPlugin };
|
|
8
8
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,iBAAS,KAAA,CAAA,MAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{UploadistaError as e}from"@uploadista/core/errors";import{ZipPlugin as t}from"@uploadista/core/flow";import{withOperationSpan as n}from"@uploadista/observability";import{Effect as r,Layer as i}from"effect";import a from"jszip";const o=()=>i.succeed(t,t.of({zip:(t,i)=>r.gen(function*(){let{includeMetadata:n}=i,o=new a;for(let e of t){let t=e.metadata?.fileName||e.metadata?.originalName||e.id;o.file(t.toString(),e.data),n&&e.metadata&&o.file(`${t}.meta.json`,JSON.stringify(e.metadata,null,2))}let s=yield*r.tryPromise({try:()=>o.generateAsync({type:`nodebuffer`,compression:`DEFLATE`,compressionOptions:{level:6}}),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{body:`Failed to generate zip file`,cause:t})});return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}).pipe(n(`zip`,`create`,{"zip.file_count":t.length,"zip.include_metadata":i.includeMetadata}))}));export{o as
|
|
1
|
+
import{UploadistaError as e}from"@uploadista/core/errors";import{ZipPlugin as t}from"@uploadista/core/flow";import{withOperationSpan as n}from"@uploadista/observability";import{Effect as r,Layer as i}from"effect";import a from"jszip";const o=()=>i.succeed(t,t.of({zip:(t,i)=>r.gen(function*(){let{includeMetadata:n}=i,o=new a;for(let e of t){let t=e.metadata?.fileName||e.metadata?.originalName||e.id;o.file(t.toString(),e.data),n&&e.metadata&&o.file(`${t}.meta.json`,JSON.stringify(e.metadata,null,2))}let s=yield*r.tryPromise({try:()=>o.generateAsync({type:`nodebuffer`,compression:`DEFLATE`,compressionOptions:{level:6}}),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{body:`Failed to generate zip file`,cause:t})});return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}).pipe(n(`zip`,`create`,{"zip.file_count":t.length,"zip.include_metadata":i.includeMetadata}))}));export{o as zipPlugin};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { ZipPlugin } from \"@uploadista/core/flow\";\nimport { withOperationSpan } from \"@uploadista/observability\";\nimport { Effect, Layer } from \"effect\";\nimport JSZip from \"jszip\";\n\nexport const
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/zip-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { ZipPlugin } from \"@uploadista/core/flow\";\nimport { withOperationSpan } from \"@uploadista/observability\";\nimport { Effect, Layer } from \"effect\";\nimport JSZip from \"jszip\";\n\nexport const zipPlugin = () => {\n return Layer.succeed(\n ZipPlugin,\n ZipPlugin.of({\n zip: (inputs, options) => {\n return Effect.gen(function* () {\n const { includeMetadata } = options;\n const zip = new JSZip();\n\n // Process all input files\n for (const input of inputs) {\n // Use metadata for filename if available, otherwise use id\n const fileName =\n input.metadata?.fileName ||\n input.metadata?.originalName ||\n input.id;\n\n zip.file(fileName.toString(), input.data);\n\n if (includeMetadata && input.metadata) {\n zip.file(\n `${fileName}.meta.json`,\n JSON.stringify(input.metadata, null, 2),\n );\n }\n }\n\n // Generate the zip file\n const zipBuffer = yield* Effect.tryPromise({\n try: () =>\n zip.generateAsync({\n type: \"nodebuffer\",\n compression: \"DEFLATE\",\n compressionOptions: {\n level: 6, // Good balance between speed and compression\n },\n }),\n catch: (error) =>\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n body: \"Failed to generate zip file\",\n cause: error,\n }),\n });\n\n // Convert to Uint8Array\n const zipBytes = new Uint8Array(\n zipBuffer.buffer,\n zipBuffer.byteOffset,\n zipBuffer.byteLength,\n );\n\n return zipBytes;\n }).pipe(\n withOperationSpan(\"zip\", \"create\", {\n \"zip.file_count\": inputs.length,\n \"zip.include_metadata\": options.includeMetadata,\n }),\n );\n },\n }),\n );\n};\n"],"mappings":"0OAMA,MAAa,MACJ,EAAM,QACX,EACA,EAAU,GAAG,CACX,KAAM,EAAQ,IACL,EAAO,IAAI,WAAa,CAC7B,GAAM,CAAE,mBAAoB,EACtB,EAAM,IAAI,EAGhB,IAAK,IAAM,KAAS,EAAQ,CAE1B,IAAM,EACJ,EAAM,UAAU,UAChB,EAAM,UAAU,cAChB,EAAM,GAER,EAAI,KAAK,EAAS,UAAU,CAAE,EAAM,KAAK,CAErC,GAAmB,EAAM,UAC3B,EAAI,KACF,GAAG,EAAS,YACZ,KAAK,UAAU,EAAM,SAAU,KAAM,EAAE,CACxC,CAKL,IAAM,EAAY,MAAO,EAAO,WAAW,CACzC,QACE,EAAI,cAAc,CAChB,KAAM,aACN,YAAa,UACb,mBAAoB,CAClB,MAAO,EACR,CACF,CAAC,CACJ,MAAQ,GACN,EAAgB,SAAS,gBAAiB,CACxC,KAAM,8BACN,MAAO,EACR,CAAC,CACL,CAAC,CASF,OANiB,IAAI,WACnB,EAAU,OACV,EAAU,WACV,EAAU,WACX,EAGD,CAAC,KACD,EAAkB,MAAO,SAAU,CACjC,iBAAkB,EAAO,OACzB,uBAAwB,EAAQ,gBACjC,CAAC,CACH,CAEJ,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/flow-utility-zipjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.20
|
|
4
|
+
"version": "0.0.20",
|
|
5
5
|
"description": "ZipJS utility for Uploadista Flow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"jszip": "3.10.1",
|
|
18
|
-
"@uploadista/core": "0.0.20
|
|
19
|
-
"@uploadista/observability": "0.0.20
|
|
18
|
+
"@uploadista/core": "0.0.20",
|
|
19
|
+
"@uploadista/observability": "0.0.20"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"effect": "^3.0.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"tsdown": "0.18.0",
|
|
30
30
|
"vitest": "4.0.15",
|
|
31
31
|
"zod": "4.2.0",
|
|
32
|
-
"@uploadista/typescript-config": "0.0.20
|
|
32
|
+
"@uploadista/typescript-config": "0.0.20"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc --noEmit && tsdown",
|
package/src/zip-plugin.ts
CHANGED