storemw-core-api 1.0.175 → 1.0.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,13 @@
1
1
  import { FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileImageCompressionOptions, FileVideoCompressionOptions, FileUploadProps, FileCategoryName, FileUploadItem } from "../../services";
2
2
  import { FeatureCallbackProps } from "../../utils";
3
+ import { ImageCompressionProviderType } from "../../services";
3
4
  export type FeatureFileStorageType = FileStorageProviderType;
4
5
  export type FeatureFileStorageConfiguration = {
5
6
  uploadMaxSize: number;
6
7
  allowedFileTypes: string[];
7
8
  imageMaxWidth?: number;
8
9
  imageQuality?: number;
10
+ imageCompressionProvider?: ImageCompressionProviderType;
9
11
  videoCRF?: number;
10
12
  videoPreset?: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow";
11
13
  videoResolution?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"fileStorageType.js","sourceRoot":"","sources":["../../../src/features/file_storage/fileStorageType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n FileStorageProviderType,\n FileLocalProviderOptions,\n FileGoogleCloudProviderOptions,\n FileAwsS3ProviderOptions,\n FileImageCompressionOptions,\n FileVideoCompressionOptions,\n FileUploadProps,\n FileCategoryName,\n FileUploadItem\n} from \"../../services\";\n\nimport { FeatureCallbackProps } from \"@/utils\";\n\nexport type FeatureFileStorageType = FileStorageProviderType\n\nexport type FeatureFileStorageConfiguration = {\n uploadMaxSize: number // e.g., 52428800 (50 MB)\n allowedFileTypes: string[] // e.g., [\"image/jpeg\", \"image/png\", \"application/pdf\", \"video/mp4\"]\n imageMaxWidth?: number // max width for images (e.g., 800)\n imageQuality?: number // compression quality (1-100)\n videoCRF?: number // Compression rate factor, lower = higher quality (e.g., 28)\n videoPreset?: \"ultrafast\" | \"superfast\" | \"veryfast\" | \"faster\" | \"fast\" | \"medium\" | \"slow\" | \"slower\" | \"veryslow\";\n videoResolution?: number; // Max width for videos, preserves aspect ratio (e.g., 1280)\n}\n\nexport type FeatureFileStorageLocalOptions = {\n basePath: string\n baseUrl: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n}\n\nexport type FeatureFileStorageGoogleCloudOptions = {\n bucketName: string\n credentialPath: string\n baseUrl: string\n basePath: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n}\n\nexport type FeatureFileStorageAwsS3Options = {\n bucketName: string\n region: string\n baseUrl: string\n basePath: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n credentials: {\n accessKeyId: string\n secretAccessKey: string\n sessionToken?: string\n }\n}\n\n/* 🔑 Discriminated union */\nexport type FeatureFileStorageOptions =\n | {\n storageType: \"local\"\n storageConfiguration: FeatureFileStorageConfiguration\n localStorageOptions: FeatureFileStorageLocalOptions\n }\n | {\n storageType: \"gcloud\"\n storageConfiguration: FeatureFileStorageConfiguration\n gcloudStorageOptions: FeatureFileStorageGoogleCloudOptions\n }\n | {\n storageType: \"aws\"\n storageConfiguration: FeatureFileStorageConfiguration\n awsStorageOptions: FeatureFileStorageAwsS3Options\n }\n\ntype DefaultUpload = {\n fieldRef: FileUploadProps[\"field_ref\"],\n fieldModule: FileUploadProps[\"field_module\"],\n tagName: FileUploadProps[\"tagName\"],\n label: FileUploadProps[\"label\"],\n refId: FileUploadProps[\"refId\"],\n refId2: FileUploadProps[\"refId2\"],\n refLabel: FileUploadProps[\"refLabel\"],\n refLabel2: FileUploadProps[\"refLabel2\"],\n remark: FileUploadProps[\"remark\"],\n description: FileUploadProps[\"description\"],\n foldernameDate: FileUploadProps[\"foldernameDate\"],\n file: FileUploadItem,\n storageProviderName: FileStorageProviderType,\n storageProviderOptions: FileLocalProviderOptions | FileGoogleCloudProviderOptions | FileAwsS3ProviderOptions,\n fileCategoryName: FileCategoryName,\n batchCode: string,\n mimeType: string,\n bufferFilebuffer: Buffer,\n bufferFileThumbnail?: Buffer,\n outputSizeBytes: number,\n fileCompressFormat: any,\n imageCompressionOptions?: FileImageCompressionOptions,\n videoCompressionOptions?: FileVideoCompressionOptions\n}\n\nexport type FeatureFileStorageStartUploadProps = FeatureCallbackProps<DefaultUpload & {\n\n}>\n\nexport type FeatureFileStorageSuccessUploadProps = FeatureCallbackProps<DefaultUpload & {\n fileId: number,\n fileThumbnailUrl: string,\n fileAssetUrl: string,\n fileDurationSeconds: number,\n}>\n\nexport type FeatureFileStorageProps = {\n onSetup: () => Promise<FeatureFileStorageOptions>,\n onStartUpload: (payload: FeatureFileStorageStartUploadProps) => Promise<any>\n onSuccessUpload: (payload: FeatureFileStorageSuccessUploadProps) => Promise<any>\n}"]}
1
+ {"version":3,"file":"fileStorageType.js","sourceRoot":"","sources":["../../../src/features/file_storage/fileStorageType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n FileStorageProviderType,\n FileLocalProviderOptions,\n FileGoogleCloudProviderOptions,\n FileAwsS3ProviderOptions,\n FileImageCompressionOptions,\n FileVideoCompressionOptions,\n FileUploadProps,\n FileCategoryName,\n FileUploadItem\n} from \"../../services\";\n\nimport { FeatureCallbackProps } from \"@/utils\";\n\nimport { ImageCompressionProviderType } from \"@/services\";\n\nexport type FeatureFileStorageType = FileStorageProviderType\n\nexport type FeatureFileStorageConfiguration = {\n uploadMaxSize: number // e.g., 52428800 (50 MB)\n allowedFileTypes: string[] // e.g., [\"image/jpeg\", \"image/png\", \"application/pdf\", \"video/mp4\"]\n imageMaxWidth?: number // max width for images (e.g., 800)\n imageQuality?: number // compression quality (1-100)\n imageCompressionProvider?: ImageCompressionProviderType // default to sharp\n videoCRF?: number // Compression rate factor, lower = higher quality (e.g., 28)\n videoPreset?: \"ultrafast\" | \"superfast\" | \"veryfast\" | \"faster\" | \"fast\" | \"medium\" | \"slow\" | \"slower\" | \"veryslow\";\n videoResolution?: number; // Max width for videos, preserves aspect ratio (e.g., 1280)\n}\n\nexport type FeatureFileStorageLocalOptions = {\n basePath: string\n baseUrl: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n}\n\nexport type FeatureFileStorageGoogleCloudOptions = {\n bucketName: string\n credentialPath: string\n baseUrl: string\n basePath: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n}\n\nexport type FeatureFileStorageAwsS3Options = {\n bucketName: string\n region: string\n baseUrl: string\n basePath: string\n skipFolderNameModuleRef: boolean\n skipFolderNameYearMonth: boolean\n credentials: {\n accessKeyId: string\n secretAccessKey: string\n sessionToken?: string\n }\n}\n\n/* 🔑 Discriminated union */\nexport type FeatureFileStorageOptions =\n | {\n storageType: \"local\"\n storageConfiguration: FeatureFileStorageConfiguration\n localStorageOptions: FeatureFileStorageLocalOptions\n }\n | {\n storageType: \"gcloud\"\n storageConfiguration: FeatureFileStorageConfiguration\n gcloudStorageOptions: FeatureFileStorageGoogleCloudOptions\n }\n | {\n storageType: \"aws\"\n storageConfiguration: FeatureFileStorageConfiguration\n awsStorageOptions: FeatureFileStorageAwsS3Options\n }\n\ntype DefaultUpload = {\n fieldRef: FileUploadProps[\"field_ref\"],\n fieldModule: FileUploadProps[\"field_module\"],\n tagName: FileUploadProps[\"tagName\"],\n label: FileUploadProps[\"label\"],\n refId: FileUploadProps[\"refId\"],\n refId2: FileUploadProps[\"refId2\"],\n refLabel: FileUploadProps[\"refLabel\"],\n refLabel2: FileUploadProps[\"refLabel2\"],\n remark: FileUploadProps[\"remark\"],\n description: FileUploadProps[\"description\"],\n foldernameDate: FileUploadProps[\"foldernameDate\"],\n file: FileUploadItem,\n storageProviderName: FileStorageProviderType,\n storageProviderOptions: FileLocalProviderOptions | FileGoogleCloudProviderOptions | FileAwsS3ProviderOptions,\n fileCategoryName: FileCategoryName,\n batchCode: string,\n mimeType: string,\n bufferFilebuffer: Buffer,\n bufferFileThumbnail?: Buffer,\n outputSizeBytes: number,\n fileCompressFormat: any,\n imageCompressionOptions?: FileImageCompressionOptions,\n videoCompressionOptions?: FileVideoCompressionOptions\n}\n\nexport type FeatureFileStorageStartUploadProps = FeatureCallbackProps<DefaultUpload & {\n\n}>\n\nexport type FeatureFileStorageSuccessUploadProps = FeatureCallbackProps<DefaultUpload & {\n fileId: number,\n fileThumbnailUrl: string,\n fileAssetUrl: string,\n fileDurationSeconds: number,\n}>\n\nexport type FeatureFileStorageProps = {\n onSetup: () => Promise<FeatureFileStorageOptions>,\n onStartUpload: (payload: FeatureFileStorageStartUploadProps) => Promise<any>\n onSuccessUpload: (payload: FeatureFileStorageSuccessUploadProps) => Promise<any>\n}"]}
@@ -1,9 +1,9 @@
1
1
  import { InjectionFieldModuleRef } from "../../services";
2
2
  import { QueryList, QueryGet } from "../../schema/common";
3
3
  import { DefaultServiceProps } from "../../utils";
4
- export { FileImageCompressionOptions } from "./ImageCompression";
5
- import { FeatureFileStorageOptions } from "../../features";
4
+ export type { FileImageCompressionOptions, ImageCompressionProviderType } from "./ImageCompressionProviderRegistry";
6
5
  export { FileVideoCompressionOptions } from "./VideoCompression";
6
+ import { FeatureFileStorageOptions } from "../../features";
7
7
  export { FileStorageProviderType } from "./FileStorageProviderRegistry";
8
8
  export { FileLocalProviderOptions } from "./FileLocalStorageProvider";
9
9
  export { FileGoogleCloudProviderOptions } from "./FileGoogleCloudStorageProvider";
@@ -13,7 +13,9 @@ const FileAwsS3StorageProvider_1 = require("./FileAwsS3StorageProvider");
13
13
  const FileStorageProviderRegistry_1 = require("./FileStorageProviderRegistry");
14
14
  const lib_1 = require("../../lib");
15
15
  const lib_2 = require("../../lib");
16
- const ImageCompression_1 = require("./ImageCompression");
16
+ // import { /*FileImageCompressionOptions,*/ compressImageBuffer } from "./ImageCompression";
17
+ // export { FileImageCompressionOptions } from "./ImageCompression"
18
+ const ImageCompressionProviderRegistry_1 = require("./ImageCompressionProviderRegistry");
17
19
  const VideoCompression_1 = require("./VideoCompression");
18
20
  const features_1 = require("../../features");
19
21
  exports.fileDataTypes = {};
@@ -256,6 +258,9 @@ const FileService = (props) => {
256
258
  quality: Number(storageConfiguration.imageQuality),
257
259
  }
258
260
  : undefined;
261
+ const imageCompressionProviderType = storageConfiguration?.imageCompressionProvider ? storageConfiguration.imageCompressionProvider : "sharp";
262
+ // get image compression provider
263
+ const imageCompressionProvider = await (0, ImageCompressionProviderRegistry_1.getImageCompressionProvider)(imageCompressionProviderType, imageCompressionOptions);
259
264
  // Video Compression
260
265
  const videoCompressionOptions = storageConfiguration?.videoCRF &&
261
266
  storageConfiguration?.videoPreset &&
@@ -285,7 +290,12 @@ const FileService = (props) => {
285
290
  // const ext = file.originalName?.split(".").pop()?.toLowerCase() ?? "";
286
291
  // Image :: Only compress if image and options provided
287
292
  if (fileCategoryName === "image" && imageCompressionOptions) {
288
- const compressed = await (0, ImageCompression_1.compressImageBuffer)(bufferToUpload, mimeType, imageCompressionOptions);
293
+ // const compressed = await compressImageBuffer(
294
+ // bufferToUpload,
295
+ // mimeType,
296
+ // imageCompressionOptions
297
+ // );
298
+ const compressed = await imageCompressionProvider.compress(bufferToUpload, mimeType, imageCompressionOptions);
289
299
  fileCompressFormat = compressed.compressFormat,
290
300
  bufferToUpload = compressed.buffer;
291
301
  outputSizeBytes = compressed.sizeBytes; // update the file size
@@ -1 +1 @@
1
- {"version":3,"file":"FileService.js","sourceRoot":"","sources":["../../../src/services/file/FileService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA0G;AAE1G,gDAAwB;AAExB,qCAGkB;AAElB,yEAAyH;AACzH,qFAAiJ;AACjJ,yEAAyH;AACzH,+EAAgG;AAQhG,+BAAuH;AAEvH,+BAGe;AAEf,yDAAsF;AAEtF,yDAAsF;AACtF,yCAAwE;AAQ3D,QAAA,aAAa,GAAG,EAC5B,CAAA;AAiGD,IAAI,aAAa,GAAG,IAAA,4BAAsB,GAAE,CAAA;AAC5C,IAAI,gBAAgB,GAAG,IAAA,+BAAyB,GAAE,CAAA;AAElD,MAAM,EAAE,YAAY,EAAE,eAAe,EAA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;YACH,UAAU;YACV,UAAU;YACV,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;YACvD,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;SAC1D,CAAC;IACN,CAAC,CAAA;IAED,+BAA+B;IAC/B,2CAA2C;IAC3C,IAAI;IAEJ,OAAO;QACH,WAAW;QACX,cAAc;QACd,cAAc;QACd,OAAO;QACP,SAAS;QACT,WAAW;QACX,gBAAgB;QAChB,mBAAmB;KACtB,CAAA;AAEL,CAAC,CAAA;AAvkBY,QAAA,WAAW,eAukBvB","sourcesContent":["import { _, logError, throwError, generateFileThumbnailBuffer, buildFeatureCallbackProps } from \"@/utils\";\n\nimport path from \"path\";\n\nimport {\n FileModel,\n ModelFileFields,\n} from \"@/models\";\n\nimport { FileLocalProviderOptions, FileLocalStorageProvider, FileLocalUploadFileProps } from \"./FileLocalStorageProvider\"\nimport { FileGoogleCloudProviderOptions, FileGoogleCloudStorageProvider, FileGoogleCloudUploadFileProps } from \"./FileGoogleCloudStorageProvider\"\nimport { FileAwsS3ProviderOptions, FileAwsS3StorageProvider, FileAwsS3UploadFileProps } from \"./FileAwsS3StorageProvider\"\nimport { getFileStorageProvider, FileStorageProviderType } from \"./FileStorageProviderRegistry\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { getFileSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport {\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect\n} from \"@/lib\";\n\nimport { FileImageCompressionOptions, compressImageBuffer } from \"./ImageCompression\";\nexport { FileImageCompressionOptions } from \"./ImageCompression\"\nimport { FileVideoCompressionOptions, compressVideoBuffer } from \"./VideoCompression\";\nimport { FeatureFileStorageOptions, FileStorageHook } from \"@/features\";\nexport { FileVideoCompressionOptions } from \"./VideoCompression\"\n\nexport { FileStorageProviderType } from \"./FileStorageProviderRegistry\";\nexport { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nexport { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nexport { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\nexport const fileDataTypes = {\n}\n\nexport type FileModuleRef = InjectionFieldModuleRef\n\nexport type FileDataType = keyof typeof fileDataTypes;\n\nexport type FileServiceProps = DefaultServiceProps & {\n};\n\nexport type FileCategoryName =\n | \"image\"\n | \"video\"\n | \"audio\"\n | \"document\"\n | \"archive\"\n | \"code\"\n | \"other\";\n\n\nexport type FileGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n // datatypes: FileDataType[]\n};\n\nexport type FileGetUsageSummaryProps = {\n accountId: number,\n};\n\nexport type FileListProps = Omit<QueryList, \"datatypes\"> & {\n // datatypes: FileDataType[]\n}\n\nexport type FileRemoveProps = {\n fileIds: BigInt[],\n // storageProviderOptions: any\n storageSetup?: FeatureFileStorageOptions\n};\n\nexport type File = {\n tagName: string;\n description: string;\n folderPath: string;\n assetUrl: string;\n thumbnailUrl: string;\n assetPath: string;\n fileLabel: string;\n fileName: string;\n contentType: string;\n fileCategoryName: string;\n inputType: string;\n inputFileSizeBytes: number;\n inputFileName: string;\n fileSizeBytes: number;\n fileDurationSeconds: number;\n fileCompressFormat: string;\n storageProviderName: string;\n foldernameDay: number;\n foldernameMonth: number;\n foldernameYear: number;\n batchCode: string;\n referId1: number;\n referId2: number;\n referLabel1: string;\n referLabel2: string;\n remark: string;\n}\n\nexport type FileUploadItem = {\n buffer: Buffer; // Raw file data\n originalName: string; // Client filename\n mimeType: string; // e.g. \"image/png\"\n sizeBytes: number; // File size in bytes\n // providerName?: FileStorageProviderType; // optional: override global provider\n};\n\n\nexport type FileCreateProps = {\n data: File & {\n fieldRef: FileModuleRef[\"field_ref\"],\n fieldModule: FileModuleRef[\"field_module\"]\n }\n}\n\nexport type FileUploadProps = FileModuleRef & {\n description?: string,\n tagName?: string,\n label?: string,\n refId: number\n refId2?: number\n refLabel?: string\n refLabel2?: string\n remark: string\n foldernameDate?: string,\n files: FileUploadItem[]\n storageSetup?: FeatureFileStorageOptions\n}\n\nlet mainSqlSelect = buildFileMainSqlSelect()\nlet defaultSqlSelect = buildFileDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getFileSqlRelationMaps(``)\n\nconst getCreatePayload = (data: FileCreateProps[\"data\"]) => {\n\n return {\n // [`${ModelFileFields.file_id}`]: fileType,\n [`${ModelFileFields.asset_path}`]: data.assetPath,\n [`${ModelFileFields.asset_url}`]: data.assetUrl,\n [`${ModelFileFields.thumbnail_url}`]: data.thumbnailUrl,\n [`${ModelFileFields.batch_code}`]: data.batchCode,\n [`${ModelFileFields.content_type}`]: data.contentType,\n [`${ModelFileFields.file_category_name}`]: data.fileCategoryName,\n [`${ModelFileFields.field_module}`]: data.fieldModule,\n [`${ModelFileFields.field_ref}`]: data.fieldRef,\n [`${ModelFileFields.file_compress_format}`]: data.fileCompressFormat,\n [`${ModelFileFields.file_label}`]: data.fileLabel,\n [`${ModelFileFields.file_name}`]: data.fileName,\n [`${ModelFileFields.file_size_bytes}`]: data.fileSizeBytes,\n [`${ModelFileFields.file_duration_seconds}`]: data.fileDurationSeconds,\n [`${ModelFileFields.tag_name}`]: data.tagName,\n [`${ModelFileFields.description}`]: data.description,\n [`${ModelFileFields.foldername_day}`]: Number(data.foldernameDay),\n [`${ModelFileFields.foldername_month}`]: Number(data.foldernameMonth),\n [`${ModelFileFields.foldername_year}`]: Number(data.foldernameYear),\n [`${ModelFileFields.input_file_name}`]: data.inputFileName,\n [`${ModelFileFields.input_file_size_bytes}`]: data.inputFileSizeBytes,\n [`${ModelFileFields.input_type}`]: data.inputType,\n [`${ModelFileFields.refer_id_1}`]: data.referId1,\n [`${ModelFileFields.refer_id_2}`]: data.referId2,\n [`${ModelFileFields.refer_label_1}`]: data.referLabel1,\n [`${ModelFileFields.refer_label_2}`]: data.referLabel2,\n [`${ModelFileFields.remark}`]: data.remark,\n [`${ModelFileFields.storage_provider_name}`]: data.storageProviderName,\n }\n\n}\n\n// compatible to browser mimetype\nexport const getBrowserSafeContentType = (incomingMime: string | undefined | null): string => {\n\n if (!incomingMime) {\n return 'application/octet-stream'; // Safe fallback for missing or empty headers\n }\n\n const cleanMime = incomingMime.toLowerCase().trim();\n\n // 1. M4A / AAC Audio Container Variations (iOS / Android recording formats)\n const m4aVariations: string[] = [\n 'audio/x-m4a',\n 'audio/m4a',\n 'audio/mp4',\n 'audio/aac',\n 'audio/x-aac'\n ];\n if (m4aVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Standard web-streaming type for M4A containers\n }\n\n // 2. Legacy Mobile Voice Recording Extensions (3GPP and AMR)\n const legacyAudioMobileVariations: string[] = [\n 'audio/3gpp',\n 'audio/3gpp2',\n 'audio/3gp',\n 'audio/amr',\n 'audio/amr-wb'\n ];\n if (legacyAudioMobileVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Map to mp4 so browser hardware layers can play them\n }\n\n // 3. WebM Audio (Commonly sent by desktop Chrome / Firefox microphone inputs)\n const webmAudioVariations: string[] = [\n 'audio/x-webm',\n 'audio/webm;codecs=opus'\n ];\n if (webmAudioVariations.includes(cleanMime)) {\n return 'audio/webm';\n }\n\n // 4. Video Formats (Fixes iOS QuickTime `.mov` and older `.3gp` video links)\n const videoVariations: string[] = [\n 'video/quicktime', // iOS recorded .mov files\n 'video/3gpp', // Older Android recorded videos\n 'video/3gpp2',\n 'video/x-m4v' // Apple video format\n ];\n if (videoVariations.includes(cleanMime)) {\n return 'video/mp4'; // Forces standard HTML5 inline web video rendering\n }\n\n // 5. Modern Image Formats (Fixes iOS `.heic` and camera `.tiff` uploads)\n const imageVariations: string[] = [\n 'image/heic',\n 'image/heif',\n 'image/tiff',\n 'image/x-tiff'\n ];\n if (imageVariations.includes(cleanMime)) {\n return 'image/jpeg'; // Ensures browsers show image previews instead of downloading files\n }\n\n // 6. Generic App Binary Blocks (Stops S3 from forcing downloads if file headers get lost)\n const genericBinaryVariations: string[] = [\n 'application/octet-stream',\n 'binary/octet-stream'\n ];\n if (genericBinaryVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Safe default assuming core mobile app asset streams\n }\n\n return incomingMime; // Keeps standard valid web-types (image/png, audio/mpeg, application/pdf, etc.) intact\n};\n\nexport const getFileCategoryNameByMimeType = (mimeType: string): FileCategoryName => {\n const lower = mimeType.toLowerCase();\n\n if (lower.startsWith(\"image/\")) return \"image\";\n if (lower.startsWith(\"video/\")) return \"video\";\n if (lower.startsWith(\"audio/\")) return \"audio\";\n\n // Edge-case audio MIME types\n if ([\"application/ogg\"].includes(lower)) return \"audio\";\n\n if (\n lower.startsWith(\"text/\") ||\n [\n \"application/pdf\",\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"application/vnd.ms-powerpoint\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \"application/rtf\",\n ].includes(lower)\n ) {\n return \"document\";\n }\n\n if (\n [\n \"application/zip\",\n \"application/x-7z-compressed\",\n \"application/x-rar-compressed\",\n \"application/x-tar\",\n \"application/gzip\",\n ].includes(lower)\n ) {\n return \"archive\";\n }\n\n if (\n lower.startsWith(\"application/json\") ||\n lower.startsWith(\"application/javascript\") ||\n lower.startsWith(\"text/html\") ||\n lower.startsWith(\"text/css\") ||\n lower.startsWith(\"text/x-python\") ||\n lower.startsWith(\"text/x-c\") ||\n lower.startsWith(\"text/x-java\")\n ) {\n return \"code\";\n }\n\n return \"other\";\n};\n\nexport const FileService = (props: FileServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const fileModel = FileModel({ ...rest })\n\n const fileGoogleCloudStorageProvider = FileGoogleCloudStorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileAwsS3StorageProvider = FileAwsS3StorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileLocalStorageProvider = FileLocalStorageProvider({})\n\n const thumbnailOptions = {\n suffix: \"-thumb\",\n ext: \"jpg\",\n mimeType: \"image/jpeg\",\n }\n\n const initBatchCode = () => {\n return `${Date.now()}_${_.random(0, 999)}`;\n }\n\n const getStorageSetup = async (overrideStorageSetup?: FeatureFileStorageOptions) => {\n\n const hookSetup = overrideStorageSetup ?\n overrideStorageSetup\n :\n await FileStorageHook.onSetup()\n\n if (hookSetup.storageType === \"local\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_LOCAL_BASE_PATH}`,\n basePath: `${hookSetup.localStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_LOCAL_BASE_URL}`,\n publicBaseUrl: `${hookSetup.localStorageOptions.baseUrl}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.localStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.localStorageOptions.skipFolderNameYearMonth)\n }\n }\n }\n\n if (hookSetup.storageType === \"gcloud\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_GCLOUD_BASE_PATH}`,\n basePath: `${hookSetup.gcloudStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_GCLOUD_BASE_URL}`,\n publicBaseUrl: `${hookSetup.gcloudStorageOptions.baseUrl}`,\n // bucketName: `${config.FILE_STORAGE_GCLOUD_BUCKET_NAME}`,\n bucketName: `${hookSetup.gcloudStorageOptions.bucketName}`,\n // credentials: `${path.resolve(process.cwd(), `${config.FILE_STORAGE_GCLOUD_CREDENTIAL_PATH}`)}`,\n credentials: `${path.resolve(process.cwd(), `${hookSetup.gcloudStorageOptions.credentialPath}`)}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n if (hookSetup.storageType === \"aws\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n basePath: `${hookSetup.awsStorageOptions.basePath}`,\n publicBaseUrl: `${hookSetup.awsStorageOptions.baseUrl}`,\n bucketName: `${hookSetup.awsStorageOptions.bucketName}`,\n region: hookSetup.awsStorageOptions?.region ?? \"\",\n credentials: {\n accessKeyId: hookSetup.awsStorageOptions.credentials.accessKeyId,\n secretAccessKey: hookSetup.awsStorageOptions.credentials.secretAccessKey,\n },\n skipFoldernameByModuleRef: Boolean(hookSetup.awsStorageOptions.skipFolderNameModuleRef),\n skipFoldernameByDate: Boolean(hookSetup.awsStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n throw new Error(\"Unsupported storage type\")\n }\n\n const uploadFiles = async ({\n field_ref = \"item\",\n field_module = \"item\",\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n files = [],\n storageSetup\n }: FileUploadProps) => {\n\n const {\n storageProviderName,\n storageProviderOptions,\n storageConfiguration\n } = await getStorageSetup(storageSetup)\n\n // get the correct provider\n const provider = await getFileStorageProvider(storageProviderName, storageProviderOptions);\n\n // Image Compression\n const imageCompressionOptions: FileImageCompressionOptions | undefined\n = storageConfiguration?.imageMaxWidth && storageConfiguration?.imageMaxWidth\n ? {\n maxWidth: Number(storageConfiguration.imageMaxWidth),\n quality: Number(storageConfiguration.imageQuality),\n }\n : undefined;\n\n // Video Compression\n const videoCompressionOptions: FileVideoCompressionOptions | undefined =\n storageConfiguration?.videoCRF &&\n storageConfiguration?.videoPreset &&\n storageConfiguration?.videoResolution\n ? {\n crf: Number(storageConfiguration.videoCRF),\n preset: storageConfiguration.videoPreset as FileVideoCompressionOptions[\"preset\"],\n resolution: Number(storageConfiguration.videoResolution),\n }\n : undefined;\n\n const allResponses = []\n\n const batchCode = initBatchCode();\n\n const fileLabel = label ?? \"\"\n const referId1 = refId ?? 0\n const referId2 = refId2 ?? 0\n const referLabel1 = refLabel ?? \"\"\n const referLabel2 = refLabel2 ?? \"\"\n const fileRemark = remark ?? \"\"\n\n for (const file of files) {\n\n let bufferToUpload = file.buffer;\n let mimeType = file.mimeType ?? \"\"\n let sizeBytes = file?.sizeBytes\n let fileOriginalName = file.originalName;\n\n let outputSizeBytes = sizeBytes // output file size\n let fileCompressFormat = `` // output image compress\n\n const fileCategoryName = getFileCategoryNameByMimeType(mimeType)\n\n // const ext = file.originalName?.split(\".\").pop()?.toLowerCase() ?? \"\";\n\n // Image :: Only compress if image and options provided\n if (fileCategoryName === \"image\" && imageCompressionOptions) {\n const compressed = await compressImageBuffer(\n bufferToUpload,\n mimeType,\n imageCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // Vide :: Only compress if video and options provided\n if (fileCategoryName === \"video\" && videoCompressionOptions) {\n const compressed = await compressVideoBuffer(\n bufferToUpload,\n mimeType,\n videoCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // generate thumbnail buffer\n const bufferThumbnail = await generateFileThumbnailBuffer(bufferToUpload, mimeType)\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onStartUpload) {\n\n await FileStorageHook.onStartUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail?.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n // upload using the provider - buffer\n const uploadResult = await provider.uploadFile({\n field_ref,\n field_module,\n buffer: bufferToUpload,\n bufferThumbnail: bufferThumbnail.buffer,\n thumbnailOptions,\n ...(foldernameDate ? { foldernameDate } : {}),\n mimeType,\n fileName: fileOriginalName\n } as FileModuleRef & (\n FileLocalUploadFileProps |\n FileGoogleCloudUploadFileProps |\n FileAwsS3UploadFileProps\n ));\n\n const fieldRef = field_ref\n const fieldModule = field_module\n\n const fileName = uploadResult?.filename ?? \"\"\n const contentType = mimeType ?? \"\"\n const folderPath = uploadResult.assetPath ?? \"\"\n const assetUrl = uploadResult.assetUrl ?? \"\"\n const thumbnailUrl = uploadResult?.thumbnailUrl ?? \"\"\n const assetPath = uploadResult.assetPath ?? \"\"\n\n const fileDurationSeconds = bufferThumbnail?.durationSeconds ?? 0\n\n const inputType = `buffer`\n const inputFileSizeBytes = sizeBytes ?? 0\n const inputFileName = fileOriginalName ?? \"\"\n\n const fileSizeBytes = outputSizeBytes ?? 0\n // const fileCompressFormat = ``\n\n const foldernameDay = uploadResult?.folderName?.day ?? \"\"\n const foldernameMonth = uploadResult?.folderName?.month ?? \"\"\n const foldernameYear = uploadResult?.folderName?.year ?? \"\"\n\n const payload: FileCreateProps = {\n data: {\n fieldRef,\n fieldModule,\n tagName,\n description,\n remark: fileRemark,\n folderPath,\n assetUrl,\n thumbnailUrl,\n assetPath,\n fileLabel,\n fileName,\n fileCategoryName,\n contentType,\n inputType,\n inputFileSizeBytes,\n inputFileName,\n fileSizeBytes,\n fileDurationSeconds,\n fileCompressFormat,\n storageProviderName,\n foldernameDay,\n foldernameMonth,\n foldernameYear,\n batchCode,\n referId1,\n referId2,\n referLabel1,\n referLabel2\n } as FileCreateProps[\"data\"],\n };\n\n let responseFile = await createFile(payload);\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onSuccessUpload) {\n await FileStorageHook.onSuccessUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fileId: Number(responseFile?.file_id),\n fileThumbnailUrl: thumbnailUrl,\n fileAssetUrl: assetUrl,\n fileDurationSeconds,\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n allResponses.push(responseFile)\n }\n\n return allResponses\n\n }\n\n // private\n const createFile = async ({ data }: FileCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create file payload: ${JSON.stringify(_data)}`);\n }\n\n const response = await fileModel.create({ data: _data })\n\n const newFileId = response?.file_id ?? \"\"\n\n return newFileId ? await getFile({ id: Number(newFileId) }) : null\n\n }\n\n const getFile = async ({ id }: FileGetProps) => {\n\n let { data } = await listFiles({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelFileFields.file_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelFileFields.file_id}`,\n sortorder: \"ASC\"\n })\n\n return data[0] ?? null;\n\n };\n\n const listFiles = async ({ limit, offset, filters = [], sortfield, sortorder }: FileListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n // sqlRelationAgg = []\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `mainfile.isdelete = false`,\n `mainfile.istrash = false`,\n // `LOWER(mainfile.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: fileModel,\n tableName: \"files\",\n mainAlias: \"mainfile\",\n countKey: `${ModelFileFields.file_id}`,\n accountId: rest.accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeFiles = async ({ fileIds, storageSetup }: FileRemoveProps) => {\n\n const {\n // storageProviderName,\n storageProviderOptions\n } = await getStorageSetup(storageSetup)\n\n if (!fileIds.length) throwError('fileIds is required');\n\n const filesToDelete = await fileModel.list({\n where: {\n file_id: { in: fileIds }\n }\n });\n\n // console.log('filesToDelete', filesToDelete)\n\n let providerResponse: any[] = []\n\n // 2️⃣ Delete the physical files\n for (const file of filesToDelete) {\n\n // check the provider to choose delete method\n const storageProviderName = file.storage_provider_name as FileStorageProviderType\n const assetUrl = file.asset_url\n const thumbnailUrl = file.thumbnail_url ?? \"\"\n const assetPath = file.asset_path\n\n if (storageProviderName === \"local\" && assetPath) {\n\n try {\n providerResponse.push(\n await fileLocalStorageProvider.removeFile(assetPath, thumbnailOptions)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Local: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"gcloud\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileGoogleCloudStorageProvider.removeFile(assetUrl, thumbnailUrl, storageProviderOptions.credentials as any)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from GCloud: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"aws\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileAwsS3StorageProvider.removeFile(assetUrl, thumbnailUrl)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Aws S3: ${assetUrl}`\n )\n }\n\n }\n\n }\n\n // remove files\n const response = await fileModel.remove({ where: { [`${ModelFileFields.file_id}`]: { in: fileIds } } });\n\n return {\n files: response,\n providerResponse\n }\n };\n\n const getFileUsageSummary = async ({ accountId = 0 }: FileGetUsageSummaryProps) => {\n\n const summaryCount = await fileModel.aggregate({\n field: `file_id`,\n operation: `count`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const summarySize = await fileModel.aggregate({\n field: `file_size_bytes`,\n operation: `sum`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const totalFiles = summaryCount ?? 0;\n const totalBytes = summarySize ?? 0;\n // const totalFiles = summary._count.id;\n\n // Optional: convert bytes to MB or GB\n const totalMB = totalBytes / (1024 * 1024);\n const totalGB = totalBytes / (1024 * 1024 * 1024);\n\n return {\n totalFiles,\n totalBytes,\n totalMB: parseFloat(totalMB.toFixed(2)), // now decimal\n totalGB: parseFloat(totalGB.toFixed(2)), // now decimal\n };\n }\n\n // const getDataTypes = () => {\n // return Object.values(fileDataTypes);\n // }\n\n return {\n uploadFiles,\n // createFile,\n // updateFile,\n getFile,\n listFiles,\n removeFiles,\n // getDataTypes,\n getFileUsageSummary\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"FileService.js","sourceRoot":"","sources":["../../../src/services/file/FileService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA0G;AAE1G,gDAAwB;AAExB,qCAGkB;AAElB,yEAAyH;AACzH,qFAAiJ;AACjJ,yEAAyH;AACzH,+EAAgG;AAQhG,+BAAuH;AAEvH,+BAGe;AAEf,6FAA6F;AAC7F,mEAAmE;AACnE,yFAA2I;AAG3I,yDAAsF;AAGtF,yCAAwE;AAO3D,QAAA,aAAa,GAAG,EAC5B,CAAA;AAiGD,IAAI,aAAa,GAAG,IAAA,4BAAsB,GAAE,CAAA;AAC5C,IAAI,gBAAgB,GAAG,IAAA,+BAAyB,GAAE,CAAA;AAElD,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAA,4BAAsB,EAAC,EAAE,CAAC,CAAA;AAEpE,MAAM,gBAAgB,GAAG,CAAC,IAA6B,EAAE,EAAE;IAEvD,OAAO;QACH,4CAA4C;QAC5C,CAAC,GAAG,wBAAe,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS;QACjD,CAAC,GAAG,wBAAe,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QAC/C,CAAC,GAAG,wBAAe,CAAC,aAAa,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY;QACvD,CAAC,GAAG,wBAAe,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS;QACjD,CAAC,GAAG,wBAAe,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;QACrD,CA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D,CAAC;IACN,CAAC,CAAA;IAED,+BAA+B;IAC/B,2CAA2C;IAC3C,IAAI;IAEJ,OAAO;QACH,WAAW;QACX,cAAc;QACd,cAAc;QACd,OAAO;QACP,SAAS;QACT,WAAW;QACX,gBAAgB;QAChB,mBAAmB;KACtB,CAAA;AAEL,CAAC,CAAA;AAvlBY,QAAA,WAAW,eAulBvB","sourcesContent":["import { _, logError, throwError, generateFileThumbnailBuffer, buildFeatureCallbackProps } from \"@/utils\";\n\nimport path from \"path\";\n\nimport {\n FileModel,\n ModelFileFields,\n} from \"@/models\";\n\nimport { FileLocalProviderOptions, FileLocalStorageProvider, FileLocalUploadFileProps } from \"./FileLocalStorageProvider\"\nimport { FileGoogleCloudProviderOptions, FileGoogleCloudStorageProvider, FileGoogleCloudUploadFileProps } from \"./FileGoogleCloudStorageProvider\"\nimport { FileAwsS3ProviderOptions, FileAwsS3StorageProvider, FileAwsS3UploadFileProps } from \"./FileAwsS3StorageProvider\"\nimport { getFileStorageProvider, FileStorageProviderType } from \"./FileStorageProviderRegistry\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { getFileSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport {\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect\n} from \"@/lib\";\n\n// import { /*FileImageCompressionOptions,*/ compressImageBuffer } from \"./ImageCompression\";\n// export { FileImageCompressionOptions } from \"./ImageCompression\"\nimport { FileImageCompressionOptions, getImageCompressionProvider, ImageCompressionProviderType } from \"./ImageCompressionProviderRegistry\"\nexport type { FileImageCompressionOptions, ImageCompressionProviderType } from \"./ImageCompressionProviderRegistry\"\n\nimport { FileVideoCompressionOptions, compressVideoBuffer } from \"./VideoCompression\";\nexport { FileVideoCompressionOptions } from \"./VideoCompression\"\n\nimport { FeatureFileStorageOptions, FileStorageHook } from \"@/features\";\n\nexport { FileStorageProviderType } from \"./FileStorageProviderRegistry\";\nexport { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nexport { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nexport { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\nexport const fileDataTypes = {\n}\n\nexport type FileModuleRef = InjectionFieldModuleRef\n\nexport type FileDataType = keyof typeof fileDataTypes;\n\nexport type FileServiceProps = DefaultServiceProps & {\n};\n\nexport type FileCategoryName =\n | \"image\"\n | \"video\"\n | \"audio\"\n | \"document\"\n | \"archive\"\n | \"code\"\n | \"other\";\n\n\nexport type FileGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n // datatypes: FileDataType[]\n};\n\nexport type FileGetUsageSummaryProps = {\n accountId: number,\n};\n\nexport type FileListProps = Omit<QueryList, \"datatypes\"> & {\n // datatypes: FileDataType[]\n}\n\nexport type FileRemoveProps = {\n fileIds: BigInt[],\n // storageProviderOptions: any\n storageSetup?: FeatureFileStorageOptions\n};\n\nexport type File = {\n tagName: string;\n description: string;\n folderPath: string;\n assetUrl: string;\n thumbnailUrl: string;\n assetPath: string;\n fileLabel: string;\n fileName: string;\n contentType: string;\n fileCategoryName: string;\n inputType: string;\n inputFileSizeBytes: number;\n inputFileName: string;\n fileSizeBytes: number;\n fileDurationSeconds: number;\n fileCompressFormat: string;\n storageProviderName: string;\n foldernameDay: number;\n foldernameMonth: number;\n foldernameYear: number;\n batchCode: string;\n referId1: number;\n referId2: number;\n referLabel1: string;\n referLabel2: string;\n remark: string;\n}\n\nexport type FileUploadItem = {\n buffer: Buffer; // Raw file data\n originalName: string; // Client filename\n mimeType: string; // e.g. \"image/png\"\n sizeBytes: number; // File size in bytes\n // providerName?: FileStorageProviderType; // optional: override global provider\n};\n\n\nexport type FileCreateProps = {\n data: File & {\n fieldRef: FileModuleRef[\"field_ref\"],\n fieldModule: FileModuleRef[\"field_module\"]\n }\n}\n\nexport type FileUploadProps = FileModuleRef & {\n description?: string,\n tagName?: string,\n label?: string,\n refId: number\n refId2?: number\n refLabel?: string\n refLabel2?: string\n remark: string\n foldernameDate?: string,\n files: FileUploadItem[]\n storageSetup?: FeatureFileStorageOptions\n}\n\nlet mainSqlSelect = buildFileMainSqlSelect()\nlet defaultSqlSelect = buildFileDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getFileSqlRelationMaps(``)\n\nconst getCreatePayload = (data: FileCreateProps[\"data\"]) => {\n\n return {\n // [`${ModelFileFields.file_id}`]: fileType,\n [`${ModelFileFields.asset_path}`]: data.assetPath,\n [`${ModelFileFields.asset_url}`]: data.assetUrl,\n [`${ModelFileFields.thumbnail_url}`]: data.thumbnailUrl,\n [`${ModelFileFields.batch_code}`]: data.batchCode,\n [`${ModelFileFields.content_type}`]: data.contentType,\n [`${ModelFileFields.file_category_name}`]: data.fileCategoryName,\n [`${ModelFileFields.field_module}`]: data.fieldModule,\n [`${ModelFileFields.field_ref}`]: data.fieldRef,\n [`${ModelFileFields.file_compress_format}`]: data.fileCompressFormat,\n [`${ModelFileFields.file_label}`]: data.fileLabel,\n [`${ModelFileFields.file_name}`]: data.fileName,\n [`${ModelFileFields.file_size_bytes}`]: data.fileSizeBytes,\n [`${ModelFileFields.file_duration_seconds}`]: data.fileDurationSeconds,\n [`${ModelFileFields.tag_name}`]: data.tagName,\n [`${ModelFileFields.description}`]: data.description,\n [`${ModelFileFields.foldername_day}`]: Number(data.foldernameDay),\n [`${ModelFileFields.foldername_month}`]: Number(data.foldernameMonth),\n [`${ModelFileFields.foldername_year}`]: Number(data.foldernameYear),\n [`${ModelFileFields.input_file_name}`]: data.inputFileName,\n [`${ModelFileFields.input_file_size_bytes}`]: data.inputFileSizeBytes,\n [`${ModelFileFields.input_type}`]: data.inputType,\n [`${ModelFileFields.refer_id_1}`]: data.referId1,\n [`${ModelFileFields.refer_id_2}`]: data.referId2,\n [`${ModelFileFields.refer_label_1}`]: data.referLabel1,\n [`${ModelFileFields.refer_label_2}`]: data.referLabel2,\n [`${ModelFileFields.remark}`]: data.remark,\n [`${ModelFileFields.storage_provider_name}`]: data.storageProviderName,\n }\n\n}\n\n// compatible to browser mimetype\nexport const getBrowserSafeContentType = (incomingMime: string | undefined | null): string => {\n\n if (!incomingMime) {\n return 'application/octet-stream'; // Safe fallback for missing or empty headers\n }\n\n const cleanMime = incomingMime.toLowerCase().trim();\n\n // 1. M4A / AAC Audio Container Variations (iOS / Android recording formats)\n const m4aVariations: string[] = [\n 'audio/x-m4a',\n 'audio/m4a',\n 'audio/mp4',\n 'audio/aac',\n 'audio/x-aac'\n ];\n if (m4aVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Standard web-streaming type for M4A containers\n }\n\n // 2. Legacy Mobile Voice Recording Extensions (3GPP and AMR)\n const legacyAudioMobileVariations: string[] = [\n 'audio/3gpp',\n 'audio/3gpp2',\n 'audio/3gp',\n 'audio/amr',\n 'audio/amr-wb'\n ];\n if (legacyAudioMobileVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Map to mp4 so browser hardware layers can play them\n }\n\n // 3. WebM Audio (Commonly sent by desktop Chrome / Firefox microphone inputs)\n const webmAudioVariations: string[] = [\n 'audio/x-webm',\n 'audio/webm;codecs=opus'\n ];\n if (webmAudioVariations.includes(cleanMime)) {\n return 'audio/webm';\n }\n\n // 4. Video Formats (Fixes iOS QuickTime `.mov` and older `.3gp` video links)\n const videoVariations: string[] = [\n 'video/quicktime', // iOS recorded .mov files\n 'video/3gpp', // Older Android recorded videos\n 'video/3gpp2',\n 'video/x-m4v' // Apple video format\n ];\n if (videoVariations.includes(cleanMime)) {\n return 'video/mp4'; // Forces standard HTML5 inline web video rendering\n }\n\n // 5. Modern Image Formats (Fixes iOS `.heic` and camera `.tiff` uploads)\n const imageVariations: string[] = [\n 'image/heic',\n 'image/heif',\n 'image/tiff',\n 'image/x-tiff'\n ];\n if (imageVariations.includes(cleanMime)) {\n return 'image/jpeg'; // Ensures browsers show image previews instead of downloading files\n }\n\n // 6. Generic App Binary Blocks (Stops S3 from forcing downloads if file headers get lost)\n const genericBinaryVariations: string[] = [\n 'application/octet-stream',\n 'binary/octet-stream'\n ];\n if (genericBinaryVariations.includes(cleanMime)) {\n return 'audio/mp4'; // Safe default assuming core mobile app asset streams\n }\n\n return incomingMime; // Keeps standard valid web-types (image/png, audio/mpeg, application/pdf, etc.) intact\n};\n\nexport const getFileCategoryNameByMimeType = (mimeType: string): FileCategoryName => {\n const lower = mimeType.toLowerCase();\n\n if (lower.startsWith(\"image/\")) return \"image\";\n if (lower.startsWith(\"video/\")) return \"video\";\n if (lower.startsWith(\"audio/\")) return \"audio\";\n\n // Edge-case audio MIME types\n if ([\"application/ogg\"].includes(lower)) return \"audio\";\n\n if (\n lower.startsWith(\"text/\") ||\n [\n \"application/pdf\",\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"application/vnd.ms-powerpoint\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \"application/rtf\",\n ].includes(lower)\n ) {\n return \"document\";\n }\n\n if (\n [\n \"application/zip\",\n \"application/x-7z-compressed\",\n \"application/x-rar-compressed\",\n \"application/x-tar\",\n \"application/gzip\",\n ].includes(lower)\n ) {\n return \"archive\";\n }\n\n if (\n lower.startsWith(\"application/json\") ||\n lower.startsWith(\"application/javascript\") ||\n lower.startsWith(\"text/html\") ||\n lower.startsWith(\"text/css\") ||\n lower.startsWith(\"text/x-python\") ||\n lower.startsWith(\"text/x-c\") ||\n lower.startsWith(\"text/x-java\")\n ) {\n return \"code\";\n }\n\n return \"other\";\n};\n\nexport const FileService = (props: FileServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const fileModel = FileModel({ ...rest })\n\n const fileGoogleCloudStorageProvider = FileGoogleCloudStorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileAwsS3StorageProvider = FileAwsS3StorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileLocalStorageProvider = FileLocalStorageProvider({})\n\n const thumbnailOptions = {\n suffix: \"-thumb\",\n ext: \"jpg\",\n mimeType: \"image/jpeg\",\n }\n\n const initBatchCode = () => {\n return `${Date.now()}_${_.random(0, 999)}`;\n }\n\n const getStorageSetup = async (overrideStorageSetup?: FeatureFileStorageOptions) => {\n\n const hookSetup = overrideStorageSetup ?\n overrideStorageSetup\n :\n await FileStorageHook.onSetup()\n\n if (hookSetup.storageType === \"local\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_LOCAL_BASE_PATH}`,\n basePath: `${hookSetup.localStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_LOCAL_BASE_URL}`,\n publicBaseUrl: `${hookSetup.localStorageOptions.baseUrl}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.localStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.localStorageOptions.skipFolderNameYearMonth)\n }\n }\n }\n\n if (hookSetup.storageType === \"gcloud\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_GCLOUD_BASE_PATH}`,\n basePath: `${hookSetup.gcloudStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_GCLOUD_BASE_URL}`,\n publicBaseUrl: `${hookSetup.gcloudStorageOptions.baseUrl}`,\n // bucketName: `${config.FILE_STORAGE_GCLOUD_BUCKET_NAME}`,\n bucketName: `${hookSetup.gcloudStorageOptions.bucketName}`,\n // credentials: `${path.resolve(process.cwd(), `${config.FILE_STORAGE_GCLOUD_CREDENTIAL_PATH}`)}`,\n credentials: `${path.resolve(process.cwd(), `${hookSetup.gcloudStorageOptions.credentialPath}`)}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n if (hookSetup.storageType === \"aws\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n basePath: `${hookSetup.awsStorageOptions.basePath}`,\n publicBaseUrl: `${hookSetup.awsStorageOptions.baseUrl}`,\n bucketName: `${hookSetup.awsStorageOptions.bucketName}`,\n region: hookSetup.awsStorageOptions?.region ?? \"\",\n credentials: {\n accessKeyId: hookSetup.awsStorageOptions.credentials.accessKeyId,\n secretAccessKey: hookSetup.awsStorageOptions.credentials.secretAccessKey,\n },\n skipFoldernameByModuleRef: Boolean(hookSetup.awsStorageOptions.skipFolderNameModuleRef),\n skipFoldernameByDate: Boolean(hookSetup.awsStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n throw new Error(\"Unsupported storage type\")\n }\n\n const uploadFiles = async ({\n field_ref = \"item\",\n field_module = \"item\",\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n files = [],\n storageSetup\n }: FileUploadProps) => {\n\n const {\n storageProviderName,\n storageProviderOptions,\n storageConfiguration\n } = await getStorageSetup(storageSetup)\n\n // get the correct provider\n const provider = await getFileStorageProvider(storageProviderName, storageProviderOptions);\n\n // Image Compression\n const imageCompressionOptions: FileImageCompressionOptions | undefined\n = storageConfiguration?.imageMaxWidth && storageConfiguration?.imageMaxWidth\n ? {\n maxWidth: Number(storageConfiguration.imageMaxWidth),\n quality: Number(storageConfiguration.imageQuality),\n }\n : undefined;\n\n\n const imageCompressionProviderType: ImageCompressionProviderType =\n storageConfiguration?.imageCompressionProvider ? storageConfiguration.imageCompressionProvider : \"sharp\"\n\n // get image compression provider\n const imageCompressionProvider = await getImageCompressionProvider(\n imageCompressionProviderType,\n imageCompressionOptions\n )\n\n // Video Compression\n const videoCompressionOptions: FileVideoCompressionOptions | undefined =\n storageConfiguration?.videoCRF &&\n storageConfiguration?.videoPreset &&\n storageConfiguration?.videoResolution\n ? {\n crf: Number(storageConfiguration.videoCRF),\n preset: storageConfiguration.videoPreset as FileVideoCompressionOptions[\"preset\"],\n resolution: Number(storageConfiguration.videoResolution),\n }\n : undefined;\n\n const allResponses = []\n\n const batchCode = initBatchCode();\n\n const fileLabel = label ?? \"\"\n const referId1 = refId ?? 0\n const referId2 = refId2 ?? 0\n const referLabel1 = refLabel ?? \"\"\n const referLabel2 = refLabel2 ?? \"\"\n const fileRemark = remark ?? \"\"\n\n for (const file of files) {\n\n let bufferToUpload = file.buffer;\n let mimeType = file.mimeType ?? \"\"\n let sizeBytes = file?.sizeBytes\n let fileOriginalName = file.originalName;\n\n let outputSizeBytes = sizeBytes // output file size\n let fileCompressFormat = `` // output image compress\n\n const fileCategoryName = getFileCategoryNameByMimeType(mimeType)\n\n // const ext = file.originalName?.split(\".\").pop()?.toLowerCase() ?? \"\";\n\n // Image :: Only compress if image and options provided\n if (fileCategoryName === \"image\" && imageCompressionOptions) {\n // const compressed = await compressImageBuffer(\n // bufferToUpload,\n // mimeType,\n // imageCompressionOptions\n // );\n\n const compressed = await imageCompressionProvider.compress(\n bufferToUpload,\n mimeType,\n imageCompressionOptions\n )\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // Vide :: Only compress if video and options provided\n if (fileCategoryName === \"video\" && videoCompressionOptions) {\n const compressed = await compressVideoBuffer(\n bufferToUpload,\n mimeType,\n videoCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // generate thumbnail buffer\n const bufferThumbnail = await generateFileThumbnailBuffer(bufferToUpload, mimeType)\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onStartUpload) {\n\n await FileStorageHook.onStartUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail?.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n // upload using the provider - buffer\n const uploadResult = await provider.uploadFile({\n field_ref,\n field_module,\n buffer: bufferToUpload,\n bufferThumbnail: bufferThumbnail.buffer,\n thumbnailOptions,\n ...(foldernameDate ? { foldernameDate } : {}),\n mimeType,\n fileName: fileOriginalName\n } as FileModuleRef & (\n FileLocalUploadFileProps |\n FileGoogleCloudUploadFileProps |\n FileAwsS3UploadFileProps\n ));\n\n const fieldRef = field_ref\n const fieldModule = field_module\n\n const fileName = uploadResult?.filename ?? \"\"\n const contentType = mimeType ?? \"\"\n const folderPath = uploadResult.assetPath ?? \"\"\n const assetUrl = uploadResult.assetUrl ?? \"\"\n const thumbnailUrl = uploadResult?.thumbnailUrl ?? \"\"\n const assetPath = uploadResult.assetPath ?? \"\"\n\n const fileDurationSeconds = bufferThumbnail?.durationSeconds ?? 0\n\n const inputType = `buffer`\n const inputFileSizeBytes = sizeBytes ?? 0\n const inputFileName = fileOriginalName ?? \"\"\n\n const fileSizeBytes = outputSizeBytes ?? 0\n // const fileCompressFormat = ``\n\n const foldernameDay = uploadResult?.folderName?.day ?? \"\"\n const foldernameMonth = uploadResult?.folderName?.month ?? \"\"\n const foldernameYear = uploadResult?.folderName?.year ?? \"\"\n\n const payload: FileCreateProps = {\n data: {\n fieldRef,\n fieldModule,\n tagName,\n description,\n remark: fileRemark,\n folderPath,\n assetUrl,\n thumbnailUrl,\n assetPath,\n fileLabel,\n fileName,\n fileCategoryName,\n contentType,\n inputType,\n inputFileSizeBytes,\n inputFileName,\n fileSizeBytes,\n fileDurationSeconds,\n fileCompressFormat,\n storageProviderName,\n foldernameDay,\n foldernameMonth,\n foldernameYear,\n batchCode,\n referId1,\n referId2,\n referLabel1,\n referLabel2\n } as FileCreateProps[\"data\"],\n };\n\n let responseFile = await createFile(payload);\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onSuccessUpload) {\n await FileStorageHook.onSuccessUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fileId: Number(responseFile?.file_id),\n fileThumbnailUrl: thumbnailUrl,\n fileAssetUrl: assetUrl,\n fileDurationSeconds,\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n allResponses.push(responseFile)\n }\n\n return allResponses\n\n }\n\n // private\n const createFile = async ({ data }: FileCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create file payload: ${JSON.stringify(_data)}`);\n }\n\n const response = await fileModel.create({ data: _data })\n\n const newFileId = response?.file_id ?? \"\"\n\n return newFileId ? await getFile({ id: Number(newFileId) }) : null\n\n }\n\n const getFile = async ({ id }: FileGetProps) => {\n\n let { data } = await listFiles({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelFileFields.file_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelFileFields.file_id}`,\n sortorder: \"ASC\"\n })\n\n return data[0] ?? null;\n\n };\n\n const listFiles = async ({ limit, offset, filters = [], sortfield, sortorder }: FileListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n // sqlRelationAgg = []\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `mainfile.isdelete = false`,\n `mainfile.istrash = false`,\n // `LOWER(mainfile.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: fileModel,\n tableName: \"files\",\n mainAlias: \"mainfile\",\n countKey: `${ModelFileFields.file_id}`,\n accountId: rest.accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeFiles = async ({ fileIds, storageSetup }: FileRemoveProps) => {\n\n const {\n // storageProviderName,\n storageProviderOptions\n } = await getStorageSetup(storageSetup)\n\n if (!fileIds.length) throwError('fileIds is required');\n\n const filesToDelete = await fileModel.list({\n where: {\n file_id: { in: fileIds }\n }\n });\n\n // console.log('filesToDelete', filesToDelete)\n\n let providerResponse: any[] = []\n\n // 2️⃣ Delete the physical files\n for (const file of filesToDelete) {\n\n // check the provider to choose delete method\n const storageProviderName = file.storage_provider_name as FileStorageProviderType\n const assetUrl = file.asset_url\n const thumbnailUrl = file.thumbnail_url ?? \"\"\n const assetPath = file.asset_path\n\n if (storageProviderName === \"local\" && assetPath) {\n\n try {\n providerResponse.push(\n await fileLocalStorageProvider.removeFile(assetPath, thumbnailOptions)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Local: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"gcloud\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileGoogleCloudStorageProvider.removeFile(assetUrl, thumbnailUrl, storageProviderOptions.credentials as any)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from GCloud: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"aws\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileAwsS3StorageProvider.removeFile(assetUrl, thumbnailUrl)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Aws S3: ${assetUrl}`\n )\n }\n\n }\n\n }\n\n // remove files\n const response = await fileModel.remove({ where: { [`${ModelFileFields.file_id}`]: { in: fileIds } } });\n\n return {\n files: response,\n providerResponse\n }\n };\n\n const getFileUsageSummary = async ({ accountId = 0 }: FileGetUsageSummaryProps) => {\n\n const summaryCount = await fileModel.aggregate({\n field: `file_id`,\n operation: `count`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const summarySize = await fileModel.aggregate({\n field: `file_size_bytes`,\n operation: `sum`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const totalFiles = summaryCount ?? 0;\n const totalBytes = summarySize ?? 0;\n // const totalFiles = summary._count.id;\n\n // Optional: convert bytes to MB or GB\n const totalMB = totalBytes / (1024 * 1024);\n const totalGB = totalBytes / (1024 * 1024 * 1024);\n\n return {\n totalFiles,\n totalBytes,\n totalMB: parseFloat(totalMB.toFixed(2)), // now decimal\n totalGB: parseFloat(totalGB.toFixed(2)), // now decimal\n };\n }\n\n // const getDataTypes = () => {\n // return Object.values(fileDataTypes);\n // }\n\n return {\n uploadFiles,\n // createFile,\n // updateFile,\n getFile,\n listFiles,\n removeFiles,\n // getDataTypes,\n getFileUsageSummary\n }\n\n}\n\n"]}
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- // import { FileLocalStorageProvider, FileLocalProviderOptions } from "./FileLocalStorageProvider";
3
- // import { FileGoogleCloudStorageProvider, FileGoogleCloudProviderOptions } from "./FileGoogleCloudStorageProvider";
4
- // import { FileAwsS3StorageProvider, FileAwsS3ProviderOptions } from "./FileAwsS3StorageProvider";
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getFileStorageProvider = void 0;
7
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorageProviderRegistry.js","sourceRoot":"","sources":["../../../src/services/file/FileStorageProviderRegistry.ts"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,qHAAqH;AACrH,mGAAmG;;;AA2CnG;;;GAGG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACvC,QAAW,EACX,OAA0C,EAC5C,EAAE;IACA,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,CAAC,CAAC;YACX,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;YACnF,OAAO,wBAAwB,CAAC,OAAc,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACZ,IAAI,8BAA8B,CAAC;YACnC,IAAI,CAAC;gBACD,8BAA8B,GAAG,CAAC,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC,8BAA8B,CAAC;YAC1H,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAC;YACN,CAAC;YACD,OAAO,8BAA8B,CAAC,OAAc,CAAC,CAAC;QAC1D,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACT,IAAI,wBAAwB,CAAC;YAC7B,IAAI,CAAC;gBACD,wBAAwB,GAAG,CAAC,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACxG,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,IAAI,KAAK,CACX,4FAA4F,CAC/F,CAAC;YACN,CAAC;YACD,OAAO,wBAAwB,CAAC,OAAc,CAAC,CAAC;QACpD,CAAC;QACD;YACI,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;AACL,CAAC,CAAC;AAlCW,QAAA,sBAAsB,0BAkCjC","sourcesContent":["// import { FileLocalStorageProvider, FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\n// import { FileGoogleCloudStorageProvider, FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\n// import { FileAwsS3StorageProvider, FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\n// Unified options mapping\nimport type { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nimport type { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nimport type { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\n// Define provider types\nexport type FileStorageProviderType = \"local\" | \"gcloud\" | \"aws\";\n\n// Define unified options type (per provider)\ntype FileStorageProviderOptionsMap = {\n local?: FileLocalProviderOptions;\n gcloud?: FileGoogleCloudProviderOptions;\n aws?: FileAwsS3ProviderOptions;\n};\n\nexport type FileStorageProviderResult = {\n assetPath: string; // path for output\n assetUrl: string; // url for output viewable public\n thumbnailUrl: string; // url for output viewable public (thumbnail)\n basePath: string; // request base path of the filename\n filename: string; // new filename output\n folderName?: {\n year: number,\n month: number,\n day: number\n }\n};\n\n// Registry (for flexibility if you add more providers later)\n// const FileStorageProviderRegistry = {\n// local: FileLocalStorageProvider,\n// gcloud: FileGoogleCloudStorageProvider,\n// aws: FileAwsS3StorageProvider,\n// };\n\ntype FileStorageProviderRegistry = {\n local?: any;\n gcloud?: any;\n aws?: any;\n};\n\n/**\n * Factory getter — returns a ready-to-use provider instance.\n * Lazy loads GCloud / AWS only if requested.\n */\nexport const getFileStorageProvider = async <T extends FileStorageProviderType>(\n provider: T,\n options?: FileStorageProviderOptionsMap[T]\n) => {\n switch (provider) {\n case \"local\": {\n const { FileLocalStorageProvider } = await import(\"./FileLocalStorageProvider.js\");\n return FileLocalStorageProvider(options as any);\n }\n case \"gcloud\": {\n let FileGoogleCloudStorageProvider;\n try {\n FileGoogleCloudStorageProvider = (await import(\"./FileGoogleCloudStorageProvider.js\")).FileGoogleCloudStorageProvider;\n } catch {\n throw new Error(\n \"Please install @google-cloud/storage to use Google Cloud provider\"\n );\n }\n return FileGoogleCloudStorageProvider(options as any);\n }\n case \"aws\": {\n let FileAwsS3StorageProvider;\n try {\n FileAwsS3StorageProvider = (await import(\"./FileAwsS3StorageProvider.js\")).FileAwsS3StorageProvider;\n } catch {\n throw new Error(\n \"Please install @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner to use AWS S3 provider\"\n );\n }\n return FileAwsS3StorageProvider(options as any);\n }\n default:\n throw new Error(`Unknown file storage provider: ${provider}`);\n }\n};\n\n// Factory getter — returns a *ready-to-use* provider instance\n// export const getFileStorageProvider = <T extends FileStorageProviderType>(\n// provider: T,\n// options?: FileStorageProviderOptionsMap[T]\n// ) => {\n// const ProviderFactory = FileStorageProviderRegistry[provider];\n\n// // Instantiate the provider with provided or default options\n// return ProviderFactory(options as any);\n// };\n\nexport { FileStorageProviderRegistry };\n"]}
1
+ {"version":3,"file":"FileStorageProviderRegistry.js","sourceRoot":"","sources":["../../../src/services/file/FileStorageProviderRegistry.ts"],"names":[],"mappings":";;;AAkCA;;;GAGG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACvC,QAAW,EACX,OAA0C,EAC5C,EAAE;IACA,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,CAAC,CAAC;YACX,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;YACnF,OAAO,wBAAwB,CAAC,OAAc,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACZ,IAAI,8BAA8B,CAAC;YACnC,IAAI,CAAC;gBACD,8BAA8B,GAAG,CAAC,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC,8BAA8B,CAAC;YAC1H,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAC;YACN,CAAC;YACD,OAAO,8BAA8B,CAAC,OAAc,CAAC,CAAC;QAC1D,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACT,IAAI,wBAAwB,CAAC;YAC7B,IAAI,CAAC;gBACD,wBAAwB,GAAG,CAAC,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACxG,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,IAAI,KAAK,CACX,4FAA4F,CAC/F,CAAC;YACN,CAAC;YACD,OAAO,wBAAwB,CAAC,OAAc,CAAC,CAAC;QACpD,CAAC;QACD;YACI,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;AACL,CAAC,CAAC;AAlCW,QAAA,sBAAsB,0BAkCjC","sourcesContent":["// Unified options mapping\nimport type { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nimport type { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nimport type { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\n// Define provider types\nexport type FileStorageProviderType = \"local\" | \"gcloud\" | \"aws\";\n\n// Define unified options type (per provider)\ntype FileStorageProviderOptionsMap = {\n local?: FileLocalProviderOptions;\n gcloud?: FileGoogleCloudProviderOptions;\n aws?: FileAwsS3ProviderOptions;\n};\n\nexport type FileStorageProviderResult = {\n assetPath: string; // path for output\n assetUrl: string; // url for output viewable public\n thumbnailUrl: string; // url for output viewable public (thumbnail)\n basePath: string; // request base path of the filename\n filename: string; // new filename output\n folderName?: {\n year: number,\n month: number,\n day: number\n }\n};\n\ntype FileStorageProviderRegistry = {\n local?: any;\n gcloud?: any;\n aws?: any;\n};\n\n/**\n * Factory getter — returns a ready-to-use provider instance.\n * Lazy loads GCloud / AWS only if requested.\n */\nexport const getFileStorageProvider = async <T extends FileStorageProviderType>(\n provider: T,\n options?: FileStorageProviderOptionsMap[T]\n) => {\n switch (provider) {\n case \"local\": {\n const { FileLocalStorageProvider } = await import(\"./FileLocalStorageProvider.js\");\n return FileLocalStorageProvider(options as any);\n }\n case \"gcloud\": {\n let FileGoogleCloudStorageProvider;\n try {\n FileGoogleCloudStorageProvider = (await import(\"./FileGoogleCloudStorageProvider.js\")).FileGoogleCloudStorageProvider;\n } catch {\n throw new Error(\n \"Please install @google-cloud/storage to use Google Cloud provider\"\n );\n }\n return FileGoogleCloudStorageProvider(options as any);\n }\n case \"aws\": {\n let FileAwsS3StorageProvider;\n try {\n FileAwsS3StorageProvider = (await import(\"./FileAwsS3StorageProvider.js\")).FileAwsS3StorageProvider;\n } catch {\n throw new Error(\n \"Please install @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner to use AWS S3 provider\"\n );\n }\n return FileAwsS3StorageProvider(options as any);\n }\n default:\n throw new Error(`Unknown file storage provider: ${provider}`);\n }\n};\n\n// Factory getter — returns a *ready-to-use* provider instance\n// export const getFileStorageProvider = <T extends FileStorageProviderType>(\n// provider: T,\n// options?: FileStorageProviderOptionsMap[T]\n// ) => {\n// const ProviderFactory = FileStorageProviderRegistry[provider];\n\n// // Instantiate the provider with provided or default options\n// return ProviderFactory(options as any);\n// };\n\nexport { FileStorageProviderRegistry };\n"]}
@@ -0,0 +1,12 @@
1
+ export type ImageCompressionProviderType = "sharp" | "jimp";
2
+ export type FileImageCompressionOptions = {
3
+ maxWidth?: number;
4
+ quality?: number;
5
+ };
6
+ export declare const getImageCompressionProvider: (provider: ImageCompressionProviderType, defaultOptions?: FileImageCompressionOptions) => Promise<{
7
+ compress: (buffer: Buffer, mimeType: string, options?: FileImageCompressionOptions) => Promise<{
8
+ compressFormat: string;
9
+ buffer: Buffer;
10
+ sizeBytes: number;
11
+ }>;
12
+ }>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getImageCompressionProvider = void 0;
4
+ const getImageCompressionProvider = async (provider, defaultOptions = {}) => {
5
+ switch (provider) {
6
+ case "sharp": {
7
+ const { compressImageBufferWithSharp } = await import("./SharpImageCompression.js");
8
+ return {
9
+ compress: async (buffer, mimeType, options) => {
10
+ const merged = {
11
+ ...defaultOptions,
12
+ ...options,
13
+ };
14
+ return compressImageBufferWithSharp(buffer, mimeType, merged);
15
+ },
16
+ };
17
+ }
18
+ case "jimp": {
19
+ const { compressImageBufferWithJimp } = await import("./JimpImageCompression.js");
20
+ return {
21
+ compress: async (buffer, mimeType, options) => {
22
+ const merged = {
23
+ ...defaultOptions,
24
+ ...options,
25
+ };
26
+ return compressImageBufferWithJimp(buffer, mimeType, merged);
27
+ },
28
+ };
29
+ }
30
+ default:
31
+ throw new Error(`Unknown provider: ${provider}`);
32
+ }
33
+ };
34
+ exports.getImageCompressionProvider = getImageCompressionProvider;
35
+ //# sourceMappingURL=ImageCompressionProviderRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageCompressionProviderRegistry.js","sourceRoot":"","sources":["../../../src/services/file/ImageCompressionProviderRegistry.ts"],"names":[],"mappings":";;;AAOO,MAAM,2BAA2B,GAAG,KAAK,EAC5C,QAAsC,EACtC,iBAA8C,EAAE,EAClD,EAAE;IACA,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,CAAC,CAAC;YACX,MAAM,EAAE,4BAA4B,EAAE,GAClC,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;YAE/C,OAAO;gBACH,QAAQ,EAAE,KAAK,EACX,MAAc,EACd,QAAgB,EAChB,OAAqC,EACvC,EAAE;oBACA,MAAM,MAAM,GAAG;wBACX,GAAG,cAAc;wBACjB,GAAG,OAAO;qBACb,CAAC;oBAEF,OAAO,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBAClE,CAAC;aACJ,CAAC;QACN,CAAC;QAED,KAAK,MAAM,CAAC,CAAC,CAAC;YACV,MAAM,EAAE,2BAA2B,EAAE,GACjC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;YAE9C,OAAO;gBACH,QAAQ,EAAE,KAAK,EACX,MAAc,EACd,QAAgB,EAChB,OAAqC,EACvC,EAAE;oBACA,MAAM,MAAM,GAAG;wBACX,GAAG,cAAc;wBACjB,GAAG,OAAO;qBACb,CAAC;oBAEF,OAAO,2BAA2B,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBACjE,CAAC;aACJ,CAAC;QACN,CAAC;QAED;YACI,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAhDW,QAAA,2BAA2B,+BAgDtC","sourcesContent":["export type ImageCompressionProviderType = \"sharp\" | \"jimp\";\n\nexport type FileImageCompressionOptions = {\n maxWidth?: number;\n quality?: number;\n};\n\nexport const getImageCompressionProvider = async (\n provider: ImageCompressionProviderType,\n defaultOptions: FileImageCompressionOptions = {}\n) => {\n switch (provider) {\n case \"sharp\": {\n const { compressImageBufferWithSharp } =\n await import(\"./SharpImageCompression.js\");\n\n return {\n compress: async (\n buffer: Buffer,\n mimeType: string,\n options?: FileImageCompressionOptions\n ) => {\n const merged = {\n ...defaultOptions,\n ...options,\n };\n\n return compressImageBufferWithSharp(buffer, mimeType, merged);\n },\n };\n }\n\n case \"jimp\": {\n const { compressImageBufferWithJimp } =\n await import(\"./JimpImageCompression.js\");\n\n return {\n compress: async (\n buffer: Buffer,\n mimeType: string,\n options?: FileImageCompressionOptions\n ) => {\n const merged = {\n ...defaultOptions,\n ...options,\n };\n\n return compressImageBufferWithJimp(buffer, mimeType, merged);\n },\n };\n }\n\n default:\n throw new Error(`Unknown provider: ${provider}`);\n }\n};"]}
@@ -0,0 +1,6 @@
1
+ import type { FileImageCompressionOptions } from "./ImageCompressionProviderRegistry";
2
+ export declare const compressImageBufferWithJimp: (buffer: Buffer, mimeType: string, options?: FileImageCompressionOptions) => Promise<{
3
+ compressFormat: string;
4
+ buffer: Buffer;
5
+ sizeBytes: number;
6
+ }>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compressImageBufferWithJimp = void 0;
4
+ const jimp_1 = require("jimp");
5
+ const compressImageBufferWithJimp = async (buffer, mimeType, options = {}) => {
6
+ const { maxWidth = 1024, quality = 80 } = options;
7
+ const SUPPORTED_IMAGE_MIMES = [
8
+ "image/jpeg",
9
+ "image/png",
10
+ "image/webp",
11
+ "image/tiff",
12
+ "image/bmp",
13
+ ];
14
+ // Skip unsupported images
15
+ if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {
16
+ return {
17
+ compressFormat: "unsupported_mime",
18
+ buffer,
19
+ sizeBytes: buffer.byteLength,
20
+ };
21
+ }
22
+ // ✅ Jimp 1.6.1 correct usage
23
+ const image = await jimp_1.Jimp.read(buffer);
24
+ // Resize (maintain aspect ratio)
25
+ if (maxWidth) {
26
+ image.resize({
27
+ w: maxWidth,
28
+ });
29
+ }
30
+ let outputBuffer;
31
+ switch (mimeType) {
32
+ case "image/png":
33
+ outputBuffer = await image.getBuffer("image/png");
34
+ break;
35
+ // case "image/webp":
36
+ // outputBuffer = await image.getBuffer("image/webp");
37
+ // break;
38
+ case "image/jpeg":
39
+ case "image/tiff":
40
+ case "image/bmp":
41
+ case "image/webp": // treat as jpeg fallback
42
+ default:
43
+ // if (mimeType === "image/jpeg") {
44
+ // image.quality(quality);
45
+ // }
46
+ // outputBuffer = await image.getBuffer("image/jpeg");
47
+ outputBuffer = await image.getBuffer("image/jpeg", {
48
+ quality,
49
+ });
50
+ break;
51
+ }
52
+ return {
53
+ compressFormat: JSON.stringify({
54
+ maxWidth,
55
+ quality,
56
+ engine: "jimp",
57
+ }),
58
+ buffer: outputBuffer,
59
+ sizeBytes: outputBuffer.byteLength,
60
+ };
61
+ };
62
+ exports.compressImageBufferWithJimp = compressImageBufferWithJimp;
63
+ //# sourceMappingURL=JimpImageCompression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JimpImageCompression.js","sourceRoot":"","sources":["../../../src/services/file/JimpImageCompression.ts"],"names":[],"mappings":";;;AAEA,+BAA4B;AAErB,MAAM,2BAA2B,GAAG,KAAK,EAC5C,MAAc,EACd,QAAgB,EAChB,UAAuC,EAAE,EAK1C,EAAE;IACD,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAElD,MAAM,qBAAqB,GAAG;QAC1B,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,WAAW;KACd,CAAC;IAEF,0BAA0B;IAC1B,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5C,OAAO;YACH,cAAc,EAAE,kBAAkB;YAClC,MAAM;YACN,SAAS,EAAE,MAAM,CAAC,UAAU;SAC/B,CAAC;IACN,CAAC;IAED,6BAA6B;IAC7B,MAAM,KAAK,GAAG,MAAM,WAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEtC,iCAAiC;IACjC,IAAI,QAAQ,EAAE,CAAC;QACX,KAAK,CAAC,MAAM,CAAC;YACT,CAAC,EAAE,QAAQ;SACd,CAAC,CAAC;IACP,CAAC;IAED,IAAI,YAAoB,CAAC;IAEzB,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,WAAW;YACZ,YAAY,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAClD,MAAM;QAEV,qBAAqB;QACrB,0DAA0D;QAC1D,aAAa;QAEb,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY,CAAC;QAClB,KAAK,WAAW,CAAC;QACjB,KAAK,YAAY,CAAC,CAAC,yBAAyB;QAC5C;YACI,mCAAmC;YACnC,8BAA8B;YAC9B,IAAI;YAEJ,sDAAsD;YACtD,YAAY,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE;gBAC/C,OAAO;aACH,CAAC,CAAC;YAEV,MAAM;IACd,CAAC;IAED,OAAO;QACH,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC;YAC3B,QAAQ;YACR,OAAO;YACP,MAAM,EAAE,MAAM;SACjB,CAAC;QACF,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,YAAY,CAAC,UAAU;KACrC,CAAC;AACN,CAAC,CAAC;AA3EW,QAAA,2BAA2B,+BA2EtC","sourcesContent":["import type { FileImageCompressionOptions } from \"./ImageCompressionProviderRegistry\";\n\nimport { Jimp } from \"jimp\";\n\nexport const compressImageBufferWithJimp = async (\n buffer: Buffer,\n mimeType: string,\n options: FileImageCompressionOptions = {}\n): Promise<{\n compressFormat: string;\n buffer: Buffer;\n sizeBytes: number;\n}> => {\n const { maxWidth = 1024, quality = 80 } = options;\n\n const SUPPORTED_IMAGE_MIMES = [\n \"image/jpeg\",\n \"image/png\",\n \"image/webp\",\n \"image/tiff\",\n \"image/bmp\",\n ];\n\n // Skip unsupported images\n if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {\n return {\n compressFormat: \"unsupported_mime\",\n buffer,\n sizeBytes: buffer.byteLength,\n };\n }\n\n // ✅ Jimp 1.6.1 correct usage\n const image = await Jimp.read(buffer);\n\n // Resize (maintain aspect ratio)\n if (maxWidth) {\n image.resize({\n w: maxWidth,\n });\n }\n\n let outputBuffer: Buffer;\n\n switch (mimeType) {\n case \"image/png\":\n outputBuffer = await image.getBuffer(\"image/png\");\n break;\n\n // case \"image/webp\":\n // outputBuffer = await image.getBuffer(\"image/webp\");\n // break;\n\n case \"image/jpeg\":\n case \"image/tiff\":\n case \"image/bmp\":\n case \"image/webp\": // treat as jpeg fallback\n default:\n // if (mimeType === \"image/jpeg\") {\n // image.quality(quality);\n // }\n\n // outputBuffer = await image.getBuffer(\"image/jpeg\");\n outputBuffer = await image.getBuffer(\"image/jpeg\", {\n quality,\n } as any);\n\n break;\n }\n\n return {\n compressFormat: JSON.stringify({\n maxWidth,\n quality,\n engine: \"jimp\",\n }),\n buffer: outputBuffer,\n sizeBytes: outputBuffer.byteLength,\n };\n};"]}
@@ -0,0 +1,9 @@
1
+ export type FileImageCompressionOptions = {
2
+ maxWidth?: number;
3
+ quality?: number;
4
+ };
5
+ export declare const compressImageBufferWithSharp: (buffer: Buffer, mimeType: string, options?: FileImageCompressionOptions) => Promise<{
6
+ compressFormat: string;
7
+ buffer: Buffer;
8
+ sizeBytes: number;
9
+ }>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.compressImageBufferWithSharp = void 0;
7
+ const sharp_1 = __importDefault(require("sharp"));
8
+ const compressImageBufferWithSharp = async (buffer, mimeType, options = {}) => {
9
+ const { maxWidth = 1024, quality = 80 } = options;
10
+ const SUPPORTED_IMAGE_MIMES = [
11
+ "image/jpeg",
12
+ "image/png",
13
+ "image/webp",
14
+ "image/tiff",
15
+ "image/bmp",
16
+ ];
17
+ // Skip unsupported images
18
+ if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {
19
+ return {
20
+ compressFormat: "",
21
+ buffer,
22
+ sizeBytes: buffer.byteLength,
23
+ };
24
+ }
25
+ // Create pipeline (Sharp equivalent of Jimp.read)
26
+ let pipeline = (0, sharp_1.default)(buffer).rotate(); // auto-orient EXIF
27
+ // Resize if needed
28
+ if (maxWidth) {
29
+ pipeline = pipeline.resize({ width: maxWidth });
30
+ }
31
+ let compressedBuffer;
32
+ switch (mimeType) {
33
+ case "image/png":
34
+ compressedBuffer = await pipeline
35
+ .png({ quality })
36
+ .toBuffer();
37
+ break;
38
+ case "image/webp":
39
+ compressedBuffer = await pipeline
40
+ .webp({ quality })
41
+ .toBuffer();
42
+ break;
43
+ case "image/jpeg":
44
+ case "image/tiff":
45
+ case "image/bmp":
46
+ default:
47
+ compressedBuffer = await pipeline
48
+ .jpeg({ quality })
49
+ .toBuffer();
50
+ break;
51
+ }
52
+ return {
53
+ compressFormat: JSON.stringify({ maxWidth, quality, engine: "sharp" }),
54
+ buffer: compressedBuffer,
55
+ sizeBytes: compressedBuffer.byteLength,
56
+ };
57
+ };
58
+ exports.compressImageBufferWithSharp = compressImageBufferWithSharp;
59
+ //# sourceMappingURL=SharpImageCompression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharpImageCompression.js","sourceRoot":"","sources":["../../../src/services/file/SharpImageCompression.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAOnB,MAAM,4BAA4B,GAAG,KAAK,EAC7C,MAAc,EACd,QAAgB,EAChB,UAAuC,EAAE,EAK1C,EAAE;IACD,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAElD,MAAM,qBAAqB,GAAG;QAC1B,YAAY;QACZ,WAAW;Q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EW,QAAA,4BAA4B,gCAkEvC","sourcesContent":["import sharp from \"sharp\";\n\nexport type FileImageCompressionOptions = {\n maxWidth?: number;\n quality?: number;\n};\n\nexport const compressImageBufferWithSharp = async (\n buffer: Buffer,\n mimeType: string,\n options: FileImageCompressionOptions = {}\n): Promise<{\n compressFormat: string;\n buffer: Buffer;\n sizeBytes: number;\n}> => {\n const { maxWidth = 1024, quality = 80 } = options;\n\n const SUPPORTED_IMAGE_MIMES = [\n \"image/jpeg\",\n \"image/png\",\n \"image/webp\",\n \"image/tiff\",\n \"image/bmp\",\n ];\n\n // Skip unsupported images\n if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {\n return {\n compressFormat: \"\",\n buffer,\n sizeBytes: buffer.byteLength,\n };\n }\n\n // Create pipeline (Sharp equivalent of Jimp.read)\n let pipeline = sharp(buffer).rotate(); // auto-orient EXIF\n\n // Resize if needed\n if (maxWidth) {\n pipeline = pipeline.resize({ width: maxWidth });\n }\n\n let compressedBuffer: Buffer;\n\n switch (mimeType) {\n case \"image/png\":\n compressedBuffer = await pipeline\n .png({ quality })\n .toBuffer();\n break;\n\n case \"image/webp\":\n compressedBuffer = await pipeline\n .webp({ quality })\n .toBuffer();\n break;\n\n case \"image/jpeg\":\n case \"image/tiff\":\n case \"image/bmp\":\n default:\n compressedBuffer = await pipeline\n .jpeg({ quality })\n .toBuffer();\n break;\n }\n\n return {\n compressFormat: JSON.stringify({ maxWidth, quality, engine: \"sharp\" }),\n buffer: compressedBuffer,\n sizeBytes: compressedBuffer.byteLength,\n };\n};"]}
@@ -0,0 +1,9 @@
1
+ export type FileImageCompressionOptions = {
2
+ maxWidth?: number;
3
+ quality?: number;
4
+ };
5
+ export declare const compressImageBuffer: (buffer: Buffer, mimeType: string, options?: FileImageCompressionOptions) => Promise<{
6
+ compressFormat: string;
7
+ buffer: Buffer;
8
+ sizeBytes: number;
9
+ }>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compressImageBuffer = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const compressImageBuffer = async (buffer, mimeType, options = {}) => {
6
+ const { maxWidth = 1024, quality = 80 } = options;
7
+ const SUPPORTED_IMAGE_MIMES = [
8
+ "image/jpeg",
9
+ "image/png",
10
+ "image/webp",
11
+ "image/tiff",
12
+ "image/bmp",
13
+ ];
14
+ // Skip unsupported images
15
+ if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {
16
+ return { compressFormat: '', buffer, sizeBytes: buffer.byteLength };
17
+ }
18
+ // let pipeline = sharp(buffer);
19
+ let pipeline = (0, utils_1.sharp)(buffer)
20
+ .rotate(); // ✅ auto-orients based on EXIF
21
+ // .resize({ width: maxWidth }); // safe to chain directly
22
+ if (maxWidth) {
23
+ pipeline = pipeline.resize({ width: maxWidth });
24
+ }
25
+ let compressedBuffer;
26
+ switch (mimeType) {
27
+ case "image/png":
28
+ compressedBuffer = await pipeline.png({ quality }).toBuffer();
29
+ break;
30
+ case "image/webp":
31
+ compressedBuffer = await pipeline.webp({ quality }).toBuffer();
32
+ break;
33
+ case "image/jpeg":
34
+ case "image/tiff":
35
+ case "image/bmp":
36
+ default:
37
+ compressedBuffer = await pipeline.jpeg({ quality }).toBuffer();
38
+ break;
39
+ }
40
+ return {
41
+ compressFormat: JSON.stringify(options),
42
+ buffer: compressedBuffer,
43
+ sizeBytes: compressedBuffer.byteLength
44
+ };
45
+ };
46
+ exports.compressImageBuffer = compressImageBuffer;
47
+ //# sourceMappingURL=unuse_ImageCompression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unuse_ImageCompression.js","sourceRoot":"","sources":["../../../src/services/file/unuse_ImageCompression.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAOzB,MAAM,mBAAmB,GAAG,KAAK,EACpC,MAAc,EACd,QAAgB,EAChB,UAAuC,EAAE,EAK1C,EAAE;IAED,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,GAAG,E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CAAC;AAEN,CAAC,CAAC;AAzDW,QAAA,mBAAmB,uBAyD9B","sourcesContent":["import { sharp } from \"@/utils\";\n\nexport type FileImageCompressionOptions = {\n maxWidth?: number;\n quality?: number;\n}\n\nexport const compressImageBuffer = async (\n buffer: Buffer,\n mimeType: string,\n options: FileImageCompressionOptions = {}\n): Promise<{\n compressFormat: string;\n buffer: Buffer;\n sizeBytes: number;\n}> => {\n\n const { maxWidth = 1024, quality = 80 } = options;\n\n const SUPPORTED_IMAGE_MIMES = [\n \"image/jpeg\",\n \"image/png\",\n \"image/webp\",\n \"image/tiff\",\n \"image/bmp\",\n ];\n\n // Skip unsupported images\n if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {\n return { compressFormat: '', buffer, sizeBytes: buffer.byteLength };\n }\n\n // let pipeline = sharp(buffer);\n let pipeline = sharp(buffer)\n .rotate() // ✅ auto-orients based on EXIF\n // .resize({ width: maxWidth }); // safe to chain directly\n\n if (maxWidth) {\n pipeline = pipeline.resize({ width: maxWidth });\n }\n\n let compressedBuffer: Buffer;\n\n switch (mimeType) {\n case \"image/png\":\n compressedBuffer = await pipeline.png({ quality }).toBuffer();\n break;\n case \"image/webp\":\n compressedBuffer = await pipeline.webp({ quality }).toBuffer();\n break;\n case \"image/jpeg\":\n case \"image/tiff\":\n case \"image/bmp\":\n default:\n compressedBuffer = await pipeline.jpeg({ quality }).toBuffer();\n break;\n }\n\n return {\n compressFormat: JSON.stringify(options),\n buffer: compressedBuffer,\n sizeBytes: compressedBuffer.byteLength\n };\n\n};"]}
@@ -33,7 +33,7 @@ export type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCre
33
33
  export { RepositoryService, repositoryTypes } from "../services/repository/RepositoryService";
34
34
  export type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from "../services/repository/RepositoryService";
35
35
  export { FileService } from "../services/file/FileService";
36
- export type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from "../services/file/FileService";
36
+ export type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, ImageCompressionProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from "../services/file/FileService";
37
37
  export { LocationService } from "../services/location/LocationService";
38
38
  export type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from "../services/location/LocationService";
39
39
  export { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from "../services/injection_field/InjectionFieldService";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,2EAA8G;AAArG,oHAAA,gBAAgB,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,mHAAA,eAAe,OAAA;AAE9D,uFAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAE7B,uFAA2G;AAAlG,4HAAA,oBAAoB,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AAEnD,oEAAkE;AAAzD,gHAAA,cAAc,OAAA;AAEvB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAGxB,0FAAyI;AAAhI,4HAAA,oBAAoB,OAAA;AAAE,2HAAA,mBAAmB,OAAA;AAAE,kIAAA,0BAA0B,OAAA;AAE9E,mGAAiG;AAAxF,kIAAA,uBAAuB,OAAA;AAGhC,2DAAyF;AAAhF,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAGpD,+DAA6D;AAApD,8GAAA,aAAa,OAAA;AAGtB,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,yEAAwF;AAA/E,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,iEAA+D;AAAtD,8GAAA,aAAa,OAAA;AAEtB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,6EAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,2DAAyD;AAAhD,0GAAA,WAAW,OAAA;AAEpB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,0FAAsI;AAA7H,8HAAA,qBAAqB,OAAA;AAAE,4HAAA,mBAAmB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE5E,yFAAuF;AAA9E,sIAAA,yBAAyB,OAAA;AAElC,kFAA8I;AAArI,wHAAA,kBAAkB,OAAA;AAAE,sHAAA,gBAAgB,OAAA;AAAE,6HAAA,uBAAuB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAEzF,wEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AAGzB,gFAAiG;AAAxF,0HAAA,mBAAmB,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AAE/C,wFAAsF;AAA7E,kIAAA,uBAAuB,OAAA;AAEhC,gFAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAG5B,+FAA+F;AAC/F,wIAAwI;AACxI,8EAA4E;AAAnE,4HAAA,oBAAoB,OAAA","sourcesContent":["export { AuthService, authTypes } from \"@/services/auth/AuthService\"\nexport type { AuthServiceProps, AuthType, AuthTokenResult, AuthJwtToken, AuthGetTokenProps } from \"@/services/auth/AuthService\"\nexport { AccessKeyService, accessKeyUserTypes, accessKeyStatus } from \"@/services/access_key/AccessKeyService\"\nexport type { AccessKeyServiceProps, AccessKeyStatus, AccessKeyUserType, AccessKeyCreateProps, AccessKeyRevokeProps } from \"@/services/access_key/AccessKeyService\"\nexport { AccessControlService } from \"@/services/access_control/AccessControlService\"\nexport type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessControlListOptionsProps } from \"@/services/access_control/AccessControlService\"\nexport { ResetPasswordService, resetPasswordMethods } from \"@/services/reset_password/ResetPasswordService\"\nexport type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services/reset_password/ResetPasswordService\"\nexport { AccountService } from \"@/services/account/AccountService\"\nexport type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from \"@/services/account/AccountService\"\nexport { BusinessService } from \"@/services/business/BusinessService\"\nexport type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from \"@/services/business/BusinessService\"\n\nexport { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from \"@/services/subscription/plan/SubscribePlanService\"\nexport type { SubscribePlanServiceProps, SubscribePlan, SubscribePlanBillingCycle, SubscribePlanCurrency, SubscribePlanGetProps, SubscribePlanListProps, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services/subscription/plan/SubscribePlanService\"\nexport { AccountSubscribeService } from \"@/services/subscription/account/AccountSubscribeService\"\nexport type { AccountSubscribeServiceProps, AccountSubscribe, AccountSubscribeGetProps, AccountSubscribeListProps, AccountSubscribeCreateProps, AccountSubscribeCancelProps } from \"@/services/subscription/account/AccountSubscribeService\"\n\nexport { UserService, userTypes, userParentSqlSelect } from \"@/services/user/UserService\"\nexport type { UserServiceProps, UserType, UserGetProps, UserListProps, UserCreateProps, UserUpdateProps, UserRemoveProps, UserReplacePasswordProps } from \"@/services/user/UserService\"\n\nexport { UserMeService } from \"@/services/user/UserMeService\"\nexport type { UserMeServiceProps, UserMeUpdateProps, UserMeChangePasswordProps } from \"@/services/user/UserMeService\"\n\nexport { AccessControlRoleService } from \"@/services/access_control/AccessControlRoleService\"\nexport type { AccessControlRoleServiceProps, AccessControlRoleUserType, AccessControlRoleGetProps, AccessControlRoleListProps, AccessControlRoleCreateProps, AccessControlRoleUpdateProps, AccessControlRoleRemoveProps } from \"@/services/access_control/AccessControlRoleService\"\n\nexport { AccessControlUserService } from \"@/services/access_control/AccessControlUserService\"\nexport type { AccessControlUserServiceProps, AccessControlUserAssignRolesProps } from \"@/services/access_control/AccessControlUserService\"\n\nexport { UserBranchService, userBranchTypes } from \"@/services/branch/UserBranchService\"\nexport type { UserBranchServiceProps, UserBranchType, UserBranchGetProps, UserBranchListProps, UserBranchCreateProps, UserBranchUpdateProps, UserBranchRemoveProps } from \"@/services/branch/UserBranchService\"\nexport { RegionService } from \"@/services/region/RegionService\"\nexport type { RegionServiceProps, RegionType, RegionGetProps, RegionCreateProps, RegionListProps, RegionUpdateProps, RegionRemoveProps } from \"@/services/region/RegionService\"\nexport { DocumentService } from \"@/services/document/DocumentService\"\nexport type { DocumentServiceProps, DocumentType, DocumentGetProps, DocumentUpdateProps, DocumentCreateProps, DocumentListProps, DocumentRemoveProps } from \"@/services/document/DocumentService\"\nexport { ItemService, itemTypes } from \"@/services/item/ItemService\"\nexport type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCreateProps, ItemListProps, ItemRemoveProps } from \"@/services/item/ItemService\"\nexport { RepositoryService, repositoryTypes } from \"@/services/repository/RepositoryService\"\nexport type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from \"@/services/repository/RepositoryService\"\nexport { FileService } from \"@/services/file/FileService\"\nexport type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from \"@/services/file/FileService\"\nexport { LocationService } from \"@/services/location/LocationService\"\nexport type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from \"@/services/location/LocationService\"\nexport { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from \"@/services/injection_field/InjectionFieldService\"\nexport type { InjectionFieldModuleRef, InjectionFieldServiceProps, InjectionFieldType, InjectionFieldDataType, InjectionFieldCreateProps, InjectionFieldListProps, InjectionFieldGetProps, InjectionFieldReplaceProps } from \"@/services/injection_field/InjectionFieldService\"\nexport { NumberDateSequenceService } from \"@/services/others/NumberDateSequenceService\"\nexport type { NumberDateSequenceModuleRef, NumberDateSequenceServiceProps, NumberDateSequenceInitProps, NumberDateSequenceCreateProps } from \"@/services/others/NumberDateSequenceService\"\nexport { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeCodeStatus } from \"@/services/one_time_code/OneTimeCodeService\"\nexport type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from \"@/services/one_time_code/OneTimeCodeService\"\nexport { SmtpEmailService } from \"@/services/gateway/SmtpEmailService\"\nexport type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from \"@/services/gateway/SmtpEmailService\"\n\nexport { SchedulerLogService, schedulerLogTypes } from \"@/services/scheduler/SchedulerLogService\"\nexport type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from \"@/services/scheduler/SchedulerLogService\"\nexport { SchedulerRequestService } from \"@/services/scheduler/SchedulerRequestService\"\nexport type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from \"@/services/scheduler/SchedulerRequestService\"\nexport { SchedulerSqlService } from \"@/services/scheduler/SchedulerSqlService\"\nexport type { SchedulerSqlServiceProps, SchedulerSqlExecuteProps } from \"@/services/scheduler/SchedulerSqlService\"\n\n// export { ChangePasswordUtilService } from \"@/services/utils/unuse/ChangePasswordUtilService\"\n// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from \"@/services/utils/unuse/ChangePasswordUtilService\"\nexport { AccessKeyUtilService } from \"@/services/utils/AccessKeyUtilService\"\nexport type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from \"@/services/utils/AccessKeyUtilService\""]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,2EAA8G;AAArG,oHAAA,gBAAgB,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,mHAAA,eAAe,OAAA;AAE9D,uFAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAE7B,uFAA2G;AAAlG,4HAAA,oBAAoB,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AAEnD,oEAAkE;AAAzD,gHAAA,cAAc,OAAA;AAEvB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAGxB,0FAAyI;AAAhI,4HAAA,oBAAoB,OAAA;AAAE,2HAAA,mBAAmB,OAAA;AAAE,kIAAA,0BAA0B,OAAA;AAE9E,mGAAiG;AAAxF,kIAAA,uBAAuB,OAAA;AAGhC,2DAAyF;AAAhF,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAGpD,+DAA6D;AAApD,8GAAA,aAAa,OAAA;AAGtB,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,yEAAwF;AAA/E,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,iEAA+D;AAAtD,8GAAA,aAAa,OAAA;AAEtB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,6EAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,2DAAyD;AAAhD,0GAAA,WAAW,OAAA;AAEpB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,0FAAsI;AAA7H,8HAAA,qBAAqB,OAAA;AAAE,4HAAA,mBAAmB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE5E,yFAAuF;AAA9E,sIAAA,yBAAyB,OAAA;AAElC,kFAA8I;AAArI,wHAAA,kBAAkB,OAAA;AAAE,sHAAA,gBAAgB,OAAA;AAAE,6HAAA,uBAAuB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAEzF,wEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AAGzB,gFAAiG;AAAxF,0HAAA,mBAAmB,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AAE/C,wFAAsF;AAA7E,kIAAA,uBAAuB,OAAA;AAEhC,gFAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAG5B,+FAA+F;AAC/F,wIAAwI;AACxI,8EAA4E;AAAnE,4HAAA,oBAAoB,OAAA","sourcesContent":["export { AuthService, authTypes } from \"@/services/auth/AuthService\"\nexport type { AuthServiceProps, AuthType, AuthTokenResult, AuthJwtToken, AuthGetTokenProps } from \"@/services/auth/AuthService\"\nexport { AccessKeyService, accessKeyUserTypes, accessKeyStatus } from \"@/services/access_key/AccessKeyService\"\nexport type { AccessKeyServiceProps, AccessKeyStatus, AccessKeyUserType, AccessKeyCreateProps, AccessKeyRevokeProps } from \"@/services/access_key/AccessKeyService\"\nexport { AccessControlService } from \"@/services/access_control/AccessControlService\"\nexport type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessControlListOptionsProps } from \"@/services/access_control/AccessControlService\"\nexport { ResetPasswordService, resetPasswordMethods } from \"@/services/reset_password/ResetPasswordService\"\nexport type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services/reset_password/ResetPasswordService\"\nexport { AccountService } from \"@/services/account/AccountService\"\nexport type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from \"@/services/account/AccountService\"\nexport { BusinessService } from \"@/services/business/BusinessService\"\nexport type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from \"@/services/business/BusinessService\"\n\nexport { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from \"@/services/subscription/plan/SubscribePlanService\"\nexport type { SubscribePlanServiceProps, SubscribePlan, SubscribePlanBillingCycle, SubscribePlanCurrency, SubscribePlanGetProps, SubscribePlanListProps, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services/subscription/plan/SubscribePlanService\"\nexport { AccountSubscribeService } from \"@/services/subscription/account/AccountSubscribeService\"\nexport type { AccountSubscribeServiceProps, AccountSubscribe, AccountSubscribeGetProps, AccountSubscribeListProps, AccountSubscribeCreateProps, AccountSubscribeCancelProps } from \"@/services/subscription/account/AccountSubscribeService\"\n\nexport { UserService, userTypes, userParentSqlSelect } from \"@/services/user/UserService\"\nexport type { UserServiceProps, UserType, UserGetProps, UserListProps, UserCreateProps, UserUpdateProps, UserRemoveProps, UserReplacePasswordProps } from \"@/services/user/UserService\"\n\nexport { UserMeService } from \"@/services/user/UserMeService\"\nexport type { UserMeServiceProps, UserMeUpdateProps, UserMeChangePasswordProps } from \"@/services/user/UserMeService\"\n\nexport { AccessControlRoleService } from \"@/services/access_control/AccessControlRoleService\"\nexport type { AccessControlRoleServiceProps, AccessControlRoleUserType, AccessControlRoleGetProps, AccessControlRoleListProps, AccessControlRoleCreateProps, AccessControlRoleUpdateProps, AccessControlRoleRemoveProps } from \"@/services/access_control/AccessControlRoleService\"\n\nexport { AccessControlUserService } from \"@/services/access_control/AccessControlUserService\"\nexport type { AccessControlUserServiceProps, AccessControlUserAssignRolesProps } from \"@/services/access_control/AccessControlUserService\"\n\nexport { UserBranchService, userBranchTypes } from \"@/services/branch/UserBranchService\"\nexport type { UserBranchServiceProps, UserBranchType, UserBranchGetProps, UserBranchListProps, UserBranchCreateProps, UserBranchUpdateProps, UserBranchRemoveProps } from \"@/services/branch/UserBranchService\"\nexport { RegionService } from \"@/services/region/RegionService\"\nexport type { RegionServiceProps, RegionType, RegionGetProps, RegionCreateProps, RegionListProps, RegionUpdateProps, RegionRemoveProps } from \"@/services/region/RegionService\"\nexport { DocumentService } from \"@/services/document/DocumentService\"\nexport type { DocumentServiceProps, DocumentType, DocumentGetProps, DocumentUpdateProps, DocumentCreateProps, DocumentListProps, DocumentRemoveProps } from \"@/services/document/DocumentService\"\nexport { ItemService, itemTypes } from \"@/services/item/ItemService\"\nexport type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCreateProps, ItemListProps, ItemRemoveProps } from \"@/services/item/ItemService\"\nexport { RepositoryService, repositoryTypes } from \"@/services/repository/RepositoryService\"\nexport type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from \"@/services/repository/RepositoryService\"\nexport { FileService } from \"@/services/file/FileService\"\nexport type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, ImageCompressionProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from \"@/services/file/FileService\"\nexport { LocationService } from \"@/services/location/LocationService\"\nexport type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from \"@/services/location/LocationService\"\nexport { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from \"@/services/injection_field/InjectionFieldService\"\nexport type { InjectionFieldModuleRef, InjectionFieldServiceProps, InjectionFieldType, InjectionFieldDataType, InjectionFieldCreateProps, InjectionFieldListProps, InjectionFieldGetProps, InjectionFieldReplaceProps } from \"@/services/injection_field/InjectionFieldService\"\nexport { NumberDateSequenceService } from \"@/services/others/NumberDateSequenceService\"\nexport type { NumberDateSequenceModuleRef, NumberDateSequenceServiceProps, NumberDateSequenceInitProps, NumberDateSequenceCreateProps } from \"@/services/others/NumberDateSequenceService\"\nexport { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeCodeStatus } from \"@/services/one_time_code/OneTimeCodeService\"\nexport type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from \"@/services/one_time_code/OneTimeCodeService\"\nexport { SmtpEmailService } from \"@/services/gateway/SmtpEmailService\"\nexport type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from \"@/services/gateway/SmtpEmailService\"\n\nexport { SchedulerLogService, schedulerLogTypes } from \"@/services/scheduler/SchedulerLogService\"\nexport type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from \"@/services/scheduler/SchedulerLogService\"\nexport { SchedulerRequestService } from \"@/services/scheduler/SchedulerRequestService\"\nexport type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from \"@/services/scheduler/SchedulerRequestService\"\nexport { SchedulerSqlService } from \"@/services/scheduler/SchedulerSqlService\"\nexport type { SchedulerSqlServiceProps, SchedulerSqlExecuteProps } from \"@/services/scheduler/SchedulerSqlService\"\n\n// export { ChangePasswordUtilService } from \"@/services/utils/unuse/ChangePasswordUtilService\"\n// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from \"@/services/utils/unuse/ChangePasswordUtilService\"\nexport { AccessKeyUtilService } from \"@/services/utils/AccessKeyUtilService\"\nexport type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from \"@/services/utils/AccessKeyUtilService\""]}
@@ -70,34 +70,34 @@ let defaultSqlSelect = {
70
70
  // ''
71
71
  // )`]: "location_name",
72
72
  // }
73
- let groupOwnerSqlSelect = {
74
- [`COALESCE(
75
- STRING_AGG(DISTINCT grp.${models_1.ModelGroupFields.group_id}::text, ', '),
76
- ''
77
- )`]: "access_group_id",
78
- [`COALESCE(
79
- STRING_AGG(DISTINCT grp.${models_1.ModelGroupFields.group_label}::text, ', '),
80
- ''
81
- )`]: "access_group_label",
82
- [`COALESCE(
83
- STRING_AGG(DISTINCT grp.${models_1.ModelGroupFields.group_description}::text, ', '),
84
- ''
85
- )`]: "access_group_description",
86
- [`COALESCE(
87
- STRING_AGG(DISTINCT grp.${models_1.ModelGroupFields.group_type}::text, ', '),
88
- ''
89
- )`]: "access_group_type"
90
- // [`COALESCE(
91
- // JSON_AGG(
92
- // DISTINCT JSONB_BUILD_OBJECT(
93
- // '${ModelGroupFields.group_label}', grp.group_label,
94
- // '${ModelGroupFields.group_id}', grp.group_id,
95
- // '${ModelGroupFields.group_type}', grp.group_type
96
- // )
97
- // ) FILTER (WHERE grp.group_id IS NOT NULL AND grp.isdelete = false AND grp.istrash = false),
98
- // '[]'
99
- // )`]: "grp"
100
- };
73
+ // let groupOwnerSqlSelect = {
74
+ // [`COALESCE(
75
+ // STRING_AGG(DISTINCT grp.${ModelGroupFields.group_id}::text, ', '),
76
+ // ''
77
+ // )`]: "access_group_id",
78
+ // [`COALESCE(
79
+ // STRING_AGG(DISTINCT grp.${ModelGroupFields.group_label}::text, ', '),
80
+ // ''
81
+ // )`]: "access_group_label",
82
+ // [`COALESCE(
83
+ // STRING_AGG(DISTINCT grp.${ModelGroupFields.group_description}::text, ', '),
84
+ // ''
85
+ // )`]: "access_group_description",
86
+ // [`COALESCE(
87
+ // STRING_AGG(DISTINCT grp.${ModelGroupFields.group_type}::text, ', '),
88
+ // ''
89
+ // )`]: "access_group_type"
90
+ // // [`COALESCE(
91
+ // // JSON_AGG(
92
+ // // DISTINCT JSONB_BUILD_OBJECT(
93
+ // // '${ModelGroupFields.group_label}', grp.group_label,
94
+ // // '${ModelGroupFields.group_id}', grp.group_id,
95
+ // // '${ModelGroupFields.group_type}', grp.group_type
96
+ // // )
97
+ // // ) FILTER (WHERE grp.group_id IS NOT NULL AND grp.isdelete = false AND grp.istrash = false),
98
+ // // '[]'
99
+ // // )`]: "grp"
100
+ // }
101
101
  const AdministratorService = (props) => {
102
102
  const { ...rest } = props;
103
103
  const administratorModel = (0, models_1.AdministratorModel)({ ...rest });
@@ -165,7 +165,7 @@ const AdministratorService = (props) => {
165
165
  (0, lib_1.buildSqlSelect)(``, defaultSqlSelect),
166
166
  // buildSqlSelect(``, userStatusIsOwnerSqlSelect),
167
167
  // buildSqlSelect(``, userPropLocationSqlSelect),
168
- (0, lib_1.buildSqlSelect)(``, groupOwnerSqlSelect)
168
+ // buildSqlSelect(``, groupOwnerSqlSelect)
169
169
  ];
170
170
  let sqlRelation = [
171
171
  (0, lib_1.buildSqlRelation)("left", "adm", "users", "usr", ["adm.user_id = usr.user_id", "usr.isdelete = false", "usr.istrash = false"]),
@@ -1 +1 @@
1
- {"version":3,"file":"AdministratorService.js","sourceRoot":"","sources":["../../../src/services/user/AdministratorService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAOkB;AAElB,yCAAwE;AAMxE,+BAAgK;AAEhK,+BAAuC;AAI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wBAAwB;IACxB,0BAA0B;IAC1B,4BAA4B;IAC5B,mBAAmB;IACnB,IAAI;IAEJ,MAAM,aAAa,GAAG;QAClB,gBAAgB,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE;QACnI,0BAA0B,EAAE,EAAE,EAAE,EAAE,0BAA0B,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,+BAA+B,EAAE;QACnK,kBAAkB,EAAE,EAAE,EAAE,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE;QACzI,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE;QAC5I,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE;QAC5I,oBAAoB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE;QAC/I,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,6BAA6B,EAAE;KACxI,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,sBAAsB,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEvE,CAAC,CAAA;AAlSY,QAAA,oBAAoB,wBAkShC","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n AdministratorModel,\n ModelAdministratorFields,\n ModelGroupFields,\n // ModelUserPropFields,\n ModelLocationFields\n} from \"@/models\";\n\nimport { InjectionFieldService, userParentSqlSelect } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nexport type UserType = \"administrator\"\n\nexport const administratorDataTypes = {\n location: \"location\",\n locationCount: \"location_count\",\n administratorInjectionFields: \"administrator_injection_fields\",\n parentUser: \"parent_user\"\n}\n\nexport type AdministratorDataType = keyof typeof administratorDataTypes;\n\nexport type AdministratorServiceProps = DefaultServiceProps & {};\n\nexport type AdministratorGetProps = {\n id: number,\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorGetByUsernameProps = {\n username: string,\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorListProps = QueryList & {\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorRemoveProps = {\n userIds: BigInt[]\n};\n\nexport type AdministratorCreateProps = {\n data:\n // administrator\n {\n administrator: {\n userId: number,\n isOwner: boolean\n }\n }\n}\n\nexport type AdministratorUpdateProps = {\n userId: number,\n data:\n // administrator\n {\n administrator: {\n // userId: number,\n }\n }\n}\n\nconst getCreatePayload = (data: AdministratorCreateProps[\"data\"]) => {\n\n if (\"administrator\" in data) {\n\n return {\n [`${ModelAdministratorFields.user_id}`]: data.administrator.userId,\n [`${ModelAdministratorFields.is_owner}`]: Boolean(data.administrator.isOwner),\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = (data: AdministratorUpdateProps[\"data\"]) => {\n\n if (\"administrator\" in data) {\n\n return {\n // [`${ModelAdministratorFields.user_id}`]: data.administrator.userId,\n }\n }\n\n return false\n\n}\n\nlet mainSqlSelect = {\n [`adm.${ModelAdministratorFields.administrator_id}`]: \"administrator_id\",\n [`adm.${ModelAdministratorFields.user_id}`]: \"user_id\",\n [`adm.${ModelAdministratorFields.is_owner}`]: \"is_owner\",\n}\n\nlet userSqlSelect = {\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`adm.${ModelAdministratorFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`adm.${ModelAdministratorFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`adm.${ModelAdministratorFields.isdelete}`]: \"isdelete\",\n [`adm.${ModelAdministratorFields.istrash}`]: \"istrash\",\n [`adm.${ModelAdministratorFields.accountid}`]: \"accountid\",\n}\n\n// let userStatusIsOwnerSqlSelect = {\n// [`COALESCE(usrsta_isowner.${ModelUserStatusFields.status}::int, 0)`]: \"is_owner\"\n// }\n\n// let userPropLocationSqlSelect = {\n// [`COALESCE(usrprop_location.${ModelUserPropFields.props_id}::int, 0)`]: \"location_id\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT usrprop_location.${ModelUserPropFields.props_id}::text, ', '),\n// ''\n// )`]: \"location_id\",\n// [`COALESCE(location.${ModelLocationFields.location_name}::text, '')`]: \"location_name\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT location.${ModelLocationFields.location_name}::text, ', '),\n// ''\n// )`]: \"location_name\",\n// }\n\nlet groupOwnerSqlSelect = {\n [`COALESCE(\n STRING_AGG(DISTINCT grp.${ModelGroupFields.group_id}::text, ', '),\n ''\n )`]: \"access_group_id\",\n [`COALESCE(\n STRING_AGG(DISTINCT grp.${ModelGroupFields.group_label}::text, ', '),\n ''\n )`]: \"access_group_label\",\n [`COALESCE(\n STRING_AGG(DISTINCT grp.${ModelGroupFields.group_description}::text, ', '),\n ''\n )`]: \"access_group_description\",\n [`COALESCE(\n STRING_AGG(DISTINCT grp.${ModelGroupFields.group_type}::text, ', '),\n ''\n )`]: \"access_group_type\"\n // [`COALESCE(\n // JSON_AGG(\n // DISTINCT JSONB_BUILD_OBJECT(\n // '${ModelGroupFields.group_label}', grp.group_label,\n // '${ModelGroupFields.group_id}', grp.group_id,\n // '${ModelGroupFields.group_type}', grp.group_type\n // )\n // ) FILTER (WHERE grp.group_id IS NOT NULL AND grp.isdelete = false AND grp.istrash = false), \n // '[]'\n // )`]: \"grp\"\n}\n\nexport const AdministratorService = (props: AdministratorServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const administratorModel = AdministratorModel({ ...rest })\n\n const injectionFieldService = InjectionFieldService({ ...rest, injectionFieldType: \"user\" })\n\n const createAdministrator = async ({ data }: AdministratorCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create administrator payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await administratorModel.create({ data: _data })\n\n return response\n }\n\n const updateAdministrator = async ({ userId, data }: AdministratorUpdateProps) => {\n\n const _data = getUpdatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid update administrator payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await administratorModel.update({ where: { [`${ModelAdministratorFields.user_id}`]: userId }, data: _data })\n\n return response\n }\n\n const getAdministrator = async ({ id, datatypes = [], includePassword = false, skipFilterAccountId = false }: AdministratorGetProps) => {\n\n let { data } = await listAdministrators({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId\n })\n\n return data[0] ?? null;\n\n };\n\n const getAdministratorByUsername = async ({ username = \"\", includePassword = false, datatypes = [], skipFilterAccountId = false }: AdministratorGetByUsernameProps) => {\n\n let { data } = await listAdministrators({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [\n { field: `username`, operator: \"=\", value: `${username}` },\n { field: `user_type`, operator: \"=\", value: `administrator` },\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId\n })\n\n return data[0] ?? null;\n\n };\n\n const listAdministrators = async ({\n includePassword = false,\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = [],\n skipFilterAccountId = false\n }: AdministratorListProps) => {\n\n let data = []\n\n if (includePassword === true) {\n userSqlSelect = {\n ...userSqlSelect,\n [`usr.${ModelUserFields.login_password}`]: \"password\",\n }\n } else {\n delete userSqlSelect[`usr.${ModelUserFields.login_password}`];\n }\n\n let sqlSelect = [\n `COUNT(*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, userSqlSelect),\n buildSqlSelect(``, defaultSqlSelect),\n // buildSqlSelect(``, userStatusIsOwnerSqlSelect),\n // buildSqlSelect(``, userPropLocationSqlSelect),\n buildSqlSelect(``, groupOwnerSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"adm\", \"users\", \"usr\", [\"adm.user_id = usr.user_id\", \"usr.isdelete = false\", \"usr.istrash = false\"]),\n buildSqlRelation(\"left\", \"adm\", \"users\", \"creator\", [\"adm.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"adm\", \"users\", \"updater\", [\"adm.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"user_status\", \"usrsta_isowner\", [\"adm.user_id = usrsta_isowner.user_id\", \"usrsta_isowner.type = 'IS_OWNER'\", \"usrsta_isowner.isdelete = false\", \"usrsta_isowner.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"user_props\", \"usrprop_location\", [\"adm.user_id = usrprop_location.user_id\", \"usrprop_location.type = 'LOCATION_ID'\", \"usrprop_location.isdelete = false\", \"usrprop_location.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"locations\", \"location\", [\"usrprop_location.props_id = location.location_id\", \"location.isdelete = false\", \"location.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"group_owners\", \"grpown\", [\"adm.user_id = grpown.user_id\", \"grpown.isdelete = false\", \"grpown.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"groups\", \"grp\", [\"grpown.group_id = grp.group_id\", \"grp.isdelete = false\", \"grp.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(userSqlSelect),\n // ...Object.keys(userStatusIsOwnerSqlSelect),\n // ...Object.keys(userPropLocationSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...userSqlSelect,\n // ...userStatusIsOwnerSqlSelect,\n // ...userPropLocationSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(administratorDataTypes.administratorInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"user\", \"administrator\")\n\n const administratorInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"uif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...administratorInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, ...(activeInjectionFields.length > 0 ? [buildSqlSelect(``, administratorInjectionFieldSqlSelect)] : [])]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"adm\", \"user_injection_fields\", \"uif\", [\"adm.user_id = uif.user_id\", \"uif.field_ref = 'user'\", \"uif.field_module = 'administrator'\", \"uif.isdelete = false\", \"uif.istrash = false\"])]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(administratorInjectionFieldSqlSelect)]\n }\n\n if (datatypes.includes(administratorDataTypes.location)) {\n\n let locationSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelLocationFields.location_id}', location.location_id,\n '${ModelLocationFields.location_code}', location.location_code,\n '${ModelLocationFields.location_name}', location.location_name,\n '${ModelLocationFields.location_type}', location.location_type,\n '${ModelLocationFields.address_1}', location.address_1,\n '${ModelLocationFields.address_2}', location.address_2,\n '${ModelLocationFields.area_id}', location.area_id,\n '${ModelLocationFields.country_id}', location.country_id,\n '${ModelLocationFields.state_id}', location.state_id,\n '${ModelLocationFields.postcode}', location.postcode,\n '${ModelLocationFields.is_default}', location.is_default,\n '${ModelLocationFields.person_contact}', location.person_contact,\n '${ModelLocationFields.person_name}', location.person_contact,\n '${ModelLocationFields.person_email}', location.person_email,\n '${ModelLocationFields.isdelete}', location.isdelete,\n '${ModelLocationFields.istrash}', location.istrash\n )\n ) FILTER (WHERE location.location_id IS NOT NULL AND location.isdelete = false AND location.istrash = false), \n '[]'\n )`]: \"locations\"\n }\n\n filterColumns = { ...filterColumns, ...locationSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, locationSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"usrprop_location\", \"location\", \"brn\", [\"adm.user_id = brn.user_id\", \"brn.isdelete = false\", \"brn.istrash = false\"])]\n\n }\n\n if (datatypes.includes(administratorDataTypes.locationCount)) {\n\n let locationCountSqlSelect = {\n [`COUNT(DISTINCT location.${ModelLocationFields.location_id})::INT`]: \"location_count\"\n }\n\n filterColumns = { ...filterColumns, ...locationCountSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, locationCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branches\", \"brncount\", [\"adm.user_id = brncount.user_id\", \"brncount.isdelete = false\", \"brncount.istrash = false\"])]\n\n }\n\n if (datatypes.includes(administratorDataTypes.parentUser)) {\n\n filterColumns = { ...filterColumns, ...userParentSqlSelect }\n\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"wrk\", \"users\", \"parentuser\", [\"usr.parent_user_id = parentuser.user_id\", \"parentuser.isdelete = false\", \"parentuser.istrash = false\"])]\n sqlSelect = [...sqlSelect, buildSqlSelect(``, userParentSqlSelect)]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(userParentSqlSelect)]\n\n }\n\n // if (datatypes.includes(customerDataTypes.branchUserCount)) {\n\n // let branchUserCountSqlSelect = {\n // [`COUNT(DISTINCT brnusrcount.${ModelBranchUserFields.branch_user_id})::INT`]: \"branch_user_count\"\n // }\n\n // filterColumns = { ...filterColumns, ...branchUserCountSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, branchUserCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branch_users\", \"brnusrcount\", [\"adm.user_id = brnusrcount.user_id\", \"brnusrcount.isdelete = false\", \"brnusrcount.istrash = false\"])]\n\n // }\n\n let sqlWhere = [\n `adm.isdelete = false`,\n `adm.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"administrators\",\n mainAlias: \"adm\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await administratorModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n\n };\n\n const removeAdministrators = async ({ userIds }: AdministratorRemoveProps) => {\n\n if (!userIds.length) throwError('userIds is required');\n\n const response = await administratorModel.remove({\n where: {\n [`${ModelAdministratorFields.user_id}`]: {\n in: userIds\n },\n [`${ModelAdministratorFields.is_owner}`]: false // cannot default is_owner account\n }\n });\n\n return response\n };\n\n const getDataTypes = () => {\n return Object.values(administratorDataTypes);\n }\n\n // return {\n // createAdministrator,\n // updateAdministrator,\n // getAdministrator,\n // listAdministrators,\n // removeAdministrators,\n // getDataTypes\n // }\n\n const methodConfigs = {\n getAdministrator: { fn: getAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator\" },\n getAdministratorByUsername: { fn: getAdministratorByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator by username\" },\n listAdministrators: { fn: listAdministrators, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list administrators\" },\n createAdministrator: { fn: createAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create administrator\" },\n updateAdministrator: { fn: updateAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update administrator\" },\n removeAdministrators: { fn: removeAdministrators, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove administrators\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator datatypes\" },\n };\n\n return ServiceFactory(\"AdministratorService\", rest, methodConfigs);\n\n}\n\n"]}
1
+ {"version":3,"file":"AdministratorService.js","sourceRoot":"","sources":["../../../src/services/user/AdministratorService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAOkB;AAElB,yCAAwE;AAMxE,+BAAgK;AAEhK,+BAAuC;AAI1B,QAAA,sBAAsB,GAAG;IAClC,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,gBAAgB;IAC/B,4BAA4B,EAAE,gCAAgC;IAC9D,UAAU,EA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;QACnI,0BAA0B,EAAE,EAAE,EAAE,EAAE,0BAA0B,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,+BAA+B,EAAE;QACnK,kBAAkB,EAAE,EAAE,EAAE,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE;QACzI,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE;QAC5I,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE;QAC5I,oBAAoB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE;QAC/I,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,6BAA6B,EAAE;KACxI,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,sBAAsB,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEvE,CAAC,CAAA;AAlSY,QAAA,oBAAoB,wBAkShC","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n AdministratorModel,\n ModelAdministratorFields,\n ModelGroupFields,\n // ModelUserPropFields,\n ModelLocationFields\n} from \"@/models\";\n\nimport { InjectionFieldService, userParentSqlSelect } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nexport type UserType = \"administrator\"\n\nexport const administratorDataTypes = {\n location: \"location\",\n locationCount: \"location_count\",\n administratorInjectionFields: \"administrator_injection_fields\",\n parentUser: \"parent_user\"\n}\n\nexport type AdministratorDataType = keyof typeof administratorDataTypes;\n\nexport type AdministratorServiceProps = DefaultServiceProps & {};\n\nexport type AdministratorGetProps = {\n id: number,\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorGetByUsernameProps = {\n username: string,\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorListProps = QueryList & {\n includePassword?: boolean\n datatypes: AdministratorDataType[]\n skipFilterAccountId?: boolean\n};\n\nexport type AdministratorRemoveProps = {\n userIds: BigInt[]\n};\n\nexport type AdministratorCreateProps = {\n data:\n // administrator\n {\n administrator: {\n userId: number,\n isOwner: boolean\n }\n }\n}\n\nexport type AdministratorUpdateProps = {\n userId: number,\n data:\n // administrator\n {\n administrator: {\n // userId: number,\n }\n }\n}\n\nconst getCreatePayload = (data: AdministratorCreateProps[\"data\"]) => {\n\n if (\"administrator\" in data) {\n\n return {\n [`${ModelAdministratorFields.user_id}`]: data.administrator.userId,\n [`${ModelAdministratorFields.is_owner}`]: Boolean(data.administrator.isOwner),\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = (data: AdministratorUpdateProps[\"data\"]) => {\n\n if (\"administrator\" in data) {\n\n return {\n // [`${ModelAdministratorFields.user_id}`]: data.administrator.userId,\n }\n }\n\n return false\n\n}\n\nlet mainSqlSelect = {\n [`adm.${ModelAdministratorFields.administrator_id}`]: \"administrator_id\",\n [`adm.${ModelAdministratorFields.user_id}`]: \"user_id\",\n [`adm.${ModelAdministratorFields.is_owner}`]: \"is_owner\",\n}\n\nlet userSqlSelect = {\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`adm.${ModelAdministratorFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`adm.${ModelAdministratorFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`adm.${ModelAdministratorFields.isdelete}`]: \"isdelete\",\n [`adm.${ModelAdministratorFields.istrash}`]: \"istrash\",\n [`adm.${ModelAdministratorFields.accountid}`]: \"accountid\",\n}\n\n// let userStatusIsOwnerSqlSelect = {\n// [`COALESCE(usrsta_isowner.${ModelUserStatusFields.status}::int, 0)`]: \"is_owner\"\n// }\n\n// let userPropLocationSqlSelect = {\n// [`COALESCE(usrprop_location.${ModelUserPropFields.props_id}::int, 0)`]: \"location_id\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT usrprop_location.${ModelUserPropFields.props_id}::text, ', '),\n// ''\n// )`]: \"location_id\",\n// [`COALESCE(location.${ModelLocationFields.location_name}::text, '')`]: \"location_name\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT location.${ModelLocationFields.location_name}::text, ', '),\n// ''\n// )`]: \"location_name\",\n// }\n\n// let groupOwnerSqlSelect = {\n// [`COALESCE(\n// STRING_AGG(DISTINCT grp.${ModelGroupFields.group_id}::text, ', '),\n// ''\n// )`]: \"access_group_id\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT grp.${ModelGroupFields.group_label}::text, ', '),\n// ''\n// )`]: \"access_group_label\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT grp.${ModelGroupFields.group_description}::text, ', '),\n// ''\n// )`]: \"access_group_description\",\n// [`COALESCE(\n// STRING_AGG(DISTINCT grp.${ModelGroupFields.group_type}::text, ', '),\n// ''\n// )`]: \"access_group_type\"\n// // [`COALESCE(\n// // JSON_AGG(\n// // DISTINCT JSONB_BUILD_OBJECT(\n// // '${ModelGroupFields.group_label}', grp.group_label,\n// // '${ModelGroupFields.group_id}', grp.group_id,\n// // '${ModelGroupFields.group_type}', grp.group_type\n// // )\n// // ) FILTER (WHERE grp.group_id IS NOT NULL AND grp.isdelete = false AND grp.istrash = false), \n// // '[]'\n// // )`]: \"grp\"\n// }\n\nexport const AdministratorService = (props: AdministratorServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const administratorModel = AdministratorModel({ ...rest })\n\n const injectionFieldService = InjectionFieldService({ ...rest, injectionFieldType: \"user\" })\n\n const createAdministrator = async ({ data }: AdministratorCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create administrator payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await administratorModel.create({ data: _data })\n\n return response\n }\n\n const updateAdministrator = async ({ userId, data }: AdministratorUpdateProps) => {\n\n const _data = getUpdatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid update administrator payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await administratorModel.update({ where: { [`${ModelAdministratorFields.user_id}`]: userId }, data: _data })\n\n return response\n }\n\n const getAdministrator = async ({ id, datatypes = [], includePassword = false, skipFilterAccountId = false }: AdministratorGetProps) => {\n\n let { data } = await listAdministrators({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId\n })\n\n return data[0] ?? null;\n\n };\n\n const getAdministratorByUsername = async ({ username = \"\", includePassword = false, datatypes = [], skipFilterAccountId = false }: AdministratorGetByUsernameProps) => {\n\n let { data } = await listAdministrators({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [\n { field: `username`, operator: \"=\", value: `${username}` },\n { field: `user_type`, operator: \"=\", value: `administrator` },\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId\n })\n\n return data[0] ?? null;\n\n };\n\n const listAdministrators = async ({\n includePassword = false,\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = [],\n skipFilterAccountId = false\n }: AdministratorListProps) => {\n\n let data = []\n\n if (includePassword === true) {\n userSqlSelect = {\n ...userSqlSelect,\n [`usr.${ModelUserFields.login_password}`]: \"password\",\n }\n } else {\n delete userSqlSelect[`usr.${ModelUserFields.login_password}`];\n }\n\n let sqlSelect = [\n `COUNT(*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, userSqlSelect),\n buildSqlSelect(``, defaultSqlSelect),\n // buildSqlSelect(``, userStatusIsOwnerSqlSelect),\n // buildSqlSelect(``, userPropLocationSqlSelect),\n // buildSqlSelect(``, groupOwnerSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"adm\", \"users\", \"usr\", [\"adm.user_id = usr.user_id\", \"usr.isdelete = false\", \"usr.istrash = false\"]),\n buildSqlRelation(\"left\", \"adm\", \"users\", \"creator\", [\"adm.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"adm\", \"users\", \"updater\", [\"adm.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"user_status\", \"usrsta_isowner\", [\"adm.user_id = usrsta_isowner.user_id\", \"usrsta_isowner.type = 'IS_OWNER'\", \"usrsta_isowner.isdelete = false\", \"usrsta_isowner.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"user_props\", \"usrprop_location\", [\"adm.user_id = usrprop_location.user_id\", \"usrprop_location.type = 'LOCATION_ID'\", \"usrprop_location.isdelete = false\", \"usrprop_location.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"locations\", \"location\", [\"usrprop_location.props_id = location.location_id\", \"location.isdelete = false\", \"location.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"group_owners\", \"grpown\", [\"adm.user_id = grpown.user_id\", \"grpown.isdelete = false\", \"grpown.istrash = false\"]),\n // buildSqlRelation(\"left\", \"adm\", \"groups\", \"grp\", [\"grpown.group_id = grp.group_id\", \"grp.isdelete = false\", \"grp.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(userSqlSelect),\n // ...Object.keys(userStatusIsOwnerSqlSelect),\n // ...Object.keys(userPropLocationSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...userSqlSelect,\n // ...userStatusIsOwnerSqlSelect,\n // ...userPropLocationSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(administratorDataTypes.administratorInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"user\", \"administrator\")\n\n const administratorInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"uif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...administratorInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, ...(activeInjectionFields.length > 0 ? [buildSqlSelect(``, administratorInjectionFieldSqlSelect)] : [])]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"adm\", \"user_injection_fields\", \"uif\", [\"adm.user_id = uif.user_id\", \"uif.field_ref = 'user'\", \"uif.field_module = 'administrator'\", \"uif.isdelete = false\", \"uif.istrash = false\"])]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(administratorInjectionFieldSqlSelect)]\n }\n\n if (datatypes.includes(administratorDataTypes.location)) {\n\n let locationSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelLocationFields.location_id}', location.location_id,\n '${ModelLocationFields.location_code}', location.location_code,\n '${ModelLocationFields.location_name}', location.location_name,\n '${ModelLocationFields.location_type}', location.location_type,\n '${ModelLocationFields.address_1}', location.address_1,\n '${ModelLocationFields.address_2}', location.address_2,\n '${ModelLocationFields.area_id}', location.area_id,\n '${ModelLocationFields.country_id}', location.country_id,\n '${ModelLocationFields.state_id}', location.state_id,\n '${ModelLocationFields.postcode}', location.postcode,\n '${ModelLocationFields.is_default}', location.is_default,\n '${ModelLocationFields.person_contact}', location.person_contact,\n '${ModelLocationFields.person_name}', location.person_contact,\n '${ModelLocationFields.person_email}', location.person_email,\n '${ModelLocationFields.isdelete}', location.isdelete,\n '${ModelLocationFields.istrash}', location.istrash\n )\n ) FILTER (WHERE location.location_id IS NOT NULL AND location.isdelete = false AND location.istrash = false), \n '[]'\n )`]: \"locations\"\n }\n\n filterColumns = { ...filterColumns, ...locationSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, locationSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"usrprop_location\", \"location\", \"brn\", [\"adm.user_id = brn.user_id\", \"brn.isdelete = false\", \"brn.istrash = false\"])]\n\n }\n\n if (datatypes.includes(administratorDataTypes.locationCount)) {\n\n let locationCountSqlSelect = {\n [`COUNT(DISTINCT location.${ModelLocationFields.location_id})::INT`]: \"location_count\"\n }\n\n filterColumns = { ...filterColumns, ...locationCountSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, locationCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branches\", \"brncount\", [\"adm.user_id = brncount.user_id\", \"brncount.isdelete = false\", \"brncount.istrash = false\"])]\n\n }\n\n if (datatypes.includes(administratorDataTypes.parentUser)) {\n\n filterColumns = { ...filterColumns, ...userParentSqlSelect }\n\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"wrk\", \"users\", \"parentuser\", [\"usr.parent_user_id = parentuser.user_id\", \"parentuser.isdelete = false\", \"parentuser.istrash = false\"])]\n sqlSelect = [...sqlSelect, buildSqlSelect(``, userParentSqlSelect)]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(userParentSqlSelect)]\n\n }\n\n // if (datatypes.includes(customerDataTypes.branchUserCount)) {\n\n // let branchUserCountSqlSelect = {\n // [`COUNT(DISTINCT brnusrcount.${ModelBranchUserFields.branch_user_id})::INT`]: \"branch_user_count\"\n // }\n\n // filterColumns = { ...filterColumns, ...branchUserCountSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, branchUserCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branch_users\", \"brnusrcount\", [\"adm.user_id = brnusrcount.user_id\", \"brnusrcount.isdelete = false\", \"brnusrcount.istrash = false\"])]\n\n // }\n\n let sqlWhere = [\n `adm.isdelete = false`,\n `adm.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"administrators\",\n mainAlias: \"adm\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await administratorModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n\n };\n\n const removeAdministrators = async ({ userIds }: AdministratorRemoveProps) => {\n\n if (!userIds.length) throwError('userIds is required');\n\n const response = await administratorModel.remove({\n where: {\n [`${ModelAdministratorFields.user_id}`]: {\n in: userIds\n },\n [`${ModelAdministratorFields.is_owner}`]: false // cannot default is_owner account\n }\n });\n\n return response\n };\n\n const getDataTypes = () => {\n return Object.values(administratorDataTypes);\n }\n\n // return {\n // createAdministrator,\n // updateAdministrator,\n // getAdministrator,\n // listAdministrators,\n // removeAdministrators,\n // getDataTypes\n // }\n\n const methodConfigs = {\n getAdministrator: { fn: getAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator\" },\n getAdministratorByUsername: { fn: getAdministratorByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator by username\" },\n listAdministrators: { fn: listAdministrators, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list administrators\" },\n createAdministrator: { fn: createAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create administrator\" },\n updateAdministrator: { fn: updateAdministrator, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update administrator\" },\n removeAdministrators: { fn: removeAdministrators, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove administrators\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get administrator datatypes\" },\n };\n\n return ServiceFactory(\"AdministratorService\", rest, methodConfigs);\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.175",
3
+ "version": "1.0.177",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",
@@ -183,6 +183,7 @@
183
183
  "ffmpeg-static": "^5.2.0",
184
184
  "ffprobe-static": "^3.1.0",
185
185
  "fluent-ffmpeg": "^2.1.3",
186
+ "jimp": "^1.6.1",
186
187
  "nodemailer": "^6.10.1",
187
188
  "nodemailer-express-handlebars": "^7.0.0",
188
189
  "sharp": "^0.34.4",
@@ -967,6 +967,22 @@ model document_injection_fields {
967
967
  document_doc_id BigInt @default(0)
968
968
  }
969
969
 
970
+ model user_injection_fields {
971
+ user_injection_field_id BigInt @id @default(autoincrement())
972
+ createdatetime DateTime? @db.Timestamptz(6)
973
+ createuserid BigInt @default(0)
974
+ updatedatetime DateTime? @db.Timestamptz(6)
975
+ updateuserid BigInt @default(0)
976
+ isdelete Boolean @default(false)
977
+ istrash Boolean @default(false)
978
+ accountid BigInt @default(0)
979
+ field_module String? @db.VarChar(200)
980
+ field_ref String? @db.VarChar(200)
981
+ user_id BigInt @default(0)
982
+ branch_id BigInt @default(0)
983
+ member_id BigInt @default(0)
984
+ }
985
+
970
986
  // ============================================================
971
987
  // UTILS
972
988
  // ============================================================