storemw-core-api 1.0.147 → 1.0.149

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.
Files changed (55) hide show
  1. package/dist/app.js +1 -0
  2. package/dist/app.js.map +1 -1
  3. package/dist/controllers/index.d.ts +1 -0
  4. package/dist/controllers/index.js +6 -1
  5. package/dist/controllers/index.js.map +1 -1
  6. package/dist/controllers/scheduler/schedulerLogController.d.ts +9 -0
  7. package/dist/controllers/scheduler/schedulerLogController.js +133 -0
  8. package/dist/controllers/scheduler/schedulerLogController.js.map +1 -0
  9. package/dist/middlewares/route/index.d.ts +1 -0
  10. package/dist/middlewares/route/index.js +7 -2
  11. package/dist/middlewares/route/index.js.map +1 -1
  12. package/dist/middlewares/route/validateSchedulerLog.d.ts +5 -0
  13. package/dist/middlewares/route/validateSchedulerLog.js +20 -0
  14. package/dist/middlewares/route/validateSchedulerLog.js.map +1 -0
  15. package/dist/models/index.d.ts +2 -0
  16. package/dist/models/index.js +4 -1
  17. package/dist/models/index.js.map +1 -1
  18. package/dist/models/scheduler/SchedulerLogModel.d.ts +371 -0
  19. package/dist/models/scheduler/SchedulerLogModel.js +13 -0
  20. package/dist/models/scheduler/SchedulerLogModel.js.map +1 -0
  21. package/dist/routes/index.d.ts +1 -0
  22. package/dist/routes/index.js +3 -1
  23. package/dist/routes/index.js.map +1 -1
  24. package/dist/routes/scheduler/schedulerLogRoutes.d.ts +2 -0
  25. package/dist/routes/scheduler/schedulerLogRoutes.js +13 -0
  26. package/dist/routes/scheduler/schedulerLogRoutes.js.map +1 -0
  27. package/dist/routes/scheduler/schedulerLogsRoutes.d.ts +2 -0
  28. package/dist/routes/scheduler/schedulerLogsRoutes.js +13 -0
  29. package/dist/routes/scheduler/schedulerLogsRoutes.js.map +1 -0
  30. package/dist/routes/scheduler/schedulersRoutes.d.ts +2 -0
  31. package/dist/routes/scheduler/schedulersRoutes.js +12 -0
  32. package/dist/routes/scheduler/schedulersRoutes.js.map +1 -0
  33. package/dist/routes/user/userMeRoutes.js +2 -2
  34. package/dist/routes/user/userMeRoutes.js.map +1 -1
  35. package/dist/schema/middleware/route/index.d.ts +2 -0
  36. package/dist/schema/middleware/route/index.js +3 -1
  37. package/dist/schema/middleware/route/index.js.map +1 -1
  38. package/dist/schema/middleware/route/schemaSchedulerLog.d.ts +4 -0
  39. package/dist/schema/middleware/route/schemaSchedulerLog.js +10 -0
  40. package/dist/schema/middleware/route/schemaSchedulerLog.js.map +1 -0
  41. package/dist/schema/payload/index.d.ts +2 -0
  42. package/dist/schema/payload/index.js +4 -1
  43. package/dist/schema/payload/index.js.map +1 -1
  44. package/dist/schema/payload/scheduler/schemaSchedulerLog.d.ts +267 -0
  45. package/dist/schema/payload/scheduler/schemaSchedulerLog.js +48 -0
  46. package/dist/schema/payload/scheduler/schemaSchedulerLog.js.map +1 -0
  47. package/dist/services/file/FileService.js.map +1 -1
  48. package/dist/services/index.d.ts +2 -0
  49. package/dist/services/index.js +4 -1
  50. package/dist/services/index.js.map +1 -1
  51. package/dist/services/scheduler/SchedulerLogService.d.ts +101 -0
  52. package/dist/services/scheduler/SchedulerLogService.js +146 -0
  53. package/dist/services/scheduler/SchedulerLogService.js.map +1 -0
  54. package/package.json +1 -1
  55. package/prisma/schema.prisma +30 -0
@@ -1 +1 @@
1
- {"version":3,"file":"FileService.js","sourceRoot":"","sources":["../../../src/services/file/FileService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA+E;AAE/E,gDAAwB;AAExB,qCAGkB;AAElB,yEAAyH;AACzH,qFAAiJ;AACjJ,yEAAyH;AACzH,+EAAgG;AAQhG,+BAAuH;AAEvH,+BAGe;AAEf,yDAAsF;AAEtF,yDAAsF;AACtF,yCAAqI;AAQxH,QAAA,aAAa,GAAG,EAC5B,CAAA;AAiGD,IAAI,aAAa,GAAG,IAAA,4BAAsB,GAAE,CAAA;AAC5C,IAAI,gBAAgB,GAAG,IAAA,+BAAyB,GAAE,CAAA;AAElD,MAAM,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kBY,QAAA,WAAW,eAukBvB","sourcesContent":["import { _, logError, throwError, generateFileThumbnailBuffer } 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, FeatureFileStorageProps, FeatureFileStorageStartUploadProps, 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\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({\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({\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,mCAA+E;AAE/E,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;AAiG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X,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 } 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\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({\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({\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"]}
@@ -38,5 +38,7 @@ export { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeC
38
38
  export type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from "../services/one_time_code/OneTimeCodeService";
39
39
  export { SmtpEmailService } from "../services/gateway/SmtpEmailService";
40
40
  export type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from "../services/gateway/SmtpEmailService";
41
+ export { SchedulerLogService, schedulerLogTypes } from "../services/scheduler/SchedulerLogService";
42
+ export type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from "../services/scheduler/SchedulerLogService";
41
43
  export { AccessKeyUtilService } from "../services/utils/AccessKeyUtilService";
42
44
  export type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from "../services/utils/AccessKeyUtilService";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccessKeyUtilService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
3
+ exports.AccessKeyUtilService = exports.schedulerLogTypes = exports.SchedulerLogService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
4
4
  var AuthService_1 = require("../services/auth/AuthService");
5
5
  Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return AuthService_1.AuthService; } });
6
6
  Object.defineProperty(exports, "authTypes", { enumerable: true, get: function () { return AuthService_1.authTypes; } });
@@ -60,6 +60,9 @@ Object.defineProperty(exports, "oneTimeCodePurposeTypes", { enumerable: true, ge
60
60
  Object.defineProperty(exports, "oneTimeCodeStatus", { enumerable: true, get: function () { return OneTimeCodeService_1.oneTimeCodeStatus; } });
61
61
  var SmtpEmailService_1 = require("../services/gateway/SmtpEmailService");
62
62
  Object.defineProperty(exports, "SmtpEmailService", { enumerable: true, get: function () { return SmtpEmailService_1.SmtpEmailService; } });
63
+ var SchedulerLogService_1 = require("../services/scheduler/SchedulerLogService");
64
+ Object.defineProperty(exports, "SchedulerLogService", { enumerable: true, get: function () { return SchedulerLogService_1.SchedulerLogService; } });
65
+ Object.defineProperty(exports, "schedulerLogTypes", { enumerable: true, get: function () { return SchedulerLogService_1.schedulerLogTypes; } });
63
66
  // export { ChangePasswordUtilService } from "../services/utils/unuse/ChangePasswordUtilService"
64
67
  // export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from "../services/utils/unuse/ChangePasswordUtilService"
65
68
  var AccessKeyUtilService_1 = require("../services/utils/AccessKeyUtilService");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;A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AAEzF,wEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AAGzB,+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\n// export { AdministratorService, administratorDataTypes } from \"@/services/user/AdministratorService\"\n// export type { AdministratorServiceProps, AdministratorGetProps, AdministratorListProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorRemoveProps } from \"@/services/user/AdministratorService\"\n// export { OperatorService, operatorDataTypes } from \"@/services/user/OperatorService\"\n// export type { OperatorServiceProps, OperatorGetProps, OperatorListProps, OperatorCreateProps, OperatorUpdateProps, OperatorRemoveProps } from \"@/services/user/OperatorService\"\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 { 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\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,sGAAsG;AACtG,qNAAqN;AACrN,uFAAuF;AACvF,kLAAkL;AAElL,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,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;AAG/C,+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\n// export { AdministratorService, administratorDataTypes } from \"@/services/user/AdministratorService\"\n// export type { AdministratorServiceProps, AdministratorGetProps, AdministratorListProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorRemoveProps } from \"@/services/user/AdministratorService\"\n// export { OperatorService, operatorDataTypes } from \"@/services/user/OperatorService\"\n// export type { OperatorServiceProps, OperatorGetProps, OperatorListProps, OperatorCreateProps, OperatorUpdateProps, OperatorRemoveProps } from \"@/services/user/OperatorService\"\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 { 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\"\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\""]}
@@ -0,0 +1,101 @@
1
+ import { QueryList, QueryGet } from "../../schema/common";
2
+ import { DefaultServiceProps } from "../../utils";
3
+ import { InjectionFieldModuleRef } from "../../services";
4
+ export type SchedulerLogModuleRef = InjectionFieldModuleRef;
5
+ export type SchedulerLogServiceProps = DefaultServiceProps & {};
6
+ export type SchedulerLogGetProps = Omit<QueryGet, "datatypes"> & {
7
+ id: number;
8
+ };
9
+ export type SchedulerLogListProps = Omit<QueryList, "datatypes"> & {};
10
+ export type SchedulerLogRemoveProps = {
11
+ schedulerLogIds: BigInt[];
12
+ };
13
+ export declare const schedulerLogTypes: {
14
+ in: string;
15
+ out: string;
16
+ };
17
+ export type SchedulerLogFlowType = keyof typeof schedulerLogTypes;
18
+ export type SchedulerLog = {
19
+ schedulerTaskId: number;
20
+ flowType: SchedulerLogFlowType;
21
+ sourceType: string;
22
+ sourceEntityId: string;
23
+ sourceEntityLabel: string;
24
+ sourceEntityData: string;
25
+ destinationType: string;
26
+ destinationEntityId: string;
27
+ destinationEntityLabel: string;
28
+ destinationSubmitPayload: string;
29
+ destinationSubmitResponse: string;
30
+ logAction: string;
31
+ logLabel: string;
32
+ logStatus: boolean;
33
+ logMesssage: string;
34
+ };
35
+ export type SchedulerLogCreateProps = {
36
+ data: SchedulerLog & {
37
+ fieldRef: SchedulerLogModuleRef["field_ref"];
38
+ fieldModule: SchedulerLogModuleRef["field_module"];
39
+ };
40
+ };
41
+ export declare const SchedulerLogService: (props: SchedulerLogServiceProps) => {
42
+ getSchedulerLog: ({ id }: SchedulerLogGetProps) => Promise<any>;
43
+ createSchedulerLog: ({ data }: SchedulerLogCreateProps) => Promise<{
44
+ createdatetime: Date | null;
45
+ createuserid: bigint;
46
+ updatedatetime: Date | null;
47
+ updateuserid: bigint;
48
+ isdelete: boolean | null;
49
+ istrash: boolean | null;
50
+ accountid: bigint;
51
+ field_ref: string;
52
+ field_module: string;
53
+ scheduler_log_id: bigint;
54
+ scheduler_task_id: bigint;
55
+ flow_type: string;
56
+ log_action: string;
57
+ log_label: string;
58
+ log_status: boolean | null;
59
+ log_message: string | null;
60
+ source_type: string | null;
61
+ source_entity_id: string | null;
62
+ source_entity_label: string | null;
63
+ source_entity_data: string | null;
64
+ destination_type: string | null;
65
+ destination_entity_id: string | null;
66
+ destination_entity_label: string | null;
67
+ destination_submit_payload: string | null;
68
+ destination_submit_response: string | null;
69
+ }>;
70
+ removeSchedulerLoges: ({ schedulerLogIds }: SchedulerLogRemoveProps) => Promise<{
71
+ createdatetime: Date | null;
72
+ createuserid: bigint;
73
+ updatedatetime: Date | null;
74
+ updateuserid: bigint;
75
+ isdelete: boolean | null;
76
+ istrash: boolean | null;
77
+ accountid: bigint;
78
+ field_ref: string;
79
+ field_module: string;
80
+ scheduler_log_id: bigint;
81
+ scheduler_task_id: bigint;
82
+ flow_type: string;
83
+ log_action: string;
84
+ log_label: string;
85
+ log_status: boolean | null;
86
+ log_message: string | null;
87
+ source_type: string | null;
88
+ source_entity_id: string | null;
89
+ source_entity_label: string | null;
90
+ source_entity_data: string | null;
91
+ destination_type: string | null;
92
+ destination_entity_id: string | null;
93
+ destination_entity_label: string | null;
94
+ destination_submit_payload: string | null;
95
+ destination_submit_response: string | null;
96
+ }[]>;
97
+ listSchedulerLoges: ({ limit, offset, filters, sortfield, sortorder }: SchedulerLogListProps) => Promise<{
98
+ data: any[];
99
+ total: number;
100
+ }>;
101
+ };
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchedulerLogService = exports.schedulerLogTypes = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const models_1 = require("../../models");
6
+ const lib_1 = require("../../lib");
7
+ exports.schedulerLogTypes = {
8
+ in: "in",
9
+ out: "out"
10
+ };
11
+ const getCreatePayload = (data) => {
12
+ return {
13
+ [`${models_1.ModelSchedulerLogFields.scheduler_task_id}`]: Number(data.schedulerTaskId),
14
+ [`${models_1.ModelSchedulerLogFields.flow_type}`]: data.flowType,
15
+ [`${models_1.ModelSchedulerLogFields.log_action}`]: data.logAction,
16
+ [`${models_1.ModelSchedulerLogFields.field_module}`]: data.fieldRef,
17
+ [`${models_1.ModelSchedulerLogFields.field_ref}`]: data.fieldModule,
18
+ [`${models_1.ModelSchedulerLogFields.source_type}`]: data.sourceType,
19
+ [`${models_1.ModelSchedulerLogFields.source_entity_id}`]: data.sourceEntityId,
20
+ [`${models_1.ModelSchedulerLogFields.source_entity_label}`]: data.sourceEntityLabel,
21
+ [`${models_1.ModelSchedulerLogFields.source_entity_data}`]: data.sourceEntityData,
22
+ [`${models_1.ModelSchedulerLogFields.destination_type}`]: data.destinationType,
23
+ [`${models_1.ModelSchedulerLogFields.destination_entity_id}`]: data.destinationEntityId,
24
+ [`${models_1.ModelSchedulerLogFields.destination_entity_label}`]: data.destinationEntityLabel,
25
+ [`${models_1.ModelSchedulerLogFields.destination_submit_payload}`]: data.destinationSubmitPayload,
26
+ [`${models_1.ModelSchedulerLogFields.destination_submit_response}`]: data.destinationSubmitResponse,
27
+ [`${models_1.ModelSchedulerLogFields.log_label}`]: data.logLabel,
28
+ [`${models_1.ModelSchedulerLogFields.log_message}`]: data.logMesssage,
29
+ [`${models_1.ModelSchedulerLogFields.log_status}`]: Boolean(data.logStatus),
30
+ };
31
+ };
32
+ let mainSqlSelect = {
33
+ [`slog.${models_1.ModelSchedulerLogFields.scheduler_log_id}`]: "scheduler_log_id",
34
+ [`slog.${models_1.ModelSchedulerLogFields.scheduler_task_id}`]: "scheduler_task_id",
35
+ [`slog.${models_1.ModelSchedulerLogFields.field_module}`]: "field_module",
36
+ [`slog.${models_1.ModelSchedulerLogFields.field_ref}`]: "field_ref",
37
+ [`slog.${models_1.ModelSchedulerLogFields.flow_type}`]: "flow_type",
38
+ [`slog.${models_1.ModelSchedulerLogFields.destination_type}`]: "destination_type",
39
+ [`slog.${models_1.ModelSchedulerLogFields.destination_entity_id}`]: "destination_entity_id",
40
+ [`slog.${models_1.ModelSchedulerLogFields.destination_entity_label}`]: "destination_entity_label",
41
+ [`slog.${models_1.ModelSchedulerLogFields.destination_submit_payload}`]: "destination_submit_payload",
42
+ [`slog.${models_1.ModelSchedulerLogFields.destination_submit_response}`]: "destination_submit_response",
43
+ [`slog.${models_1.ModelSchedulerLogFields.source_type}`]: "source_type",
44
+ [`slog.${models_1.ModelSchedulerLogFields.source_entity_id}`]: "source_entity_id",
45
+ [`slog.${models_1.ModelSchedulerLogFields.source_entity_label}`]: "source_entity_label",
46
+ [`slog.${models_1.ModelSchedulerLogFields.source_entity_data}`]: "source_entity_data",
47
+ [`slog.${models_1.ModelSchedulerLogFields.log_action}`]: "log_action",
48
+ [`slog.${models_1.ModelSchedulerLogFields.log_label}`]: "log_label",
49
+ [`slog.${models_1.ModelSchedulerLogFields.log_message}`]: "log_message",
50
+ [`slog.${models_1.ModelSchedulerLogFields.log_status}`]: "log_status",
51
+ };
52
+ let defaultSqlSelect = {
53
+ [`slog.${models_1.ModelSchedulerLogFields.createdatetime}`]: "createdatetime",
54
+ [`creator.${models_1.ModelUserFields.login_username}`]: "createusername",
55
+ [`slog.${models_1.ModelSchedulerLogFields.updatedatetime}`]: "updatedatetime",
56
+ [`updater.${models_1.ModelUserFields.login_username}`]: "updateusername",
57
+ [`slog.${models_1.ModelSchedulerLogFields.isdelete}`]: "isdelete",
58
+ [`slog.${models_1.ModelSchedulerLogFields.istrash}`]: "istrash",
59
+ [`slog.${models_1.ModelSchedulerLogFields.accountid}`]: "accountid",
60
+ };
61
+ const SchedulerLogService = (props) => {
62
+ const { ...rest } = props;
63
+ const schedulerLogModel = (0, models_1.SchedulerLogModel)({ ...rest });
64
+ const createSchedulerLog = async ({ data }) => {
65
+ const _data = getCreatePayload(data);
66
+ if (!_data) {
67
+ throw new Error(`Invalid create scheduler log payload: ${JSON.stringify(_data)}`);
68
+ }
69
+ let response = await schedulerLogModel.create({ data: _data });
70
+ return response;
71
+ };
72
+ const getSchedulerLog = async ({ id }) => {
73
+ let { data } = await listSchedulerLoges({
74
+ limit: 1,
75
+ offset: 0,
76
+ filters: [{ field: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`, operator: "=", value: id }],
77
+ sortfield: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`,
78
+ sortorder: "ASC",
79
+ });
80
+ return data[0] ?? null;
81
+ };
82
+ const listSchedulerLoges = async ({ limit, offset, filters = [], sortfield, sortorder }) => {
83
+ let data = [];
84
+ let sqlSelect = [
85
+ `COUNT(slog.*) OVER() as filtered_count`,
86
+ (0, lib_1.buildSqlSelect)(``, mainSqlSelect),
87
+ // buildSqlSelect(``, regionSqlSelect),
88
+ (0, lib_1.buildSqlSelect)(``, defaultSqlSelect)
89
+ ];
90
+ let sqlRelation = [
91
+ // buildSqlRelation("left", "slog", "states", "slogstate", ["slog.state_id = slogstate.state_id", "slogstate.isdelete = false", "slogstate.istrash = false"]),
92
+ // buildSqlRelation("left", "slog", "countries", "slogcoun", ["slog.country_id = slogcoun.country_id", "slogcoun.isdelete = false", "slogcoun.istrash = false"]),
93
+ // buildSqlRelation("left", "slog", "areas", "slogarea", ["slog.area_id = slogarea.area_id", "slogarea.isdelete = false", "slogarea.istrash = false"]),
94
+ (0, lib_1.buildSqlRelation)("left", "slog", "users", "creator", ["slog.createuserid = creator.user_id", "creator.isdelete = false", "creator.istrash = false"]),
95
+ (0, lib_1.buildSqlRelation)("left", "slog", "users", "updater", ["slog.updateuserid = updater.user_id", "updater.isdelete = false", "updater.istrash = false"])
96
+ ];
97
+ let sqlGroupBy = [
98
+ ...Object.keys(mainSqlSelect),
99
+ // ...Object.keys(regionSqlSelect),
100
+ ...Object.keys(defaultSqlSelect)
101
+ ];
102
+ let filterColumns = {
103
+ ...mainSqlSelect,
104
+ // ...regionSqlSelect,
105
+ ...defaultSqlSelect
106
+ };
107
+ let sqlWhere = [
108
+ `slog.isdelete = false`,
109
+ `slog.istrash = false`,
110
+ ...(filters.length ? [(0, lib_1.buildSqlWhere)(filters, filterColumns)?.where] : []),
111
+ ];
112
+ let sqlOrderby = (0, lib_1.buildSqlOrderBy)(sortfield, sortorder);
113
+ let sqlLimitOffset = (0, lib_1.buildSqlLimitOffset)(limit, offset);
114
+ const sqlRaw = (0, lib_1.buildSqlRawSelect)({
115
+ tableName: "scheduler_logs",
116
+ mainAlias: "slog",
117
+ accountId: rest.accountId,
118
+ sqlSelect,
119
+ sqlRelation,
120
+ sqlWhere,
121
+ sqlGroupBy,
122
+ sqlOrderby,
123
+ sqlLimitOffset
124
+ });
125
+ data = await schedulerLogModel.raw(sqlRaw);
126
+ const response = {
127
+ data: data.map(({ filtered_count, ...rest }) => rest),
128
+ total: data.length ? Number(data[0].filtered_count) : 0
129
+ };
130
+ return response;
131
+ };
132
+ const removeSchedulerLoges = async ({ schedulerLogIds }) => {
133
+ if (!schedulerLogIds.length)
134
+ (0, utils_1.throwError)('schedulerLogIds is required');
135
+ const response = await schedulerLogModel.remove({ where: { [`${models_1.ModelSchedulerLogFields.scheduler_log_id}`]: { in: schedulerLogIds } } });
136
+ return response;
137
+ };
138
+ return {
139
+ getSchedulerLog,
140
+ createSchedulerLog,
141
+ removeSchedulerLoges,
142
+ listSchedulerLoges
143
+ };
144
+ };
145
+ exports.SchedulerLogService = SchedulerLogService;
146
+ //# sourceMappingURL=SchedulerLogService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchedulerLogService.js","sourceRoot":"","sources":["../../../src/services/scheduler/SchedulerLogService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAIkB;AAQlB,+BAAiI;AAiBpH,QAAA,iBAAiB,GAAG;IAC7B,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;CACb,CAAA;AAgCD,MAAM,gBAAgB,GAAG,CAAC,IAAqC,EAAE,EAAE;IAE/D,OAAO;QACH,CAAC,GAAG,gCAAuB,CAAC,iBAAiB,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;QAC9E,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QACvD,CAAC,GAAG,gCAAuB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS;QAEzD,CAAC,GAAG,gCAAuB,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QAC1D,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;QAE1D,CAAC,GAAG,gCAAuB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU;QAC3D,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc;QACpE,CAAC,GAAG,gCAAuB,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB;QAC1E,CAAC,GAAG,gCAAuB,CAAC,kBAAkB,EAAE,CAAC,EAAE,IAAI,CAAC,gBAAgB;QAExE,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,eAAe;QACrE,CAAC,GAAG,gCAAuB,CAAC,qBAAqB,EAAE,C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E1C,MAAM,QAAQ,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YACrD,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1D,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAAE,eAAe,EAA2B,EAAE,EAAE;QAEhF,IAAI,CAAC,eAAe,CAAC,MAAM;YAAE,IAAA,kBAAU,EAAC,6BAA6B,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzI,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAC;IAEF,OAAO;QACH,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;KACrB,CAAA;AAEL,CAAC,CAAA;AAlHY,QAAA,mBAAmB,uBAkH/B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n SchedulerLogModel,\n ModelSchedulerLogFields\n} from \"@/models\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nexport type SchedulerLogModuleRef = InjectionFieldModuleRef\n\nexport type SchedulerLogServiceProps = DefaultServiceProps & {};\n\nexport type SchedulerLogGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n};\n\nexport type SchedulerLogListProps = Omit<QueryList, \"datatypes\"> & {\n};\n\nexport type SchedulerLogRemoveProps = {\n schedulerLogIds: BigInt[]\n};\n\nexport const schedulerLogTypes = {\n in: \"in\",\n out: \"out\"\n}\n\nexport type SchedulerLogFlowType = keyof typeof schedulerLogTypes\n\nexport type SchedulerLog = {\n schedulerTaskId: number;\n flowType: SchedulerLogFlowType;\n\n sourceType: string;\n sourceEntityId: string;\n sourceEntityLabel: string;\n sourceEntityData: string;\n\n destinationType: string;\n destinationEntityId: string;\n destinationEntityLabel: string;\n destinationSubmitPayload: string;\n destinationSubmitResponse: string;\n\n logAction: string;\n logLabel: string;\n logStatus: boolean;\n logMesssage: string;\n}\n\nexport type SchedulerLogCreateProps = {\n data: SchedulerLog & {\n fieldRef: SchedulerLogModuleRef[\"field_ref\"],\n fieldModule: SchedulerLogModuleRef[\"field_module\"]\n }\n}\n\nconst getCreatePayload = (data: SchedulerLogCreateProps[\"data\"]) => {\n\n return {\n [`${ModelSchedulerLogFields.scheduler_task_id}`]: Number(data.schedulerTaskId),\n [`${ModelSchedulerLogFields.flow_type}`]: data.flowType,\n [`${ModelSchedulerLogFields.log_action}`]: data.logAction,\n\n [`${ModelSchedulerLogFields.field_module}`]: data.fieldRef,\n [`${ModelSchedulerLogFields.field_ref}`]: data.fieldModule,\n\n [`${ModelSchedulerLogFields.source_type}`]: data.sourceType,\n [`${ModelSchedulerLogFields.source_entity_id}`]: data.sourceEntityId,\n [`${ModelSchedulerLogFields.source_entity_label}`]: data.sourceEntityLabel,\n [`${ModelSchedulerLogFields.source_entity_data}`]: data.sourceEntityData,\n\n [`${ModelSchedulerLogFields.destination_type}`]: data.destinationType,\n [`${ModelSchedulerLogFields.destination_entity_id}`]: data.destinationEntityId,\n [`${ModelSchedulerLogFields.destination_entity_label}`]: data.destinationEntityLabel,\n [`${ModelSchedulerLogFields.destination_submit_payload}`]: data.destinationSubmitPayload,\n [`${ModelSchedulerLogFields.destination_submit_response}`]: data.destinationSubmitResponse,\n\n [`${ModelSchedulerLogFields.log_label}`]: data.logLabel,\n [`${ModelSchedulerLogFields.log_message}`]: data.logMesssage,\n [`${ModelSchedulerLogFields.log_status}`]: Boolean(data.logStatus),\n }\n\n}\n\nlet mainSqlSelect = {\n [`slog.${ModelSchedulerLogFields.scheduler_log_id}`]: \"scheduler_log_id\",\n [`slog.${ModelSchedulerLogFields.scheduler_task_id}`]: \"scheduler_task_id\",\n [`slog.${ModelSchedulerLogFields.field_module}`]: \"field_module\",\n [`slog.${ModelSchedulerLogFields.field_ref}`]: \"field_ref\",\n [`slog.${ModelSchedulerLogFields.flow_type}`]: \"flow_type\",\n [`slog.${ModelSchedulerLogFields.destination_type}`]: \"destination_type\",\n [`slog.${ModelSchedulerLogFields.destination_entity_id}`]: \"destination_entity_id\",\n [`slog.${ModelSchedulerLogFields.destination_entity_label}`]: \"destination_entity_label\",\n [`slog.${ModelSchedulerLogFields.destination_submit_payload}`]: \"destination_submit_payload\",\n [`slog.${ModelSchedulerLogFields.destination_submit_response}`]: \"destination_submit_response\",\n [`slog.${ModelSchedulerLogFields.source_type}`]: \"source_type\",\n [`slog.${ModelSchedulerLogFields.source_entity_id}`]: \"source_entity_id\",\n [`slog.${ModelSchedulerLogFields.source_entity_label}`]: \"source_entity_label\",\n [`slog.${ModelSchedulerLogFields.source_entity_data}`]: \"source_entity_data\",\n [`slog.${ModelSchedulerLogFields.log_action}`]: \"log_action\",\n [`slog.${ModelSchedulerLogFields.log_label}`]: \"log_label\",\n [`slog.${ModelSchedulerLogFields.log_message}`]: \"log_message\",\n [`slog.${ModelSchedulerLogFields.log_status}`]: \"log_status\",\n}\n\nlet defaultSqlSelect = {\n [`slog.${ModelSchedulerLogFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`slog.${ModelSchedulerLogFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`slog.${ModelSchedulerLogFields.isdelete}`]: \"isdelete\",\n [`slog.${ModelSchedulerLogFields.istrash}`]: \"istrash\",\n [`slog.${ModelSchedulerLogFields.accountid}`]: \"accountid\",\n}\n\nexport const SchedulerLogService = (props: SchedulerLogServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const schedulerLogModel = SchedulerLogModel({ ...rest })\n\n const createSchedulerLog = async ({ data }: SchedulerLogCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create scheduler log payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await schedulerLogModel.create({ data: _data })\n\n return response\n }\n\n const getSchedulerLog = async ({ id }: SchedulerLogGetProps) => {\n\n let { data } = await listSchedulerLoges({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelSchedulerLogFields.scheduler_log_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelSchedulerLogFields.scheduler_log_id}`,\n sortorder: \"ASC\",\n })\n\n return data[0] ?? null;\n\n };\n\n const listSchedulerLoges = async ({ limit, offset, filters = [], sortfield, sortorder }: SchedulerLogListProps) => {\n\n let data = []\n\n let sqlSelect = [\n `COUNT(slog.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n // buildSqlSelect(``, regionSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n // buildSqlRelation(\"left\", \"slog\", \"states\", \"slogstate\", [\"slog.state_id = slogstate.state_id\", \"slogstate.isdelete = false\", \"slogstate.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"countries\", \"slogcoun\", [\"slog.country_id = slogcoun.country_id\", \"slogcoun.isdelete = false\", \"slogcoun.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"areas\", \"slogarea\", [\"slog.area_id = slogarea.area_id\", \"slogarea.isdelete = false\", \"slogarea.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"creator\", [\"slog.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"updater\", [\"slog.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n // ...Object.keys(regionSqlSelect), \n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n // ...regionSqlSelect, \n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `slog.isdelete = false`,\n `slog.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: \"scheduler_logs\",\n mainAlias: \"slog\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n data = await schedulerLogModel.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 removeSchedulerLoges = async ({ schedulerLogIds }: SchedulerLogRemoveProps) => {\n\n if (!schedulerLogIds.length) throwError('schedulerLogIds is required');\n\n const response = await schedulerLogModel.remove({ where: { [`${ModelSchedulerLogFields.scheduler_log_id}`]: { in: schedulerLogIds } } });\n\n return response\n };\n\n return {\n getSchedulerLog,\n createSchedulerLog,\n removeSchedulerLoges,\n listSchedulerLoges\n }\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.147",
3
+ "version": "1.0.149",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",