Files
klz-cables.com/.pnpm-store/v10/files/4c/6c60d3bea4c96608953b16a829018072270c7e4368f26aeb0ffdaa9f15bb7c691e843fc7efbe55807308578c0e17214ff129624597a7cc38b6d17f88c4645f
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
4.5 KiB
Plaintext

{"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/fileFactory.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from '../../config/types.js'\nimport type { FileShape } from './index.js'\n\nimport {\n checkAndMakeDir,\n debugLog,\n isFunc,\n moveFile,\n promiseCallback,\n saveBufferToFile,\n} from './utilities.js'\n\ntype MoveFile = (\n filePath: string,\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => (resolve: () => void, reject: () => void) => void\n\n/**\n * Returns Local function that moves the file to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromTemp: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving temporary file ${options.tempFilePath} to ${filePath}`)\n moveFile(options.tempFilePath, filePath, promiseCallback(resolve, reject))\n}\n\n/**\n * Returns Local function that moves the file from buffer to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromBuffer: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving uploaded buffer to ${filePath}`)\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n saveBufferToFile(options.buffer, filePath, promiseCallback(resolve, reject))\n}\n\ntype FileFactoryOptions = {\n buffer: Buffer\n encoding: string\n hash: Buffer | string\n mimetype: string\n name: string\n size: number\n tempFilePath: string\n truncated: boolean\n}\ntype FileFactory = (\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => FileShape\nexport const fileFactory: FileFactory = (options, fileUploadOptions) => {\n // see: https://github.com/richardgirges/express-fileupload/issues/14\n // firefox uploads empty file in case of cache miss when f5ing page.\n // resulting in unexpected behavior. if there is no file data, the file is invalid.\n // if (!fileUploadOptions.useTempFiles && !options.buffer.length) return;\n\n // Create and return file object.\n return {\n name: options.name,\n data: options.buffer,\n encoding: options.encoding,\n md5: options.hash,\n mimetype: options.mimetype,\n mv: (filePath: string, callback) => {\n // Define a proper move function.\n const moveFunc = fileUploadOptions.useTempFiles\n ? moveFromTemp(filePath, options, fileUploadOptions)\n : moveFromBuffer(filePath, options, fileUploadOptions)\n // Create a folder for a file.\n checkAndMakeDir(fileUploadOptions, filePath)\n // If callback is passed in, use the callback API, otherwise return a promise.\n const defaultReject = () => undefined\n return isFunc(callback) ? moveFunc(callback, defaultReject) : new Promise(moveFunc)\n },\n size: options.size,\n tempFilePath: options.tempFilePath,\n truncated: options.truncated,\n }\n}\n"],"names":["checkAndMakeDir","debugLog","isFunc","moveFile","promiseCallback","saveBufferToFile","moveFromTemp","filePath","options","fileUploadOptions","resolve","reject","tempFilePath","moveFromBuffer","buffer","fileFactory","name","data","encoding","md5","hash","mimetype","mv","callback","moveFunc","useTempFiles","defaultReject","undefined","Promise","size","truncated"],"mappings":"AAGA,SACEA,eAAe,EACfC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfC,gBAAgB,QACX,iBAAgB;AAQvB;;;CAGC,GACD,MAAMC,eAAyB,CAACC,UAAUC,SAASC,oBAAsB,CAACC,SAASC;QACjFV,SAASQ,mBAAmB,CAAC,sBAAsB,EAAED,QAAQI,YAAY,CAAC,IAAI,EAAEL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