node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
/// <reference types="node" />
/// <reference types="node" />
import { ReadStream } from 'fs';
interface File {
name: string;
alternativeText?: string;
caption?: string;
width?: number;
height?: number;
formats?: Record<string, unknown>;
hash: string;
ext?: string;
mime: string;
size: number;
sizeInBytes: number;
url: string;
previewUrl?: string;
path?: string;
provider?: string;
provider_metadata?: Record<string, unknown>;
stream?: ReadStream;
buffer?: Buffer;
}
interface InitOptions {
sizeLimit?: number;
}
interface CheckFileSizeOptions {
sizeLimit?: number;
}
declare const _default: {
init({ sizeLimit: providerOptionsSizeLimit }?: InitOptions): {
checkFileSize(file: File, options: CheckFileSizeOptions): void;
uploadStream(file: File): Promise<void>;
upload(file: File): Promise<void>;
delete(file: File): Promise<string | void>;
};
};
export default _default;
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,OAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAQpC,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,oBAAoB;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;mDAG+C,WAAW;4BAiBjC,IAAI,WAAW,oBAAoB;2BAkBpC,IAAI,GAAG,QAAQ,IAAI,CAAC;qBAuB1B,IAAI,GAAG,QAAQ,IAAI,CAAC;qBAoBpB,IAAI,GAAG,QAAQ,MAAM,GAAG,IAAI,CAAC;;;AA/EhD,wBAoGE"}
+104
View File
@@ -0,0 +1,104 @@
'use strict';
var stream = require('stream');
var fs = require('fs');
var path = require('path');
var fse = require('fs-extra');
var utils = require('@strapi/utils');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var utils__namespace = /*#__PURE__*/_interopNamespaceDefault(utils);
const { PayloadTooLargeError } = utils__namespace.errors;
const { kbytesToBytes, bytesToHumanReadable } = utils__namespace.file;
const UPLOADS_FOLDER_NAME = 'uploads';
var index = {
init ({ sizeLimit: providerOptionsSizeLimit } = {}) {
// TODO V5: remove providerOptions sizeLimit
if (providerOptionsSizeLimit) {
process.emitWarning('[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config');
}
// Ensure uploads folder exists
const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
if (!fse.pathExistsSync(uploadPath)) {
throw new Error(`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`);
}
return {
checkFileSize (file, options) {
const { sizeLimit } = options ?? {};
// TODO V5: remove providerOptions sizeLimit
if (providerOptionsSizeLimit) {
if (kbytesToBytes(file.size) > providerOptionsSizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(providerOptionsSizeLimit)}.`);
} else if (sizeLimit) {
if (kbytesToBytes(file.size) > sizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`);
}
},
uploadStream (file) {
if (!file.stream) {
return Promise.reject(new Error('Missing file stream'));
}
const { stream: stream$1 } = file;
return new Promise((resolve, reject)=>{
stream.pipeline(stream$1, fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)), (err)=>{
if (err) {
return reject(err);
}
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
resolve();
});
});
},
upload (file) {
if (!file.buffer) {
return Promise.reject(new Error('Missing file buffer'));
}
const { buffer } = file;
return new Promise((resolve, reject)=>{
// write file in public/assets folder
fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err)=>{
if (err) {
return reject(err);
}
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
resolve();
});
});
},
delete (file) {
return new Promise((resolve, reject)=>{
const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);
if (!fs.existsSync(filePath)) {
resolve("File doesn't exist");
return;
}
// remove file from public/assets folder
fs.unlink(filePath, (err)=>{
if (err) {
return reject(err);
}
resolve();
});
});
}
};
}
};
module.exports = index;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":["PayloadTooLargeError","utils","errors","kbytesToBytes","bytesToHumanReadable","file","UPLOADS_FOLDER_NAME","init","sizeLimit","providerOptionsSizeLimit","process","emitWarning","uploadPath","path","resolve","strapi","dirs","static","public","fse","pathExistsSync","Error","checkFileSize","options","size","name","uploadStream","stream","Promise","reject","pipeline","fs","createWriteStream","join","hash","ext","err","url","upload","buffer","writeFile","delete","filePath","existsSync","unlink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,EAAEA,oBAAoB,EAAE,GAAGC,iBAAMC,MAAM;AAC7C,MAAM,EAAEC,aAAa,EAAEC,oBAAoB,EAAE,GAAGH,iBAAMI,IAAI;AAE1D,MAAMC,mBAAsB,GAAA,SAAA;AAU5B,YAALine truncated
+83
View File
@@ -0,0 +1,83 @@
import { pipeline } from 'stream';
import fs from 'fs';
import path from 'path';
import fse from 'fs-extra';
import * as utils from '@strapi/utils';
const { PayloadTooLargeError } = utils.errors;
const { kbytesToBytes, bytesToHumanReadable } = utils.file;
const UPLOADS_FOLDER_NAME = 'uploads';
var index = {
init ({ sizeLimit: providerOptionsSizeLimit } = {}) {
// TODO V5: remove providerOptions sizeLimit
if (providerOptionsSizeLimit) {
process.emitWarning('[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config');
}
// Ensure uploads folder exists
const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
if (!fse.pathExistsSync(uploadPath)) {
throw new Error(`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`);
}
return {
checkFileSize (file, options) {
const { sizeLimit } = options ?? {};
// TODO V5: remove providerOptions sizeLimit
if (providerOptionsSizeLimit) {
if (kbytesToBytes(file.size) > providerOptionsSizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(providerOptionsSizeLimit)}.`);
} else if (sizeLimit) {
if (kbytesToBytes(file.size) > sizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`);
}
},
uploadStream (file) {
if (!file.stream) {
return Promise.reject(new Error('Missing file stream'));
}
const { stream } = file;
return new Promise((resolve, reject)=>{
pipeline(stream, fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)), (err)=>{
if (err) {
return reject(err);
}
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
resolve();
});
});
},
upload (file) {
if (!file.buffer) {
return Promise.reject(new Error('Missing file buffer'));
}
const { buffer } = file;
return new Promise((resolve, reject)=>{
// write file in public/assets folder
fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err)=>{
if (err) {
return reject(err);
}
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
resolve();
});
});
},
delete (file) {
return new Promise((resolve, reject)=>{
const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);
if (!fs.existsSync(filePath)) {
resolve("File doesn't exist");
return;
}
// remove file from public/assets folder
fs.unlink(filePath, (err)=>{
if (err) {
return reject(err);
}
resolve();
});
});
}
};
}
};
export { index as default };
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":["PayloadTooLargeError","utils","errors","kbytesToBytes","bytesToHumanReadable","file","UPLOADS_FOLDER_NAME","init","sizeLimit","providerOptionsSizeLimit","process","emitWarning","uploadPath","path","resolve","strapi","dirs","static","public","fse","pathExistsSync","Error","checkFileSize","options","size","name","uploadStream","stream","Promise","reject","pipeline","fs","createWriteStream","join","hash","ext","err","url","upload","buffer","writeFile","delete","filePath","existsSync","unlink"],"mappings":";;;;;;AA8BA,MAAM,EAAEA,oBAAoB,EAAE,GAAGC,MAAMC,MAAM;AAC7C,MAAM,EAAEC,aAAa,EAAEC,oBAAoB,EAAE,GAAGH,MAAMI,IAAI;AAE1D,MAAMC,mBAAsB,GAAA,SAAA;AAU5B,YAAe;AACbC,IAAAA,IAAAA,CALine truncated