1 | {"version":3,"sources":["../../factories/file_factory.ts","../../factories/middleware_factory.ts"],"sourcesContent":["/*\n * @adonisjs/bodyparser\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { MultipartFile } from '../src/multipart/file.js'\nimport { FileValidationOptions } from '../src/types.js'\n\ntype FileFactoryParameters = {\n fieldName: string\n clientName: string\n headers: any\n size: number\n extname: string\n type: string\n subtype: string\n}\n\n/**\n * File factory exposes the API to create fake multipart file instances\n * for testing\n */\nexport class MultipartFileFactory {\n #parameters: Partial<FileFactoryParameters> = {}\n\n /**\n * Merge factory params\n */\n merge(params: Partial<FileFactoryParameters>): this {\n this.#parameters = Object.assign(this.#parameters, params)\n return this\n }\n\n /**\n * Create an instance of multipart file\n */\n create(validationOptions?: Partial<FileValidationOptions>) {\n const file = new MultipartFile(\n {\n fieldName: this.#parameters.fieldName || 'file',\n clientName:\n this.#parameters.clientName || this.#parameters.extname\n ? `file.${this.#parameters.extname}`\n : 'file',\n headers: this.#parameters.headers || {},\n },\n validationOptions || {}\n )\n\n file.size = this.#parameters.size || 0\n file.extname = this.#parameters.extname\n file.type = this.#parameters.type\n file.subtype = this.#parameters.subtype\n file.state = 'consumed'\n\n file.validate()\n return file\n }\n}\n","/*\n * @adonisjs/bodyparser\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport lodash from '@poppinss/utils/lodash'\n\nimport { defineConfig } from '../src/define_config.js'\nimport { BodyParserMiddleware } from '../src/bodyparser_middleware.js'\nimport type { BodyParserConfig, BodyParserOptionalConfig } from '../src/types.js'\n\n/**\n * Factory to create bodyparser middleware instance\n */\nexport class BodyParserMiddlewareFactory {\n #config: BodyParserConfig = defineConfig({})\n\n #getConfig(): BodyParserConfig {\n return this.#config\n }\n\n merge(config: BodyParserOptionalConfig) {\n this.#config = lodash.merge(this.#config, config)\n return this\n }\n\n create() {\n return new BodyParserMiddleware(this.#getConfig())\n }\n}\n"],"mappings":";;;;;;;;;;;AA0BO,IAAM,uBAAN,MAA2B;AAAA,EAChC,cAA8C,CAAC;AAAA;AAAA;AAAA;AAAA,EAK/C,MAAM,QAA8C;AAClD,SAAK,cAAc,OAAO,OAAO,KAAK,aAAa,MAAM;AACzD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,mBAAoD;AACzD,UAAM,OAAO,IAAI;AAAA,MACf;AAAA,QACE,WAAW,KAAK,YAAY,aAAa;AAAA,QACzC,YACE,KAAK,YAAY,cAAc,KAAK,YAAY,UAC5C,QAAQ,KAAK,YAAY,OAAO,KAChC;AAAA,QACN,SAAS,KAAK,YAAY,WAAW,CAAC;AAAA,MACxC;AAAA,MACA,qBAAqB,CAAC;AAAA,IACxB;AAEA,SAAK,OAAO,KAAK,YAAY,QAAQ;AACrC,SAAK,UAAU,KAAK,YAAY;AAChC,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,UAAU,KAAK,YAAY;AAChC,SAAK,QAAQ;AAEb,SAAK,SAAS;AACd,WAAO;AAAA,EACT;AACF;;;ACrDA,OAAO,YAAY;AASZ,IAAM,8BAAN,MAAkC;AAAA,EACvC,UAA4B,aAAa,CAAC,CAAC;AAAA,EAE3C,aAA+B;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAkC;AACtC,SAAK,UAAU,OAAO,MAAM,KAAK,SAAS,MAAM;AAChD,WAAO;AAAA,EACT;AAAA,EAEA,SAAS;AACP,WAAO,IAAI,qBAAqB,KAAK,WAAW,CAAC;AAAA,EACnD;AACF;","names":[]} |