node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

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

View File

@@ -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"}

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long