@nexim/upload-types
Version:
TypeScript types and interfaces for Nexim Media Upload Service, including image preset configurations and file handling types
8 lines (7 loc) • 4.25 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/main.ts"],
"sourcesContent": ["import { packageTracer } from '@alwatr/package-tracer';\nimport type { ErrorResponse } from '@alwatr/nanotron';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\n/**\n * Configuration presets for image upload and processing.\n * Each preset defines both client-side and server-side image processing parameters.\n */\nexport const uploadImagePresetRecord = {\n 'product-image': {\n client: {\n defaultAppendName: '.jpeg',\n quality: 75,\n height: -1 as number,\n width: 640 as number,\n },\n format: [\n {\n type: 'webp',\n appendName: '.webp.org',\n formatOptions: {\n quality: 75,\n },\n },\n {\n type: 'jpeg',\n appendName: '.jpeg',\n formatOptions: {\n quality: 75,\n mozjpeg: true,\n },\n },\n ],\n },\n 'financial-document': {\n client: {\n defaultAppendName: '.jpeg',\n quality: 75,\n height: -1 as number,\n width: 640 as number,\n },\n format: [\n {\n type: 'webp',\n appendName: '.webp.org',\n formatOptions: {\n quality: 75,\n },\n },\n {\n type: 'jpeg',\n appendName: '.jpeg',\n formatOptions: {\n quality: 75,\n mozjpeg: true,\n },\n },\n ],\n },\n 'blog-post-cover': {\n client: {\n defaultAppendName: '.jpeg',\n quality: 75,\n height: -1 as number,\n width: 1024 as number,\n },\n format: [\n {\n type: 'webp',\n appendName: '.webp.org',\n formatOptions: {\n quality: 75,\n },\n },\n {\n type: 'jpeg',\n appendName: '.jpeg',\n formatOptions: {\n quality: 75,\n mozjpeg: true,\n },\n },\n ],\n },\n} as const;\n\n/**\n * Details about an uploaded file stored in the system.\n * Includes common fields and type-specific fields using a discriminated union.\n */\nexport type FileDetail = {\n /** ID of the user who uploaded the file */\n userId: string;\n\n /** Description of the file for maintenance */\n description: string;\n} & (\n | {\n /** Indicates this is a regular file */\n type: 'file';\n }\n | {\n /** Indicates this is an image with multiple format variants */\n type: 'image';\n /** List of file name suffixes for each variant */\n variants: string[];\n }\n);\n\n/**\n * The error response type from the service API.\n * Inherits from the base ErrorResponse type.\n *\n * @internal\n */\nexport type ErrorServiceResponse = ErrorResponse;\n\n/**\n * The success response type from the service API.\n * Contains a data payload of the specified generic type.\n *\n * @internal\n */\nexport type SuccessServiceResponse<TData extends Json> = {\n ok: true;\n data: TData;\n};\n\n/**\n * Combined type representing either a success or error response.\n *\n * @internal\n */\nexport type ServiceResponse<TData extends Json> = SuccessServiceResponse<TData> | ErrorResponse;\n"],
"mappings": ";;;AAAA,SAAS,qBAAqB;AAG9B,aAAc,eAAc,IAAI,uBAAkB,OAAmB;AAM9D,IAAM,0BAA0B;AAAA,EACrC,iBAAiB;AAAA,IACf,QAAQ;AAAA,MACN,mBAAmB;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,SAAS;AAAA,UACT,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,sBAAsB;AAAA,IACpB,QAAQ;AAAA,MACN,mBAAmB;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,SAAS;AAAA,UACT,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,mBAAmB;AAAA,IACjB,QAAQ;AAAA,MACN,mBAAmB;AAAA,MACnB,S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