acomm-core-lib 2.6.2
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.
- package/README.md +75 -0
- package/dist/package.json +125 -0
- package/dist/src/app.controller.d.ts +8 -0
- package/dist/src/app.controller.js +69 -0
- package/dist/src/app.controller.js.map +1 -0
- package/dist/src/app.module.d.ts +2 -0
- package/dist/src/app.module.js +151 -0
- package/dist/src/app.module.js.map +1 -0
- package/dist/src/app.service.d.ts +5 -0
- package/dist/src/app.service.js +30 -0
- package/dist/src/app.service.js.map +1 -0
- package/dist/src/app_cluster.service.d.ts +3 -0
- package/dist/src/app_cluster.service.js +64 -0
- package/dist/src/app_cluster.service.js.map +1 -0
- package/dist/src/core/activity_log/activity_log.enum.d.ts +31 -0
- package/dist/src/core/activity_log/activity_log.enum.js +38 -0
- package/dist/src/core/activity_log/activity_log.enum.js.map +1 -0
- package/dist/src/core/activity_log/activity_log.layout.d.ts +2 -0
- package/dist/src/core/activity_log/activity_log.layout.js +331 -0
- package/dist/src/core/activity_log/activity_log.layout.js.map +1 -0
- package/dist/src/core/activity_log/activity_log.module.d.ts +2 -0
- package/dist/src/core/activity_log/activity_log.module.js +39 -0
- package/dist/src/core/activity_log/activity_log.module.js.map +1 -0
- package/dist/src/core/activity_log/activity_log.schema.d.ts +24 -0
- package/dist/src/core/activity_log/activity_log.schema.js +117 -0
- package/dist/src/core/activity_log/activity_log.schema.js.map +1 -0
- package/dist/src/core/activity_log/activity_log.service.d.ts +14 -0
- package/dist/src/core/activity_log/activity_log.service.js +58 -0
- package/dist/src/core/activity_log/activity_log.service.js.map +1 -0
- package/dist/src/core/address/address.enum.d.ts +8 -0
- package/dist/src/core/address/address.enum.js +13 -0
- package/dist/src/core/address/address.enum.js.map +1 -0
- package/dist/src/core/address/address.layout.d.ts +7 -0
- package/dist/src/core/address/address.layout.js +1297 -0
- package/dist/src/core/address/address.layout.js.map +1 -0
- package/dist/src/core/address/address.module.d.ts +2 -0
- package/dist/src/core/address/address.module.js +87 -0
- package/dist/src/core/address/address.module.js.map +1 -0
- package/dist/src/core/address/address.schema.d.ts +69 -0
- package/dist/src/core/address/address.schema.js +267 -0
- package/dist/src/core/address/address.schema.js.map +1 -0
- package/dist/src/core/address/address.service.d.ts +49 -0
- package/dist/src/core/address/address.service.js +171 -0
- package/dist/src/core/address/address.service.js.map +1 -0
- package/dist/src/core/address/data/country.json +1484 -0
- package/dist/src/core/address/data/time_zone.json +1702 -0
- package/dist/src/core/api_key/api_key.constant.d.ts +29 -0
- package/dist/src/core/api_key/api_key.constant.js +34 -0
- package/dist/src/core/api_key/api_key.constant.js.map +1 -0
- package/dist/src/core/api_key/api_key.controller.d.ts +8 -0
- package/dist/src/core/api_key/api_key.controller.js +60 -0
- package/dist/src/core/api_key/api_key.controller.js.map +1 -0
- package/dist/src/core/api_key/api_key.enum.d.ts +5 -0
- package/dist/src/core/api_key/api_key.enum.js +10 -0
- package/dist/src/core/api_key/api_key.enum.js.map +1 -0
- package/dist/src/core/api_key/api_key.layout.d.ts +2 -0
- package/dist/src/core/api_key/api_key.layout.js +1133 -0
- package/dist/src/core/api_key/api_key.layout.js.map +1 -0
- package/dist/src/core/api_key/api_key.module.d.ts +2 -0
- package/dist/src/core/api_key/api_key.module.js +40 -0
- package/dist/src/core/api_key/api_key.module.js.map +1 -0
- package/dist/src/core/api_key/api_key.schema.d.ts +42 -0
- package/dist/src/core/api_key/api_key.schema.js +189 -0
- package/dist/src/core/api_key/api_key.schema.js.map +1 -0
- package/dist/src/core/api_key/api_key.service.d.ts +23 -0
- package/dist/src/core/api_key/api_key.service.js +278 -0
- package/dist/src/core/api_key/api_key.service.js.map +1 -0
- package/dist/src/core/attachment/attachment.config.d.ts +4 -0
- package/dist/src/core/attachment/attachment.config.js +8 -0
- package/dist/src/core/attachment/attachment.config.js.map +1 -0
- package/dist/src/core/attachment/attachment.controller.d.ts +15 -0
- package/dist/src/core/attachment/attachment.controller.js +141 -0
- package/dist/src/core/attachment/attachment.controller.js.map +1 -0
- package/dist/src/core/attachment/attachment.enum.d.ts +22 -0
- package/dist/src/core/attachment/attachment.enum.js +28 -0
- package/dist/src/core/attachment/attachment.enum.js.map +1 -0
- package/dist/src/core/attachment/attachment.layout.d.ts +2 -0
- package/dist/src/core/attachment/attachment.layout.js +100 -0
- package/dist/src/core/attachment/attachment.layout.js.map +1 -0
- package/dist/src/core/attachment/attachment.module.d.ts +2 -0
- package/dist/src/core/attachment/attachment.module.js +42 -0
- package/dist/src/core/attachment/attachment.module.js.map +1 -0
- package/dist/src/core/attachment/attachment.schema.d.ts +26 -0
- package/dist/src/core/attachment/attachment.schema.js +131 -0
- package/dist/src/core/attachment/attachment.schema.js.map +1 -0
- package/dist/src/core/attachment/attachment.service.d.ts +38 -0
- package/dist/src/core/attachment/attachment.service.js +417 -0
- package/dist/src/core/attachment/attachment.service.js.map +1 -0
- package/dist/src/core/attachment/providers/local.provider.d.ts +14 -0
- package/dist/src/core/attachment/providers/local.provider.js +71 -0
- package/dist/src/core/attachment/providers/local.provider.js.map +1 -0
- package/dist/src/core/attachment/providers/provider.base.d.ts +6 -0
- package/dist/src/core/attachment/providers/provider.base.js +16 -0
- package/dist/src/core/attachment/providers/provider.base.js.map +1 -0
- package/dist/src/core/attachment/providers/provider.interface.d.ts +5 -0
- package/dist/src/core/attachment/providers/provider.interface.js +3 -0
- package/dist/src/core/attachment/providers/provider.interface.js.map +1 -0
- package/dist/src/core/audit_log/audit_log.enum.d.ts +48 -0
- package/dist/src/core/audit_log/audit_log.enum.js +54 -0
- package/dist/src/core/audit_log/audit_log.enum.js.map +1 -0
- package/dist/src/core/audit_log/audit_log.layout.d.ts +2 -0
- package/dist/src/core/audit_log/audit_log.layout.js +372 -0
- package/dist/src/core/audit_log/audit_log.layout.js.map +1 -0
- package/dist/src/core/audit_log/audit_log.module.d.ts +2 -0
- package/dist/src/core/audit_log/audit_log.module.js +39 -0
- package/dist/src/core/audit_log/audit_log.module.js.map +1 -0
- package/dist/src/core/audit_log/audit_log.schema.d.ts +14 -0
- package/dist/src/core/audit_log/audit_log.schema.js +67 -0
- package/dist/src/core/audit_log/audit_log.schema.js.map +1 -0
- package/dist/src/core/audit_log/audit_log.service.d.ts +14 -0
- package/dist/src/core/audit_log/audit_log.service.js +68 -0
- package/dist/src/core/audit_log/audit_log.service.js.map +1 -0
- package/dist/src/core/auth/auth.controller.d.ts +22 -0
- package/dist/src/core/auth/auth.controller.js +266 -0
- package/dist/src/core/auth/auth.controller.js.map +1 -0
- package/dist/src/core/auth/auth.module.d.ts +2 -0
- package/dist/src/core/auth/auth.module.js +37 -0
- package/dist/src/core/auth/auth.module.js.map +1 -0
- package/dist/src/core/auth/auth.service.d.ts +87 -0
- package/dist/src/core/auth/auth.service.js +930 -0
- package/dist/src/core/auth/auth.service.js.map +1 -0
- package/dist/src/core/auth/constants.d.ts +7 -0
- package/dist/src/core/auth/constants.js +9 -0
- package/dist/src/core/auth/constants.js.map +1 -0
- package/dist/src/core/auth/guards/basic.guard.d.ts +1 -0
- package/dist/src/core/auth/guards/basic.guard.js +7 -0
- package/dist/src/core/auth/guards/basic.guard.js.map +1 -0
- package/dist/src/core/auth/guards/jwt_auth.guard.d.ts +19 -0
- package/dist/src/core/auth/guards/jwt_auth.guard.js +526 -0
- package/dist/src/core/auth/guards/jwt_auth.guard.js.map +1 -0
- package/dist/src/core/auth/guards/public.guard.d.ts +1 -0
- package/dist/src/core/auth/guards/public.guard.js +7 -0
- package/dist/src/core/auth/guards/public.guard.js.map +1 -0
- package/dist/src/core/auth/providers/auth_local.provider.d.ts +13 -0
- package/dist/src/core/auth/providers/auth_local.provider.js +75 -0
- package/dist/src/core/auth/providers/auth_local.provider.js.map +1 -0
- package/dist/src/core/auth/providers/auth_otp.provider.d.ts +13 -0
- package/dist/src/core/auth/providers/auth_otp.provider.js +77 -0
- package/dist/src/core/auth/providers/auth_otp.provider.js.map +1 -0
- package/dist/src/core/auth/providers/auth_provider.interface.d.ts +12 -0
- package/dist/src/core/auth/providers/auth_provider.interface.js +3 -0
- package/dist/src/core/auth/providers/auth_provider.interface.js.map +1 -0
- package/dist/src/core/auth/providers/base_auth.provider.d.ts +7 -0
- package/dist/src/core/auth/providers/base_auth.provider.js +25 -0
- package/dist/src/core/auth/providers/base_auth.provider.js.map +1 -0
- package/dist/src/core/auth/strategies/jwt.strategy.d.ts +6 -0
- package/dist/src/core/auth/strategies/jwt.strategy.js +37 -0
- package/dist/src/core/auth/strategies/jwt.strategy.js.map +1 -0
- package/dist/src/core/cache/cache.controller.d.ts +13 -0
- package/dist/src/core/cache/cache.controller.js +67 -0
- package/dist/src/core/cache/cache.controller.js.map +1 -0
- package/dist/src/core/cache/cache.decorator.d.ts +1 -0
- package/dist/src/core/cache/cache.decorator.js +7 -0
- package/dist/src/core/cache/cache.decorator.js.map +1 -0
- package/dist/src/core/cache/cache.interceptor.d.ts +8 -0
- package/dist/src/core/cache/cache.interceptor.js +57 -0
- package/dist/src/core/cache/cache.interceptor.js.map +1 -0
- package/dist/src/core/cache/cache.module.d.ts +2 -0
- package/dist/src/core/cache/cache.module.js +29 -0
- package/dist/src/core/cache/cache.module.js.map +1 -0
- package/dist/src/core/cache/cache.service.d.ts +15 -0
- package/dist/src/core/cache/cache.service.js +60 -0
- package/dist/src/core/cache/cache.service.js.map +1 -0
- package/dist/src/core/cache/cache.utils.d.ts +12 -0
- package/dist/src/core/cache/cache.utils.js +116 -0
- package/dist/src/core/cache/cache.utils.js.map +1 -0
- package/dist/src/core/comment_data/comment_data.controller.d.ts +8 -0
- package/dist/src/core/comment_data/comment_data.controller.js +56 -0
- package/dist/src/core/comment_data/comment_data.controller.js.map +1 -0
- package/dist/src/core/comment_data/comment_data.layout.d.ts +2 -0
- package/dist/src/core/comment_data/comment_data.layout.js +274 -0
- package/dist/src/core/comment_data/comment_data.layout.js.map +1 -0
- package/dist/src/core/comment_data/comment_data.module.d.ts +2 -0
- package/dist/src/core/comment_data/comment_data.module.js +40 -0
- package/dist/src/core/comment_data/comment_data.module.js.map +1 -0
- package/dist/src/core/comment_data/comment_data.schema.d.ts +13 -0
- package/dist/src/core/comment_data/comment_data.schema.js +53 -0
- package/dist/src/core/comment_data/comment_data.schema.js.map +1 -0
- package/dist/src/core/comment_data/comment_data.service.d.ts +15 -0
- package/dist/src/core/comment_data/comment_data.service.js +63 -0
- package/dist/src/core/comment_data/comment_data.service.js.map +1 -0
- package/dist/src/core/common/base/base.controller.d.ts +42 -0
- package/dist/src/core/common/base/base.controller.js +440 -0
- package/dist/src/core/common/base/base.controller.js.map +1 -0
- package/dist/src/core/common/base/base.schema.d.ts +12 -0
- package/dist/src/core/common/base/base.schema.js +61 -0
- package/dist/src/core/common/base/base.schema.js.map +1 -0
- package/dist/src/core/common/base/base.service.d.ts +87 -0
- package/dist/src/core/common/base/base.service.js +1218 -0
- package/dist/src/core/common/base/base.service.js.map +1 -0
- package/dist/src/core/common/base/base_external_data_source.provider.d.ts +18 -0
- package/dist/src/core/common/base/base_external_data_source.provider.js +50 -0
- package/dist/src/core/common/base/base_external_data_source.provider.js.map +1 -0
- package/dist/src/core/common/base/base_log.controller.d.ts +7 -0
- package/dist/src/core/common/base/base_log.controller.js +35 -0
- package/dist/src/core/common/base/base_log.controller.js.map +1 -0
- package/dist/src/core/common/base/base_log.service.d.ts +13 -0
- package/dist/src/core/common/base/base_log.service.js +142 -0
- package/dist/src/core/common/base/base_log.service.js.map +1 -0
- package/dist/src/core/common/base/base_module.controller.d.ts +9 -0
- package/dist/src/core/common/base/base_module.controller.js +63 -0
- package/dist/src/core/common/base/base_module.controller.js.map +1 -0
- package/dist/src/core/common/base/base_module.service.d.ts +20 -0
- package/dist/src/core/common/base/base_module.service.js +56 -0
- package/dist/src/core/common/base/base_module.service.js.map +1 -0
- package/dist/src/core/common/constants.d.ts +57 -0
- package/dist/src/core/common/constants.js +98 -0
- package/dist/src/core/common/constants.js.map +1 -0
- package/dist/src/core/common/decorator/safe_params.decorator.d.ts +1 -0
- package/dist/src/core/common/decorator/safe_params.decorator.js +11 -0
- package/dist/src/core/common/decorator/safe_params.decorator.js.map +1 -0
- package/dist/src/core/common/dto/search_query.dto.d.ts +6 -0
- package/dist/src/core/common/dto/search_query.dto.js +7 -0
- package/dist/src/core/common/dto/search_query.dto.js.map +1 -0
- package/dist/src/core/common/dto/search_result.dto.d.ts +7 -0
- package/dist/src/core/common/dto/search_result.dto.js +7 -0
- package/dist/src/core/common/dto/search_result.dto.js.map +1 -0
- package/dist/src/core/common/filter/all_exception.filter.d.ts +4 -0
- package/dist/src/core/common/filter/all_exception.filter.js +31 -0
- package/dist/src/core/common/filter/all_exception.filter.js.map +1 -0
- package/dist/src/core/common/function/andConditions.d.ts +12 -0
- package/dist/src/core/common/function/andConditions.js +17 -0
- package/dist/src/core/common/function/andConditions.js.map +1 -0
- package/dist/src/core/common/function/autoGenerateO2M.d.ts +14 -0
- package/dist/src/core/common/function/autoGenerateO2M.js +57 -0
- package/dist/src/core/common/function/autoGenerateO2M.js.map +1 -0
- package/dist/src/core/common/function/cleanData.d.ts +9 -0
- package/dist/src/core/common/function/cleanData.js +23 -0
- package/dist/src/core/common/function/cleanData.js.map +1 -0
- package/dist/src/core/common/function/convertArrayObjToField.d.ts +17 -0
- package/dist/src/core/common/function/convertArrayObjToField.js +23 -0
- package/dist/src/core/common/function/convertArrayObjToField.js.map +1 -0
- package/dist/src/core/common/function/convertArrayToO2M.d.ts +13 -0
- package/dist/src/core/common/function/convertArrayToO2M.js +23 -0
- package/dist/src/core/common/function/convertArrayToO2M.js.map +1 -0
- package/dist/src/core/common/function/convertArrayToOption.d.ts +12 -0
- package/dist/src/core/common/function/convertArrayToOption.js +34 -0
- package/dist/src/core/common/function/convertArrayToOption.js.map +1 -0
- package/dist/src/core/common/function/convertAttributeArray.d.ts +12 -0
- package/dist/src/core/common/function/convertAttributeArray.js +29 -0
- package/dist/src/core/common/function/convertAttributeArray.js.map +1 -0
- package/dist/src/core/common/function/convertDate.d.ts +17 -0
- package/dist/src/core/common/function/convertDate.js +39 -0
- package/dist/src/core/common/function/convertDate.js.map +1 -0
- package/dist/src/core/common/function/convertImage.d.ts +17 -0
- package/dist/src/core/common/function/convertImage.js +18 -0
- package/dist/src/core/common/function/convertImage.js.map +1 -0
- package/dist/src/core/common/function/convertJSONAttrToO2M.d.ts +14 -0
- package/dist/src/core/common/function/convertJSONAttrToO2M.js +79 -0
- package/dist/src/core/common/function/convertJSONAttrToO2M.js.map +1 -0
- package/dist/src/core/common/function/convertStringDate.d.ts +12 -0
- package/dist/src/core/common/function/convertStringDate.js +23 -0
- package/dist/src/core/common/function/convertStringDate.js.map +1 -0
- package/dist/src/core/common/function/convertTime.d.ts +12 -0
- package/dist/src/core/common/function/convertTime.js +41 -0
- package/dist/src/core/common/function/convertTime.js.map +1 -0
- package/dist/src/core/common/function/convertTimestampToDate.d.ts +13 -0
- package/dist/src/core/common/function/convertTimestampToDate.js +14 -0
- package/dist/src/core/common/function/convertTimestampToDate.js.map +1 -0
- package/dist/src/core/common/function/convertToJSONStructure.d.ts +12 -0
- package/dist/src/core/common/function/convertToJSONStructure.js +23 -0
- package/dist/src/core/common/function/convertToJSONStructure.js.map +1 -0
- package/dist/src/core/common/function/convertXMLArray.d.ts +12 -0
- package/dist/src/core/common/function/convertXMLArray.js +81 -0
- package/dist/src/core/common/function/convertXMLArray.js.map +1 -0
- package/dist/src/core/common/function/convertXMLObject.d.ts +12 -0
- package/dist/src/core/common/function/convertXMLObject.js +62 -0
- package/dist/src/core/common/function/convertXMLObject.js.map +1 -0
- package/dist/src/core/common/function/currency.d.ts +12 -0
- package/dist/src/core/common/function/currency.js +49 -0
- package/dist/src/core/common/function/currency.js.map +1 -0
- package/dist/src/core/common/function/currentDate.d.ts +12 -0
- package/dist/src/core/common/function/currentDate.js +34 -0
- package/dist/src/core/common/function/currentDate.js.map +1 -0
- package/dist/src/core/common/function/customSplit.d.ts +12 -0
- package/dist/src/core/common/function/customSplit.js +21 -0
- package/dist/src/core/common/function/customSplit.js.map +1 -0
- package/dist/src/core/common/function/dateIso.d.ts +13 -0
- package/dist/src/core/common/function/dateIso.js +19 -0
- package/dist/src/core/common/function/dateIso.js.map +1 -0
- package/dist/src/core/common/function/defaultType.json +23 -0
- package/dist/src/core/common/function/findData.d.ts +12 -0
- package/dist/src/core/common/function/findData.js +33 -0
- package/dist/src/core/common/function/findData.js.map +1 -0
- package/dist/src/core/common/function/findKeyValueArray.d.ts +12 -0
- package/dist/src/core/common/function/findKeyValueArray.js +29 -0
- package/dist/src/core/common/function/findKeyValueArray.js.map +1 -0
- package/dist/src/core/common/function/formatDate.d.ts +12 -0
- package/dist/src/core/common/function/formatDate.js +34 -0
- package/dist/src/core/common/function/formatDate.js.map +1 -0
- package/dist/src/core/common/function/freeStyle.d.ts +9 -0
- package/dist/src/core/common/function/freeStyle.js +13 -0
- package/dist/src/core/common/function/freeStyle.js.map +1 -0
- package/dist/src/core/common/function/generateBarcode.d.ts +17 -0
- package/dist/src/core/common/function/generateBarcode.js +34 -0
- package/dist/src/core/common/function/generateBarcode.js.map +1 -0
- package/dist/src/core/common/function/generateFilters.d.ts +12 -0
- package/dist/src/core/common/function/generateFilters.js +18 -0
- package/dist/src/core/common/function/generateFilters.js.map +1 -0
- package/dist/src/core/common/function/generateUUID.d.ts +9 -0
- package/dist/src/core/common/function/generateUUID.js +14 -0
- package/dist/src/core/common/function/generateUUID.js.map +1 -0
- package/dist/src/core/common/function/get.d.ts +17 -0
- package/dist/src/core/common/function/get.js +28 -0
- package/dist/src/core/common/function/get.js.map +1 -0
- package/dist/src/core/common/function/getCompany.d.ts +14 -0
- package/dist/src/core/common/function/getCompany.js +26 -0
- package/dist/src/core/common/function/getCompany.js.map +1 -0
- package/dist/src/core/common/function/getCurrentCollapseData.d.ts +13 -0
- package/dist/src/core/common/function/getCurrentCollapseData.js +22 -0
- package/dist/src/core/common/function/getCurrentCollapseData.js.map +1 -0
- package/dist/src/core/common/function/getCurrentDate.d.ts +12 -0
- package/dist/src/core/common/function/getCurrentDate.js +16 -0
- package/dist/src/core/common/function/getCurrentDate.js.map +1 -0
- package/dist/src/core/common/function/getCurrentFilters.d.ts +9 -0
- package/dist/src/core/common/function/getCurrentFilters.js +14 -0
- package/dist/src/core/common/function/getCurrentFilters.js.map +1 -0
- package/dist/src/core/common/function/getCurrentForm.d.ts +12 -0
- package/dist/src/core/common/function/getCurrentForm.js +18 -0
- package/dist/src/core/common/function/getCurrentForm.js.map +1 -0
- package/dist/src/core/common/function/getCurrentId.d.ts +9 -0
- package/dist/src/core/common/function/getCurrentId.js +14 -0
- package/dist/src/core/common/function/getCurrentId.js.map +1 -0
- package/dist/src/core/common/function/getCurrentIndexData.d.ts +12 -0
- package/dist/src/core/common/function/getCurrentIndexData.js +18 -0
- package/dist/src/core/common/function/getCurrentIndexData.js.map +1 -0
- package/dist/src/core/common/function/getDocument.d.ts +13 -0
- package/dist/src/core/common/function/getDocument.js +16 -0
- package/dist/src/core/common/function/getDocument.js.map +1 -0
- package/dist/src/core/common/function/getEndExportdate.d.ts +17 -0
- package/dist/src/core/common/function/getEndExportdate.js +32 -0
- package/dist/src/core/common/function/getEndExportdate.js.map +1 -0
- package/dist/src/core/common/function/getEntityId.d.ts +12 -0
- package/dist/src/core/common/function/getEntityId.js +15 -0
- package/dist/src/core/common/function/getEntityId.js.map +1 -0
- package/dist/src/core/common/function/getEntityRecord.d.ts +12 -0
- package/dist/src/core/common/function/getEntityRecord.js +42 -0
- package/dist/src/core/common/function/getEntityRecord.js.map +1 -0
- package/dist/src/core/common/function/getErrors.d.ts +12 -0
- package/dist/src/core/common/function/getErrors.js +17 -0
- package/dist/src/core/common/function/getErrors.js.map +1 -0
- package/dist/src/core/common/function/getGlobalSetting.d.ts +12 -0
- package/dist/src/core/common/function/getGlobalSetting.js +21 -0
- package/dist/src/core/common/function/getGlobalSetting.js.map +1 -0
- package/dist/src/core/common/function/getHeaders.d.ts +13 -0
- package/dist/src/core/common/function/getHeaders.js +28 -0
- package/dist/src/core/common/function/getHeaders.js.map +1 -0
- package/dist/src/core/common/function/getJSONData.d.ts +13 -0
- package/dist/src/core/common/function/getJSONData.js +17 -0
- package/dist/src/core/common/function/getJSONData.js.map +1 -0
- package/dist/src/core/common/function/getJSONKeys.d.ts +17 -0
- package/dist/src/core/common/function/getJSONKeys.js +24 -0
- package/dist/src/core/common/function/getJSONKeys.js.map +1 -0
- package/dist/src/core/common/function/getMimeType.d.ts +12 -0
- package/dist/src/core/common/function/getMimeType.js +20 -0
- package/dist/src/core/common/function/getMimeType.js.map +1 -0
- package/dist/src/core/common/function/getNameFromUrl.d.ts +12 -0
- package/dist/src/core/common/function/getNameFromUrl.js +19 -0
- package/dist/src/core/common/function/getNameFromUrl.js.map +1 -0
- package/dist/src/core/common/function/getObjectData.d.ts +12 -0
- package/dist/src/core/common/function/getObjectData.js +27 -0
- package/dist/src/core/common/function/getObjectData.js.map +1 -0
- package/dist/src/core/common/function/getOptionFromApi.d.ts +17 -0
- package/dist/src/core/common/function/getOptionFromApi.js +24 -0
- package/dist/src/core/common/function/getOptionFromApi.js.map +1 -0
- package/dist/src/core/common/function/getOptions.d.ts +12 -0
- package/dist/src/core/common/function/getOptions.js +18 -0
- package/dist/src/core/common/function/getOptions.js.map +1 -0
- package/dist/src/core/common/function/getOriginalData.d.ts +17 -0
- package/dist/src/core/common/function/getOriginalData.js +18 -0
- package/dist/src/core/common/function/getOriginalData.js.map +1 -0
- package/dist/src/core/common/function/getParentData.d.ts +13 -0
- package/dist/src/core/common/function/getParentData.js +14 -0
- package/dist/src/core/common/function/getParentData.js.map +1 -0
- package/dist/src/core/common/function/getProfile.d.ts +13 -0
- package/dist/src/core/common/function/getProfile.js +30 -0
- package/dist/src/core/common/function/getProfile.js.map +1 -0
- package/dist/src/core/common/function/getProfileImage.d.ts +9 -0
- package/dist/src/core/common/function/getProfileImage.js +20 -0
- package/dist/src/core/common/function/getProfileImage.js.map +1 -0
- package/dist/src/core/common/function/getRawData.d.ts +12 -0
- package/dist/src/core/common/function/getRawData.js +17 -0
- package/dist/src/core/common/function/getRawData.js.map +1 -0
- package/dist/src/core/common/function/getRequestData.d.ts +11 -0
- package/dist/src/core/common/function/getRequestData.js +16 -0
- package/dist/src/core/common/function/getRequestData.js.map +1 -0
- package/dist/src/core/common/function/getRequestStatus.d.ts +9 -0
- package/dist/src/core/common/function/getRequestStatus.js +14 -0
- package/dist/src/core/common/function/getRequestStatus.js.map +1 -0
- package/dist/src/core/common/function/getResponse.d.ts +12 -0
- package/dist/src/core/common/function/getResponse.js +17 -0
- package/dist/src/core/common/function/getResponse.js.map +1 -0
- package/dist/src/core/common/function/getResult.d.ts +12 -0
- package/dist/src/core/common/function/getResult.js +17 -0
- package/dist/src/core/common/function/getResult.js.map +1 -0
- package/dist/src/core/common/function/getRunningNumber.d.ts +12 -0
- package/dist/src/core/common/function/getRunningNumber.js +19 -0
- package/dist/src/core/common/function/getRunningNumber.js.map +1 -0
- package/dist/src/core/common/function/getSetting.d.ts +12 -0
- package/dist/src/core/common/function/getSetting.js +17 -0
- package/dist/src/core/common/function/getSetting.js.map +1 -0
- package/dist/src/core/common/function/getStartExportdate.d.ts +17 -0
- package/dist/src/core/common/function/getStartExportdate.js +34 -0
- package/dist/src/core/common/function/getStartExportdate.js.map +1 -0
- package/dist/src/core/common/function/getTableColumn.d.ts +13 -0
- package/dist/src/core/common/function/getTableColumn.js +57 -0
- package/dist/src/core/common/function/getTableColumn.js.map +1 -0
- package/dist/src/core/common/function/getTimeLogs.d.ts +12 -0
- package/dist/src/core/common/function/getTimeLogs.js +17 -0
- package/dist/src/core/common/function/getTimeLogs.js.map +1 -0
- package/dist/src/core/common/function/hideString.d.ts +12 -0
- package/dist/src/core/common/function/hideString.js +27 -0
- package/dist/src/core/common/function/hideString.js.map +1 -0
- package/dist/src/core/common/function/ifConditions.d.ts +12 -0
- package/dist/src/core/common/function/ifConditions.js +27 -0
- package/dist/src/core/common/function/ifConditions.js.map +1 -0
- package/dist/src/core/common/function/isEmpty.d.ts +12 -0
- package/dist/src/core/common/function/isEmpty.js +18 -0
- package/dist/src/core/common/function/isEmpty.js.map +1 -0
- package/dist/src/core/common/function/jsonArray.d.ts +12 -0
- package/dist/src/core/common/function/jsonArray.js +22 -0
- package/dist/src/core/common/function/jsonArray.js.map +1 -0
- package/dist/src/core/common/function/last.d.ts +17 -0
- package/dist/src/core/common/function/last.js +25 -0
- package/dist/src/core/common/function/last.js.map +1 -0
- package/dist/src/core/common/function/leftString.d.ts +12 -0
- package/dist/src/core/common/function/leftString.js +20 -0
- package/dist/src/core/common/function/leftString.js.map +1 -0
- package/dist/src/core/common/function/length.d.ts +13 -0
- package/dist/src/core/common/function/length.js +21 -0
- package/dist/src/core/common/function/length.js.map +1 -0
- package/dist/src/core/common/function/mapping.d.ts +1185 -0
- package/dist/src/core/common/function/mapping.js +206 -0
- package/dist/src/core/common/function/mapping.js.map +1 -0
- package/dist/src/core/common/function/multiply.d.ts +13 -0
- package/dist/src/core/common/function/multiply.js +17 -0
- package/dist/src/core/common/function/multiply.js.map +1 -0
- package/dist/src/core/common/function/negativeValue.d.ts +13 -0
- package/dist/src/core/common/function/negativeValue.js +23 -0
- package/dist/src/core/common/function/negativeValue.js.map +1 -0
- package/dist/src/core/common/function/notConditions.d.ts +12 -0
- package/dist/src/core/common/function/notConditions.js +17 -0
- package/dist/src/core/common/function/notConditions.js.map +1 -0
- package/dist/src/core/common/function/numberInWord.d.ts +17 -0
- package/dist/src/core/common/function/numberInWord.js +34 -0
- package/dist/src/core/common/function/numberInWord.js.map +1 -0
- package/dist/src/core/common/function/objectId.d.ts +13 -0
- package/dist/src/core/common/function/objectId.js +16 -0
- package/dist/src/core/common/function/objectId.js.map +1 -0
- package/dist/src/core/common/function/orConditions.d.ts +12 -0
- package/dist/src/core/common/function/orConditions.js +17 -0
- package/dist/src/core/common/function/orConditions.js.map +1 -0
- package/dist/src/core/common/function/padStart.d.ts +17 -0
- package/dist/src/core/common/function/padStart.js +18 -0
- package/dist/src/core/common/function/padStart.js.map +1 -0
- package/dist/src/core/common/function/random.d.ts +12 -0
- package/dist/src/core/common/function/random.js +29 -0
- package/dist/src/core/common/function/random.js.map +1 -0
- package/dist/src/core/common/function/randomBytes.d.ts +12 -0
- package/dist/src/core/common/function/randomBytes.js +17 -0
- package/dist/src/core/common/function/randomBytes.js.map +1 -0
- package/dist/src/core/common/function/replaceString.d.ts +12 -0
- package/dist/src/core/common/function/replaceString.js +22 -0
- package/dist/src/core/common/function/replaceString.js.map +1 -0
- package/dist/src/core/common/function/rightString.d.ts +12 -0
- package/dist/src/core/common/function/rightString.js +20 -0
- package/dist/src/core/common/function/rightString.js.map +1 -0
- package/dist/src/core/common/function/round.d.ts +12 -0
- package/dist/src/core/common/function/round.js +23 -0
- package/dist/src/core/common/function/round.js.map +1 -0
- package/dist/src/core/common/function/runningNumber.d.ts +12 -0
- package/dist/src/core/common/function/runningNumber.js +26 -0
- package/dist/src/core/common/function/runningNumber.js.map +1 -0
- package/dist/src/core/common/function/subString.d.ts +12 -0
- package/dist/src/core/common/function/subString.js +19 -0
- package/dist/src/core/common/function/subString.js.map +1 -0
- package/dist/src/core/common/function/sumBy.d.ts +13 -0
- package/dist/src/core/common/function/sumBy.js +24 -0
- package/dist/src/core/common/function/sumBy.js.map +1 -0
- package/dist/src/core/common/function/sumData.d.ts +13 -0
- package/dist/src/core/common/function/sumData.js +28 -0
- package/dist/src/core/common/function/sumData.js.map +1 -0
- package/dist/src/core/common/function/sumIf.d.ts +13 -0
- package/dist/src/core/common/function/sumIf.js +26 -0
- package/dist/src/core/common/function/sumIf.js.map +1 -0
- package/dist/src/core/common/function/sumValue.d.ts +12 -0
- package/dist/src/core/common/function/sumValue.js +26 -0
- package/dist/src/core/common/function/sumValue.js.map +1 -0
- package/dist/src/core/common/function/toBoolean.d.ts +12 -0
- package/dist/src/core/common/function/toBoolean.js +23 -0
- package/dist/src/core/common/function/toBoolean.js.map +1 -0
- package/dist/src/core/common/function/toCamelCase.d.ts +13 -0
- package/dist/src/core/common/function/toCamelCase.js +16 -0
- package/dist/src/core/common/function/toCamelCase.js.map +1 -0
- package/dist/src/core/common/function/toFloat.d.ts +17 -0
- package/dist/src/core/common/function/toFloat.js +25 -0
- package/dist/src/core/common/function/toFloat.js.map +1 -0
- package/dist/src/core/common/function/toInt.d.ts +12 -0
- package/dist/src/core/common/function/toInt.js +20 -0
- package/dist/src/core/common/function/toInt.js.map +1 -0
- package/dist/src/core/common/function/toJson.d.ts +13 -0
- package/dist/src/core/common/function/toJson.js +16 -0
- package/dist/src/core/common/function/toJson.js.map +1 -0
- package/dist/src/core/common/function/toLowerCase.d.ts +13 -0
- package/dist/src/core/common/function/toLowerCase.js +16 -0
- package/dist/src/core/common/function/toLowerCase.js.map +1 -0
- package/dist/src/core/common/function/toPascalCase.d.ts +13 -0
- package/dist/src/core/common/function/toPascalCase.js +16 -0
- package/dist/src/core/common/function/toPascalCase.js.map +1 -0
- package/dist/src/core/common/function/toSnakeCase.d.ts +13 -0
- package/dist/src/core/common/function/toSnakeCase.js +16 -0
- package/dist/src/core/common/function/toSnakeCase.js.map +1 -0
- package/dist/src/core/common/function/toString.d.ts +12 -0
- package/dist/src/core/common/function/toString.js +25 -0
- package/dist/src/core/common/function/toString.js.map +1 -0
- package/dist/src/core/common/function/toUpperCase.d.ts +13 -0
- package/dist/src/core/common/function/toUpperCase.js +16 -0
- package/dist/src/core/common/function/toUpperCase.js.map +1 -0
- package/dist/src/core/common/function/translateOption.d.ts +17 -0
- package/dist/src/core/common/function/translateOption.js +55 -0
- package/dist/src/core/common/function/translateOption.js.map +1 -0
- package/dist/src/core/common/function/uploadImageFromUrl.d.ts +13 -0
- package/dist/src/core/common/function/uploadImageFromUrl.js +18 -0
- package/dist/src/core/common/function/uploadImageFromUrl.js.map +1 -0
- package/dist/src/core/common/interceptors/external.interceptor.d.ts +9 -0
- package/dist/src/core/common/interceptors/external.interceptor.js +113 -0
- package/dist/src/core/common/interceptors/external.interceptor.js.map +1 -0
- package/dist/src/core/common/interceptors/filter.interceptor.d.ts +8 -0
- package/dist/src/core/common/interceptors/filter.interceptor.js +192 -0
- package/dist/src/core/common/interceptors/filter.interceptor.js.map +1 -0
- package/dist/src/core/common/interface/external_data_source.interface.d.ts +16 -0
- package/dist/src/core/common/interface/external_data_source.interface.js +3 -0
- package/dist/src/core/common/interface/external_data_source.interface.js.map +1 -0
- package/dist/src/core/common/interface/module_setting.interface.d.ts +6 -0
- package/dist/src/core/common/interface/module_setting.interface.js +3 -0
- package/dist/src/core/common/interface/module_setting.interface.js.map +1 -0
- package/dist/src/core/common/utils/attachment.d.ts +5 -0
- package/dist/src/core/common/utils/attachment.js +50 -0
- package/dist/src/core/common/utils/attachment.js.map +1 -0
- package/dist/src/core/common/utils/authenticator.d.ts +5 -0
- package/dist/src/core/common/utils/authenticator.js +30 -0
- package/dist/src/core/common/utils/authenticator.js.map +1 -0
- package/dist/src/core/common/utils/build_search.d.ts +11 -0
- package/dist/src/core/common/utils/build_search.js +459 -0
- package/dist/src/core/common/utils/build_search.js.map +1 -0
- package/dist/src/core/common/utils/bull_queue.d.ts +24 -0
- package/dist/src/core/common/utils/bull_queue.js +156 -0
- package/dist/src/core/common/utils/bull_queue.js.map +1 -0
- package/dist/src/core/common/utils/chart.d.ts +12 -0
- package/dist/src/core/common/utils/chart.js +201 -0
- package/dist/src/core/common/utils/chart.js.map +1 -0
- package/dist/src/core/common/utils/common.d.ts +4 -0
- package/dist/src/core/common/utils/common.js +56 -0
- package/dist/src/core/common/utils/common.js.map +1 -0
- package/dist/src/core/common/utils/date.d.ts +7 -0
- package/dist/src/core/common/utils/date.js +97 -0
- package/dist/src/core/common/utils/date.js.map +1 -0
- package/dist/src/core/common/utils/decimal2Json.d.ts +4 -0
- package/dist/src/core/common/utils/decimal2Json.js +131 -0
- package/dist/src/core/common/utils/decimal2Json.js.map +1 -0
- package/dist/src/core/common/utils/diff.d.ts +3 -0
- package/dist/src/core/common/utils/diff.js +81 -0
- package/dist/src/core/common/utils/diff.js.map +1 -0
- package/dist/src/core/common/utils/entity.d.ts +13 -0
- package/dist/src/core/common/utils/entity.js +119 -0
- package/dist/src/core/common/utils/entity.js.map +1 -0
- package/dist/src/core/common/utils/eval.d.ts +3 -0
- package/dist/src/core/common/utils/eval.js +30 -0
- package/dist/src/core/common/utils/eval.js.map +1 -0
- package/dist/src/core/common/utils/example.d.ts +3 -0
- package/dist/src/core/common/utils/example.js +152 -0
- package/dist/src/core/common/utils/example.js.map +1 -0
- package/dist/src/core/common/utils/executions.d.ts +3 -0
- package/dist/src/core/common/utils/executions.js +73 -0
- package/dist/src/core/common/utils/executions.js.map +1 -0
- package/dist/src/core/common/utils/external_data.d.ts +2 -0
- package/dist/src/core/common/utils/external_data.js +20 -0
- package/dist/src/core/common/utils/external_data.js.map +1 -0
- package/dist/src/core/common/utils/external_module.d.ts +12 -0
- package/dist/src/core/common/utils/external_module.js +203 -0
- package/dist/src/core/common/utils/external_module.js.map +1 -0
- package/dist/src/core/common/utils/file.d.ts +6 -0
- package/dist/src/core/common/utils/file.js +80 -0
- package/dist/src/core/common/utils/file.js.map +1 -0
- package/dist/src/core/common/utils/form.d.ts +4 -0
- package/dist/src/core/common/utils/form.js +21 -0
- package/dist/src/core/common/utils/form.js.map +1 -0
- package/dist/src/core/common/utils/func.d.ts +17 -0
- package/dist/src/core/common/utils/func.js +314 -0
- package/dist/src/core/common/utils/func.js.map +1 -0
- package/dist/src/core/common/utils/global.d.ts +6 -0
- package/dist/src/core/common/utils/global.js +72 -0
- package/dist/src/core/common/utils/global.js.map +1 -0
- package/dist/src/core/common/utils/hook.d.ts +5 -0
- package/dist/src/core/common/utils/hook.js +188 -0
- package/dist/src/core/common/utils/hook.js.map +1 -0
- package/dist/src/core/common/utils/initial.d.ts +4 -0
- package/dist/src/core/common/utils/initial.js +318 -0
- package/dist/src/core/common/utils/initial.js.map +1 -0
- package/dist/src/core/common/utils/layout.d.ts +7 -0
- package/dist/src/core/common/utils/layout.js +160 -0
- package/dist/src/core/common/utils/layout.js.map +1 -0
- package/dist/src/core/common/utils/masking.d.ts +3 -0
- package/dist/src/core/common/utils/masking.js +55 -0
- package/dist/src/core/common/utils/masking.js.map +1 -0
- package/dist/src/core/common/utils/math.d.ts +2 -0
- package/dist/src/core/common/utils/math.js +8 -0
- package/dist/src/core/common/utils/math.js.map +1 -0
- package/dist/src/core/common/utils/media.d.ts +70 -0
- package/dist/src/core/common/utils/media.js +90 -0
- package/dist/src/core/common/utils/media.js.map +1 -0
- package/dist/src/core/common/utils/mongo.d.ts +4 -0
- package/dist/src/core/common/utils/mongo.js +891 -0
- package/dist/src/core/common/utils/mongo.js.map +1 -0
- package/dist/src/core/common/utils/mongoose.d.ts +2 -0
- package/dist/src/core/common/utils/mongoose.js +152 -0
- package/dist/src/core/common/utils/mongoose.js.map +1 -0
- package/dist/src/core/common/utils/ocr.d.ts +1 -0
- package/dist/src/core/common/utils/ocr.js +35 -0
- package/dist/src/core/common/utils/ocr.js.map +1 -0
- package/dist/src/core/common/utils/otp.d.ts +16 -0
- package/dist/src/core/common/utils/otp.js +103 -0
- package/dist/src/core/common/utils/otp.js.map +1 -0
- package/dist/src/core/common/utils/permission.d.ts +5 -0
- package/dist/src/core/common/utils/permission.js +122 -0
- package/dist/src/core/common/utils/permission.js.map +1 -0
- package/dist/src/core/common/utils/random.d.ts +2 -0
- package/dist/src/core/common/utils/random.js +14 -0
- package/dist/src/core/common/utils/random.js.map +1 -0
- package/dist/src/core/common/utils/recaptcha.d.ts +1 -0
- package/dist/src/core/common/utils/recaptcha.js +21 -0
- package/dist/src/core/common/utils/recaptcha.js.map +1 -0
- package/dist/src/core/common/utils/redis.d.ts +31 -0
- package/dist/src/core/common/utils/redis.js +261 -0
- package/dist/src/core/common/utils/redis.js.map +1 -0
- package/dist/src/core/common/utils/regex.d.ts +1 -0
- package/dist/src/core/common/utils/regex.js +8 -0
- package/dist/src/core/common/utils/regex.js.map +1 -0
- package/dist/src/core/common/utils/replace.d.ts +5 -0
- package/dist/src/core/common/utils/replace.js +84 -0
- package/dist/src/core/common/utils/replace.js.map +1 -0
- package/dist/src/core/common/utils/request.d.ts +5 -0
- package/dist/src/core/common/utils/request.js +82 -0
- package/dist/src/core/common/utils/request.js.map +1 -0
- package/dist/src/core/common/utils/retry.d.ts +1 -0
- package/dist/src/core/common/utils/retry.js +30 -0
- package/dist/src/core/common/utils/retry.js.map +1 -0
- package/dist/src/core/common/utils/rewrite_url.d.ts +4 -0
- package/dist/src/core/common/utils/rewrite_url.js +18 -0
- package/dist/src/core/common/utils/rewrite_url.js.map +1 -0
- package/dist/src/core/common/utils/running.d.ts +1 -0
- package/dist/src/core/common/utils/running.js +46 -0
- package/dist/src/core/common/utils/running.js.map +1 -0
- package/dist/src/core/common/utils/schedule.d.ts +1 -0
- package/dist/src/core/common/utils/schedule.js +15 -0
- package/dist/src/core/common/utils/schedule.js.map +1 -0
- package/dist/src/core/common/utils/schema.d.ts +65 -0
- package/dist/src/core/common/utils/schema.js +2629 -0
- package/dist/src/core/common/utils/schema.js.map +1 -0
- package/dist/src/core/common/utils/sleep.d.ts +2 -0
- package/dist/src/core/common/utils/sleep.js +8 -0
- package/dist/src/core/common/utils/sleep.js.map +1 -0
- package/dist/src/core/common/utils/template.d.ts +2 -0
- package/dist/src/core/common/utils/template.js +169 -0
- package/dist/src/core/common/utils/template.js.map +1 -0
- package/dist/src/core/common/utils/text_search.d.ts +27 -0
- package/dist/src/core/common/utils/text_search.js +237 -0
- package/dist/src/core/common/utils/text_search.js.map +1 -0
- package/dist/src/core/common/utils/time.d.ts +1 -0
- package/dist/src/core/common/utils/time.js +17 -0
- package/dist/src/core/common/utils/time.js.map +1 -0
- package/dist/src/core/common/utils/token.d.ts +5 -0
- package/dist/src/core/common/utils/token.js +13 -0
- package/dist/src/core/common/utils/token.js.map +1 -0
- package/dist/src/core/common/utils/transform.d.ts +8 -0
- package/dist/src/core/common/utils/transform.js +409 -0
- package/dist/src/core/common/utils/transform.js.map +1 -0
- package/dist/src/core/common/utils/translate.d.ts +5 -0
- package/dist/src/core/common/utils/translate.js +73 -0
- package/dist/src/core/common/utils/translate.js.map +1 -0
- package/dist/src/core/common/utils/validate.d.ts +6 -0
- package/dist/src/core/common/utils/validate.js +323 -0
- package/dist/src/core/common/utils/validate.js.map +1 -0
- package/dist/src/core/company/company.constant.d.ts +9 -0
- package/dist/src/core/company/company.constant.js +13 -0
- package/dist/src/core/company/company.constant.js.map +1 -0
- package/dist/src/core/company/company.layout.d.ts +2 -0
- package/dist/src/core/company/company.layout.js +507 -0
- package/dist/src/core/company/company.layout.js.map +1 -0
- package/dist/src/core/company/company.module.d.ts +2 -0
- package/dist/src/core/company/company.module.js +40 -0
- package/dist/src/core/company/company.module.js.map +1 -0
- package/dist/src/core/company/company.schema.d.ts +25 -0
- package/dist/src/core/company/company.schema.js +137 -0
- package/dist/src/core/company/company.schema.js.map +1 -0
- package/dist/src/core/company/company.service.d.ts +22 -0
- package/dist/src/core/company/company.service.js +140 -0
- package/dist/src/core/company/company.service.js.map +1 -0
- package/dist/src/core/config/attachment.d.ts +15 -0
- package/dist/src/core/config/attachment.js +35 -0
- package/dist/src/core/config/attachment.js.map +1 -0
- package/dist/src/core/config/auth.d.ts +4 -0
- package/dist/src/core/config/auth.js +6 -0
- package/dist/src/core/config/auth.js.map +1 -0
- package/dist/src/core/config/cache.d.ts +5 -0
- package/dist/src/core/config/cache.js +7 -0
- package/dist/src/core/config/cache.js.map +1 -0
- package/dist/src/core/config/mongodb.d.ts +4 -0
- package/dist/src/core/config/mongodb.js +6 -0
- package/dist/src/core/config/mongodb.js.map +1 -0
- package/dist/src/core/config/queue.d.ts +4 -0
- package/dist/src/core/config/queue.js +6 -0
- package/dist/src/core/config/queue.js.map +1 -0
- package/dist/src/core/config/schedule_action.d.ts +5 -0
- package/dist/src/core/config/schedule_action.js +7 -0
- package/dist/src/core/config/schedule_action.js.map +1 -0
- package/dist/src/core/core.controller.d.ts +51 -0
- package/dist/src/core/core.controller.js +555 -0
- package/dist/src/core/core.controller.js.map +1 -0
- package/dist/src/core/core.module.d.ts +2 -0
- package/dist/src/core/core.module.js +101 -0
- package/dist/src/core/core.module.js.map +1 -0
- package/dist/src/core/core.service.d.ts +121 -0
- package/dist/src/core/core.service.js +716 -0
- package/dist/src/core/core.service.js.map +1 -0
- package/dist/src/core/currency/currency.layout.d.ts +2 -0
- package/dist/src/core/currency/currency.layout.js +194 -0
- package/dist/src/core/currency/currency.layout.js.map +1 -0
- package/dist/src/core/currency/currency.module.d.ts +2 -0
- package/dist/src/core/currency/currency.module.js +38 -0
- package/dist/src/core/currency/currency.module.js.map +1 -0
- package/dist/src/core/currency/currency.schema.d.ts +9 -0
- package/dist/src/core/currency/currency.schema.js +30 -0
- package/dist/src/core/currency/currency.schema.js.map +1 -0
- package/dist/src/core/currency/currency.service.d.ts +13 -0
- package/dist/src/core/currency/currency.service.js +55 -0
- package/dist/src/core/currency/currency.service.js.map +1 -0
- package/dist/src/core/currency/data/currency.json +646 -0
- package/dist/src/core/custom_function/custom_function.controller.d.ts +7 -0
- package/dist/src/core/custom_function/custom_function.controller.js +50 -0
- package/dist/src/core/custom_function/custom_function.controller.js.map +1 -0
- package/dist/src/core/custom_function/custom_function.enum.d.ts +22 -0
- package/dist/src/core/custom_function/custom_function.enum.js +28 -0
- package/dist/src/core/custom_function/custom_function.enum.js.map +1 -0
- package/dist/src/core/custom_function/custom_function.layout.d.ts +2 -0
- package/dist/src/core/custom_function/custom_function.layout.js +521 -0
- package/dist/src/core/custom_function/custom_function.layout.js.map +1 -0
- package/dist/src/core/custom_function/custom_function.module.d.ts +2 -0
- package/dist/src/core/custom_function/custom_function.module.js +41 -0
- package/dist/src/core/custom_function/custom_function.module.js.map +1 -0
- package/dist/src/core/custom_function/custom_function.schema.d.ts +15 -0
- package/dist/src/core/custom_function/custom_function.schema.js +68 -0
- package/dist/src/core/custom_function/custom_function.schema.js.map +1 -0
- package/dist/src/core/custom_function/custom_function.service.d.ts +18 -0
- package/dist/src/core/custom_function/custom_function.service.js +116 -0
- package/dist/src/core/custom_function/custom_function.service.js.map +1 -0
- package/dist/src/core/database/database.constant.d.ts +35 -0
- package/dist/src/core/database/database.constant.js +218 -0
- package/dist/src/core/database/database.constant.js.map +1 -0
- package/dist/src/core/database/database.controller.d.ts +8 -0
- package/dist/src/core/database/database.controller.js +56 -0
- package/dist/src/core/database/database.controller.js.map +1 -0
- package/dist/src/core/database/database.module.d.ts +2 -0
- package/dist/src/core/database/database.module.js +24 -0
- package/dist/src/core/database/database.module.js.map +1 -0
- package/dist/src/core/database/database.service.d.ts +13 -0
- package/dist/src/core/database/database.service.js +184 -0
- package/dist/src/core/database/database.service.js.map +1 -0
- package/dist/src/core/deploy/deploy.action.d.ts +3 -0
- package/dist/src/core/deploy/deploy.action.js +82 -0
- package/dist/src/core/deploy/deploy.action.js.map +1 -0
- package/dist/src/core/deploy/deploy.controller.d.ts +7 -0
- package/dist/src/core/deploy/deploy.controller.js +53 -0
- package/dist/src/core/deploy/deploy.controller.js.map +1 -0
- package/dist/src/core/deploy/deploy.enum.d.ts +5 -0
- package/dist/src/core/deploy/deploy.enum.js +10 -0
- package/dist/src/core/deploy/deploy.enum.js.map +1 -0
- package/dist/src/core/deploy/deploy.layout.d.ts +4 -0
- package/dist/src/core/deploy/deploy.layout.js +1110 -0
- package/dist/src/core/deploy/deploy.layout.js.map +1 -0
- package/dist/src/core/deploy/deploy.module.d.ts +2 -0
- package/dist/src/core/deploy/deploy.module.js +57 -0
- package/dist/src/core/deploy/deploy.module.js.map +1 -0
- package/dist/src/core/deploy/deploy.schema.d.ts +28 -0
- package/dist/src/core/deploy/deploy.schema.js +111 -0
- package/dist/src/core/deploy/deploy.schema.js.map +1 -0
- package/dist/src/core/deploy/deploy.service.d.ts +38 -0
- package/dist/src/core/deploy/deploy.service.js +557 -0
- package/dist/src/core/deploy/deploy.service.js.map +1 -0
- package/dist/src/core/deploy/log/deploy_log.schema.d.ts +20 -0
- package/dist/src/core/deploy/log/deploy_log.schema.js +90 -0
- package/dist/src/core/deploy/log/deploy_log.schema.js.map +1 -0
- package/dist/src/core/deploy/log/deploy_log.service.d.ts +12 -0
- package/dist/src/core/deploy/log/deploy_log.service.js +44 -0
- package/dist/src/core/deploy/log/deploy_log.service.js.map +1 -0
- package/dist/src/core/entities/entities.controller.d.ts +69 -0
- package/dist/src/core/entities/entities.controller.js +801 -0
- package/dist/src/core/entities/entities.controller.js.map +1 -0
- package/dist/src/core/entities/entities.module.d.ts +2 -0
- package/dist/src/core/entities/entities.module.js +38 -0
- package/dist/src/core/entities/entities.module.js.map +1 -0
- package/dist/src/core/entities/entities.service.d.ts +71 -0
- package/dist/src/core/entities/entities.service.js +2271 -0
- package/dist/src/core/entities/entities.service.js.map +1 -0
- package/dist/src/core/entities/entity.enum.d.ts +33 -0
- package/dist/src/core/entities/entity.enum.js +44 -0
- package/dist/src/core/entities/entity.enum.js.map +1 -0
- package/dist/src/core/entities/entity.schema.d.ts +357 -0
- package/dist/src/core/entities/entity.schema.js +1460 -0
- package/dist/src/core/entities/entity.schema.js.map +1 -0
- package/dist/src/core/entities/provider/data_permission.base.d.ts +4 -0
- package/dist/src/core/entities/provider/data_permission.base.js +10 -0
- package/dist/src/core/entities/provider/data_permission.base.js.map +1 -0
- package/dist/src/core/entities/provider/data_permission.interface.d.ts +3 -0
- package/dist/src/core/entities/provider/data_permission.interface.js +3 -0
- package/dist/src/core/entities/provider/data_permission.interface.js.map +1 -0
- package/dist/src/core/execution_log/execution_log.enum.d.ts +4 -0
- package/dist/src/core/execution_log/execution_log.enum.js +9 -0
- package/dist/src/core/execution_log/execution_log.enum.js.map +1 -0
- package/dist/src/core/execution_log/execution_log.layout.d.ts +2 -0
- package/dist/src/core/execution_log/execution_log.layout.js +226 -0
- package/dist/src/core/execution_log/execution_log.layout.js.map +1 -0
- package/dist/src/core/execution_log/execution_log.module.d.ts +2 -0
- package/dist/src/core/execution_log/execution_log.module.js +39 -0
- package/dist/src/core/execution_log/execution_log.module.js.map +1 -0
- package/dist/src/core/execution_log/execution_log.schema.d.ts +13 -0
- package/dist/src/core/execution_log/execution_log.schema.js +58 -0
- package/dist/src/core/execution_log/execution_log.schema.js.map +1 -0
- package/dist/src/core/execution_log/execution_log.service.d.ts +12 -0
- package/dist/src/core/execution_log/execution_log.service.js +47 -0
- package/dist/src/core/execution_log/execution_log.service.js.map +1 -0
- package/dist/src/core/external_provider/external_provider.controller.d.ts +6 -0
- package/dist/src/core/external_provider/external_provider.controller.js +41 -0
- package/dist/src/core/external_provider/external_provider.controller.js.map +1 -0
- package/dist/src/core/external_provider/external_provider.module.d.ts +2 -0
- package/dist/src/core/external_provider/external_provider.module.js +29 -0
- package/dist/src/core/external_provider/external_provider.module.js.map +1 -0
- package/dist/src/core/external_provider/external_provider.service.d.ts +18 -0
- package/dist/src/core/external_provider/external_provider.service.js +32 -0
- package/dist/src/core/external_provider/external_provider.service.js.map +1 -0
- package/dist/src/core/guards/csrf.guard.d.ts +9 -0
- package/dist/src/core/guards/csrf.guard.js +57 -0
- package/dist/src/core/guards/csrf.guard.js.map +1 -0
- package/dist/src/core/import_export/import_export.controller.d.ts +28 -0
- package/dist/src/core/import_export/import_export.controller.js +201 -0
- package/dist/src/core/import_export/import_export.controller.js.map +1 -0
- package/dist/src/core/import_export/import_export.enum.d.ts +24 -0
- package/dist/src/core/import_export/import_export.enum.js +32 -0
- package/dist/src/core/import_export/import_export.enum.js.map +1 -0
- package/dist/src/core/import_export/import_export.hook.d.ts +16 -0
- package/dist/src/core/import_export/import_export.hook.js +24 -0
- package/dist/src/core/import_export/import_export.hook.js.map +1 -0
- package/dist/src/core/import_export/import_export.layout.d.ts +2 -0
- package/dist/src/core/import_export/import_export.layout.js +2059 -0
- package/dist/src/core/import_export/import_export.layout.js.map +1 -0
- package/dist/src/core/import_export/import_export.module.d.ts +2 -0
- package/dist/src/core/import_export/import_export.module.js +51 -0
- package/dist/src/core/import_export/import_export.module.js.map +1 -0
- package/dist/src/core/import_export/import_export.schema.d.ts +40 -0
- package/dist/src/core/import_export/import_export.schema.js +175 -0
- package/dist/src/core/import_export/import_export.schema.js.map +1 -0
- package/dist/src/core/import_export/import_export.service.d.ts +94 -0
- package/dist/src/core/import_export/import_export.service.js +2723 -0
- package/dist/src/core/import_export/import_export.service.js.map +1 -0
- package/dist/src/core/import_export/import_export.utils.d.ts +3 -0
- package/dist/src/core/import_export/import_export.utils.js +21 -0
- package/dist/src/core/import_export/import_export.utils.js.map +1 -0
- package/dist/src/core/import_export/log/import_export_log.layout.d.ts +2 -0
- package/dist/src/core/import_export/log/import_export_log.layout.js +423 -0
- package/dist/src/core/import_export/log/import_export_log.layout.js.map +1 -0
- package/dist/src/core/import_export/log/import_export_log.schema.d.ts +23 -0
- package/dist/src/core/import_export/log/import_export_log.schema.js +131 -0
- package/dist/src/core/import_export/log/import_export_log.schema.js.map +1 -0
- package/dist/src/core/import_export/log/import_export_log.service.d.ts +12 -0
- package/dist/src/core/import_export/log/import_export_log.service.js +49 -0
- package/dist/src/core/import_export/log/import_export_log.service.js.map +1 -0
- package/dist/src/core/import_export/provider/export.provider.d.ts +8 -0
- package/dist/src/core/import_export/provider/export.provider.js +244 -0
- package/dist/src/core/import_export/provider/export.provider.js.map +1 -0
- package/dist/src/core/import_export/provider/import.provider.d.ts +8 -0
- package/dist/src/core/import_export/provider/import.provider.js +238 -0
- package/dist/src/core/import_export/provider/import.provider.js.map +1 -0
- package/dist/src/core/import_export/provider/provider.base.d.ts +8 -0
- package/dist/src/core/import_export/provider/provider.base.js +19 -0
- package/dist/src/core/import_export/provider/provider.base.js.map +1 -0
- package/dist/src/core/import_export/provider/provider.interface.d.ts +6 -0
- package/dist/src/core/import_export/provider/provider.interface.js +3 -0
- package/dist/src/core/import_export/provider/provider.interface.js.map +1 -0
- package/dist/src/core/index.d.ts +271 -0
- package/dist/src/core/index.js +668 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/language/langauge.constant.d.ts +9 -0
- package/dist/src/core/language/langauge.constant.js +13 -0
- package/dist/src/core/language/langauge.constant.js.map +1 -0
- package/dist/src/core/language/langauge.enum.d.ts +4 -0
- package/dist/src/core/language/langauge.enum.js +9 -0
- package/dist/src/core/language/langauge.enum.js.map +1 -0
- package/dist/src/core/language/language.controller.d.ts +6 -0
- package/dist/src/core/language/language.controller.js +36 -0
- package/dist/src/core/language/language.controller.js.map +1 -0
- package/dist/src/core/language/language.hook.d.ts +13 -0
- package/dist/src/core/language/language.hook.js +36 -0
- package/dist/src/core/language/language.hook.js.map +1 -0
- package/dist/src/core/language/language.layout.d.ts +2 -0
- package/dist/src/core/language/language.layout.js +299 -0
- package/dist/src/core/language/language.layout.js.map +1 -0
- package/dist/src/core/language/language.module.d.ts +2 -0
- package/dist/src/core/language/language.module.js +42 -0
- package/dist/src/core/language/language.module.js.map +1 -0
- package/dist/src/core/language/language.schema.d.ts +13 -0
- package/dist/src/core/language/language.schema.js +57 -0
- package/dist/src/core/language/language.schema.js.map +1 -0
- package/dist/src/core/language/language.service.d.ts +14 -0
- package/dist/src/core/language/language.service.js +76 -0
- package/dist/src/core/language/language.service.js.map +1 -0
- package/dist/src/core/layout/chart_widget/chart_widget.controller.d.ts +7 -0
- package/dist/src/core/layout/chart_widget/chart_widget.controller.js +54 -0
- package/dist/src/core/layout/chart_widget/chart_widget.controller.js.map +1 -0
- package/dist/src/core/layout/chart_widget/chart_widget.service.d.ts +36 -0
- package/dist/src/core/layout/chart_widget/chart_widget.service.js +1355 -0
- package/dist/src/core/layout/chart_widget/chart_widget.service.js.map +1 -0
- package/dist/src/core/layout/layout.constant.d.ts +17 -0
- package/dist/src/core/layout/layout.constant.js +23 -0
- package/dist/src/core/layout/layout.constant.js.map +1 -0
- package/dist/src/core/layout/layout.module.d.ts +2 -0
- package/dist/src/core/layout/layout.module.js +43 -0
- package/dist/src/core/layout/layout.module.js.map +1 -0
- package/dist/src/core/layout/share_widget/share_widget.layout.d.ts +2 -0
- package/dist/src/core/layout/share_widget/share_widget.layout.js +5 -0
- package/dist/src/core/layout/share_widget/share_widget.layout.js.map +1 -0
- package/dist/src/core/layout/share_widget/share_widget.schema.d.ts +14 -0
- package/dist/src/core/layout/share_widget/share_widget.schema.js +80 -0
- package/dist/src/core/layout/share_widget/share_widget.schema.js.map +1 -0
- package/dist/src/core/layout/share_widget/share_widget.service.d.ts +19 -0
- package/dist/src/core/layout/share_widget/share_widget.service.js +110 -0
- package/dist/src/core/layout/share_widget/share_widget.service.js.map +1 -0
- package/dist/src/core/mail/log/mail_log.layout.d.ts +2 -0
- package/dist/src/core/mail/log/mail_log.layout.js +697 -0
- package/dist/src/core/mail/log/mail_log.layout.js.map +1 -0
- package/dist/src/core/mail/log/mail_log.schema.d.ts +21 -0
- package/dist/src/core/mail/log/mail_log.schema.js +94 -0
- package/dist/src/core/mail/log/mail_log.schema.js.map +1 -0
- package/dist/src/core/mail/log/mail_log.service.d.ts +12 -0
- package/dist/src/core/mail/log/mail_log.service.js +49 -0
- package/dist/src/core/mail/log/mail_log.service.js.map +1 -0
- package/dist/src/core/mail/mail.controller.d.ts +7 -0
- package/dist/src/core/mail/mail.controller.js +50 -0
- package/dist/src/core/mail/mail.controller.js.map +1 -0
- package/dist/src/core/mail/mail.custom_actions.d.ts +27 -0
- package/dist/src/core/mail/mail.custom_actions.js +35 -0
- package/dist/src/core/mail/mail.custom_actions.js.map +1 -0
- package/dist/src/core/mail/mail.enum.d.ts +3 -0
- package/dist/src/core/mail/mail.enum.js +8 -0
- package/dist/src/core/mail/mail.enum.js.map +1 -0
- package/dist/src/core/mail/mail.hook.d.ts +15 -0
- package/dist/src/core/mail/mail.hook.js +23 -0
- package/dist/src/core/mail/mail.hook.js.map +1 -0
- package/dist/src/core/mail/mail.layout.d.ts +2 -0
- package/dist/src/core/mail/mail.layout.js +653 -0
- package/dist/src/core/mail/mail.layout.js.map +1 -0
- package/dist/src/core/mail/mail.module.d.ts +2 -0
- package/dist/src/core/mail/mail.module.js +50 -0
- package/dist/src/core/mail/mail.module.js.map +1 -0
- package/dist/src/core/mail/mail.schema.d.ts +24 -0
- package/dist/src/core/mail/mail.schema.js +106 -0
- package/dist/src/core/mail/mail.schema.js.map +1 -0
- package/dist/src/core/mail/mail.service.d.ts +19 -0
- package/dist/src/core/mail/mail.service.js +193 -0
- package/dist/src/core/mail/mail.service.js.map +1 -0
- package/dist/src/core/map_location/map_location.layout.d.ts +2 -0
- package/dist/src/core/map_location/map_location.layout.js +102 -0
- package/dist/src/core/map_location/map_location.layout.js.map +1 -0
- package/dist/src/core/map_location/map_location.schema.d.ts +10 -0
- package/dist/src/core/map_location/map_location.schema.js +46 -0
- package/dist/src/core/map_location/map_location.schema.js.map +1 -0
- package/dist/src/core/map_location/map_location.service.d.ts +12 -0
- package/dist/src/core/map_location/map_location.service.js +44 -0
- package/dist/src/core/map_location/map_location.service.js.map +1 -0
- package/dist/src/core/map_location/map_locatioon.module.d.ts +2 -0
- package/dist/src/core/map_location/map_locatioon.module.js +38 -0
- package/dist/src/core/map_location/map_locatioon.module.js.map +1 -0
- package/dist/src/core/middlewares/request.middleware.d.ts +2 -0
- package/dist/src/core/middlewares/request.middleware.js +11 -0
- package/dist/src/core/middlewares/request.middleware.js.map +1 -0
- package/dist/src/core/notification/log/log.layout.d.ts +2 -0
- package/dist/src/core/notification/log/log.layout.js +19 -0
- package/dist/src/core/notification/log/log.layout.js.map +1 -0
- package/dist/src/core/notification/log/log.schema.d.ts +23 -0
- package/dist/src/core/notification/log/log.schema.js +94 -0
- package/dist/src/core/notification/log/log.schema.js.map +1 -0
- package/dist/src/core/notification/log/log.service.d.ts +12 -0
- package/dist/src/core/notification/log/log.service.js +45 -0
- package/dist/src/core/notification/log/log.service.js.map +1 -0
- package/dist/src/core/notification/message/message.controller.d.ts +6 -0
- package/dist/src/core/notification/message/message.controller.js +36 -0
- package/dist/src/core/notification/message/message.controller.js.map +1 -0
- package/dist/src/core/notification/message/message.custom_action.d.ts +15 -0
- package/dist/src/core/notification/message/message.custom_action.js +21 -0
- package/dist/src/core/notification/message/message.custom_action.js.map +1 -0
- package/dist/src/core/notification/message/message.layout.d.ts +2 -0
- package/dist/src/core/notification/message/message.layout.js +732 -0
- package/dist/src/core/notification/message/message.layout.js.map +1 -0
- package/dist/src/core/notification/message/message.schema.d.ts +22 -0
- package/dist/src/core/notification/message/message.schema.js +97 -0
- package/dist/src/core/notification/message/message.schema.js.map +1 -0
- package/dist/src/core/notification/message/message.service.d.ts +23 -0
- package/dist/src/core/notification/message/message.service.js +203 -0
- package/dist/src/core/notification/message/message.service.js.map +1 -0
- package/dist/src/core/notification/message/message.workflow.d.ts +2 -0
- package/dist/src/core/notification/message/message.workflow.js +455 -0
- package/dist/src/core/notification/message/message.workflow.js.map +1 -0
- package/dist/src/core/notification/message_queue/message_queue.controller.d.ts +6 -0
- package/dist/src/core/notification/message_queue/message_queue.controller.js +36 -0
- package/dist/src/core/notification/message_queue/message_queue.controller.js.map +1 -0
- package/dist/src/core/notification/message_queue/message_queue.layout.d.ts +2 -0
- package/dist/src/core/notification/message_queue/message_queue.layout.js +5 -0
- package/dist/src/core/notification/message_queue/message_queue.layout.js.map +1 -0
- package/dist/src/core/notification/message_queue/message_queue.schema.d.ts +17 -0
- package/dist/src/core/notification/message_queue/message_queue.schema.js +63 -0
- package/dist/src/core/notification/message_queue/message_queue.schema.js.map +1 -0
- package/dist/src/core/notification/message_queue/message_queue.service.d.ts +16 -0
- package/dist/src/core/notification/message_queue/message_queue.service.js +151 -0
- package/dist/src/core/notification/message_queue/message_queue.service.js.map +1 -0
- package/dist/src/core/notification/notification.constant.d.ts +8 -0
- package/dist/src/core/notification/notification.constant.js +13 -0
- package/dist/src/core/notification/notification.constant.js.map +1 -0
- package/dist/src/core/notification/notification.module.d.ts +2 -0
- package/dist/src/core/notification/notification.module.js +85 -0
- package/dist/src/core/notification/notification.module.js.map +1 -0
- package/dist/src/core/notification/subscription /subscription.controller.d.ts +7 -0
- package/dist/src/core/notification/subscription /subscription.controller.js +51 -0
- package/dist/src/core/notification/subscription /subscription.controller.js.map +1 -0
- package/dist/src/core/notification/subscription /subscription.layout.d.ts +2 -0
- package/dist/src/core/notification/subscription /subscription.layout.js +5 -0
- package/dist/src/core/notification/subscription /subscription.layout.js.map +1 -0
- package/dist/src/core/notification/subscription /subscription.schema.d.ts +11 -0
- package/dist/src/core/notification/subscription /subscription.schema.js +48 -0
- package/dist/src/core/notification/subscription /subscription.schema.js.map +1 -0
- package/dist/src/core/notification/subscription /subscription.service.d.ts +14 -0
- package/dist/src/core/notification/subscription /subscription.service.js +82 -0
- package/dist/src/core/notification/subscription /subscription.service.js.map +1 -0
- package/dist/src/core/pipeline/job/job.controller.d.ts +8 -0
- package/dist/src/core/pipeline/job/job.controller.js +59 -0
- package/dist/src/core/pipeline/job/job.controller.js.map +1 -0
- package/dist/src/core/pipeline/job/job.layout.d.ts +2 -0
- package/dist/src/core/pipeline/job/job.layout.js +5 -0
- package/dist/src/core/pipeline/job/job.layout.js.map +1 -0
- package/dist/src/core/pipeline/job/job.schema.d.ts +16 -0
- package/dist/src/core/pipeline/job/job.schema.js +80 -0
- package/dist/src/core/pipeline/job/job.schema.js.map +1 -0
- package/dist/src/core/pipeline/job/job.service.d.ts +21 -0
- package/dist/src/core/pipeline/job/job.service.js +259 -0
- package/dist/src/core/pipeline/job/job.service.js.map +1 -0
- package/dist/src/core/pipeline/log/log.layout.d.ts +2 -0
- package/dist/src/core/pipeline/log/log.layout.js +276 -0
- package/dist/src/core/pipeline/log/log.layout.js.map +1 -0
- package/dist/src/core/pipeline/log/log.schema.d.ts +20 -0
- package/dist/src/core/pipeline/log/log.schema.js +93 -0
- package/dist/src/core/pipeline/log/log.schema.js.map +1 -0
- package/dist/src/core/pipeline/log/log.service.d.ts +12 -0
- package/dist/src/core/pipeline/log/log.service.js +48 -0
- package/dist/src/core/pipeline/log/log.service.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.controller.d.ts +6 -0
- package/dist/src/core/pipeline/pipeline.controller.js +41 -0
- package/dist/src/core/pipeline/pipeline.controller.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.dto.d.ts +5 -0
- package/dist/src/core/pipeline/pipeline.dto.js +7 -0
- package/dist/src/core/pipeline/pipeline.dto.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.enum.d.ts +16 -0
- package/dist/src/core/pipeline/pipeline.enum.js +23 -0
- package/dist/src/core/pipeline/pipeline.enum.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.layout.d.ts +2 -0
- package/dist/src/core/pipeline/pipeline.layout.js +625 -0
- package/dist/src/core/pipeline/pipeline.layout.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.module.d.ts +2 -0
- package/dist/src/core/pipeline/pipeline.module.js +59 -0
- package/dist/src/core/pipeline/pipeline.module.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.schema.d.ts +11 -0
- package/dist/src/core/pipeline/pipeline.schema.js +39 -0
- package/dist/src/core/pipeline/pipeline.schema.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.service.d.ts +21 -0
- package/dist/src/core/pipeline/pipeline.service.js +282 -0
- package/dist/src/core/pipeline/pipeline.service.js.map +1 -0
- package/dist/src/core/pipeline/pipeline.utils.d.ts +1 -0
- package/dist/src/core/pipeline/pipeline.utils.js +30 -0
- package/dist/src/core/pipeline/pipeline.utils.js.map +1 -0
- package/dist/src/core/pipeline/provider/base_pipeline.provider.d.ts +8 -0
- package/dist/src/core/pipeline/provider/base_pipeline.provider.js +16 -0
- package/dist/src/core/pipeline/provider/base_pipeline.provider.js.map +1 -0
- package/dist/src/core/pipeline/provider/pipeline.interface.d.ts +6 -0
- package/dist/src/core/pipeline/provider/pipeline.interface.js +3 -0
- package/dist/src/core/pipeline/provider/pipeline.interface.js.map +1 -0
- package/dist/src/core/queue/queue.controller.d.ts +21 -0
- package/dist/src/core/queue/queue.controller.js +99 -0
- package/dist/src/core/queue/queue.controller.js.map +1 -0
- package/dist/src/core/queue/queue.module.d.ts +4 -0
- package/dist/src/core/queue/queue.module.js +200 -0
- package/dist/src/core/queue/queue.module.js.map +1 -0
- package/dist/src/core/queue/queue.processor.d.ts +46 -0
- package/dist/src/core/queue/queue.processor.js +461 -0
- package/dist/src/core/queue/queue.processor.js.map +1 -0
- package/dist/src/core/queue/queue.service.d.ts +19 -0
- package/dist/src/core/queue/queue.service.js +73 -0
- package/dist/src/core/queue/queue.service.js.map +1 -0
- package/dist/src/core/reason/reason.layout.d.ts +4 -0
- package/dist/src/core/reason/reason.layout.js +579 -0
- package/dist/src/core/reason/reason.layout.js.map +1 -0
- package/dist/src/core/reason/reason.module.d.ts +2 -0
- package/dist/src/core/reason/reason.module.js +52 -0
- package/dist/src/core/reason/reason.module.js.map +1 -0
- package/dist/src/core/reason/reason.schema.d.ts +31 -0
- package/dist/src/core/reason/reason.schema.js +119 -0
- package/dist/src/core/reason/reason.schema.js.map +1 -0
- package/dist/src/core/reason/reason.service.d.ts +26 -0
- package/dist/src/core/reason/reason.service.js +82 -0
- package/dist/src/core/reason/reason.service.js.map +1 -0
- package/dist/src/core/redis/redis.constant.d.ts +2 -0
- package/dist/src/core/redis/redis.constant.js +6 -0
- package/dist/src/core/redis/redis.constant.js.map +1 -0
- package/dist/src/core/redis/redis.controller.d.ts +9 -0
- package/dist/src/core/redis/redis.controller.js +72 -0
- package/dist/src/core/redis/redis.controller.js.map +1 -0
- package/dist/src/core/redis/redis.module.d.ts +2 -0
- package/dist/src/core/redis/redis.module.js +24 -0
- package/dist/src/core/redis/redis.module.js.map +1 -0
- package/dist/src/core/redis/redis.service.d.ts +12 -0
- package/dist/src/core/redis/redis.service.js +145 -0
- package/dist/src/core/redis/redis.service.js.map +1 -0
- package/dist/src/core/rewrite_url/provider/provider.base.d.ts +7 -0
- package/dist/src/core/rewrite_url/provider/provider.base.js +12 -0
- package/dist/src/core/rewrite_url/provider/provider.base.js.map +1 -0
- package/dist/src/core/rewrite_url/provider/provider.interface.d.ts +9 -0
- package/dist/src/core/rewrite_url/provider/provider.interface.js +3 -0
- package/dist/src/core/rewrite_url/provider/provider.interface.js.map +1 -0
- package/dist/src/core/rewrite_url/rewrite_url.constant.d.ts +1 -0
- package/dist/src/core/rewrite_url/rewrite_url.constant.js +5 -0
- package/dist/src/core/rewrite_url/rewrite_url.constant.js.map +1 -0
- package/dist/src/core/rewrite_url/rewrite_url.controller.d.ts +7 -0
- package/dist/src/core/rewrite_url/rewrite_url.controller.js +52 -0
- package/dist/src/core/rewrite_url/rewrite_url.controller.js.map +1 -0
- package/dist/src/core/rewrite_url/rewrite_url.module.d.ts +2 -0
- package/dist/src/core/rewrite_url/rewrite_url.module.js +26 -0
- package/dist/src/core/rewrite_url/rewrite_url.module.js.map +1 -0
- package/dist/src/core/rewrite_url/rewrite_url.service.d.ts +10 -0
- package/dist/src/core/rewrite_url/rewrite_url.service.js +103 -0
- package/dist/src/core/rewrite_url/rewrite_url.service.js.map +1 -0
- package/dist/src/core/schedule_action/log/schedule_log.layout.d.ts +2 -0
- package/dist/src/core/schedule_action/log/schedule_log.layout.js +458 -0
- package/dist/src/core/schedule_action/log/schedule_log.layout.js.map +1 -0
- package/dist/src/core/schedule_action/log/schedule_log.schema.d.ts +15 -0
- package/dist/src/core/schedule_action/log/schedule_log.schema.js +70 -0
- package/dist/src/core/schedule_action/log/schedule_log.schema.js.map +1 -0
- package/dist/src/core/schedule_action/log/schedule_log.service.d.ts +12 -0
- package/dist/src/core/schedule_action/log/schedule_log.service.js +49 -0
- package/dist/src/core/schedule_action/log/schedule_log.service.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.controller.d.ts +14 -0
- package/dist/src/core/schedule_action/schedule_action.controller.js +103 -0
- package/dist/src/core/schedule_action/schedule_action.controller.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.enum.d.ts +12 -0
- package/dist/src/core/schedule_action/schedule_action.enum.js +19 -0
- package/dist/src/core/schedule_action/schedule_action.enum.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.hook.d.ts +11 -0
- package/dist/src/core/schedule_action/schedule_action.hook.js +19 -0
- package/dist/src/core/schedule_action/schedule_action.hook.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.layout.d.ts +2 -0
- package/dist/src/core/schedule_action/schedule_action.layout.js +615 -0
- package/dist/src/core/schedule_action/schedule_action.layout.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.module.d.ts +2 -0
- package/dist/src/core/schedule_action/schedule_action.module.js +65 -0
- package/dist/src/core/schedule_action/schedule_action.module.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.schema.d.ts +30 -0
- package/dist/src/core/schedule_action/schedule_action.schema.js +139 -0
- package/dist/src/core/schedule_action/schedule_action.schema.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action.service.d.ts +30 -0
- package/dist/src/core/schedule_action/schedule_action.service.js +319 -0
- package/dist/src/core/schedule_action/schedule_action.service.js.map +1 -0
- package/dist/src/core/schedule_action/schedule_action_cron.service.d.ts +17 -0
- package/dist/src/core/schedule_action/schedule_action_cron.service.js +222 -0
- package/dist/src/core/schedule_action/schedule_action_cron.service.js.map +1 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.schema.d.ts +11 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.schema.js +40 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.schema.js.map +1 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.service.d.ts +14 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.service.js +74 -0
- package/dist/src/core/search_text/reindex_search_text/reindex_search_text.service.js.map +1 -0
- package/dist/src/core/search_text/search_text.controller.d.ts +8 -0
- package/dist/src/core/search_text/search_text.controller.js +57 -0
- package/dist/src/core/search_text/search_text.controller.js.map +1 -0
- package/dist/src/core/search_text/search_text.module.d.ts +2 -0
- package/dist/src/core/search_text/search_text.module.js +51 -0
- package/dist/src/core/search_text/search_text.module.js.map +1 -0
- package/dist/src/core/search_text/search_text.schema.d.ts +10 -0
- package/dist/src/core/search_text/search_text.schema.js +38 -0
- package/dist/src/core/search_text/search_text.schema.js.map +1 -0
- package/dist/src/core/search_text/search_text.service.d.ts +30 -0
- package/dist/src/core/search_text/search_text.service.js +295 -0
- package/dist/src/core/search_text/search_text.service.js.map +1 -0
- package/dist/src/core/setting/dto/auth_setting.dto.d.ts +43 -0
- package/dist/src/core/setting/dto/auth_setting.dto.js +151 -0
- package/dist/src/core/setting/dto/auth_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/es_setting.dto.d.ts +3 -0
- package/dist/src/core/setting/dto/es_setting.dto.js +21 -0
- package/dist/src/core/setting/dto/es_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/general_setting.dto.d.ts +10 -0
- package/dist/src/core/setting/dto/general_setting.dto.js +49 -0
- package/dist/src/core/setting/dto/general_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/layout_setting.dto.d.ts +5 -0
- package/dist/src/core/setting/dto/layout_setting.dto.js +29 -0
- package/dist/src/core/setting/dto/layout_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/log_setting.dto.d.ts +17 -0
- package/dist/src/core/setting/dto/log_setting.dto.js +57 -0
- package/dist/src/core/setting/dto/log_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/login_method.dto.d.ts +4 -0
- package/dist/src/core/setting/dto/login_method.dto.js +25 -0
- package/dist/src/core/setting/dto/login_method.dto.js.map +1 -0
- package/dist/src/core/setting/dto/media_setting.dto.d.ts +29 -0
- package/dist/src/core/setting/dto/media_setting.dto.js +43 -0
- package/dist/src/core/setting/dto/media_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/menu_setting.dto.d.ts +17 -0
- package/dist/src/core/setting/dto/menu_setting.dto.js +76 -0
- package/dist/src/core/setting/dto/menu_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/queue_setting.dto.d.ts +3 -0
- package/dist/src/core/setting/dto/queue_setting.dto.js +21 -0
- package/dist/src/core/setting/dto/queue_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/schedule_setting.dto.d.ts +5 -0
- package/dist/src/core/setting/dto/schedule_setting.dto.js +29 -0
- package/dist/src/core/setting/dto/schedule_setting.dto.js.map +1 -0
- package/dist/src/core/setting/dto/swagger_setting.dto.d.ts +5 -0
- package/dist/src/core/setting/dto/swagger_setting.dto.js +29 -0
- package/dist/src/core/setting/dto/swagger_setting.dto.js.map +1 -0
- package/dist/src/core/setting/setting.constant.d.ts +309 -0
- package/dist/src/core/setting/setting.constant.js +650 -0
- package/dist/src/core/setting/setting.constant.js.map +1 -0
- package/dist/src/core/setting/setting.controller.d.ts +54 -0
- package/dist/src/core/setting/setting.controller.js +487 -0
- package/dist/src/core/setting/setting.controller.js.map +1 -0
- package/dist/src/core/setting/setting.module.d.ts +2 -0
- package/dist/src/core/setting/setting.module.js +40 -0
- package/dist/src/core/setting/setting.module.js.map +1 -0
- package/dist/src/core/setting/setting.schema.d.ts +10 -0
- package/dist/src/core/setting/setting.schema.js +35 -0
- package/dist/src/core/setting/setting.schema.js.map +1 -0
- package/dist/src/core/setting/setting.service.d.ts +76 -0
- package/dist/src/core/setting/setting.service.js +1378 -0
- package/dist/src/core/setting/setting.service.js.map +1 -0
- package/dist/src/core/shortly/shortly.constant.d.ts +5 -0
- package/dist/src/core/shortly/shortly.constant.js +10 -0
- package/dist/src/core/shortly/shortly.constant.js.map +1 -0
- package/dist/src/core/shortly/shortly.module.d.ts +2 -0
- package/dist/src/core/shortly/shortly.module.js +42 -0
- package/dist/src/core/shortly/shortly.module.js.map +1 -0
- package/dist/src/core/shortly/url/url.controller.d.ts +6 -0
- package/dist/src/core/shortly/url/url.controller.js +41 -0
- package/dist/src/core/shortly/url/url.controller.js.map +1 -0
- package/dist/src/core/shortly/url/url.layout.d.ts +2 -0
- package/dist/src/core/shortly/url/url.layout.js +486 -0
- package/dist/src/core/shortly/url/url.layout.js.map +1 -0
- package/dist/src/core/shortly/url/url.schema.d.ts +15 -0
- package/dist/src/core/shortly/url/url.schema.js +69 -0
- package/dist/src/core/shortly/url/url.schema.js.map +1 -0
- package/dist/src/core/shortly/url/url.service.d.ts +16 -0
- package/dist/src/core/shortly/url/url.service.js +108 -0
- package/dist/src/core/shortly/url/url.service.js.map +1 -0
- package/dist/src/core/sms/log/sms_log.layout.d.ts +2 -0
- package/dist/src/core/sms/log/sms_log.layout.js +668 -0
- package/dist/src/core/sms/log/sms_log.layout.js.map +1 -0
- package/dist/src/core/sms/log/sms_log.schema.d.ts +27 -0
- package/dist/src/core/sms/log/sms_log.schema.js +115 -0
- package/dist/src/core/sms/log/sms_log.schema.js.map +1 -0
- package/dist/src/core/sms/log/sms_log.service.d.ts +14 -0
- package/dist/src/core/sms/log/sms_log.service.js +70 -0
- package/dist/src/core/sms/log/sms_log.service.js.map +1 -0
- package/dist/src/core/sms/sms.controller.d.ts +6 -0
- package/dist/src/core/sms/sms.controller.js +41 -0
- package/dist/src/core/sms/sms.controller.js.map +1 -0
- package/dist/src/core/sms/sms.enum.d.ts +12 -0
- package/dist/src/core/sms/sms.enum.js +19 -0
- package/dist/src/core/sms/sms.enum.js.map +1 -0
- package/dist/src/core/sms/sms.layout.d.ts +2 -0
- package/dist/src/core/sms/sms.layout.js +766 -0
- package/dist/src/core/sms/sms.layout.js.map +1 -0
- package/dist/src/core/sms/sms.module.d.ts +2 -0
- package/dist/src/core/sms/sms.module.js +49 -0
- package/dist/src/core/sms/sms.module.js.map +1 -0
- package/dist/src/core/sms/sms.schema.d.ts +24 -0
- package/dist/src/core/sms/sms.schema.js +107 -0
- package/dist/src/core/sms/sms.schema.js.map +1 -0
- package/dist/src/core/sms/sms.service.d.ts +16 -0
- package/dist/src/core/sms/sms.service.js +272 -0
- package/dist/src/core/sms/sms.service.js.map +1 -0
- package/dist/src/core/template/data/templates.json +192 -0
- package/dist/src/core/template/log/print_log.enum.d.ts +5 -0
- package/dist/src/core/template/log/print_log.enum.js +10 -0
- package/dist/src/core/template/log/print_log.enum.js.map +1 -0
- package/dist/src/core/template/log/print_log.layout.d.ts +2 -0
- package/dist/src/core/template/log/print_log.layout.js +483 -0
- package/dist/src/core/template/log/print_log.layout.js.map +1 -0
- package/dist/src/core/template/log/print_log.schema.d.ts +18 -0
- package/dist/src/core/template/log/print_log.schema.js +104 -0
- package/dist/src/core/template/log/print_log.schema.js.map +1 -0
- package/dist/src/core/template/log/print_log.service.d.ts +12 -0
- package/dist/src/core/template/log/print_log.service.js +49 -0
- package/dist/src/core/template/log/print_log.service.js.map +1 -0
- package/dist/src/core/template/provider/base_template.provider.d.ts +9 -0
- package/dist/src/core/template/provider/base_template.provider.js +22 -0
- package/dist/src/core/template/provider/base_template.provider.js.map +1 -0
- package/dist/src/core/template/provider/email.provider.d.ts +8 -0
- package/dist/src/core/template/provider/email.provider.js +155 -0
- package/dist/src/core/template/provider/email.provider.js.map +1 -0
- package/dist/src/core/template/provider/sms.provider.d.ts +8 -0
- package/dist/src/core/template/provider/sms.provider.js +93 -0
- package/dist/src/core/template/provider/sms.provider.js.map +1 -0
- package/dist/src/core/template/provider/template.interface.d.ts +7 -0
- package/dist/src/core/template/provider/template.interface.js +3 -0
- package/dist/src/core/template/provider/template.interface.js.map +1 -0
- package/dist/src/core/template/provider/template_email.provider.d.ts +8 -0
- package/dist/src/core/template/provider/template_email.provider.js +472 -0
- package/dist/src/core/template/provider/template_email.provider.js.map +1 -0
- package/dist/src/core/template/provider/template_print.provider.d.ts +9 -0
- package/dist/src/core/template/provider/template_print.provider.js +1114 -0
- package/dist/src/core/template/provider/template_print.provider.js.map +1 -0
- package/dist/src/core/template/provider/template_sms.provider.d.ts +8 -0
- package/dist/src/core/template/provider/template_sms.provider.js +453 -0
- package/dist/src/core/template/provider/template_sms.provider.js.map +1 -0
- package/dist/src/core/template/template.controller.d.ts +15 -0
- package/dist/src/core/template/template.controller.js +140 -0
- package/dist/src/core/template/template.controller.js.map +1 -0
- package/dist/src/core/template/template.enum.d.ts +34 -0
- package/dist/src/core/template/template.enum.js +43 -0
- package/dist/src/core/template/template.enum.js.map +1 -0
- package/dist/src/core/template/template.hook.d.ts +18 -0
- package/dist/src/core/template/template.hook.js +26 -0
- package/dist/src/core/template/template.hook.js.map +1 -0
- package/dist/src/core/template/template.layout.d.ts +2 -0
- package/dist/src/core/template/template.layout.js +399 -0
- package/dist/src/core/template/template.layout.js.map +1 -0
- package/dist/src/core/template/template.module.d.ts +2 -0
- package/dist/src/core/template/template.module.js +49 -0
- package/dist/src/core/template/template.module.js.map +1 -0
- package/dist/src/core/template/template.schema.d.ts +57 -0
- package/dist/src/core/template/template.schema.js +265 -0
- package/dist/src/core/template/template.schema.js.map +1 -0
- package/dist/src/core/template/template.service.d.ts +49 -0
- package/dist/src/core/template/template.service.js +900 -0
- package/dist/src/core/template/template.service.js.map +1 -0
- package/dist/src/core/template/template.utils.d.ts +25 -0
- package/dist/src/core/template/template.utils.js +292 -0
- package/dist/src/core/template/template.utils.js.map +1 -0
- package/dist/src/core/translate/translate.controller.d.ts +8 -0
- package/dist/src/core/translate/translate.controller.js +74 -0
- package/dist/src/core/translate/translate.controller.js.map +1 -0
- package/dist/src/core/translate/translate.enum.d.ts +5 -0
- package/dist/src/core/translate/translate.enum.js +10 -0
- package/dist/src/core/translate/translate.enum.js.map +1 -0
- package/dist/src/core/translate/translate.hook.d.ts +13 -0
- package/dist/src/core/translate/translate.hook.js +21 -0
- package/dist/src/core/translate/translate.hook.js.map +1 -0
- package/dist/src/core/translate/translate.json +2011 -0
- package/dist/src/core/translate/translate.layout.d.ts +2 -0
- package/dist/src/core/translate/translate.layout.js +95 -0
- package/dist/src/core/translate/translate.layout.js.map +1 -0
- package/dist/src/core/translate/translate.module.d.ts +2 -0
- package/dist/src/core/translate/translate.module.js +42 -0
- package/dist/src/core/translate/translate.module.js.map +1 -0
- package/dist/src/core/translate/translate.schema.d.ts +16 -0
- package/dist/src/core/translate/translate.schema.js +76 -0
- package/dist/src/core/translate/translate.schema.js.map +1 -0
- package/dist/src/core/translate/translate.service.d.ts +17 -0
- package/dist/src/core/translate/translate.service.js +139 -0
- package/dist/src/core/translate/translate.service.js.map +1 -0
- package/dist/src/core/users/user.config.d.ts +4 -0
- package/dist/src/core/users/user.config.js +8 -0
- package/dist/src/core/users/user.config.js.map +1 -0
- package/dist/src/core/users/user.constant.d.ts +4 -0
- package/dist/src/core/users/user.constant.js +36 -0
- package/dist/src/core/users/user.constant.js.map +1 -0
- package/dist/src/core/users/user.controller.d.ts +33 -0
- package/dist/src/core/users/user.controller.js +292 -0
- package/dist/src/core/users/user.controller.js.map +1 -0
- package/dist/src/core/users/user.enum.d.ts +40 -0
- package/dist/src/core/users/user.enum.js +48 -0
- package/dist/src/core/users/user.enum.js.map +1 -0
- package/dist/src/core/users/user.hook.d.ts +25 -0
- package/dist/src/core/users/user.hook.js +36 -0
- package/dist/src/core/users/user.hook.js.map +1 -0
- package/dist/src/core/users/user.layout.d.ts +4 -0
- package/dist/src/core/users/user.layout.js +2333 -0
- package/dist/src/core/users/user.layout.js.map +1 -0
- package/dist/src/core/users/user.module.d.ts +2 -0
- package/dist/src/core/users/user.module.js +77 -0
- package/dist/src/core/users/user.module.js.map +1 -0
- package/dist/src/core/users/user.permission.d.ts +2 -0
- package/dist/src/core/users/user.permission.js +10 -0
- package/dist/src/core/users/user.permission.js.map +1 -0
- package/dist/src/core/users/user.schema.d.ts +73 -0
- package/dist/src/core/users/user.schema.js +316 -0
- package/dist/src/core/users/user.schema.js.map +1 -0
- package/dist/src/core/users/user.service.d.ts +100 -0
- package/dist/src/core/users/user.service.js +1551 -0
- package/dist/src/core/users/user.service.js.map +1 -0
- package/dist/src/core/version_data/version_data.module.d.ts +2 -0
- package/dist/src/core/version_data/version_data.module.js +38 -0
- package/dist/src/core/version_data/version_data.module.js.map +1 -0
- package/dist/src/core/version_data/version_data.schema.d.ts +13 -0
- package/dist/src/core/version_data/version_data.schema.js +55 -0
- package/dist/src/core/version_data/version_data.schema.js.map +1 -0
- package/dist/src/core/version_data/version_data.service.d.ts +12 -0
- package/dist/src/core/version_data/version_data.service.js +43 -0
- package/dist/src/core/version_data/version_data.service.js.map +1 -0
- package/dist/src/core/widget/widget.controller.d.ts +6 -0
- package/dist/src/core/widget/widget.controller.js +42 -0
- package/dist/src/core/widget/widget.controller.js.map +1 -0
- package/dist/src/core/widget/widget.enum.d.ts +19 -0
- package/dist/src/core/widget/widget.enum.js +25 -0
- package/dist/src/core/widget/widget.enum.js.map +1 -0
- package/dist/src/core/widget/widget.module.d.ts +2 -0
- package/dist/src/core/widget/widget.module.js +40 -0
- package/dist/src/core/widget/widget.module.js.map +1 -0
- package/dist/src/core/widget/widget.schema.d.ts +21 -0
- package/dist/src/core/widget/widget.schema.js +94 -0
- package/dist/src/core/widget/widget.schema.js.map +1 -0
- package/dist/src/core/widget/widget.service.d.ts +15 -0
- package/dist/src/core/widget/widget.service.js +370 -0
- package/dist/src/core/widget/widget.service.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/main.js +235 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/modules/index.d.ts +1 -0
- package/dist/src/modules/index.js +6 -0
- package/dist/src/modules/index.js.map +1 -0
- package/dist/src/modules/modules.d.ts +3 -0
- package/dist/src/modules/modules.js +8 -0
- package/dist/src/modules/modules.js.map +1 -0
- package/dist/src/private.controller.d.ts +6 -0
- package/dist/src/private.controller.js +44 -0
- package/dist/src/private.controller.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/typings/node/index.d.ts +4 -0
- package/dist/typings/node/index.js +1 -0
- package/dist/typings/node/index.js.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,2723 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
21
|
+
t[p[i]] = s[p[i]];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
var ImportExportService_1;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.ImportExportService = void 0;
|
|
28
|
+
const mongoose = require("mongoose");
|
|
29
|
+
const _ = require("lodash");
|
|
30
|
+
const csv = require("csvtojson");
|
|
31
|
+
const mime = require("mime-types");
|
|
32
|
+
const cartesian = require("cartesian");
|
|
33
|
+
const moment = require("moment");
|
|
34
|
+
const monent_tz = require("moment-timezone");
|
|
35
|
+
const lzutf8 = require("lzutf8");
|
|
36
|
+
const excel = require("exceljs");
|
|
37
|
+
const qs = require("qs");
|
|
38
|
+
const path = require("path");
|
|
39
|
+
const XLSX = require("cc-xlsx");
|
|
40
|
+
const iconv = require("iconv-lite");
|
|
41
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
42
|
+
const common_1 = require("@nestjs/common");
|
|
43
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
44
|
+
const json2csv_1 = require("json2csv");
|
|
45
|
+
const axios_1 = require("axios");
|
|
46
|
+
const uuid_1 = require("uuid");
|
|
47
|
+
const flat_1 = require("flat");
|
|
48
|
+
const entities_service_1 = require("../entities/entities.service");
|
|
49
|
+
const base_service_1 = require("../common/base/base.service");
|
|
50
|
+
const import_export_schema_1 = require("./import_export.schema");
|
|
51
|
+
const import_export_enum_1 = require("./import_export.enum");
|
|
52
|
+
const schema_1 = require("../common/utils/schema");
|
|
53
|
+
const import_export_hook_1 = require("./import_export.hook");
|
|
54
|
+
const func_1 = require("../common/utils/func");
|
|
55
|
+
const transform_1 = require("../common/utils/transform");
|
|
56
|
+
const random_1 = require("../common/utils/random");
|
|
57
|
+
const redis_1 = require("../common/utils/redis");
|
|
58
|
+
const mongo_1 = require("../common/utils/mongo");
|
|
59
|
+
const build_search_1 = require("../common/utils/build_search");
|
|
60
|
+
const import_export_layout_1 = require("./import_export.layout");
|
|
61
|
+
const validate_1 = require("../common/utils/validate");
|
|
62
|
+
const import_export_log_service_1 = require("./log/import_export_log.service");
|
|
63
|
+
const activity_log_enum_1 = require("../activity_log/activity_log.enum");
|
|
64
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
65
|
+
const ocr_1 = require("../common/utils/ocr");
|
|
66
|
+
const constants_1 = require("../common/constants");
|
|
67
|
+
const entity_1 = require("../common/utils/entity");
|
|
68
|
+
const import_export_utils_1 = require("./import_export.utils");
|
|
69
|
+
const file_type_1 = require("file-type");
|
|
70
|
+
const hook_1 = require("../common/utils/hook");
|
|
71
|
+
const eval_1 = require("../common/utils/eval");
|
|
72
|
+
const regex_1 = require("../common/utils/regex");
|
|
73
|
+
const external_module_1 = require("../common/utils/external_module");
|
|
74
|
+
let _http;
|
|
75
|
+
const TTL = 1800;
|
|
76
|
+
const REGEX_ISO_FORMAT = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;
|
|
77
|
+
const REGEX_NUMBER_FORMAT = /^\d+$/;
|
|
78
|
+
let ImportExportService = ImportExportService_1 = class ImportExportService extends base_service_1.BaseService {
|
|
79
|
+
constructor(cls, entitiesService, log, model) {
|
|
80
|
+
super(cls, model);
|
|
81
|
+
this.cls = cls;
|
|
82
|
+
this.entitiesService = entitiesService;
|
|
83
|
+
this.log = log;
|
|
84
|
+
this.model = model;
|
|
85
|
+
this._filterOut = (i, filters) => {
|
|
86
|
+
const results = [];
|
|
87
|
+
for (const filter of filters) {
|
|
88
|
+
const operate = filter[1];
|
|
89
|
+
const value = _.get(i, filter[0]);
|
|
90
|
+
let result;
|
|
91
|
+
switch (operate) {
|
|
92
|
+
case "=":
|
|
93
|
+
result = `${value}` == `${filter[2]}`;
|
|
94
|
+
break;
|
|
95
|
+
case "!=":
|
|
96
|
+
result = `${value}` !== `${filter[2]}`;
|
|
97
|
+
break;
|
|
98
|
+
case "in":
|
|
99
|
+
result = filter[2].includes(value);
|
|
100
|
+
break;
|
|
101
|
+
case "not_in":
|
|
102
|
+
result = !filter[2].includes(value);
|
|
103
|
+
break;
|
|
104
|
+
case "is_empty":
|
|
105
|
+
result =
|
|
106
|
+
_.isUndefined(value) ||
|
|
107
|
+
_.isNull(value) ||
|
|
108
|
+
(_.isArray(value) && _.isEmpty(value));
|
|
109
|
+
break;
|
|
110
|
+
case "is_not_empty":
|
|
111
|
+
result = !(_.isUndefined(value) ||
|
|
112
|
+
_.isNull(value) ||
|
|
113
|
+
(_.isArray(value) && _.isEmpty(value)));
|
|
114
|
+
break;
|
|
115
|
+
case ">":
|
|
116
|
+
result = +value > +filter[2];
|
|
117
|
+
break;
|
|
118
|
+
case "<":
|
|
119
|
+
result = +value < +filter[2];
|
|
120
|
+
break;
|
|
121
|
+
case ">=":
|
|
122
|
+
result = +value >= +filter[2];
|
|
123
|
+
break;
|
|
124
|
+
case "<=":
|
|
125
|
+
result = +value <= +filter[2];
|
|
126
|
+
break;
|
|
127
|
+
case "true":
|
|
128
|
+
result = ["y", "1", "yes", "true"].includes(`${value}`.toLowerCase());
|
|
129
|
+
case "false":
|
|
130
|
+
result = ["n", "0", "no", "false"].includes(`${value}`.toLowerCase());
|
|
131
|
+
}
|
|
132
|
+
if (!result)
|
|
133
|
+
return false;
|
|
134
|
+
results.push(result);
|
|
135
|
+
}
|
|
136
|
+
return results.every(i => i);
|
|
137
|
+
};
|
|
138
|
+
this._filters = (data, mapping, filters, type) => {
|
|
139
|
+
if (!_.isArray(filters)) {
|
|
140
|
+
return data;
|
|
141
|
+
}
|
|
142
|
+
const fields = mapping
|
|
143
|
+
.filter(i => type.includes(i.type))
|
|
144
|
+
.map(i => i.header);
|
|
145
|
+
const keys = filters.filter(i => fields.includes(i[0]));
|
|
146
|
+
if (_.isEmpty(keys)) {
|
|
147
|
+
return data;
|
|
148
|
+
}
|
|
149
|
+
return data.filter(i => this._filterOut(i, keys));
|
|
150
|
+
};
|
|
151
|
+
this._afterExecution = (data, mapping, groupFields, filterOut) => {
|
|
152
|
+
const showFields = mapping
|
|
153
|
+
.filter(i => i.show !== false)
|
|
154
|
+
.map(i => i._header);
|
|
155
|
+
if (!_.isEmpty(filterOut)) {
|
|
156
|
+
data = this._filters(data, mapping, filterOut, ["calculation"]);
|
|
157
|
+
}
|
|
158
|
+
if (!_.isEmpty(groupFields)) {
|
|
159
|
+
data = _.uniqBy(data, x => {
|
|
160
|
+
return _.reduce(groupFields, (r, i) => {
|
|
161
|
+
r.push(_.get(x, i, ""));
|
|
162
|
+
return r;
|
|
163
|
+
}, []).join("|");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return data.map(i => _.pick(i, showFields));
|
|
167
|
+
};
|
|
168
|
+
this._cleanData = data => {
|
|
169
|
+
for (const key in data) {
|
|
170
|
+
if (_.isArray(data[key])) {
|
|
171
|
+
data[key] = data[key]
|
|
172
|
+
.map(i => this._cleanData(i))
|
|
173
|
+
.filter(i => !this._isEmpty(i));
|
|
174
|
+
}
|
|
175
|
+
else if (_.isPlainObject(data[key])) {
|
|
176
|
+
data[key] = this._cleanData(data[key]);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
if (this._isEmpty(data[key])) {
|
|
180
|
+
delete data[key];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return data;
|
|
185
|
+
};
|
|
186
|
+
this._getTimeFormatTtl = data => {
|
|
187
|
+
let value = 1;
|
|
188
|
+
let result = 24 * 60 * 60 * 1000;
|
|
189
|
+
let unit = "days";
|
|
190
|
+
if (_.isEmpty(data))
|
|
191
|
+
return { ttl: result, unit, value };
|
|
192
|
+
const symbol = data.substr(data.length - 1);
|
|
193
|
+
const time = data.slice(0, -1);
|
|
194
|
+
if (symbol === "m") {
|
|
195
|
+
result = parseInt(time) * 60 * 1000;
|
|
196
|
+
unit = "minutes";
|
|
197
|
+
}
|
|
198
|
+
if (symbol === "h") {
|
|
199
|
+
result = parseInt(time) * 60 * 60 * 1000;
|
|
200
|
+
unit = "hours";
|
|
201
|
+
}
|
|
202
|
+
if (symbol === "d") {
|
|
203
|
+
result = parseInt(time) * 24 * 60 * 60 * 1000;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
ttl: result,
|
|
207
|
+
value: parseInt(time),
|
|
208
|
+
unit
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
_prepareLog() {
|
|
213
|
+
return {
|
|
214
|
+
status: activity_log_enum_1.ActivityLogStatus.successfully,
|
|
215
|
+
action: import_export_enum_1.ImportExportType.export,
|
|
216
|
+
filters: [],
|
|
217
|
+
code: undefined,
|
|
218
|
+
start_process_time: new Date(),
|
|
219
|
+
end_process_time: undefined,
|
|
220
|
+
message: undefined,
|
|
221
|
+
import_file: [],
|
|
222
|
+
export_file: [],
|
|
223
|
+
error_file: [],
|
|
224
|
+
user_id: undefined
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
async init() {
|
|
228
|
+
await this.entitiesService.refreshSystemSchema(ImportExportService_1, this.model, import_export_schema_1.ImportExport, import_export_schema_1.ImportExportSchema, {
|
|
229
|
+
hooks: import_export_hook_1.ImportExportHook,
|
|
230
|
+
layouts: import_export_layout_1.ImportExportLayout
|
|
231
|
+
});
|
|
232
|
+
await this._prepareSystem();
|
|
233
|
+
return "import_export";
|
|
234
|
+
}
|
|
235
|
+
async _prepareSystem() {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
const providers = constants_1.CONST.CUSTOM_PROVIDERS.filter(p => p.module_code === "import_export");
|
|
238
|
+
const defaultLayout = import_export_layout_1.ImportExportLayout[0];
|
|
239
|
+
const tabsBlock = defaultLayout.detail.blocks.find(i => i.type === "tabs");
|
|
240
|
+
const autoTab = tabsBlock.tabs[3];
|
|
241
|
+
const providerLayouts = [];
|
|
242
|
+
const providerTriggers = [];
|
|
243
|
+
for (const provider of providers) {
|
|
244
|
+
const layouts = ((_a = constants_1.CONST.CUSTOM_MODULES_SETTINGS[provider.code]) === null || _a === void 0 ? void 0 : _a.layouts) || [];
|
|
245
|
+
const layout = layouts.find(i => i.key);
|
|
246
|
+
if (!layout)
|
|
247
|
+
continue;
|
|
248
|
+
providerLayouts.push(layout);
|
|
249
|
+
for (const column of ((_b = layout === null || layout === void 0 ? void 0 : layout.layout) === null || _b === void 0 ? void 0 : _b.fields) || []) {
|
|
250
|
+
for (const field of column) {
|
|
251
|
+
providerTriggers.push({
|
|
252
|
+
field: field.unique_key,
|
|
253
|
+
method: "show",
|
|
254
|
+
value: "'${ provider }' === '" + provider.code + "'"
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
autoTab.blocks[0].layout.fields[0].push({
|
|
260
|
+
field: "select",
|
|
261
|
+
type: "standard_component",
|
|
262
|
+
unique_key: "standard_component_select_caae4e8cf39ebc818940",
|
|
263
|
+
key: "provider",
|
|
264
|
+
label: "Provider",
|
|
265
|
+
link_type: "key",
|
|
266
|
+
entity: "custom",
|
|
267
|
+
options: providers.map(i => i.code),
|
|
268
|
+
mode: "single",
|
|
269
|
+
trigger: providerTriggers,
|
|
270
|
+
_translates: {
|
|
271
|
+
"en-US": {
|
|
272
|
+
label: "",
|
|
273
|
+
placeholder: "",
|
|
274
|
+
description: ""
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
autoTab.blocks.splice(1, 0, ...providerLayouts);
|
|
279
|
+
(0, entity_1.addSystemLayout)("import_export", defaultLayout);
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
async mapping(data, mapping, entity) {
|
|
283
|
+
const request = this.cls.get("request");
|
|
284
|
+
const profile = _.get(request, "profile");
|
|
285
|
+
const headers = _.get(request, "headers");
|
|
286
|
+
const dataExecute = Object.assign({ _profile: profile, _headers: headers }, data);
|
|
287
|
+
const res = {};
|
|
288
|
+
for (const field of mapping) {
|
|
289
|
+
let nData = _.get(data, field.header);
|
|
290
|
+
const defaultValue = _.get(field, "options.data_default_value") ||
|
|
291
|
+
_.get(field, "style.data_default_value");
|
|
292
|
+
if (defaultValue && !nData) {
|
|
293
|
+
if (REGEX_NUMBER_FORMAT.test(defaultValue)) {
|
|
294
|
+
nData = parseFloat(defaultValue);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
nData = defaultValue;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
nData = await (0, func_1.executeFunc)(nData, entity, dataExecute);
|
|
301
|
+
const tzName = _.get(field, "options.data_timezone") ||
|
|
302
|
+
_.get(field, "style.data_timezone");
|
|
303
|
+
const dataType = _.get(field, "style.data_type");
|
|
304
|
+
const fieldType = _.get(entity.fields.find(f => f.name === field.field), "type");
|
|
305
|
+
if (dataType === "string") {
|
|
306
|
+
nData = `${nData}`;
|
|
307
|
+
}
|
|
308
|
+
if (dataType === "boolean") {
|
|
309
|
+
nData = ["true", "1", "yes", "y"].includes(`${nData}`.toLowerCase())
|
|
310
|
+
? true
|
|
311
|
+
: false;
|
|
312
|
+
}
|
|
313
|
+
if ((["date", "datetime"].includes(fieldType) ||
|
|
314
|
+
["date"].includes(dataType)) &&
|
|
315
|
+
tzName &&
|
|
316
|
+
nData) {
|
|
317
|
+
nData = moment(nData)
|
|
318
|
+
.utc()
|
|
319
|
+
.format("YYYY-MM-DD HH:mm:ss");
|
|
320
|
+
nData = monent_tz
|
|
321
|
+
.tz(nData, tzName)
|
|
322
|
+
.utc()
|
|
323
|
+
.format();
|
|
324
|
+
}
|
|
325
|
+
if (fieldType === "json" && !!(field === null || field === void 0 ? void 0 : field.key)) {
|
|
326
|
+
let oldData = _.get(res, `${field.field}`, {});
|
|
327
|
+
_.set(oldData, `${field === null || field === void 0 ? void 0 : field.key}`, nData);
|
|
328
|
+
nData = oldData;
|
|
329
|
+
}
|
|
330
|
+
res[field.field] = nData;
|
|
331
|
+
}
|
|
332
|
+
return res;
|
|
333
|
+
}
|
|
334
|
+
_autosizeColumnCells({ columns }) {
|
|
335
|
+
let dataMax;
|
|
336
|
+
let max;
|
|
337
|
+
columns.forEach(column => {
|
|
338
|
+
dataMax = [];
|
|
339
|
+
column.eachCell({ includeEmpty: false }, cell => {
|
|
340
|
+
var _a;
|
|
341
|
+
dataMax.push(((_a = cell.value) === null || _a === void 0 ? void 0 : _a.toString().length) || 0);
|
|
342
|
+
});
|
|
343
|
+
max = Math.max(...dataMax);
|
|
344
|
+
if (column.width === 9) {
|
|
345
|
+
column.width = max < 10 ? 10 : max;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
_getFormula(fn) {
|
|
350
|
+
let formula;
|
|
351
|
+
switch (fn) {
|
|
352
|
+
case import_export_enum_1.ImportExportExcelFunction.sum:
|
|
353
|
+
formula = "SUM";
|
|
354
|
+
break;
|
|
355
|
+
case import_export_enum_1.ImportExportExcelFunction.average:
|
|
356
|
+
formula = "AVERAGE";
|
|
357
|
+
break;
|
|
358
|
+
case import_export_enum_1.ImportExportExcelFunction.count:
|
|
359
|
+
formula = "COUNT";
|
|
360
|
+
break;
|
|
361
|
+
case import_export_enum_1.ImportExportExcelFunction.max:
|
|
362
|
+
formula = "MAX";
|
|
363
|
+
break;
|
|
364
|
+
case import_export_enum_1.ImportExportExcelFunction.min:
|
|
365
|
+
formula = "MIN";
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
return formula;
|
|
369
|
+
}
|
|
370
|
+
_numToAlpha(num) {
|
|
371
|
+
let alpha = "";
|
|
372
|
+
for (; num >= 0; num = Math.floor(num / 26) - 1) {
|
|
373
|
+
alpha = String.fromCharCode((num % 26) + 0x41) + alpha;
|
|
374
|
+
}
|
|
375
|
+
return alpha;
|
|
376
|
+
}
|
|
377
|
+
_buildColumnsArray(range) {
|
|
378
|
+
const res = [];
|
|
379
|
+
for (let i = 0; i < range; i++) {
|
|
380
|
+
res.push(this._numToAlpha(i));
|
|
381
|
+
}
|
|
382
|
+
return res;
|
|
383
|
+
}
|
|
384
|
+
_addStyle(worksheet, cell, data) {
|
|
385
|
+
const style = {
|
|
386
|
+
alignment: {}
|
|
387
|
+
};
|
|
388
|
+
if (!_.isEmpty(data.font)) {
|
|
389
|
+
style["font"] = data.font;
|
|
390
|
+
}
|
|
391
|
+
if (data.alignment) {
|
|
392
|
+
style["alignment"] = { vertical: "middle", horizontal: data.alignment };
|
|
393
|
+
}
|
|
394
|
+
if (data.wrap_text) {
|
|
395
|
+
style["alignment"]["wrapText"] = true;
|
|
396
|
+
}
|
|
397
|
+
const borders = _.get(data, "border.borders", []);
|
|
398
|
+
const borderStyle = {
|
|
399
|
+
style: _.get(data, "border.style", "thin")
|
|
400
|
+
};
|
|
401
|
+
if (!_.isEmpty(borders)) {
|
|
402
|
+
let borderS = {
|
|
403
|
+
top: borderStyle,
|
|
404
|
+
left: borderStyle,
|
|
405
|
+
bottom: borderStyle,
|
|
406
|
+
right: borderStyle
|
|
407
|
+
};
|
|
408
|
+
if (!borders.includes("outer")) {
|
|
409
|
+
borderS = _.pick(borderS, borders);
|
|
410
|
+
}
|
|
411
|
+
style["border"] = borderS;
|
|
412
|
+
}
|
|
413
|
+
const nCell = worksheet.getCell(cell);
|
|
414
|
+
nCell.style = style;
|
|
415
|
+
if (data.default_value && !nCell.value) {
|
|
416
|
+
if (REGEX_NUMBER_FORMAT.test(data.default_value)) {
|
|
417
|
+
nCell.value = parseFloat(data.default_value);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
nCell.value = data.default_value;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (data.data_format) {
|
|
424
|
+
if (_.isString(nCell.value) && REGEX_ISO_FORMAT.test(nCell.value)) {
|
|
425
|
+
nCell.value = moment(nCell.value).format(data.data_format);
|
|
426
|
+
}
|
|
427
|
+
nCell.numFmt = data.data_format;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async _addColumnValue(columns, worksheet, address, row, itemsStartRow, itemsEndRow, filters) {
|
|
431
|
+
let currentAddr = "A";
|
|
432
|
+
let currentIndex = 0;
|
|
433
|
+
for (const col of columns) {
|
|
434
|
+
const style = {
|
|
435
|
+
font: _.get(col, "font"),
|
|
436
|
+
alignment: _.get(col, "alignment"),
|
|
437
|
+
border: _.get(col, "border"),
|
|
438
|
+
data_format: _.get(col, "data_format"),
|
|
439
|
+
wrap_text: _.get(col, "wrap_text")
|
|
440
|
+
};
|
|
441
|
+
const cell = `${currentAddr}${row}`;
|
|
442
|
+
if (col.format === "value") {
|
|
443
|
+
const value = `${await (0, func_1.executeFunc)(_.get(col, "value", ""), {}, filters)}`;
|
|
444
|
+
worksheet.getCell(cell).value = value;
|
|
445
|
+
this._addStyle(worksheet, cell, style);
|
|
446
|
+
const merge = _.get(col, "merge");
|
|
447
|
+
if (merge) {
|
|
448
|
+
const addr = address[currentIndex + merge - 1];
|
|
449
|
+
worksheet.mergeCells(`${cell}:${addr}${row}`);
|
|
450
|
+
currentAddr = address[currentIndex + merge];
|
|
451
|
+
currentIndex = currentIndex + merge;
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
currentAddr = address[currentIndex + 1];
|
|
455
|
+
currentIndex = currentIndex + 1;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
const formula = this._getFormula(col.format);
|
|
460
|
+
worksheet.getCell(cell).value = {
|
|
461
|
+
formula: `${formula}(${currentAddr}${itemsStartRow}:${currentAddr}${itemsEndRow})`,
|
|
462
|
+
date1904: false
|
|
463
|
+
};
|
|
464
|
+
this._addStyle(worksheet, cell, style);
|
|
465
|
+
currentAddr = address[currentIndex + 1];
|
|
466
|
+
currentIndex = currentIndex + 1;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
async exportData(items, config, filters, example) {
|
|
471
|
+
const fileType = _.isArray(_.get(config, "file_ext"))
|
|
472
|
+
? _.get(config, "file_ext.0")
|
|
473
|
+
: _.get(config, "file_ext");
|
|
474
|
+
const ignoreExportHeader = _.get(config, "ignore_export_header", false);
|
|
475
|
+
const showMapping = _.get(config, "mapping", []).filter(i => i.show !== false);
|
|
476
|
+
if (fileType === "csv") {
|
|
477
|
+
const fields = showMapping.map(i => ({
|
|
478
|
+
label: i.header,
|
|
479
|
+
value: row => row[i._header]
|
|
480
|
+
}));
|
|
481
|
+
const temp = new json2csv_1.Parser({
|
|
482
|
+
delimiter: _.get(config, "delimiter") || ",",
|
|
483
|
+
header: !ignoreExportHeader,
|
|
484
|
+
fields
|
|
485
|
+
}).parse(items);
|
|
486
|
+
const buff = Buffer.from(temp);
|
|
487
|
+
return `data:text/csv;base64,${buff.toString("base64")}`;
|
|
488
|
+
}
|
|
489
|
+
if (fileType === "txt") {
|
|
490
|
+
const fields = showMapping.map(i => ({
|
|
491
|
+
label: i.header,
|
|
492
|
+
value: row => row[i._header]
|
|
493
|
+
}));
|
|
494
|
+
const temp = new json2csv_1.Parser({
|
|
495
|
+
delimiter: _.get(config, "delimiter") || ",",
|
|
496
|
+
header: !ignoreExportHeader,
|
|
497
|
+
fields
|
|
498
|
+
}).parse(items);
|
|
499
|
+
const buff = Buffer.from(temp);
|
|
500
|
+
return `data:text/plain;base64,${buff.toString("base64")}`;
|
|
501
|
+
}
|
|
502
|
+
if (fileType === "xlsx") {
|
|
503
|
+
try {
|
|
504
|
+
filters = _.isEmpty(filters) ? {} : filters;
|
|
505
|
+
filters = _.isString(filters)
|
|
506
|
+
? qs.parse(filters, { strictNullHandling: true })
|
|
507
|
+
: filters;
|
|
508
|
+
}
|
|
509
|
+
catch (e) {
|
|
510
|
+
filters = {};
|
|
511
|
+
}
|
|
512
|
+
const workbook = new excel.Workbook();
|
|
513
|
+
const worksheet = workbook.addWorksheet("Sheet 1");
|
|
514
|
+
const address = this._buildColumnsArray(showMapping.length);
|
|
515
|
+
const columns = showMapping.map(i => ({
|
|
516
|
+
header: i.header,
|
|
517
|
+
key: i._header
|
|
518
|
+
}));
|
|
519
|
+
const headerCol = showMapping.map(i => i.header);
|
|
520
|
+
const startRow = _.get(config, "import_excel_options.start_header_row", 1);
|
|
521
|
+
startRow > 1 && example
|
|
522
|
+
? (worksheet.getRow(startRow).values = headerCol)
|
|
523
|
+
: (worksheet.columns = columns);
|
|
524
|
+
for (const item of items) {
|
|
525
|
+
showMapping.map(i => _.isPlainObject(item[i._header]) ? (item[i._header] = "") : item);
|
|
526
|
+
}
|
|
527
|
+
worksheet.addRows(items);
|
|
528
|
+
let itemsStartRow = 2;
|
|
529
|
+
let itemsEndRow = items.length + 1;
|
|
530
|
+
showMapping.forEach((mp, index) => {
|
|
531
|
+
if (!_.isEmpty(mp.style) || !_.isEmpty(mp.options)) {
|
|
532
|
+
const addr = address[index];
|
|
533
|
+
const headerStyle = {
|
|
534
|
+
font: _.get(mp, "style.header_font"),
|
|
535
|
+
alignment: _.get(mp, "style.header_alignment"),
|
|
536
|
+
border: _.get(mp, "style.header_border"),
|
|
537
|
+
wrap_text: _.get(mp, "style.header_wrap_text")
|
|
538
|
+
};
|
|
539
|
+
const width = _.get(mp, "style.header_width");
|
|
540
|
+
if (width) {
|
|
541
|
+
worksheet.getColumn(index + 1).width = width;
|
|
542
|
+
}
|
|
543
|
+
this._addStyle(worksheet, `${addr}1`, headerStyle);
|
|
544
|
+
const dataStyle = {
|
|
545
|
+
font: _.get(mp, "style.data_font"),
|
|
546
|
+
alignment: _.get(mp, "style.data_alignment"),
|
|
547
|
+
border: _.get(mp, "style.data_border"),
|
|
548
|
+
wrap_text: _.get(mp, "style.data_wrap_text"),
|
|
549
|
+
data_format: _.get(mp, "options.data_format") ||
|
|
550
|
+
_.get(mp, "style.data_format"),
|
|
551
|
+
default_value: example ? "" : _.get(mp, "style.data_default_value")
|
|
552
|
+
};
|
|
553
|
+
for (let i = itemsStartRow; i <= itemsEndRow; i++) {
|
|
554
|
+
this._addStyle(worksheet, `${addr}${i}`, dataStyle);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
if (ignoreExportHeader) {
|
|
559
|
+
worksheet.spliceRows(1, 1);
|
|
560
|
+
}
|
|
561
|
+
this._autosizeColumnCells(worksheet);
|
|
562
|
+
const header = _.get(config, "header");
|
|
563
|
+
if (!_.isEmpty(header)) {
|
|
564
|
+
for (const hd of header) {
|
|
565
|
+
worksheet.insertRow(1, "", "n");
|
|
566
|
+
itemsStartRow += 1;
|
|
567
|
+
itemsEndRow += 1;
|
|
568
|
+
}
|
|
569
|
+
let headerRow = 1;
|
|
570
|
+
for (const hd of header) {
|
|
571
|
+
const columns = _.get(hd, "columns", []);
|
|
572
|
+
await this._addColumnValue(columns, worksheet, address, headerRow, itemsStartRow, itemsEndRow, filters);
|
|
573
|
+
headerRow += 1;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
const footer = _.get(config, "footer");
|
|
577
|
+
let emptyRow = _.cloneDeep(items[0]);
|
|
578
|
+
emptyRow = _.mapValues(emptyRow, () => "");
|
|
579
|
+
if (!_.isEmpty(footer)) {
|
|
580
|
+
let endRow = itemsEndRow;
|
|
581
|
+
for (const ft of footer) {
|
|
582
|
+
worksheet.addRow(emptyRow);
|
|
583
|
+
endRow += 1;
|
|
584
|
+
const columns = _.get(ft, "columns", []);
|
|
585
|
+
await this._addColumnValue(columns, worksheet, address, endRow, itemsStartRow, itemsEndRow, filters);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
589
|
+
const buff = Buffer.from(buffer);
|
|
590
|
+
return `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,${buff.toString("base64")}`;
|
|
591
|
+
}
|
|
592
|
+
if (fileType === "json") {
|
|
593
|
+
const buff = Buffer.from(JSON.stringify(items));
|
|
594
|
+
return `data:application/json;base64,${buff.toString("base64")}`;
|
|
595
|
+
}
|
|
596
|
+
console.log("file type", fileType);
|
|
597
|
+
throw new Error("Invalid format type");
|
|
598
|
+
}
|
|
599
|
+
_translateData(item, locale, entity) {
|
|
600
|
+
const allowFields = entity.fields.filter(i => i.allow_translate);
|
|
601
|
+
item["_translates"] = { [locale]: {} };
|
|
602
|
+
for (const field of allowFields) {
|
|
603
|
+
if (_.get(item, field["name"])) {
|
|
604
|
+
_.set(item, `_translates.${locale}.${field["name"]}`, _.get(item, field["name"]));
|
|
605
|
+
delete item[field["name"]];
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return item;
|
|
609
|
+
}
|
|
610
|
+
_prepareFlatData(data, fields, mapping, key, index) {
|
|
611
|
+
index = index || 0;
|
|
612
|
+
const newField = key ? fields.filter(i => i.startsWith(key)) : fields;
|
|
613
|
+
const pickFields = newField.map(i => i.split(".")[index]).filter(i => i);
|
|
614
|
+
const newData = pickFields.length > 0 ? _.pick(data, [...pickFields, "_id"]) : data;
|
|
615
|
+
for (const field in newData) {
|
|
616
|
+
const newKey = key ? `${key}.${field}` : field;
|
|
617
|
+
if (!_.isObject(newData[field]))
|
|
618
|
+
continue;
|
|
619
|
+
if (_.isPlainObject(newData[field])) {
|
|
620
|
+
newData[field] = this._prepareFlatData(newData[field], newField, mapping, newKey, index + 1);
|
|
621
|
+
}
|
|
622
|
+
if (_.isArray(newData[field])) {
|
|
623
|
+
if (!_.isPlainObject(newData[field][0])) {
|
|
624
|
+
newData[field] = newData[field].join(",");
|
|
625
|
+
}
|
|
626
|
+
if (_.isArray(newData[field])) {
|
|
627
|
+
newData[field] = _.flatten(newData[field].map((i) => this._prepareFlatData(i, newField, mapping, newKey, index + 1)));
|
|
628
|
+
}
|
|
629
|
+
if (_.isEmpty(newData[field])) {
|
|
630
|
+
newData[field] = [null];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return _.flatten(cartesian(newData));
|
|
635
|
+
}
|
|
636
|
+
_getFields(mapping) {
|
|
637
|
+
const fields = [];
|
|
638
|
+
for (const item of mapping) {
|
|
639
|
+
if (item.type === "calculation")
|
|
640
|
+
continue;
|
|
641
|
+
if (item.type === "format") {
|
|
642
|
+
item.key = (0, random_1.randomString)(10, false);
|
|
643
|
+
}
|
|
644
|
+
if (item.type === "field" && !!item.key) {
|
|
645
|
+
const newKey = `${item === null || item === void 0 ? void 0 : item.field}.${item.key}`;
|
|
646
|
+
fields.push(newKey);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
fields.push(item.key || item.field);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return fields;
|
|
653
|
+
}
|
|
654
|
+
async _convertData(data, entityName, fields, o2oFields, o2mFields) {
|
|
655
|
+
for (const field of fields) {
|
|
656
|
+
if (data[field]) {
|
|
657
|
+
data[field] = [data[field]];
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
661
|
+
for (const field of o2oFields) {
|
|
662
|
+
if (!_.isEmpty(data[field])) {
|
|
663
|
+
const entityO2o = entity.fields.find(f => f.name === field);
|
|
664
|
+
if (entityO2o.allow_create_update)
|
|
665
|
+
continue;
|
|
666
|
+
const ids = await (0, schema_1.callListIdsInternalService)(entity.fields.find(f => f.name === field).related_ref, "", data[field]);
|
|
667
|
+
if (_.isEmpty(ids)) {
|
|
668
|
+
delete data[field];
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
data[field] = Object.assign({ id: ids[0] }, data[field]);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
for (const field of o2mFields) {
|
|
675
|
+
if (!_.isEmpty(data[field])) {
|
|
676
|
+
const entityO2m = entity.fields.find(f => f.name === field);
|
|
677
|
+
if (entityO2m.allow_create_update)
|
|
678
|
+
continue;
|
|
679
|
+
const relatedRef = entityO2m.related_ref;
|
|
680
|
+
const res = await (0, schema_1.callListIdsInternalService)(relatedRef, "", data[field]);
|
|
681
|
+
data[field] = [Object.assign({ id: res[0] }, data[field])];
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
data[field] = [];
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return data;
|
|
688
|
+
}
|
|
689
|
+
async _handleAddImportExportLog(config, options) {
|
|
690
|
+
const request = this.cls.get("request");
|
|
691
|
+
const userId = _.get(request, "profile.id");
|
|
692
|
+
const log = this._prepareLog();
|
|
693
|
+
log["action"] = _.get(config, "type");
|
|
694
|
+
log["code"] = _.get(config, "code");
|
|
695
|
+
log["end_process_time"] = new Date();
|
|
696
|
+
log["user_id"] = userId;
|
|
697
|
+
log["status"] = (options === null || options === void 0 ? void 0 : options.status) || activity_log_enum_1.ActivityLogStatus.successfully;
|
|
698
|
+
if (log["action"] === import_export_enum_1.ImportExportType.export) {
|
|
699
|
+
log["filters"] = JSON.parse(JSON.stringify(_.get(options, "filters")).replace(/\$\w+[",']:/gm, match => {
|
|
700
|
+
return match.replace("$", "_S_");
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
log["file_type"] = config.file_ext.toString();
|
|
704
|
+
const filename = _.get(options, "data.filename", "").replace(/ /gm, "");
|
|
705
|
+
if (!_.isEmpty(options === null || options === void 0 ? void 0 : options.wholeFile) &&
|
|
706
|
+
log["action"] === import_export_enum_1.ImportExportType.export) {
|
|
707
|
+
log["export_file"].push({
|
|
708
|
+
name: filename,
|
|
709
|
+
upload_data: _.get(options, "wholeFile.data")
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
if (!_.isEmpty(options === null || options === void 0 ? void 0 : options.wholeFile) &&
|
|
713
|
+
log["action"] === import_export_enum_1.ImportExportType.import) {
|
|
714
|
+
log["ocr_message"] =
|
|
715
|
+
log["file_type"] === "pdf" ? _.get(options, "data.data") : undefined;
|
|
716
|
+
log["ocr_mapping_data"] =
|
|
717
|
+
log["file_type"] === "pdf"
|
|
718
|
+
? _.get(options, "data.mapping_data", {})
|
|
719
|
+
: undefined;
|
|
720
|
+
log["import_file"].push({
|
|
721
|
+
name: filename,
|
|
722
|
+
upload_data: _.get(options, "wholeFile.data")
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
if (!_.isEmpty(options === null || options === void 0 ? void 0 : options.errorFile) &&
|
|
726
|
+
log["action"] === import_export_enum_1.ImportExportType.import) {
|
|
727
|
+
log["status"] = activity_log_enum_1.ActivityLogStatus.failed;
|
|
728
|
+
if (log["file_type"] === "pdf") {
|
|
729
|
+
log["ocr_error_message"] = _.get(options, "errorFile");
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
log["error_file"].push({
|
|
733
|
+
name: `error_${filename}`,
|
|
734
|
+
upload_data: _.get(options, "errorFile.data")
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return await this.log.create(log);
|
|
739
|
+
}
|
|
740
|
+
_isEmpty(data) {
|
|
741
|
+
return (data === "" ||
|
|
742
|
+
data === undefined ||
|
|
743
|
+
data === null ||
|
|
744
|
+
(_.isPlainObject(data) && _.isEmpty(data)));
|
|
745
|
+
}
|
|
746
|
+
async _checkFormatRunningNumber(oldData, data, mapping) {
|
|
747
|
+
const runningMapping = mapping.filter(i => i && i._format_running);
|
|
748
|
+
if (oldData.length > data.length && !_.isEmpty(runningMapping)) {
|
|
749
|
+
for (let i = 0; i < data.length; i++) {
|
|
750
|
+
for (const m of runningMapping) {
|
|
751
|
+
data[i][m._header] = await (0, func_1.executeFunc)(m._format_running, {}, { _index: i + 1 });
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
async getConfig(id) {
|
|
757
|
+
let result = /^[0-9a-fA-F]{24}$/.test(id)
|
|
758
|
+
? await this.findOne(id)
|
|
759
|
+
: await this.find(undefined, { code: id });
|
|
760
|
+
if (!result) {
|
|
761
|
+
throw new Error("Import/Export config is not available");
|
|
762
|
+
}
|
|
763
|
+
if (!result.enable) {
|
|
764
|
+
throw new Error("Import/Export config is disabled");
|
|
765
|
+
}
|
|
766
|
+
result = JSON.parse(JSON.stringify(result));
|
|
767
|
+
return result;
|
|
768
|
+
}
|
|
769
|
+
checkMissingHeader(data, config) {
|
|
770
|
+
try {
|
|
771
|
+
let nResult = _.cloneDeep(data);
|
|
772
|
+
config.forEach((i) => {
|
|
773
|
+
const default_value = _.get(i, "options.data_default_value", "") ||
|
|
774
|
+
_.get(i, "style.data_default_value", "");
|
|
775
|
+
const header = _.get(i, "header", "");
|
|
776
|
+
const nData = nResult.map((item) => {
|
|
777
|
+
const checkValue = _.get(item, `${header}`);
|
|
778
|
+
if (!checkValue && default_value) {
|
|
779
|
+
return Object.assign(Object.assign({}, item), { [`${header}`]: default_value });
|
|
780
|
+
}
|
|
781
|
+
else if (!_.isNumber(checkValue) && !checkValue) {
|
|
782
|
+
return Object.assign(Object.assign({}, item), { [`${header}`]: undefined });
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
return item;
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
nResult = nData;
|
|
789
|
+
});
|
|
790
|
+
return nResult;
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
return data;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
convertDataXLSX(data) {
|
|
797
|
+
try {
|
|
798
|
+
const cleanup = _.reduce(data, (r, v) => {
|
|
799
|
+
const obj = {};
|
|
800
|
+
for (const k of Object.keys(v)) {
|
|
801
|
+
obj[k.replace(/(\n|\r)/g, "").trim()] = v[k];
|
|
802
|
+
}
|
|
803
|
+
r.push(obj);
|
|
804
|
+
return r;
|
|
805
|
+
}, []);
|
|
806
|
+
const temp = cleanup.map((v) => {
|
|
807
|
+
if (_.isPlainObject(v)) {
|
|
808
|
+
let valueObj = {};
|
|
809
|
+
for (const [key, value] of Object.entries(v)) {
|
|
810
|
+
if (value instanceof Date) {
|
|
811
|
+
const convertDate = moment(value).format("YYYY-MM-DD HH:mm:ss");
|
|
812
|
+
valueObj[key] = convertDate;
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
valueObj[key] = value;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
return valueObj;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return v;
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
return temp;
|
|
825
|
+
}
|
|
826
|
+
catch (error) {
|
|
827
|
+
return data;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
async _getRawTextData(data, config) {
|
|
831
|
+
if (_.isPlainObject(data) || _.isArray(data)) {
|
|
832
|
+
return data;
|
|
833
|
+
}
|
|
834
|
+
const buff = Buffer.from(data.indexOf(";base64,") > 0 ? data.split(";base64,")[1] : data, "base64");
|
|
835
|
+
if (data.startsWith("data:text/csv;base64,")) {
|
|
836
|
+
return buff.toString("utf8");
|
|
837
|
+
}
|
|
838
|
+
if (data.startsWith("data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,") ||
|
|
839
|
+
data.startsWith("data:application/vnd.ms-excel;base64,")) {
|
|
840
|
+
const workbook = XLSX.read(buff, { cellDates: true });
|
|
841
|
+
const sheetName = _.get(config, "import_excel_options.sheet_name", workbook.SheetNames[0]);
|
|
842
|
+
const converted = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
|
|
843
|
+
return converted;
|
|
844
|
+
}
|
|
845
|
+
return "";
|
|
846
|
+
}
|
|
847
|
+
async decodeData(data, config) {
|
|
848
|
+
if (_.isPlainObject(data) || _.isArray(data)) {
|
|
849
|
+
return data;
|
|
850
|
+
}
|
|
851
|
+
const buff = Buffer.from(data.indexOf(";base64,") > 0 ? data.split(";base64,")[1] : data, "base64");
|
|
852
|
+
if (data.startsWith("data:text/csv;base64,")) {
|
|
853
|
+
let buffStr = buff.toString("utf8").replace(/\x00/g, "");
|
|
854
|
+
let result = await csv({
|
|
855
|
+
delimiter: _.get(config, "delimiter", ",") || ","
|
|
856
|
+
}).fromString(buffStr);
|
|
857
|
+
if (_.isEmpty(result)) {
|
|
858
|
+
throw new Error("Missing file header");
|
|
859
|
+
}
|
|
860
|
+
result = this.checkMissingHeader(result, config.mapping);
|
|
861
|
+
return result;
|
|
862
|
+
}
|
|
863
|
+
if (data.startsWith("data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,") ||
|
|
864
|
+
data.startsWith("data:application/vnd.ms-excel;base64,")) {
|
|
865
|
+
const workbook = XLSX.read(buff, { cellDates: true });
|
|
866
|
+
const sheetName = _.get(config, "import_excel_options.sheet_name", workbook.SheetNames[0]);
|
|
867
|
+
const findingText = _.get(config, "import_excel_options.finding_text", "");
|
|
868
|
+
const startHeaderRow = _.get(config, "import_excel_options.start_header_row", 1);
|
|
869
|
+
const startDataRow = _.get(config, "import_excel_options.start_data_row", 1);
|
|
870
|
+
const stopIsEmptyRow = _.get(config, "import_excel_options.stop_is_empty_row", false);
|
|
871
|
+
const sheet = workbook.Sheets[sheetName];
|
|
872
|
+
const range = XLSX.utils.decode_range(sheet["!ref"]);
|
|
873
|
+
const newRang = _.cloneDeep(range);
|
|
874
|
+
if (!_.isEmpty(findingText)) {
|
|
875
|
+
for (let r = range.s.r; r <= range.e.r; r++) {
|
|
876
|
+
const cellRef = XLSX.utils.encode_cell({ c: range.s.c, r });
|
|
877
|
+
if (_.isUndefined(workbook.Sheets[sheetName][cellRef]))
|
|
878
|
+
continue;
|
|
879
|
+
const text = workbook.Sheets[sheetName][cellRef].v;
|
|
880
|
+
if (text === findingText) {
|
|
881
|
+
newRang.s.r = r + startHeaderRow;
|
|
882
|
+
r = range.e.r;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
else if (startHeaderRow > 1) {
|
|
887
|
+
newRang.s.r = startHeaderRow - 1;
|
|
888
|
+
}
|
|
889
|
+
if (stopIsEmptyRow) {
|
|
890
|
+
for (let r = newRang.s.r + startDataRow; r <= newRang.e.r; r++) {
|
|
891
|
+
const cellRef = XLSX.utils.encode_cell({ c: range.s.c, r });
|
|
892
|
+
if (!_.isUndefined(workbook.Sheets[sheetName][cellRef]))
|
|
893
|
+
continue;
|
|
894
|
+
newRang.e.r = r - 1;
|
|
895
|
+
r = range.e.r;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
let countEmptyBeforeData = 0;
|
|
899
|
+
for (let r = newRang.s.r; r <= newRang.e.r; r++) {
|
|
900
|
+
const cellRef = XLSX.utils.encode_cell({ c: range.s.c, r });
|
|
901
|
+
if (!_.isUndefined(workbook.Sheets[sheetName][cellRef]))
|
|
902
|
+
continue;
|
|
903
|
+
countEmptyBeforeData++;
|
|
904
|
+
}
|
|
905
|
+
let converted = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {
|
|
906
|
+
range: newRang
|
|
907
|
+
});
|
|
908
|
+
if (startDataRow > 1) {
|
|
909
|
+
converted = converted.slice(startDataRow - countEmptyBeforeData - 1);
|
|
910
|
+
}
|
|
911
|
+
const temp = this.convertDataXLSX(converted);
|
|
912
|
+
if (_.isEmpty(temp)) {
|
|
913
|
+
throw new Error("Missing file header");
|
|
914
|
+
}
|
|
915
|
+
const result = this.checkMissingHeader(temp, config.mapping);
|
|
916
|
+
return result;
|
|
917
|
+
}
|
|
918
|
+
if (data.startsWith("data:application/pdf;base64,")) {
|
|
919
|
+
const base64pdf = data.replace("data:application/pdf;base64,", "");
|
|
920
|
+
const buf = Buffer.from(base64pdf, "base64");
|
|
921
|
+
const convertText = await (0, ocr_1.recognizePDF)(buf, {
|
|
922
|
+
width: 4760,
|
|
923
|
+
height: 6736
|
|
924
|
+
});
|
|
925
|
+
return convertText;
|
|
926
|
+
}
|
|
927
|
+
if (data.startsWith("data:application/json")) {
|
|
928
|
+
const base64pdf = data.replace("data:application/json;base64,", "");
|
|
929
|
+
const buf = Buffer.from(base64pdf, "base64");
|
|
930
|
+
const jsonObject = JSON.parse(buf.toString("utf8"));
|
|
931
|
+
return _.isPlainObject(jsonObject) ? [jsonObject] : jsonObject;
|
|
932
|
+
}
|
|
933
|
+
if (data.startsWith("data:text/xml") ||
|
|
934
|
+
data.startsWith("data:application/xml")) {
|
|
935
|
+
const base64pdf = data
|
|
936
|
+
.replace("data:text/xml;base64,", "")
|
|
937
|
+
.replace("data:application/xml;base64,", "");
|
|
938
|
+
const buf = Buffer.from(base64pdf, "base64");
|
|
939
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
940
|
+
ignoreAttributes: false,
|
|
941
|
+
attributeNamePrefix: "@_",
|
|
942
|
+
ignoreDeclaration: true,
|
|
943
|
+
parseTagValue: true,
|
|
944
|
+
trimValues: true
|
|
945
|
+
});
|
|
946
|
+
try {
|
|
947
|
+
const jsonObject = parser.parse(buf.toString("utf8"));
|
|
948
|
+
return _.isPlainObject(jsonObject) ? [jsonObject] : jsonObject;
|
|
949
|
+
}
|
|
950
|
+
catch (xmlError) {
|
|
951
|
+
console.error("❌ Error converting XML to JSON:", xmlError);
|
|
952
|
+
throw new Error(xmlError.message);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
const delimiter = _.isEmpty(config.delimiter)
|
|
956
|
+
? ","
|
|
957
|
+
: _.get(config, "delimiter");
|
|
958
|
+
const endcoding = _.get(config, "import_text_options.encoding", "utf8");
|
|
959
|
+
const ignoreFirstLine = _.get(config, "import_text_options.ignore_first_line", 0);
|
|
960
|
+
const ignoreLastLine = _.get(config, "import_text_options.ignore_last_line", 0);
|
|
961
|
+
const ignoreFirstColumn = _.get(config, "import_text_options.ignore_first_column", 0);
|
|
962
|
+
const ignoreLastColumn = _.get(config, "import_text_options.ignore_last_column", 0);
|
|
963
|
+
const rawText = iconv.decode(buff, endcoding);
|
|
964
|
+
let lines = rawText.trim().split("\n");
|
|
965
|
+
if (ignoreFirstLine > 0 || ignoreLastLine > 0) {
|
|
966
|
+
lines = lines.slice(ignoreFirstLine, lines.length - ignoreLastLine);
|
|
967
|
+
}
|
|
968
|
+
const dataArray = [];
|
|
969
|
+
for (const line of lines) {
|
|
970
|
+
let row = line.split(delimiter);
|
|
971
|
+
if (ignoreFirstColumn > 0 || ignoreLastColumn > 0) {
|
|
972
|
+
row = row.slice(ignoreFirstColumn, row.length - ignoreLastColumn);
|
|
973
|
+
}
|
|
974
|
+
if (row.length <= 0)
|
|
975
|
+
continue;
|
|
976
|
+
dataArray.push(row);
|
|
977
|
+
}
|
|
978
|
+
const result = dataArray.map(row => {
|
|
979
|
+
const obj = {};
|
|
980
|
+
config.mapping.forEach((mapItem, index) => {
|
|
981
|
+
var _a;
|
|
982
|
+
obj[mapItem.field] = (_a = row[index]) !== null && _a !== void 0 ? _a : null;
|
|
983
|
+
});
|
|
984
|
+
return obj;
|
|
985
|
+
});
|
|
986
|
+
return result;
|
|
987
|
+
}
|
|
988
|
+
async listExistsByUnique(entityName, filters) {
|
|
989
|
+
const result = await (0, schema_1.callFindInternalService)(entityName, undefined, filters);
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
async revertMapping(data, mapping, entity) {
|
|
993
|
+
const res = {};
|
|
994
|
+
let count = 1;
|
|
995
|
+
for (const field of mapping) {
|
|
996
|
+
let value;
|
|
997
|
+
if (field.type === "format") {
|
|
998
|
+
value = _.get(data, field.key, "");
|
|
999
|
+
}
|
|
1000
|
+
else {
|
|
1001
|
+
const newField = field.key
|
|
1002
|
+
? `${field.field}.${field.key}`
|
|
1003
|
+
: field.field;
|
|
1004
|
+
const newValue = _.get(data, newField, "");
|
|
1005
|
+
if (_.isPlainObject(newField) || _.isArray(newValue)) {
|
|
1006
|
+
try {
|
|
1007
|
+
value = JSON.stringify(newValue);
|
|
1008
|
+
}
|
|
1009
|
+
catch (error) {
|
|
1010
|
+
value = "";
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
value = newValue;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (_.has(res, field.header)) {
|
|
1018
|
+
res[`${field.header}__${count}`] = value;
|
|
1019
|
+
field["_header"] = `${field.header}__${count}`;
|
|
1020
|
+
count += 1;
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
res[field.header] = value;
|
|
1024
|
+
field["_header"] = field.header;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
return res;
|
|
1028
|
+
}
|
|
1029
|
+
async getPeviousImportData(data) {
|
|
1030
|
+
for (let row of data) {
|
|
1031
|
+
let result = await redis_1.redisCache.get(`IMPORT_${row.code}`);
|
|
1032
|
+
row["previous_import"] =
|
|
1033
|
+
(result || []).filter(item => moment().isBefore(item.expired)) || [];
|
|
1034
|
+
}
|
|
1035
|
+
return data;
|
|
1036
|
+
}
|
|
1037
|
+
async importData(items, additionalData, config, data) {
|
|
1038
|
+
var _a;
|
|
1039
|
+
try {
|
|
1040
|
+
const request = this.cls.get("request");
|
|
1041
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
1042
|
+
const fieldType = _.get(entity, "fields", []).filter(j => !["id", "system", "_translates"].includes(j.name));
|
|
1043
|
+
const uniqueFields = _.get(entity, "fields", [])
|
|
1044
|
+
.filter(i => i.unique)
|
|
1045
|
+
.map(i => i.name);
|
|
1046
|
+
const locale = data.locale;
|
|
1047
|
+
const languages = await (0, schema_1.getSetting)("data_languages");
|
|
1048
|
+
const isDefault = !locale ||
|
|
1049
|
+
_.get(languages.find(i => i.code === locale), "default_data_translate");
|
|
1050
|
+
const docRefs = [];
|
|
1051
|
+
let importErrorData = [];
|
|
1052
|
+
let importWarningData = [];
|
|
1053
|
+
let resultWarningImportData;
|
|
1054
|
+
let allPreviousImport;
|
|
1055
|
+
if (config.file_ext.toString() !== "pdf") {
|
|
1056
|
+
for (const [index, i] of items.entries()) {
|
|
1057
|
+
let item = await this._prepareData(entity.name, i);
|
|
1058
|
+
if (!_.isEmpty(additionalData) && _.isPlainObject(additionalData)) {
|
|
1059
|
+
item = Object.assign(Object.assign({}, item), additionalData);
|
|
1060
|
+
}
|
|
1061
|
+
let items = {};
|
|
1062
|
+
if (!["json", "xml"].includes(config.file_ext.toString())) {
|
|
1063
|
+
items = await this.revertMapping(i, config === null || config === void 0 ? void 0 : config.mapping, entity);
|
|
1064
|
+
}
|
|
1065
|
+
try {
|
|
1066
|
+
let exists = undefined;
|
|
1067
|
+
const warningMessage = [];
|
|
1068
|
+
const uniqueConditions = _.pick(item, uniqueFields);
|
|
1069
|
+
if (uniqueFields.length > 0 &&
|
|
1070
|
+
Object.keys(uniqueConditions).length > 0) {
|
|
1071
|
+
const filterValues = _.pick(item, uniqueFields);
|
|
1072
|
+
const filterConditions = _.reduce(Object.keys(filterValues), (r, v) => {
|
|
1073
|
+
if (_.isPlainObject(filterValues[v])) {
|
|
1074
|
+
if (!_.isEmpty(filterValues[v]["id"])) {
|
|
1075
|
+
r[v] = filterValues[v]["id"];
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
r[v] = filterValues[v];
|
|
1080
|
+
}
|
|
1081
|
+
return r;
|
|
1082
|
+
}, {});
|
|
1083
|
+
exists = await this.listExistsByUnique(entity.name, filterConditions);
|
|
1084
|
+
}
|
|
1085
|
+
if (!isDefault) {
|
|
1086
|
+
item = this._translateData(i, locale, entity);
|
|
1087
|
+
}
|
|
1088
|
+
const importOption = _.get(config, "option");
|
|
1089
|
+
let result = {};
|
|
1090
|
+
if (["both", "update"].includes(importOption) &&
|
|
1091
|
+
!_.isEmpty(exists)) {
|
|
1092
|
+
exists["id"] = exists["_id"];
|
|
1093
|
+
delete exists["_id"];
|
|
1094
|
+
result = await (0, schema_1.callUpdateInternalService)(entity.name, _.merge(exists, item), _.get(request, "headers"));
|
|
1095
|
+
}
|
|
1096
|
+
if (["both", "create"].includes(importOption) &&
|
|
1097
|
+
_.isEmpty(exists)) {
|
|
1098
|
+
result = await (0, schema_1.callCreateInternalService)(entity.name, item, _.get(request, "headers"));
|
|
1099
|
+
}
|
|
1100
|
+
if (["create"].includes(importOption) && !_.isEmpty(exists)) {
|
|
1101
|
+
const mapping = _.get(config, "mapping", []);
|
|
1102
|
+
for (const u of Object.keys(uniqueConditions)) {
|
|
1103
|
+
const header = (_a = mapping.find((i) => (i === null || i === void 0 ? void 0 : i.field) === u)) === null || _a === void 0 ? void 0 : _a.header;
|
|
1104
|
+
warningMessage.push(`duplicate value on column ${header} at row ${index + 1}`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (["update"].includes(importOption) && _.isEmpty(exists)) {
|
|
1108
|
+
warningMessage.push(`Can't find the update list at row ${index + 1}`);
|
|
1109
|
+
}
|
|
1110
|
+
importWarningData.push(Object.assign(Object.assign({ row: index + 1 }, items), { message: warningMessage.join(",") }));
|
|
1111
|
+
docRefs.push(result.id);
|
|
1112
|
+
}
|
|
1113
|
+
catch (e) {
|
|
1114
|
+
const errorMessage = [];
|
|
1115
|
+
let errorRelated = false;
|
|
1116
|
+
for (const ft of fieldType) {
|
|
1117
|
+
const fieldKey = ft.name;
|
|
1118
|
+
for (const it in item) {
|
|
1119
|
+
if (ft.type !== "related") {
|
|
1120
|
+
if (fieldKey === it) {
|
|
1121
|
+
if (ft.type === "number") {
|
|
1122
|
+
let checkNumber = /^[0-9]*$/g.test(item[it]);
|
|
1123
|
+
if (!checkNumber) {
|
|
1124
|
+
errorMessage.push(`${fieldKey} field is wrong type`);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
else if (typeof item[it] !== ft.type) {
|
|
1128
|
+
errorMessage.push(`${fieldKey} field is wrong type`);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
errorRelated = true;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
data["error"] += 1;
|
|
1138
|
+
if (errorRelated) {
|
|
1139
|
+
errorMessage.push(e);
|
|
1140
|
+
}
|
|
1141
|
+
common_1.Logger.error(e);
|
|
1142
|
+
importErrorData.push(Object.assign(Object.assign({ row: index + 2 }, items), { message: errorMessage.join(",") }));
|
|
1143
|
+
}
|
|
1144
|
+
data["current"] += 1;
|
|
1145
|
+
data["finish"] = data["current"] >= data["total"];
|
|
1146
|
+
redis_1.redisCache.set(`IMPORT_${data.ref_id}`, data, TTL);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
else {
|
|
1150
|
+
try {
|
|
1151
|
+
const jsonData = await this._convertPDFTextToJSON(entity.name, data.data, config.mapping);
|
|
1152
|
+
const saveData = await this._prepareData(entity.name, jsonData);
|
|
1153
|
+
data["mapping_data"] = saveData;
|
|
1154
|
+
if (_.isEmpty(saveData)) {
|
|
1155
|
+
throw new Error();
|
|
1156
|
+
}
|
|
1157
|
+
let exists = undefined;
|
|
1158
|
+
const uniqueConditions = _.pick(saveData, uniqueFields);
|
|
1159
|
+
if (uniqueFields.length > 0 &&
|
|
1160
|
+
Object.keys(uniqueConditions).length > 0) {
|
|
1161
|
+
exists = await this.listExistsByUnique(entity.name, _.pick(saveData, uniqueFields));
|
|
1162
|
+
}
|
|
1163
|
+
const importOption = config.option.toString();
|
|
1164
|
+
let result = {};
|
|
1165
|
+
if (["both", "update"].includes(importOption) && !_.isEmpty(exists)) {
|
|
1166
|
+
exists["id"] = exists["_id"];
|
|
1167
|
+
delete exists["_id"];
|
|
1168
|
+
result = await (0, schema_1.callUpdateInternalService)(entity.name, _.merge(exists, saveData), _.get(request, "headers"));
|
|
1169
|
+
}
|
|
1170
|
+
if (["both", "create"].includes(importOption) && _.isEmpty(exists)) {
|
|
1171
|
+
result = await (0, schema_1.callCreateInternalService)(entity.name, saveData, _.get(request, "headers"));
|
|
1172
|
+
}
|
|
1173
|
+
docRefs.push(result.id);
|
|
1174
|
+
data["current"] = 1;
|
|
1175
|
+
data["finish"] = true;
|
|
1176
|
+
redis_1.redisCache.set(`IMPORT_${data.ref_id}`, data, TTL);
|
|
1177
|
+
}
|
|
1178
|
+
catch (e) {
|
|
1179
|
+
let errorRelated = false;
|
|
1180
|
+
data["error"] = 1;
|
|
1181
|
+
data["current"] = 1;
|
|
1182
|
+
data["finish"] = true;
|
|
1183
|
+
redis_1.redisCache.set(`IMPORT_${data.ref_id}`, data, TTL);
|
|
1184
|
+
common_1.Logger.error(e);
|
|
1185
|
+
importErrorData.push({
|
|
1186
|
+
message: e.message
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
let resultErrorImportData = undefined;
|
|
1191
|
+
if (!_.isEmpty(importErrorData)) {
|
|
1192
|
+
resultErrorImportData = await this._getErrorImportData(config, entity, importErrorData);
|
|
1193
|
+
}
|
|
1194
|
+
resultWarningImportData =
|
|
1195
|
+
!_.isEmpty(importWarningData) &&
|
|
1196
|
+
(await this._getErrorImportData(config, entity, importWarningData));
|
|
1197
|
+
await (0, schema_1.callAddQueueInternal)("import_export", "after_execute", {
|
|
1198
|
+
id: config.id || config._id,
|
|
1199
|
+
docRefs
|
|
1200
|
+
});
|
|
1201
|
+
await (0, hook_1.executeHooks)(entity, "import", "after", {
|
|
1202
|
+
headers: _.get(request, "headers"),
|
|
1203
|
+
body: {},
|
|
1204
|
+
profile: _.get(request, "profile", {})
|
|
1205
|
+
}, { id: undefined });
|
|
1206
|
+
if (_.isEmpty(resultWarningImportData)) {
|
|
1207
|
+
resultWarningImportData = await this._getFileData(config, entity, lzutf8.decompress(data.original, {
|
|
1208
|
+
inputEncoding: "BinaryString"
|
|
1209
|
+
}));
|
|
1210
|
+
}
|
|
1211
|
+
const importExportLogResult = await this._handleAddImportExportLog(config, {
|
|
1212
|
+
wholeFile: resultWarningImportData,
|
|
1213
|
+
errorFile: resultErrorImportData,
|
|
1214
|
+
data
|
|
1215
|
+
});
|
|
1216
|
+
if (!_.isEmpty(resultErrorImportData)) {
|
|
1217
|
+
const generalSetting = await (0, schema_1.getSetting)("general");
|
|
1218
|
+
const showLogMaximumDay = _.get(generalSetting, "import_export.show_log_maximum_day", 1);
|
|
1219
|
+
const expireDetail = this._getTimeFormatTtl(showLogMaximumDay);
|
|
1220
|
+
const errorAttachment = _.cloneDeep(importExportLogResult);
|
|
1221
|
+
_.set(errorAttachment, "error", data["error"]);
|
|
1222
|
+
_.set(errorAttachment, "total", data["total"]);
|
|
1223
|
+
_.set(errorAttachment, "import_at", moment().toISOString());
|
|
1224
|
+
_.set(errorAttachment, "name", data["filename"]);
|
|
1225
|
+
_.set(errorAttachment, "expired", moment()
|
|
1226
|
+
.add(_.get(expireDetail, "value", 1), expireDetail.unit)
|
|
1227
|
+
.toISOString());
|
|
1228
|
+
const previousImport = await redis_1.redisCache.get(`IMPORT_${config.code}`);
|
|
1229
|
+
allPreviousImport = _.isEmpty(previousImport)
|
|
1230
|
+
? [errorAttachment]
|
|
1231
|
+
: [errorAttachment, ...previousImport];
|
|
1232
|
+
allPreviousImport = allPreviousImport.filter(item => moment().isBefore(item.expired));
|
|
1233
|
+
await redis_1.redisCache.set(`IMPORT_${data.ref_id}`, allPreviousImport, expireDetail.ttl);
|
|
1234
|
+
}
|
|
1235
|
+
return { id: config.id, doc_refs: docRefs };
|
|
1236
|
+
}
|
|
1237
|
+
catch (e) {
|
|
1238
|
+
console.log("------- ERROR ---------");
|
|
1239
|
+
console.error(e);
|
|
1240
|
+
await redis_1.redisCache.set(`IMPORT_${data.ref_id}`, Object.assign(Object.assign({}, data), { finish: true }));
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
async downloadFile(url) {
|
|
1244
|
+
if (!_http) {
|
|
1245
|
+
_http = axios_1.default.create();
|
|
1246
|
+
}
|
|
1247
|
+
const res = await _http.get(url, { responseType: "arraybuffer" });
|
|
1248
|
+
return Buffer.from(res.data).toString("base64");
|
|
1249
|
+
}
|
|
1250
|
+
async _setSchedule(data) {
|
|
1251
|
+
if (!data.allow_auto_upload) {
|
|
1252
|
+
try {
|
|
1253
|
+
await (0, schema_1.callDeleteInternalService)("schedule_action", `import_export__${data._id}`);
|
|
1254
|
+
}
|
|
1255
|
+
catch (e) {
|
|
1256
|
+
common_1.Logger.error(`Failed to delete auto import/export schedule is ${data.name}`);
|
|
1257
|
+
}
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1260
|
+
const entity = await (0, schema_1.loadEntity)("import_export");
|
|
1261
|
+
const type = data.type.toString() === "export" ? "Export" : "Import";
|
|
1262
|
+
const schedule = {
|
|
1263
|
+
enabled: true,
|
|
1264
|
+
name: `Auto ${type} ${data.name} from SFTP`,
|
|
1265
|
+
entity: entity.id,
|
|
1266
|
+
code: `import_export__${data._id}`,
|
|
1267
|
+
execute_time: data.schedule,
|
|
1268
|
+
action: {
|
|
1269
|
+
type: "internal",
|
|
1270
|
+
url: "/import_export/execute_schedule",
|
|
1271
|
+
method: "patch",
|
|
1272
|
+
body: {
|
|
1273
|
+
id: `${data._id}`
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
await (0, schema_1.callInternalService)("schedule_action", "post", "create_system_schedule", schedule);
|
|
1278
|
+
return true;
|
|
1279
|
+
}
|
|
1280
|
+
async _findRelateData(entityName, data) {
|
|
1281
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1282
|
+
const uniqueFields = entity.fields.filter(i => i.unique).map(i => i.name);
|
|
1283
|
+
if (uniqueFields.length === 0)
|
|
1284
|
+
return;
|
|
1285
|
+
const exists = await this.listExistsByUnique(entityName, _.pick(data, uniqueFields));
|
|
1286
|
+
return _.get(exists, "_id") ? exists : undefined;
|
|
1287
|
+
}
|
|
1288
|
+
async _convertPDFTextToJSON(entityName, text, mapping) {
|
|
1289
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1290
|
+
const result = {};
|
|
1291
|
+
for (const m of mapping) {
|
|
1292
|
+
if (_.isEmpty(m.options)) {
|
|
1293
|
+
common_1.Logger.log(`Ignore mapping ${m.field} option is empty`);
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
if (_.isEmpty(m.options.term_regex)) {
|
|
1297
|
+
common_1.Logger.log(`Ignore mapping ${m.field} word prefix or word suffix is empty`);
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
const escapedTermRegex = (0, regex_1.escapeRegex)(m.options.term_regex);
|
|
1301
|
+
const regx = new RegExp(escapedTermRegex);
|
|
1302
|
+
const findText = text.match(regx);
|
|
1303
|
+
if (_.isEmpty(findText)) {
|
|
1304
|
+
result[m.field] = undefined;
|
|
1305
|
+
}
|
|
1306
|
+
else if (findText.length == -0) {
|
|
1307
|
+
result[m.field] = undefined;
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
result[m.field] = findText[m.options.term_group || 1];
|
|
1311
|
+
if (!_.isEmpty(m.options.remove_words)) {
|
|
1312
|
+
const escapedRemoveWords = m.options.remove_words.map(word => (0, regex_1.escapeRegex)(word));
|
|
1313
|
+
const regexRW = new RegExp(escapedRemoveWords.join("|"), "gi");
|
|
1314
|
+
result[m.field] = result[m.field].replace(regexRW, "");
|
|
1315
|
+
}
|
|
1316
|
+
if (!_.isEmpty(m.options.template)) {
|
|
1317
|
+
const term = result[m.field];
|
|
1318
|
+
result[m.field] = await (0, func_1.executeFunc)((0, transform_1.transformString)(m.options.template, {
|
|
1319
|
+
term
|
|
1320
|
+
}), entity, { term });
|
|
1321
|
+
try {
|
|
1322
|
+
result[m.field] = (0, eval_1.safeEval)((0, eval_1.sanitizeExpression)(`return (${result[m.field]})`));
|
|
1323
|
+
}
|
|
1324
|
+
catch (e) { }
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
return result;
|
|
1329
|
+
}
|
|
1330
|
+
async _prepareData(entityName, data) {
|
|
1331
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1332
|
+
for (const key in data) {
|
|
1333
|
+
if (key === "_ref_rows") {
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
const field = entity.fields.find(i => i.name === key);
|
|
1337
|
+
if (_.isUndefined(field))
|
|
1338
|
+
continue;
|
|
1339
|
+
if (field.type === "number") {
|
|
1340
|
+
if (_.isUndefined(data[key]))
|
|
1341
|
+
continue;
|
|
1342
|
+
if (_.isString(data[key])) {
|
|
1343
|
+
data[key] = _.round(data[key], field.decimal_length || 0);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
else if (field.type === "related") {
|
|
1347
|
+
if (_.isEmpty(data[key]))
|
|
1348
|
+
continue;
|
|
1349
|
+
if (!field.allow_create_update) {
|
|
1350
|
+
data[key] =
|
|
1351
|
+
field.related_type === "one2many"
|
|
1352
|
+
? await Promise.all(data[key].map(async (i) => await this._findRelateData(field.related_ref, i)))
|
|
1353
|
+
: await this._findRelateData(field.related_ref, data[key]);
|
|
1354
|
+
}
|
|
1355
|
+
if (field.allow_create_update) {
|
|
1356
|
+
data[key] = await this._prepareData(field.related_ref, data[key]);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
return this._cleanData(data);
|
|
1361
|
+
}
|
|
1362
|
+
async _prepareFormatField(data, entity, mapping) {
|
|
1363
|
+
const request = this.cls.get("request");
|
|
1364
|
+
const profile = _.get(request, "profile");
|
|
1365
|
+
const headers = _.get(request, "headers");
|
|
1366
|
+
const dataExecute = Object.assign({ _profile: profile, _headers: headers }, data);
|
|
1367
|
+
for (const item of mapping) {
|
|
1368
|
+
try {
|
|
1369
|
+
if (item.type !== "format")
|
|
1370
|
+
continue;
|
|
1371
|
+
if (_.get(item, "format", "").includes("_getRunningNumber")) {
|
|
1372
|
+
item["_format_running"] = item.format;
|
|
1373
|
+
}
|
|
1374
|
+
const temp = await (0, transform_1.transform)(entity, dataExecute, { res: item.format });
|
|
1375
|
+
const value = _.get(temp, "res") || "";
|
|
1376
|
+
if (_.isArray(value)) {
|
|
1377
|
+
data[item.key] = value.join(",");
|
|
1378
|
+
}
|
|
1379
|
+
else if (_.isPlainObject(value)) {
|
|
1380
|
+
data[item.key] = JSON.stringify(value);
|
|
1381
|
+
}
|
|
1382
|
+
else {
|
|
1383
|
+
data[item.key] = value;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
catch (e) { }
|
|
1387
|
+
}
|
|
1388
|
+
return data;
|
|
1389
|
+
}
|
|
1390
|
+
async _exportExecute(data, entity, mapping, fields, allFields) {
|
|
1391
|
+
const temp = await this._prepareFormatField(data, entity, mapping);
|
|
1392
|
+
return this._prepareFlatData(_.pick(temp, fields), allFields, mapping);
|
|
1393
|
+
}
|
|
1394
|
+
async _executeCalculation(data, entity, mapping) {
|
|
1395
|
+
const calculationFields = mapping.filter(i => i.type === "calculation");
|
|
1396
|
+
const hash = (0, random_1.randomString)(20, false);
|
|
1397
|
+
for (const field of calculationFields) {
|
|
1398
|
+
for (const item of data) {
|
|
1399
|
+
const temp = await (0, transform_1.transform)(entity, Object.assign(Object.assign({}, item), { _all: data, _hash: hash }), { res: field.format });
|
|
1400
|
+
const value = _.get(temp, "res", "");
|
|
1401
|
+
if (_.isArray(value)) {
|
|
1402
|
+
item[field.header] = value.join(",");
|
|
1403
|
+
}
|
|
1404
|
+
else if (_.isPlainObject(value)) {
|
|
1405
|
+
item[field.header] = JSON.stringify(value);
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
item[field.header] = value;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
(0, func_1.removeRunningKey)(hash);
|
|
1413
|
+
return data;
|
|
1414
|
+
}
|
|
1415
|
+
async _setExportRedis(ref_id, percent, data, errorMsg) {
|
|
1416
|
+
if (ref_id) {
|
|
1417
|
+
const dataSetRedis = {
|
|
1418
|
+
ref_id,
|
|
1419
|
+
percent,
|
|
1420
|
+
finish: percent >= 100 || percent < 0,
|
|
1421
|
+
status: percent >= 100 ? "success" : percent < 0 ? "failed" : "processing"
|
|
1422
|
+
};
|
|
1423
|
+
if (dataSetRedis.finish && data) {
|
|
1424
|
+
dataSetRedis["export_data"] = data;
|
|
1425
|
+
}
|
|
1426
|
+
if (dataSetRedis.status === "failed" && errorMsg) {
|
|
1427
|
+
dataSetRedis["error_message"] = errorMsg;
|
|
1428
|
+
}
|
|
1429
|
+
await redis_1.redisCache.set(`EXPORT_${ref_id}`, dataSetRedis, TTL);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
_flatObject(data, keyObject) {
|
|
1433
|
+
for (const key in data) {
|
|
1434
|
+
keyObject = keyObject ? `${keyObject}.${key}` : key;
|
|
1435
|
+
if (_.isPlainObject(data[keyObject])) {
|
|
1436
|
+
keyObject = this._flatObject(data[keyObject], keyObject);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
return keyObject;
|
|
1440
|
+
}
|
|
1441
|
+
_mergeJsonFields(oldData, newData) {
|
|
1442
|
+
if (_.isEmpty(oldData)) {
|
|
1443
|
+
return newData;
|
|
1444
|
+
}
|
|
1445
|
+
const __checkDiff = (o, n) => {
|
|
1446
|
+
return JSON.stringify(o) !== JSON.stringify(n);
|
|
1447
|
+
};
|
|
1448
|
+
const plainKeys = Object.keys(newData).filter(k => !_.isPlainObject(newData[k]));
|
|
1449
|
+
const nestKeys = Object.keys(newData).filter(k => _.isPlainObject(newData[k]));
|
|
1450
|
+
if (_.isPlainObject(oldData)) {
|
|
1451
|
+
if (__checkDiff(_.pick(oldData, plainKeys), _.pick(newData, plainKeys))) {
|
|
1452
|
+
return _.cloneDeep([oldData, newData]);
|
|
1453
|
+
}
|
|
1454
|
+
else {
|
|
1455
|
+
const result = _.cloneDeep(oldData);
|
|
1456
|
+
for (const k of nestKeys) {
|
|
1457
|
+
result[k] = this._mergeJsonFields(oldData[k], newData[k]);
|
|
1458
|
+
}
|
|
1459
|
+
return result;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
else if (_.isArray(oldData)) {
|
|
1463
|
+
for (let i = 0; i < oldData.length; i++) {
|
|
1464
|
+
if (!__checkDiff(_.pick(oldData[i], plainKeys), _.pick(newData, plainKeys))) {
|
|
1465
|
+
const result = _.cloneDeep(oldData);
|
|
1466
|
+
for (const k of nestKeys) {
|
|
1467
|
+
result[i][k] = this._mergeJsonFields(oldData[i][k], newData[k]);
|
|
1468
|
+
}
|
|
1469
|
+
return result;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return _.cloneDeep([...oldData, newData]);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
async _mergeO2mFields(entityName, oldData, data) {
|
|
1476
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1477
|
+
const uniqueFields = entity.fields.filter(i => i.unique).map(i => i.name);
|
|
1478
|
+
if (_.isEmpty(oldData)) {
|
|
1479
|
+
oldData = [];
|
|
1480
|
+
}
|
|
1481
|
+
if (_.isPlainObject(oldData)) {
|
|
1482
|
+
oldData = [oldData];
|
|
1483
|
+
}
|
|
1484
|
+
if (_.isArray(data) && !_.isPlainObject(data)) {
|
|
1485
|
+
data = data[0];
|
|
1486
|
+
}
|
|
1487
|
+
if (_.isEmpty(uniqueFields)) {
|
|
1488
|
+
oldData.push(data);
|
|
1489
|
+
return oldData;
|
|
1490
|
+
}
|
|
1491
|
+
const uniqueValues = _.pick(data, uniqueFields);
|
|
1492
|
+
if (_.isEmpty(uniqueValues)) {
|
|
1493
|
+
oldData.push(data);
|
|
1494
|
+
return oldData;
|
|
1495
|
+
}
|
|
1496
|
+
const isExists = uniqueFields.length > 0 &&
|
|
1497
|
+
oldData.find(i => _.isEqual(_.pick(i, uniqueFields), uniqueValues));
|
|
1498
|
+
if (isExists) {
|
|
1499
|
+
await this._mergeO2oFields(entityName, isExists, data);
|
|
1500
|
+
}
|
|
1501
|
+
else if (!isExists && !_.isEmpty(data)) {
|
|
1502
|
+
oldData.push(data);
|
|
1503
|
+
}
|
|
1504
|
+
return oldData;
|
|
1505
|
+
}
|
|
1506
|
+
async _mergeO2oFields(entityName, oldData, data) {
|
|
1507
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1508
|
+
const o2mFields = entity.fields
|
|
1509
|
+
.filter(i => i.related_type === "one2many")
|
|
1510
|
+
.map(i => i.name);
|
|
1511
|
+
const imageFields = entity.fields
|
|
1512
|
+
.filter(i => i.type === "image")
|
|
1513
|
+
.map(i => i.name);
|
|
1514
|
+
for (const key in data) {
|
|
1515
|
+
if (o2mFields.includes(key)) {
|
|
1516
|
+
if (oldData[key] && !_.isArray(oldData[key])) {
|
|
1517
|
+
oldData[key] = [oldData[key]];
|
|
1518
|
+
}
|
|
1519
|
+
oldData[key] = await this._mergeO2mFields(entity.fields.find(i => i.name === key).related_ref, oldData[key], data[key]);
|
|
1520
|
+
}
|
|
1521
|
+
if (imageFields.includes(key)) {
|
|
1522
|
+
_.isArray(data[key])
|
|
1523
|
+
? oldData[key].push(...data[key])
|
|
1524
|
+
: oldData[key].push(data[key]);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
return oldData;
|
|
1528
|
+
}
|
|
1529
|
+
_removeDuplicates(keyDuplicates, data) {
|
|
1530
|
+
if (_.isEmpty(keyDuplicates))
|
|
1531
|
+
return data;
|
|
1532
|
+
keyDuplicates.forEach(element => {
|
|
1533
|
+
const duplicatesData = _.get(data, element);
|
|
1534
|
+
if (!_.isEmpty(duplicatesData) && _.isArray(duplicatesData)) {
|
|
1535
|
+
const nData = _.uniqWith(duplicatesData, _.isEqual);
|
|
1536
|
+
if (nData.length > 1) {
|
|
1537
|
+
_.set(data, element, nData);
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
_.set(data, element, nData[0]);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
async _transformDataForImport(data, mapping, entityName, importErrorData, additionalData) {
|
|
1546
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1547
|
+
const uniqueFields = entity.fields.filter(i => i.unique).map(i => i.name);
|
|
1548
|
+
const requiredFields = entity.fields
|
|
1549
|
+
.filter(i => i.required && !["id", "system"].includes(i.name))
|
|
1550
|
+
.map(i => i.name);
|
|
1551
|
+
const o2mFields = entity.fields
|
|
1552
|
+
.filter(i => i.related_type === "one2many")
|
|
1553
|
+
.map(i => i.name);
|
|
1554
|
+
const imageFields = entity.fields
|
|
1555
|
+
.filter(i => i.type === "image")
|
|
1556
|
+
.map(i => i.name);
|
|
1557
|
+
const o2oFields = entity.fields
|
|
1558
|
+
.filter(i => i.related_type === "one2one")
|
|
1559
|
+
.map(i => i.name);
|
|
1560
|
+
const jsonFields = entity.fields
|
|
1561
|
+
.filter(i => i.type === "json")
|
|
1562
|
+
.map(i => i.name);
|
|
1563
|
+
const headers = Object.keys(data[0]);
|
|
1564
|
+
const headerLosts = mapping
|
|
1565
|
+
.filter(m => !headers.includes(m.header) &&
|
|
1566
|
+
_.isEmpty(_.get(m, "options.data_default_value") ||
|
|
1567
|
+
_.get(m, "style.data_default_value")))
|
|
1568
|
+
.map(m => m.header);
|
|
1569
|
+
const result = [];
|
|
1570
|
+
let indexError = 0;
|
|
1571
|
+
for (const [index, i] of data.entries()) {
|
|
1572
|
+
let removeDuplicates = false;
|
|
1573
|
+
const keyRemoveDuplicates = [];
|
|
1574
|
+
const itemStep1 = await this.mapping(i, mapping, entity);
|
|
1575
|
+
let item = (0, flat_1.unflatten)(itemStep1);
|
|
1576
|
+
item = this._cleanData(item);
|
|
1577
|
+
if (!_.isEmpty(headerLosts)) {
|
|
1578
|
+
importErrorData.push(Object.assign(Object.assign({ row: index + 2 }, item), { message: `Headers ${headerLosts.join(", ")} not found ` }));
|
|
1579
|
+
continue;
|
|
1580
|
+
}
|
|
1581
|
+
item = await this._convertDataFromType(entityName, item, mapping);
|
|
1582
|
+
item = await this._convertData(item, entityName, [...imageFields], o2oFields, o2mFields);
|
|
1583
|
+
if (!_.isEmpty(additionalData) && _.isPlainObject(additionalData)) {
|
|
1584
|
+
item = Object.assign(Object.assign({}, item), additionalData);
|
|
1585
|
+
}
|
|
1586
|
+
const unique = _.pick(item, uniqueFields);
|
|
1587
|
+
const errorMessage = [];
|
|
1588
|
+
const isExists = !_.isEmpty(unique)
|
|
1589
|
+
? result.find((i, existIndex) => {
|
|
1590
|
+
indexError = existIndex;
|
|
1591
|
+
return _.isEqual(_.pick(i, uniqueFields), unique);
|
|
1592
|
+
})
|
|
1593
|
+
: undefined;
|
|
1594
|
+
if (!isExists) {
|
|
1595
|
+
item["_ref_rows"] = [index + 2];
|
|
1596
|
+
result.push(item);
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
for (const key in item) {
|
|
1600
|
+
if (o2mFields.includes(key) && !_.isEmpty(item[key])) {
|
|
1601
|
+
removeDuplicates = true;
|
|
1602
|
+
isExists[key] = await this._mergeO2mFields(entity.fields.find(i => i.name === key).related_ref, isExists[key], item[key]);
|
|
1603
|
+
}
|
|
1604
|
+
if (o2oFields.includes(key) && !_.isEmpty(item[key])) {
|
|
1605
|
+
isExists[key] = await this._mergeO2oFields(entity.fields.find(i => i.name === key).related_ref, isExists[key], item[key]);
|
|
1606
|
+
}
|
|
1607
|
+
if (imageFields.includes(key) && item[key]) {
|
|
1608
|
+
isExists[key].push(item[key]);
|
|
1609
|
+
}
|
|
1610
|
+
if (jsonFields.includes(key) && item[key]) {
|
|
1611
|
+
isExists[key] = this._mergeJsonFields(isExists[key], item[key]);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
isExists["_ref_rows"].push(index + 2);
|
|
1615
|
+
}
|
|
1616
|
+
if (removeDuplicates) {
|
|
1617
|
+
this._removeDuplicates(keyRemoveDuplicates, isExists);
|
|
1618
|
+
}
|
|
1619
|
+
for (const re of requiredFields) {
|
|
1620
|
+
if (!_.isNumber(item[re]) &&
|
|
1621
|
+
!_.isBoolean(item[re]) &&
|
|
1622
|
+
!_.isDate(item[re]) &&
|
|
1623
|
+
_.isEmpty(item[re])) {
|
|
1624
|
+
errorMessage.push(`${re} field is required field`);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
if (!_.isEmpty(errorMessage)) {
|
|
1628
|
+
importErrorData.push(Object.assign(Object.assign({ row: index + 2 }, item), { message: errorMessage.join(",") }));
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
return result;
|
|
1632
|
+
}
|
|
1633
|
+
async _validateJsonData(data, config, entityName, importErrorData, additionalData) {
|
|
1634
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1635
|
+
const tData = [];
|
|
1636
|
+
for (const d of data) {
|
|
1637
|
+
const temp = await (0, transform_1.transform)(entity, _.isEmpty(config.main_key) ? d : d[config.main_key], config.mapping, "main", "", true);
|
|
1638
|
+
if (_.isEmpty(temp)) {
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
tData.push(temp);
|
|
1642
|
+
}
|
|
1643
|
+
console.log(tData);
|
|
1644
|
+
const requiredFields = entity.fields.filter(i => i.required && !["id", "system"].includes(i.name));
|
|
1645
|
+
const o2mFields = entity.fields
|
|
1646
|
+
.filter(i => i.related_type === "one2many")
|
|
1647
|
+
.map(i => i.name);
|
|
1648
|
+
const imageFields = entity.fields
|
|
1649
|
+
.filter(i => i.type === "image")
|
|
1650
|
+
.map(i => i.name);
|
|
1651
|
+
const o2oFields = entity.fields
|
|
1652
|
+
.filter(i => i.related_type === "one2one")
|
|
1653
|
+
.map(i => i.name);
|
|
1654
|
+
if (_.isUndefined(importErrorData)) {
|
|
1655
|
+
importErrorData = [];
|
|
1656
|
+
}
|
|
1657
|
+
const result = [];
|
|
1658
|
+
for (const [i, d] of tData.entries()) {
|
|
1659
|
+
const item = await this._convertData(_.cloneDeep(d), entityName, [...imageFields], o2oFields, o2mFields);
|
|
1660
|
+
result.push(item);
|
|
1661
|
+
const errorMessage = [];
|
|
1662
|
+
for (const re of requiredFields) {
|
|
1663
|
+
if (re.type === "string" && _.isEmpty(item[re.name])) {
|
|
1664
|
+
errorMessage.push(`${re.name} field is required field`);
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
if (_.isUndefined(item[re.name]) || _.isNil(item[re.name])) {
|
|
1668
|
+
errorMessage.push(`${re.name} field is required field`);
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
if (!_.isEmpty(errorMessage)) {
|
|
1673
|
+
importErrorData.push(Object.assign(Object.assign({ row: i + 2 }, item), { message: errorMessage.join(",") }));
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return result;
|
|
1677
|
+
}
|
|
1678
|
+
async _getErrorImportData(config, entity, errorData) {
|
|
1679
|
+
if (_.isEmpty(errorData))
|
|
1680
|
+
return [];
|
|
1681
|
+
if (config.file_ext.toString() === "pdf") {
|
|
1682
|
+
return errorData.message;
|
|
1683
|
+
}
|
|
1684
|
+
if (["json", "xml"].includes(config.file_ext.toString())) {
|
|
1685
|
+
return errorData.message;
|
|
1686
|
+
}
|
|
1687
|
+
let customConfig = _.cloneDeep(config);
|
|
1688
|
+
customConfig["mapping"] = customConfig.mapping.map(i => {
|
|
1689
|
+
_.set(i, "_header", i.header);
|
|
1690
|
+
return i;
|
|
1691
|
+
});
|
|
1692
|
+
customConfig.mapping.unshift({
|
|
1693
|
+
type: "field",
|
|
1694
|
+
show: true,
|
|
1695
|
+
field: "row",
|
|
1696
|
+
_header: "row",
|
|
1697
|
+
header: "Row"
|
|
1698
|
+
});
|
|
1699
|
+
customConfig.mapping.push({
|
|
1700
|
+
type: "field",
|
|
1701
|
+
show: true,
|
|
1702
|
+
field: "message",
|
|
1703
|
+
_header: "message",
|
|
1704
|
+
header: "Message"
|
|
1705
|
+
});
|
|
1706
|
+
const fileName = await (0, func_1.executeFunc)(customConfig.file_format, entity, {});
|
|
1707
|
+
const result = await this.exportData(errorData, customConfig, {});
|
|
1708
|
+
const fileData = {
|
|
1709
|
+
filename: `${fileName ||
|
|
1710
|
+
`error_${moment().format("YYYY-MM-DD")}`}.${_.get(customConfig, "file_ext")}`,
|
|
1711
|
+
data: result
|
|
1712
|
+
};
|
|
1713
|
+
return fileData;
|
|
1714
|
+
}
|
|
1715
|
+
async _getFileData(config, entity, data) {
|
|
1716
|
+
let customConfig = _.cloneDeep(config);
|
|
1717
|
+
if (!["pdf", "json", "xml"].includes(config.file_ext.toString())) {
|
|
1718
|
+
customConfig["mapping"] = customConfig.mapping.map(i => {
|
|
1719
|
+
_.set(i, "_header", i.field);
|
|
1720
|
+
return i;
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
const fileName = await (0, func_1.executeFunc)(customConfig.file_format, entity, {});
|
|
1724
|
+
const fileData = {
|
|
1725
|
+
filename: `${fileName || moment().format("YYYY-MM-DD")}.${_.get(customConfig, "file_ext")}`,
|
|
1726
|
+
data: data
|
|
1727
|
+
};
|
|
1728
|
+
return fileData;
|
|
1729
|
+
}
|
|
1730
|
+
async _convertDataFromType(entityName, item, mapping) {
|
|
1731
|
+
const entity = await (0, schema_1.loadEntity)(entityName);
|
|
1732
|
+
for (const key in item) {
|
|
1733
|
+
const field = entity.fields.find(i => i.name === _.snakeCase(key));
|
|
1734
|
+
if (!field)
|
|
1735
|
+
continue;
|
|
1736
|
+
if (_.isArray(item[key]) && _.get(field, "related_ref")) {
|
|
1737
|
+
for (let i = 0; i < item[key].length; i++) {
|
|
1738
|
+
item[key][i] = await this._convertDataFromType(field.related_ref, item[key][i]);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
if (_.isPlainObject(item[key]) && _.get(field, "related_ref")) {
|
|
1742
|
+
item[key] = await this._convertDataFromType(field.related_ref, item[key]);
|
|
1743
|
+
}
|
|
1744
|
+
if (!_.isPlainObject(item[key])) {
|
|
1745
|
+
if (field.type === "string") {
|
|
1746
|
+
item[key] = `${item[key]}`;
|
|
1747
|
+
}
|
|
1748
|
+
if (field.type === "number") {
|
|
1749
|
+
if (`${item[key]}` === "-") {
|
|
1750
|
+
item[key] = 0;
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
item[key] = `${item[key]}`.replace(/[$€£¥₹₽R$CHFkr₩₺R฿]/, "");
|
|
1754
|
+
item[key] = `${item[key]}`.replace(",", "");
|
|
1755
|
+
item[key] = `${item[key]}`.replace(/[ABCDEFGHIJKLNMOPQRSTUVWXYZ]/, "");
|
|
1756
|
+
if (`${item[key]}`.indexOf("%") !== -1) {
|
|
1757
|
+
item[key] = `${item[key]}`.replace("%", "");
|
|
1758
|
+
item[key] =
|
|
1759
|
+
(item[key] * (_.get(field, "decimal_legnth") > 0 ? 1.0 : 1)) /
|
|
1760
|
+
100;
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
item[key] =
|
|
1764
|
+
item[key] * (_.get(field, "decimal_legnth") > 0 ? 1.0 : 1);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
if (field.type === "boolean") {
|
|
1769
|
+
item[key] = ["true", "1", "yes", "y"].includes(`${item[key]}`.toLowerCase())
|
|
1770
|
+
? true
|
|
1771
|
+
: false;
|
|
1772
|
+
}
|
|
1773
|
+
if (["date", "datetime"].includes(field.type_date) &&
|
|
1774
|
+
!_.isEmpty(item[key])) {
|
|
1775
|
+
const option = _.get(mapping === null || mapping === void 0 ? void 0 : mapping.find(m => m.field === key), "options", {});
|
|
1776
|
+
item[key] = moment(item[key], _.get(option, "data_format", "YYYY-MM-DD")).toDate();
|
|
1777
|
+
}
|
|
1778
|
+
if (field.type === "options") {
|
|
1779
|
+
item[key] = `${item[key]}`.split("|");
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
return item;
|
|
1784
|
+
}
|
|
1785
|
+
async _autoExport(config) {
|
|
1786
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
1787
|
+
let filters = {};
|
|
1788
|
+
if (!_.isEmpty(config.condition)) {
|
|
1789
|
+
filters = {
|
|
1790
|
+
$and: (0, mongo_1.convertConditionToMongoQuery)(_.cloneDeep(config.condition), entity, true)
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
const exportData = await this.export(config._id, filters, "", 1, _.get(config, "data_limit", 100), undefined, undefined, undefined, true);
|
|
1794
|
+
const filename = `${await (0, func_1.executeFunc)(config.file_format, entity, {})}.${_.get(config, "file_ext")}`;
|
|
1795
|
+
const base64String = exportData.data.split(";base64,")[1];
|
|
1796
|
+
const mimeInfo = await (0, file_type_1.fromBuffer)(Buffer.from(base64String, "base64"));
|
|
1797
|
+
const mimeType = mimeInfo
|
|
1798
|
+
? _.get(mimeInfo, "mime")
|
|
1799
|
+
: exportData.data.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0];
|
|
1800
|
+
const data = lzutf8.compress(exportData.data.split(";base64,")[1], {
|
|
1801
|
+
outputEncoding: "BinaryString"
|
|
1802
|
+
});
|
|
1803
|
+
const provider = config.provider.toString();
|
|
1804
|
+
const body = {};
|
|
1805
|
+
_.set(body, "id", config.id);
|
|
1806
|
+
_.set(body, "provider", provider);
|
|
1807
|
+
_.set(body, "config", config[provider]);
|
|
1808
|
+
_.set(body, "action", "push");
|
|
1809
|
+
_.set(body, "options", {
|
|
1810
|
+
source_path: { data, filename, encoding: "base64", compress: true },
|
|
1811
|
+
path: config.upload_path,
|
|
1812
|
+
mime: mimeType
|
|
1813
|
+
});
|
|
1814
|
+
await (0, schema_1.callAddQueueInternal)("import_export", "job_execute", body);
|
|
1815
|
+
}
|
|
1816
|
+
async _getFilters(filters, config, layoutCode) {
|
|
1817
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
1818
|
+
if (_.isEmpty(layoutCode)) {
|
|
1819
|
+
return filters;
|
|
1820
|
+
}
|
|
1821
|
+
const layout = _.get(entity, "layouts", []).find(i => i.code === layoutCode);
|
|
1822
|
+
const laFilters = (0, mongo_1.convertFilterToMongoQuery)(_.get(layout, "filters.filters", []), entity);
|
|
1823
|
+
if (_.isEmpty(laFilters)) {
|
|
1824
|
+
return filters;
|
|
1825
|
+
}
|
|
1826
|
+
const layoutFilter = JSON.parse(await (0, func_1.executeFunc)(JSON.stringify(laFilters), entity, {}));
|
|
1827
|
+
const customFilters = _.get(filters, "$and")
|
|
1828
|
+
? filters
|
|
1829
|
+
: { $and: _.isEmpty(filters) ? [] : [...filters] };
|
|
1830
|
+
customFilters["$and"].push(...layoutFilter);
|
|
1831
|
+
return customFilters;
|
|
1832
|
+
}
|
|
1833
|
+
async _executeCustom(data, entity, actions) {
|
|
1834
|
+
var _a;
|
|
1835
|
+
if (_.isEmpty(actions)) {
|
|
1836
|
+
return false;
|
|
1837
|
+
}
|
|
1838
|
+
for (const action of actions) {
|
|
1839
|
+
try {
|
|
1840
|
+
let params = {}, headers = {}, body = {};
|
|
1841
|
+
const modelName = action.url.substr(0, action.url.indexOf("/"));
|
|
1842
|
+
if (!_.isEmpty(action.headers)) {
|
|
1843
|
+
headers = await (0, transform_1.transform)(entity, data, action.headers);
|
|
1844
|
+
}
|
|
1845
|
+
if (!_.isEmpty(action.params)) {
|
|
1846
|
+
params = await (0, transform_1.transform)(entity, data, action.params);
|
|
1847
|
+
}
|
|
1848
|
+
let pathF = action.url.replace(/:[a-zA-Z0-9_]{1,}/g, x => {
|
|
1849
|
+
return "${ " + x.replace(":", "") + " }";
|
|
1850
|
+
});
|
|
1851
|
+
let url = (0, transform_1.transformString)(pathF, Object.assign(Object.assign({}, data), params), false, true);
|
|
1852
|
+
if (!_.isEmpty(action.body)) {
|
|
1853
|
+
body = await (0, transform_1.transform)(entity, data, action.body);
|
|
1854
|
+
}
|
|
1855
|
+
if (["get"].includes(action.method.toLowerCase()) && !_.isEmpty(body)) {
|
|
1856
|
+
url = `${url}${url.indexOf("?") === -1 ? "?" : "&"}${(0, transform_1.transformQuery)(body)}`;
|
|
1857
|
+
}
|
|
1858
|
+
if (action.type !== "internal") {
|
|
1859
|
+
throw new Error("Invalid action type");
|
|
1860
|
+
}
|
|
1861
|
+
url = url.replace(`${modelName}/`, "");
|
|
1862
|
+
await (0, schema_1.callInternalService)(modelName, action.method, url, body, headers);
|
|
1863
|
+
}
|
|
1864
|
+
catch (e) {
|
|
1865
|
+
throw new Error(((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.message) || (e === null || e === void 0 ? void 0 : e.message));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
return true;
|
|
1869
|
+
}
|
|
1870
|
+
async _afterrExecute(data, entity, config) {
|
|
1871
|
+
const execution = _.get(config, "after_execute", []);
|
|
1872
|
+
if (_.isEmpty(execution)) {
|
|
1873
|
+
return true;
|
|
1874
|
+
}
|
|
1875
|
+
for (const exec of execution) {
|
|
1876
|
+
const cond = await (0, validate_1.getConditions)(data, _.get(exec, "conditions", []), entity);
|
|
1877
|
+
if (!_.isEmpty(cond) && !(0, eval_1.safeEval)((0, eval_1.sanitizeExpression)(`return (${cond})`))) {
|
|
1878
|
+
continue;
|
|
1879
|
+
}
|
|
1880
|
+
if (_.isEmpty(exec.type)) {
|
|
1881
|
+
exec.type = "custom";
|
|
1882
|
+
}
|
|
1883
|
+
switch (exec.type.toLowerCase()) {
|
|
1884
|
+
case "custom":
|
|
1885
|
+
await this._executeCustom(data, entity, exec === null || exec === void 0 ? void 0 : exec.actions);
|
|
1886
|
+
break;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return true;
|
|
1890
|
+
}
|
|
1891
|
+
async export(id, filters, keywords, page, pageSize, locale, ref_id, headers, usePageSize, layout) {
|
|
1892
|
+
let config;
|
|
1893
|
+
try {
|
|
1894
|
+
config = await this.getConfig(id);
|
|
1895
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
1896
|
+
await this._setExportRedis(ref_id, 10);
|
|
1897
|
+
if (!config.enable) {
|
|
1898
|
+
common_1.Logger.log(`${config.name} is not enable`, "ImportExportService#NotEnable");
|
|
1899
|
+
return false;
|
|
1900
|
+
}
|
|
1901
|
+
common_1.Logger.log(`Export data for config ${config.name}`, "ImportExport#Service");
|
|
1902
|
+
const allFields = this._getFields(config.mapping);
|
|
1903
|
+
const fields = allFields.map(i => i.split(".")[0]);
|
|
1904
|
+
const generalSetting = await (0, schema_1.getSetting)("general");
|
|
1905
|
+
await this._setExportRedis(ref_id, 20);
|
|
1906
|
+
const exportMaximumRows = _.get(generalSetting, "import_export_setting.export_maximum_rows", 1000);
|
|
1907
|
+
const exportSize = usePageSize ? pageSize : exportMaximumRows;
|
|
1908
|
+
const customHeaders = Object.assign(Object.assign({}, (headers || {})), { "Accept-Language": locale || "en-US", _need_mask: true });
|
|
1909
|
+
(0, schema_1.prepareHeader)(customHeaders);
|
|
1910
|
+
if (JSON.stringify(filters) === '{"null":null}') {
|
|
1911
|
+
filters = {};
|
|
1912
|
+
}
|
|
1913
|
+
let customFilters = _.isPlainObject(filters)
|
|
1914
|
+
? filters
|
|
1915
|
+
: (0, build_search_1.convertFilter)(filters);
|
|
1916
|
+
customFilters = await this._getFilters(customFilters, config, layout);
|
|
1917
|
+
const data = exportSize === 0
|
|
1918
|
+
? { rows: [{}] }
|
|
1919
|
+
: await (0, schema_1.callListInternalService)(entity.name, keywords, customFilters, _.get(config, "sort", []).join(","), _.get(config, "query_fields", []).join(","), page, exportSize, customHeaders);
|
|
1920
|
+
await this._setExportRedis(ref_id, 40);
|
|
1921
|
+
const prepareDataBeforeFlatten = [];
|
|
1922
|
+
let row = 1;
|
|
1923
|
+
const docRefs = [];
|
|
1924
|
+
for (const i of data.rows) {
|
|
1925
|
+
docRefs.push(i.id);
|
|
1926
|
+
i["_index"] = row;
|
|
1927
|
+
const result = await this._exportExecute(i, entity, config.mapping, fields, allFields);
|
|
1928
|
+
prepareDataBeforeFlatten.push(result);
|
|
1929
|
+
row += 1;
|
|
1930
|
+
}
|
|
1931
|
+
const flatData = _.flatten(prepareDataBeforeFlatten);
|
|
1932
|
+
await this._setExportRedis(ref_id, 60);
|
|
1933
|
+
let result = [];
|
|
1934
|
+
for (const i of _.isEmpty(flatData) ? [{}] : flatData) {
|
|
1935
|
+
const revertMapping = await this.revertMapping(i, config.mapping, entity);
|
|
1936
|
+
result.push(revertMapping);
|
|
1937
|
+
}
|
|
1938
|
+
await this._setExportRedis(ref_id, 80);
|
|
1939
|
+
const resultBeforeFilters = _.cloneDeep(result);
|
|
1940
|
+
result = this._filters(result, config.mapping, config.filters, [
|
|
1941
|
+
"field",
|
|
1942
|
+
"format"
|
|
1943
|
+
]);
|
|
1944
|
+
const afterCalculation = await this._executeCalculation(result, entity, config.mapping);
|
|
1945
|
+
const afterExecution = this._afterExecution(afterCalculation, config.mapping, config.group_by_fields, config.filters);
|
|
1946
|
+
await this._checkFormatRunningNumber(resultBeforeFilters, afterExecution, config.mapping);
|
|
1947
|
+
const fileFormat = _.get(config, "file_format") ||
|
|
1948
|
+
"download_${ _date('DD-MM-YYYY','0h','') }";
|
|
1949
|
+
const fileExt = _.get(config, "file_ext", "");
|
|
1950
|
+
const filename = `${await (0, func_1.executeFunc)(fileFormat, entity, {})}.${fileExt}`;
|
|
1951
|
+
const dataExport = {
|
|
1952
|
+
filename: filename,
|
|
1953
|
+
data: await this.exportData(afterExecution, config, filters)
|
|
1954
|
+
};
|
|
1955
|
+
await (0, schema_1.callAddQueueInternal)("import_export", "after_execute", {
|
|
1956
|
+
id: config.id || config._id,
|
|
1957
|
+
docRefs
|
|
1958
|
+
});
|
|
1959
|
+
const request = this.cls.get("request");
|
|
1960
|
+
await (0, hook_1.executeHooks)(entity, "export", "after", {
|
|
1961
|
+
headers: _.get(request, "headers"),
|
|
1962
|
+
body: {},
|
|
1963
|
+
profile: _.get(request, "profile", {})
|
|
1964
|
+
}, { id: undefined });
|
|
1965
|
+
await this._setExportRedis(ref_id, 100, dataExport);
|
|
1966
|
+
await this._handleAddImportExportLog(config, {
|
|
1967
|
+
data: {
|
|
1968
|
+
filename: dataExport === null || dataExport === void 0 ? void 0 : dataExport.filename
|
|
1969
|
+
},
|
|
1970
|
+
wholeFile: dataExport,
|
|
1971
|
+
filters
|
|
1972
|
+
});
|
|
1973
|
+
return dataExport;
|
|
1974
|
+
}
|
|
1975
|
+
catch (e) {
|
|
1976
|
+
await this._setExportRedis(ref_id, -1, undefined, e.message);
|
|
1977
|
+
await this._handleAddImportExportLog(config, { filters });
|
|
1978
|
+
throw e;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
async exportRawData(id, filters, keywords, page, pageSize, locale, example) {
|
|
1982
|
+
try {
|
|
1983
|
+
const config = await this.getConfig(id);
|
|
1984
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
1985
|
+
if (!config.enable) {
|
|
1986
|
+
common_1.Logger.log(`${config.name} is not enable`, "ImportExportService#NotEnable");
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1989
|
+
common_1.Logger.log(`Export data for config ${config.name}`, "ImportExport#Service");
|
|
1990
|
+
const allFields = this._getFields(config.mapping);
|
|
1991
|
+
const fields = allFields.map(i => i.split(".")[0]);
|
|
1992
|
+
const generalSetting = await (0, schema_1.getSetting)("general");
|
|
1993
|
+
const exportMaximumRows = _.get(generalSetting, "import_export_setting.export_maximum_rows", 1000);
|
|
1994
|
+
const exportSize = pageSize > exportMaximumRows ? exportMaximumRows : pageSize;
|
|
1995
|
+
const data = exportSize === 0
|
|
1996
|
+
? { rows: [{}] }
|
|
1997
|
+
: await (0, schema_1.callListInternalService)(entity.name, keywords, filters, _.get(config, "sort", []).join(","), _.get(config, "query_fields", []).join(","), page, exportSize, { "Accept-Language": locale || "en-US" });
|
|
1998
|
+
if (!example && _.get(data, "rows.length") === 0) {
|
|
1999
|
+
const mapping = config.mapping.filter(i => i.show);
|
|
2000
|
+
const dataExport = [
|
|
2001
|
+
_.reduce(mapping, (r, i) => {
|
|
2002
|
+
r[i.header] = "";
|
|
2003
|
+
return r;
|
|
2004
|
+
}, {})
|
|
2005
|
+
];
|
|
2006
|
+
return dataExport;
|
|
2007
|
+
}
|
|
2008
|
+
const prepareDataBeforeFlatten = [];
|
|
2009
|
+
let row = 1;
|
|
2010
|
+
const docRefs = [];
|
|
2011
|
+
for (const i of data.rows) {
|
|
2012
|
+
docRefs.push(i.id);
|
|
2013
|
+
i["_index"] = row;
|
|
2014
|
+
const result = await this._exportExecute(i, entity, config.mapping, fields, allFields);
|
|
2015
|
+
prepareDataBeforeFlatten.push(result);
|
|
2016
|
+
row += 1;
|
|
2017
|
+
}
|
|
2018
|
+
const flatData = _.flatten(prepareDataBeforeFlatten);
|
|
2019
|
+
let result = [];
|
|
2020
|
+
for (const i of _.isEmpty(flatData) ? [{}] : flatData) {
|
|
2021
|
+
const revertMapping = await this.revertMapping(i, config.mapping, entity);
|
|
2022
|
+
result.push(revertMapping);
|
|
2023
|
+
}
|
|
2024
|
+
const resultBeforeFilters = _.cloneDeep(result);
|
|
2025
|
+
result = this._filters(result, config.mapping, config.filters, [
|
|
2026
|
+
"field",
|
|
2027
|
+
"format"
|
|
2028
|
+
]);
|
|
2029
|
+
const afterCalculation = await this._executeCalculation(result, entity, config.mapping);
|
|
2030
|
+
const afterExecution = this._afterExecution(afterCalculation, config.mapping, config.group_by_fields, config.filters);
|
|
2031
|
+
await this._checkFormatRunningNumber(resultBeforeFilters, afterExecution, config.mapping);
|
|
2032
|
+
if (example) {
|
|
2033
|
+
return {
|
|
2034
|
+
data: await this.exportData(afterExecution, config, filters, example)
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
await (0, schema_1.callAddQueueInternal)("import_export", "after_execute", {
|
|
2038
|
+
id: config.id || config._id,
|
|
2039
|
+
docRefs
|
|
2040
|
+
});
|
|
2041
|
+
const request = this.cls.get("request");
|
|
2042
|
+
await (0, hook_1.executeHooks)(entity, "export", "after", {
|
|
2043
|
+
headers: _.get(request, "headers"),
|
|
2044
|
+
body: {},
|
|
2045
|
+
profile: _.get(request, "profile", {})
|
|
2046
|
+
}, { id: undefined });
|
|
2047
|
+
return afterExecution;
|
|
2048
|
+
}
|
|
2049
|
+
catch (e) {
|
|
2050
|
+
throw e;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
async getExportProgress(id) {
|
|
2054
|
+
const data = await redis_1.redisCache.get(`EXPORT_${id}`);
|
|
2055
|
+
if (!data) {
|
|
2056
|
+
throw new Error("Invalid reference id");
|
|
2057
|
+
}
|
|
2058
|
+
return data;
|
|
2059
|
+
}
|
|
2060
|
+
async prepareExport(id, filters, keywords, page, pageSize, locale, layout) {
|
|
2061
|
+
const request = this.cls.get("request");
|
|
2062
|
+
const config = await this.getConfig(id);
|
|
2063
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2064
|
+
const generalSetting = await (0, schema_1.getSetting)("general");
|
|
2065
|
+
const exportMaximumRows = _.get(generalSetting, "import_export_setting.export_maximum_rows", 1000);
|
|
2066
|
+
const filename = await (0, func_1.executeFunc)(config.file_format, entity, {});
|
|
2067
|
+
filters = _.isPlainObject(filters)
|
|
2068
|
+
? filters
|
|
2069
|
+
: (0, build_search_1.convertFilter)(decodeURIComponent(filters));
|
|
2070
|
+
const count = await (0, schema_1.callCountInternalService)(entity.name, keywords, filters);
|
|
2071
|
+
if (count > exportMaximumRows) {
|
|
2072
|
+
throw new Error(`Cannot export transaction because it's over maximum ${exportMaximumRows} rows limit`);
|
|
2073
|
+
}
|
|
2074
|
+
const refId = (0, uuid_1.v4)();
|
|
2075
|
+
await this._setExportRedis(refId, 0);
|
|
2076
|
+
await (0, schema_1.callAddQueueInternal)("queue", "import_export", {
|
|
2077
|
+
id,
|
|
2078
|
+
filters,
|
|
2079
|
+
keywords,
|
|
2080
|
+
page,
|
|
2081
|
+
exportMaximumRows,
|
|
2082
|
+
locale,
|
|
2083
|
+
layout,
|
|
2084
|
+
ref_id: refId,
|
|
2085
|
+
action: "ready_to_export",
|
|
2086
|
+
headers: _.get(request, "headers", {})
|
|
2087
|
+
});
|
|
2088
|
+
return {
|
|
2089
|
+
ref_id: refId,
|
|
2090
|
+
filename,
|
|
2091
|
+
percent: 0,
|
|
2092
|
+
finish: false,
|
|
2093
|
+
status: "processing"
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
async prepareImport(id, data, locale, extraData, filename) {
|
|
2097
|
+
const request = this.cls.get("request");
|
|
2098
|
+
const config = await this.getConfig(id);
|
|
2099
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2100
|
+
const originalData = extraData || data;
|
|
2101
|
+
const result = {
|
|
2102
|
+
ref_id: (0, uuid_1.v4)(),
|
|
2103
|
+
filename,
|
|
2104
|
+
percent: 0,
|
|
2105
|
+
finish: false,
|
|
2106
|
+
status: "processing"
|
|
2107
|
+
};
|
|
2108
|
+
redis_1.redisCache.set(`VERIFY_${result.ref_id}`, result, TTL);
|
|
2109
|
+
await (0, schema_1.callAddQueueInternal)("queue", "import_export", {
|
|
2110
|
+
id,
|
|
2111
|
+
locale,
|
|
2112
|
+
ref_id: result.ref_id,
|
|
2113
|
+
action: "ready_to_verify",
|
|
2114
|
+
headers: _.get(request, "headers", {}),
|
|
2115
|
+
data,
|
|
2116
|
+
extraData,
|
|
2117
|
+
filename
|
|
2118
|
+
});
|
|
2119
|
+
return result;
|
|
2120
|
+
}
|
|
2121
|
+
async import(id, data, locale, extraData, filename, refId, additionalData) {
|
|
2122
|
+
const res = {
|
|
2123
|
+
ref_id: _.isEmpty(refId) ? (0, uuid_1.v4)() : refId,
|
|
2124
|
+
locale,
|
|
2125
|
+
total: 0,
|
|
2126
|
+
current: 0,
|
|
2127
|
+
create: 0,
|
|
2128
|
+
update: 0,
|
|
2129
|
+
success: 0,
|
|
2130
|
+
error: 0,
|
|
2131
|
+
filename,
|
|
2132
|
+
error_validating_custom_import: false
|
|
2133
|
+
};
|
|
2134
|
+
if (_.isEmpty(refId)) {
|
|
2135
|
+
refId = res.ref_id;
|
|
2136
|
+
}
|
|
2137
|
+
let config, entity;
|
|
2138
|
+
try {
|
|
2139
|
+
console.log("-------- IMPORT START ------------");
|
|
2140
|
+
config = await this.getConfig(id);
|
|
2141
|
+
entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2142
|
+
const originalData = extraData ? JSON.stringify(extraData) : data;
|
|
2143
|
+
const txtData = await this._getRawTextData(extraData || data, config);
|
|
2144
|
+
data = await this.decodeData(extraData || data, config);
|
|
2145
|
+
if (_.isEmpty(data)) {
|
|
2146
|
+
await redis_1.redisCache.set(`VERIFY_${refId}`, Object.assign(Object.assign({}, res), { percent: 100, finish: true, status: "success" }), TTL);
|
|
2147
|
+
await redis_1.redisCache.set(`IMPORT_${refId}`, _.merge({
|
|
2148
|
+
data: [],
|
|
2149
|
+
config_id: id,
|
|
2150
|
+
original: ""
|
|
2151
|
+
}, Object.assign({}, res)), TTL);
|
|
2152
|
+
return res;
|
|
2153
|
+
}
|
|
2154
|
+
const initialData = _.cloneDeep(data);
|
|
2155
|
+
const importCondition = _.get(config, "import_condition", []);
|
|
2156
|
+
if (!config.enable) {
|
|
2157
|
+
throw new Error(`${config.name} is disabled`);
|
|
2158
|
+
}
|
|
2159
|
+
const uniqueFields = _.get(entity, "fields", [])
|
|
2160
|
+
.filter(i => i.unique)
|
|
2161
|
+
.map(i => i.name);
|
|
2162
|
+
let importData = [];
|
|
2163
|
+
let isErrorValidatingCustom = false;
|
|
2164
|
+
const importErrorData = [];
|
|
2165
|
+
if (config.file_ext.toString() !== "pdf") {
|
|
2166
|
+
if (["json", "xml"].includes(config.file_ext.toString())) {
|
|
2167
|
+
data = await this._validateJsonData(data, config["json_mapping"], entity.name, importErrorData, additionalData);
|
|
2168
|
+
}
|
|
2169
|
+
else {
|
|
2170
|
+
data = await this._transformDataForImport(data, config["mapping"], entity.name, importErrorData, additionalData);
|
|
2171
|
+
}
|
|
2172
|
+
data = this._cleanData(data);
|
|
2173
|
+
if (!_.isEmpty(importCondition)) {
|
|
2174
|
+
const entity = await (0, schema_1.loadEntity)(_.get(config, "entity", ""));
|
|
2175
|
+
const nData = _.cloneDeep(data);
|
|
2176
|
+
const nArray = [];
|
|
2177
|
+
for (let i = 0; i < data.length; i++) {
|
|
2178
|
+
const conditions = await (0, validate_1.getConditions)(nData[i], importCondition, entity);
|
|
2179
|
+
if (!_.isEmpty(conditions) && !(0, eval_1.safeEval)((0, eval_1.sanitizeExpression)(`return (${conditions})`)))
|
|
2180
|
+
continue;
|
|
2181
|
+
nArray.push(nData[i]);
|
|
2182
|
+
}
|
|
2183
|
+
data = nArray;
|
|
2184
|
+
}
|
|
2185
|
+
if (_.isEmpty(data)) {
|
|
2186
|
+
await this._handleAddImportExportLog(config, {
|
|
2187
|
+
data: {
|
|
2188
|
+
filename
|
|
2189
|
+
},
|
|
2190
|
+
wholeFile: {
|
|
2191
|
+
data: originalData
|
|
2192
|
+
},
|
|
2193
|
+
status: activity_log_enum_1.ActivityLogStatus.failed
|
|
2194
|
+
});
|
|
2195
|
+
await redis_1.redisCache.set(`VERIFY_${refId}`, Object.assign(Object.assign({}, res), { percent: 0, finish: true, error_message: "Empty Data", status: "failed" }), TTL);
|
|
2196
|
+
return res;
|
|
2197
|
+
}
|
|
2198
|
+
let create = 0, update = 0, error = 0;
|
|
2199
|
+
for (const item of data) {
|
|
2200
|
+
try {
|
|
2201
|
+
const exists = uniqueFields.length > 0
|
|
2202
|
+
? await this.listExistsByUnique(entity.name, _.pick(item, uniqueFields))
|
|
2203
|
+
: undefined;
|
|
2204
|
+
_.isEmpty(exists) ? (create += 1) : (update += 1);
|
|
2205
|
+
}
|
|
2206
|
+
catch (e) {
|
|
2207
|
+
common_1.Logger.error(e.message);
|
|
2208
|
+
error += 1;
|
|
2209
|
+
}
|
|
2210
|
+
finally {
|
|
2211
|
+
importData.push(item);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
let totalImportData = initialData.length;
|
|
2215
|
+
const isErrorValidatingStandard = !_.isEmpty(importErrorData);
|
|
2216
|
+
try {
|
|
2217
|
+
importData = await (0, schema_1.callInternalService)(config.entity, "patch", "import_validate", {
|
|
2218
|
+
id: config.id,
|
|
2219
|
+
code: config.code,
|
|
2220
|
+
data: importData,
|
|
2221
|
+
data_text: txtData,
|
|
2222
|
+
original_data: originalData,
|
|
2223
|
+
filename
|
|
2224
|
+
});
|
|
2225
|
+
totalImportData = importData.length;
|
|
2226
|
+
if (create > totalImportData) {
|
|
2227
|
+
create = totalImportData;
|
|
2228
|
+
}
|
|
2229
|
+
if (create + update > totalImportData) {
|
|
2230
|
+
update = totalImportData - create;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
catch (e) {
|
|
2234
|
+
const errMessage = `import custom validate failed :: ${e.message}`;
|
|
2235
|
+
importData = importData.map(i => {
|
|
2236
|
+
return Object.assign(Object.assign({}, i), { _error: errMessage });
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
for (const [index, i] of importData.entries()) {
|
|
2240
|
+
if (_.isUndefined(i._error) || _.isEmpty(i._error))
|
|
2241
|
+
continue;
|
|
2242
|
+
for (const eRow of i._ref_rows) {
|
|
2243
|
+
const existsError = importErrorData.find(er => er.row === eRow);
|
|
2244
|
+
const errMessage = i._error;
|
|
2245
|
+
isErrorValidatingCustom = true;
|
|
2246
|
+
delete i._error;
|
|
2247
|
+
if (existsError) {
|
|
2248
|
+
existsError.message = `${existsError.message}, ${errMessage}`;
|
|
2249
|
+
}
|
|
2250
|
+
else {
|
|
2251
|
+
importErrorData.push(Object.assign(Object.assign({ row: eRow }, initialData[eRow - 2]), { message: errMessage }));
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
const errorImportData = await this._getErrorImportData(config, entity, _.sortBy(importErrorData, "row"));
|
|
2256
|
+
res.create = create;
|
|
2257
|
+
res.update = update;
|
|
2258
|
+
res.success = totalImportData - importErrorData.length;
|
|
2259
|
+
res.error = importErrorData.length;
|
|
2260
|
+
res.total = totalImportData;
|
|
2261
|
+
res.error_validating_custom_import =
|
|
2262
|
+
!isErrorValidatingStandard && isErrorValidatingCustom;
|
|
2263
|
+
const compressData = lzutf8.compress(originalData, {
|
|
2264
|
+
outputEncoding: "BinaryString"
|
|
2265
|
+
});
|
|
2266
|
+
await redis_1.redisCache.set(`IMPORT_${res.ref_id}`, _.merge({
|
|
2267
|
+
data: JSON.stringify(importData),
|
|
2268
|
+
config_id: id,
|
|
2269
|
+
original: compressData
|
|
2270
|
+
}, Object.assign(Object.assign({}, res), { total: importData.length })), TTL);
|
|
2271
|
+
if (res.total === 0) {
|
|
2272
|
+
await this._handleAddImportExportLog(config, {
|
|
2273
|
+
data: {
|
|
2274
|
+
filename
|
|
2275
|
+
},
|
|
2276
|
+
wholeFile: {
|
|
2277
|
+
data: originalData
|
|
2278
|
+
},
|
|
2279
|
+
status: activity_log_enum_1.ActivityLogStatus.warning
|
|
2280
|
+
});
|
|
2281
|
+
return res;
|
|
2282
|
+
}
|
|
2283
|
+
_.set(res, "errorImportData", errorImportData);
|
|
2284
|
+
if (!_.isEmpty(errorImportData)) {
|
|
2285
|
+
if (_.isEmpty(filename)) {
|
|
2286
|
+
filename = await (0, func_1.executeFunc)(config.file_format, entity, {});
|
|
2287
|
+
}
|
|
2288
|
+
await this._handleAddImportExportLog(config, {
|
|
2289
|
+
data: {
|
|
2290
|
+
filename: filename
|
|
2291
|
+
},
|
|
2292
|
+
wholeFile: {
|
|
2293
|
+
data: originalData
|
|
2294
|
+
},
|
|
2295
|
+
errorFile: {
|
|
2296
|
+
data: _.get(errorImportData, "data")
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
else {
|
|
2302
|
+
res.create = 1;
|
|
2303
|
+
res.update = 0;
|
|
2304
|
+
res.success = 1;
|
|
2305
|
+
res.error = 0;
|
|
2306
|
+
res.total = 1;
|
|
2307
|
+
const compressData = lzutf8.compress(originalData, {
|
|
2308
|
+
outputEncoding: "BinaryString"
|
|
2309
|
+
});
|
|
2310
|
+
await redis_1.redisCache.set(`IMPORT_${res.ref_id}`, _.merge({
|
|
2311
|
+
data: data,
|
|
2312
|
+
config_id: id,
|
|
2313
|
+
original: compressData
|
|
2314
|
+
}, res), TTL);
|
|
2315
|
+
}
|
|
2316
|
+
await redis_1.redisCache.set(`VERIFY_${refId}`, Object.assign(Object.assign({}, res), { percent: 100, finish: true, status: _.isEmpty(res["errorImportData"]) ? "success" : "failed" }), TTL);
|
|
2317
|
+
}
|
|
2318
|
+
catch (e) {
|
|
2319
|
+
console.error(e);
|
|
2320
|
+
if (config && entity) {
|
|
2321
|
+
try {
|
|
2322
|
+
const errorImportData = await this._getErrorImportData(config, entity, [{ row: 2, message: e.message }]);
|
|
2323
|
+
_.set(res, "errorImportData", errorImportData);
|
|
2324
|
+
if (!_.isEmpty(errorImportData)) {
|
|
2325
|
+
const originalData = extraData ? JSON.stringify(extraData) : data;
|
|
2326
|
+
if (_.isEmpty(filename)) {
|
|
2327
|
+
filename = await (0, func_1.executeFunc)(config.file_format, entity, {});
|
|
2328
|
+
}
|
|
2329
|
+
await this._handleAddImportExportLog(config, {
|
|
2330
|
+
data: {
|
|
2331
|
+
filename: filename
|
|
2332
|
+
},
|
|
2333
|
+
wholeFile: {
|
|
2334
|
+
data: originalData
|
|
2335
|
+
},
|
|
2336
|
+
errorFile: {
|
|
2337
|
+
data: _.get(errorImportData, "data")
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
catch (error) { }
|
|
2343
|
+
}
|
|
2344
|
+
await redis_1.redisCache.set(`VERIFY_${refId}`, Object.assign(Object.assign({}, res), { percent: 0, finish: true, error_message: e.message, status: "failed" }), TTL);
|
|
2345
|
+
}
|
|
2346
|
+
finally {
|
|
2347
|
+
return res;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
async execute(id, needResult = false, additionalData) {
|
|
2351
|
+
const request = this.cls.get("request");
|
|
2352
|
+
const data = await redis_1.redisCache.get(`IMPORT_${id}`);
|
|
2353
|
+
if (!data) {
|
|
2354
|
+
throw new Error("Invalid reference id");
|
|
2355
|
+
}
|
|
2356
|
+
if (data["current"] > 0) {
|
|
2357
|
+
throw new Error("Already executed");
|
|
2358
|
+
}
|
|
2359
|
+
if (_.isEmpty(data.data)) {
|
|
2360
|
+
redis_1.redisCache.set(`IMPORT_${id}`, Object.assign(Object.assign({}, data), { finish: true, percent: 100 }), TTL);
|
|
2361
|
+
return { id, doc_ref: [] };
|
|
2362
|
+
}
|
|
2363
|
+
const config = await this.getConfig(data.config_id);
|
|
2364
|
+
if (!config.enable) {
|
|
2365
|
+
common_1.Logger.log(`${config.name} is not enable`, "ImportExportService#NotEnable");
|
|
2366
|
+
return false;
|
|
2367
|
+
}
|
|
2368
|
+
const items = config.file_ext.toString() !== "pdf" ? JSON.parse(data.data) : [];
|
|
2369
|
+
if (needResult) {
|
|
2370
|
+
return this.importData(items, additionalData, config, data);
|
|
2371
|
+
}
|
|
2372
|
+
else {
|
|
2373
|
+
await (0, schema_1.callAddQueueInternal)("queue", "import_export", {
|
|
2374
|
+
id,
|
|
2375
|
+
items,
|
|
2376
|
+
config,
|
|
2377
|
+
data: Object.assign(Object.assign({}, data), { additional_data: additionalData }),
|
|
2378
|
+
action: "ready_to_import",
|
|
2379
|
+
_headers: Object.assign(Object.assign({}, request.headers), { action_user: _.get(request, "profile._id").toString() })
|
|
2380
|
+
});
|
|
2381
|
+
return true;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
async executeSchedule(id) {
|
|
2385
|
+
const config = await this.getConfig(id);
|
|
2386
|
+
if (!config.enable) {
|
|
2387
|
+
common_1.Logger.log("Config is not enable", "ImportExport#ExecuteSchedule");
|
|
2388
|
+
return false;
|
|
2389
|
+
}
|
|
2390
|
+
if (!config.allow_auto_upload) {
|
|
2391
|
+
common_1.Logger.log("Config is not allow auto import/export ", "ImportExport#ExecuteSchedule");
|
|
2392
|
+
return false;
|
|
2393
|
+
}
|
|
2394
|
+
const actionType = config.type.toString();
|
|
2395
|
+
if (actionType === "import") {
|
|
2396
|
+
const provider = config.provider.toString();
|
|
2397
|
+
await (0, schema_1.callAddQueueInternal)("import_export", "job_execute", {
|
|
2398
|
+
id,
|
|
2399
|
+
provider,
|
|
2400
|
+
config: config[provider],
|
|
2401
|
+
action: "pull",
|
|
2402
|
+
options: {
|
|
2403
|
+
path: _.get(config, "download_path"),
|
|
2404
|
+
id: config.id,
|
|
2405
|
+
archive_path: _.get(config, "download_archive_path")
|
|
2406
|
+
}
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
if (actionType === "export") {
|
|
2410
|
+
await this._autoExport(config);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
async processJob(id, action, option) {
|
|
2414
|
+
if (action === "ready_to_import") {
|
|
2415
|
+
try {
|
|
2416
|
+
await this.importData(option.items, option.additional_data, option.config, option.data);
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
catch (e) {
|
|
2420
|
+
console.error(e);
|
|
2421
|
+
return false;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
if (action === "ready_to_verify") {
|
|
2425
|
+
await this.import(option.id, option.data, option.locale, option.extraData, option.filename, option.ref_id);
|
|
2426
|
+
return true;
|
|
2427
|
+
}
|
|
2428
|
+
if (action === "ready_to_export") {
|
|
2429
|
+
try {
|
|
2430
|
+
await this.export(option.id, option.filters, option.keywords, option.page, option.pageSize, option.locale, option.ref_id, option.headers, option.pageSize > 0, option.layout);
|
|
2431
|
+
return true;
|
|
2432
|
+
}
|
|
2433
|
+
catch (e) {
|
|
2434
|
+
return false;
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
const config = await this.getConfig(id);
|
|
2438
|
+
if (!config) {
|
|
2439
|
+
return false;
|
|
2440
|
+
}
|
|
2441
|
+
if (action === "import" && _.get(config, "type") === "import") {
|
|
2442
|
+
const sourceLocation = _.get(option, "source_location", "url");
|
|
2443
|
+
let data = undefined;
|
|
2444
|
+
let filename = option.filename
|
|
2445
|
+
? option.filename
|
|
2446
|
+
: option.file_url
|
|
2447
|
+
? path.basename(option.file_url)
|
|
2448
|
+
: "";
|
|
2449
|
+
if (_.isEmpty(filename)) {
|
|
2450
|
+
throw new Error("Filename is required for import");
|
|
2451
|
+
}
|
|
2452
|
+
if (_.isEmpty(option.extraData)) {
|
|
2453
|
+
if (!_.isEmpty(option.attachment_id)) {
|
|
2454
|
+
data = await (0, schema_1.callInternalService)("attachment", "get", `download/${option.attachment_id}`);
|
|
2455
|
+
data = `data:${mime.lookup(option.filename)};base64,${data}`;
|
|
2456
|
+
}
|
|
2457
|
+
else {
|
|
2458
|
+
data = await this.downloadFile(option.file_url);
|
|
2459
|
+
data = `data:${mime.lookup(option.file_url)};base64,${data}`;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
const importResult = await this.import(id, data, undefined, option.extraData, filename, undefined, option.additional_data);
|
|
2463
|
+
if (importResult.error > 0) {
|
|
2464
|
+
return false;
|
|
2465
|
+
}
|
|
2466
|
+
if (importResult.total === 0) {
|
|
2467
|
+
return true;
|
|
2468
|
+
}
|
|
2469
|
+
return this.execute(importResult.ref_id, option.need_result, option.additional_data);
|
|
2470
|
+
}
|
|
2471
|
+
if (action === "export" && _.get(config, "type") === "export") {
|
|
2472
|
+
return true;
|
|
2473
|
+
}
|
|
2474
|
+
common_1.Logger.log(`Config option didn't match with params ${action}`, "ImportExport#NotMatch");
|
|
2475
|
+
return false;
|
|
2476
|
+
}
|
|
2477
|
+
async getProgress(id) {
|
|
2478
|
+
const data = await redis_1.redisCache.get(`IMPORT_${id}`);
|
|
2479
|
+
if (!data) {
|
|
2480
|
+
throw new Error("Invalid reference id");
|
|
2481
|
+
}
|
|
2482
|
+
data["percent"] = Math.floor((data["current"] / data["total"]) * 100);
|
|
2483
|
+
return _.omit(data, ["data", "config_id"]);
|
|
2484
|
+
}
|
|
2485
|
+
async getVerifyProgress(id) {
|
|
2486
|
+
const data = await redis_1.redisCache.get(`VERIFY_${id}`);
|
|
2487
|
+
if (!data) {
|
|
2488
|
+
throw new Error("Invalid reference id");
|
|
2489
|
+
}
|
|
2490
|
+
return _.omit(data, ["data", "config_id"]);
|
|
2491
|
+
}
|
|
2492
|
+
async getProgresses(records) {
|
|
2493
|
+
const result = [];
|
|
2494
|
+
for (const item of _.uniqBy(records, "ref_id")) {
|
|
2495
|
+
const key = item.action === "import"
|
|
2496
|
+
? `IMPORT_${item.ref_id}`
|
|
2497
|
+
: `EXPORT_${item.ref_id}`;
|
|
2498
|
+
const data = await redis_1.redisCache.get(key);
|
|
2499
|
+
if (!data)
|
|
2500
|
+
continue;
|
|
2501
|
+
item.action === "import" &&
|
|
2502
|
+
(data["percent"] = Math.floor((data["current"] / data["total"]) * 100));
|
|
2503
|
+
result.push(_.omit(data, ["data", "config_id"]));
|
|
2504
|
+
}
|
|
2505
|
+
return result;
|
|
2506
|
+
}
|
|
2507
|
+
async hook(id) {
|
|
2508
|
+
try {
|
|
2509
|
+
const config = await this.findOne(id);
|
|
2510
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2511
|
+
const countImpExp = await (0, schema_1.callInternalService)("import_export", "get", `count?filters=allow_manual_upload%3Dtrue%26enable%3Dtrue%26entity%3D${entity._id}`);
|
|
2512
|
+
await (0, schema_1.callUpdateSchemaInternal)(`${entity._id}`, {
|
|
2513
|
+
allow_manual_import_export: countImpExp > 0
|
|
2514
|
+
});
|
|
2515
|
+
await this._setSchedule(config);
|
|
2516
|
+
return true;
|
|
2517
|
+
}
|
|
2518
|
+
catch (e) {
|
|
2519
|
+
common_1.Logger.error(`Hook for import / export error : ${e.message}`);
|
|
2520
|
+
return false;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
async delete(id) {
|
|
2524
|
+
const data = await this.findOne(id);
|
|
2525
|
+
try {
|
|
2526
|
+
await (0, schema_1.callDeleteInternalService)("schedule_action", `import_export__${data._id}`);
|
|
2527
|
+
}
|
|
2528
|
+
catch (e) {
|
|
2529
|
+
common_1.Logger.error(`Failed to delete auto import/export schedule is ${data.name}`);
|
|
2530
|
+
}
|
|
2531
|
+
return super.delete(id);
|
|
2532
|
+
}
|
|
2533
|
+
async afterExecute(id, docRefs) {
|
|
2534
|
+
const request = this.cls.get("request");
|
|
2535
|
+
const config = mongoose.Types.ObjectId.isValid(id)
|
|
2536
|
+
? await (0, schema_1.callGetInternalService)("import_export", id)
|
|
2537
|
+
: await (0, schema_1.callFindInternalService)("import_export", "", { code: id });
|
|
2538
|
+
if (_.isEmpty(config)) {
|
|
2539
|
+
throw new Error("Import/Export does not exists in system");
|
|
2540
|
+
}
|
|
2541
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2542
|
+
request.headers = Object.assign(Object.assign({}, request.headers), { ignore_activity_log: "false" });
|
|
2543
|
+
await this._afterrExecute({ doc_refs: docRefs }, entity, config);
|
|
2544
|
+
return true;
|
|
2545
|
+
}
|
|
2546
|
+
async search(keywords, filters, page = 1, page_size = 10, sort = "", grouping, noTranslate, fields) {
|
|
2547
|
+
const result = await super.search(keywords, filters, page, page_size, sort, grouping, noTranslate, fields);
|
|
2548
|
+
const nRows = await this.getPeviousImportData(_.get(result, "rows", []));
|
|
2549
|
+
_.set(result, "rows", nRows);
|
|
2550
|
+
return result;
|
|
2551
|
+
}
|
|
2552
|
+
async jobExecute(jobData) {
|
|
2553
|
+
const request = this.cls.get("request");
|
|
2554
|
+
const headers = _.get(request, "headers");
|
|
2555
|
+
const { provider: providerCode, config, action, options, id } = jobData;
|
|
2556
|
+
if (action === "push") {
|
|
2557
|
+
const sourcePath = options === null || options === void 0 ? void 0 : options.source_path;
|
|
2558
|
+
let data;
|
|
2559
|
+
if (_.isPlainObject(sourcePath)) {
|
|
2560
|
+
data = sourcePath.data;
|
|
2561
|
+
const matches = data.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
|
|
2562
|
+
if (!_.isEmpty(matches)) {
|
|
2563
|
+
data = matches[2];
|
|
2564
|
+
}
|
|
2565
|
+
if (sourcePath.compress) {
|
|
2566
|
+
data = lzutf8.decompress(data, { inputEncoding: "BinaryString" });
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
if (!_.isPlainObject(sourcePath) && !_.isString(sourcePath)) {
|
|
2570
|
+
throw new Error("Invalid source path format");
|
|
2571
|
+
}
|
|
2572
|
+
options["source_path"]["data"] = data;
|
|
2573
|
+
const importConfig = await this.getConfig(id);
|
|
2574
|
+
const entityName = importConfig.entity;
|
|
2575
|
+
const providerConfig = await (0, import_export_utils_1.getCustomProvider)(providerCode);
|
|
2576
|
+
const isExternal = providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.external;
|
|
2577
|
+
if (isExternal && entityName) {
|
|
2578
|
+
return await (0, external_module_1.callExecuteExternalProviderModule)(entityName, providerCode, "export", [{
|
|
2579
|
+
id,
|
|
2580
|
+
data,
|
|
2581
|
+
source: options === null || options === void 0 ? void 0 : options.source_path,
|
|
2582
|
+
filename: sourcePath.filename,
|
|
2583
|
+
path: options.path,
|
|
2584
|
+
mime: options.mime,
|
|
2585
|
+
headers
|
|
2586
|
+
}]);
|
|
2587
|
+
}
|
|
2588
|
+
else {
|
|
2589
|
+
const provider = await (0, import_export_utils_1.getProvider)(config, providerCode);
|
|
2590
|
+
return await provider.export({
|
|
2591
|
+
id,
|
|
2592
|
+
data,
|
|
2593
|
+
source: options === null || options === void 0 ? void 0 : options.source_path,
|
|
2594
|
+
filename: sourcePath.filename,
|
|
2595
|
+
path: options.path,
|
|
2596
|
+
mime: options.mime,
|
|
2597
|
+
headers
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
if (action === "pull") {
|
|
2602
|
+
const importConfig = await this.getConfig(id);
|
|
2603
|
+
const entityName = importConfig.entity;
|
|
2604
|
+
const providerConfig = await (0, import_export_utils_1.getCustomProvider)(providerCode);
|
|
2605
|
+
const isExternal = providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.external;
|
|
2606
|
+
let res;
|
|
2607
|
+
if (isExternal && entityName) {
|
|
2608
|
+
res = await (0, external_module_1.callExecuteExternalProviderModule)(entityName, providerCode, "import", [{
|
|
2609
|
+
id,
|
|
2610
|
+
path: options.path,
|
|
2611
|
+
archive_path: options.archive_path,
|
|
2612
|
+
error_path: options.error_path,
|
|
2613
|
+
headers
|
|
2614
|
+
}]);
|
|
2615
|
+
}
|
|
2616
|
+
else {
|
|
2617
|
+
const provider = await (0, import_export_utils_1.getProvider)(config, providerCode);
|
|
2618
|
+
res = await provider.import({
|
|
2619
|
+
id,
|
|
2620
|
+
path: options.path,
|
|
2621
|
+
archive_path: options.archive_path,
|
|
2622
|
+
error_path: options.error_path,
|
|
2623
|
+
headers
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
for (const file of res || []) {
|
|
2627
|
+
await (0, schema_1.callAddQueueInternal)("queue", "import_export", file);
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
async executeImport(data) {
|
|
2632
|
+
var _a, _b;
|
|
2633
|
+
try {
|
|
2634
|
+
const request = this.cls.get("request");
|
|
2635
|
+
const headers = _.get(request, "headers");
|
|
2636
|
+
const { provider: providerCode, connector } = data, rest = __rest(data, ["provider", "connector"]);
|
|
2637
|
+
const entityName = rest.entity || ((_a = data === null || data === void 0 ? void 0 : data.import) === null || _a === void 0 ? void 0 : _a.entity);
|
|
2638
|
+
const providerConfig = await (0, import_export_utils_1.getCustomProvider)(providerCode);
|
|
2639
|
+
const isExternal = providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.external;
|
|
2640
|
+
let res;
|
|
2641
|
+
let provider;
|
|
2642
|
+
if (isExternal && entityName) {
|
|
2643
|
+
res = await (0, external_module_1.callExecuteExternalProviderModule)(entityName, providerCode, "import", [Object.assign(Object.assign({}, rest), { headers })]);
|
|
2644
|
+
}
|
|
2645
|
+
else {
|
|
2646
|
+
provider = await (0, import_export_utils_1.getProvider)({ connector }, providerCode);
|
|
2647
|
+
res = await provider.import(Object.assign(Object.assign({}, rest), { headers }));
|
|
2648
|
+
}
|
|
2649
|
+
let errorCount = 0;
|
|
2650
|
+
for (const file of res || []) {
|
|
2651
|
+
await provider.move(file.source_file, file.archive_file, undefined);
|
|
2652
|
+
const res = await this.processJob(((_b = data === null || data === void 0 ? void 0 : data.import) === null || _b === void 0 ? void 0 : _b.id) || (data === null || data === void 0 ? void 0 : data.id), "import", file).catch(async (e) => {
|
|
2653
|
+
errorCount += 1;
|
|
2654
|
+
if (isExternal)
|
|
2655
|
+
await (0, external_module_1.callExecuteExternalProviderModule)(entityName, providerCode, "move", [file.archive_file, file.error_file, undefined]);
|
|
2656
|
+
if (provider)
|
|
2657
|
+
provider.move(file.archive_file, file.error_file, undefined);
|
|
2658
|
+
});
|
|
2659
|
+
if (res === false) {
|
|
2660
|
+
errorCount += 1;
|
|
2661
|
+
if (isExternal)
|
|
2662
|
+
await (0, external_module_1.callExecuteExternalProviderModule)(entityName, providerCode, "move", [file.archive_file, file.error_file, undefined]);
|
|
2663
|
+
if (provider)
|
|
2664
|
+
provider.move(file.archive_file, file.error_file, undefined);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
if (errorCount > 0)
|
|
2668
|
+
throw new Error(`Import failed ${errorCount} files`);
|
|
2669
|
+
return true;
|
|
2670
|
+
}
|
|
2671
|
+
catch (e) {
|
|
2672
|
+
throw e;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
async executeExport(body) {
|
|
2676
|
+
try {
|
|
2677
|
+
const request = this.cls.get("request");
|
|
2678
|
+
const headers = _.get(request, "headers");
|
|
2679
|
+
const { provider: providerCode, connector } = body, options = __rest(body, ["provider", "connector"]);
|
|
2680
|
+
const config = await this.getConfig(body.id);
|
|
2681
|
+
const entity = await (0, schema_1.loadEntity)(config.entity);
|
|
2682
|
+
let filters = {};
|
|
2683
|
+
if (!_.isEmpty(options.conditions)) {
|
|
2684
|
+
filters = {
|
|
2685
|
+
$and: (0, mongo_1.convertConditionToMongoQuery)(_.cloneDeep(options.conditions), entity, true)
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
const exportData = await this.export(config._id, filters, "", 1, undefined, undefined, undefined, undefined, false);
|
|
2689
|
+
const filename = `${await (0, func_1.executeFunc)(options.filename || config.file_format, entity, {})}.${_.get(config, "file_ext")}`;
|
|
2690
|
+
delete options.filename;
|
|
2691
|
+
const base64String = exportData.data.split(";base64,")[1];
|
|
2692
|
+
const mimeInfo = await (0, file_type_1.fromBuffer)(Buffer.from(base64String, "base64"));
|
|
2693
|
+
const mimeType = mimeInfo
|
|
2694
|
+
? _.get(mimeInfo, "mime")
|
|
2695
|
+
: exportData.data.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0];
|
|
2696
|
+
const data = exportData.data.split(";base64,")[1];
|
|
2697
|
+
const providerConfig = await (0, import_export_utils_1.getCustomProvider)(providerCode);
|
|
2698
|
+
const isExternal = providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.external;
|
|
2699
|
+
let res;
|
|
2700
|
+
if (isExternal && config.entity) {
|
|
2701
|
+
res = await (0, external_module_1.callExecuteExternalProviderModule)(config.entity, providerCode, "export", [Object.assign(Object.assign({ source: { data }, filename, mime_type: mimeType }, options), { headers })]);
|
|
2702
|
+
}
|
|
2703
|
+
else {
|
|
2704
|
+
const provider = await (0, import_export_utils_1.getProvider)({ connector }, providerCode);
|
|
2705
|
+
res = await provider.export(Object.assign(Object.assign({ source: { data }, filename, mime_type: mimeType }, options), { headers }));
|
|
2706
|
+
}
|
|
2707
|
+
if (!res)
|
|
2708
|
+
throw new Error("Export failed");
|
|
2709
|
+
}
|
|
2710
|
+
catch (e) {
|
|
2711
|
+
throw e;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
exports.ImportExportService = ImportExportService;
|
|
2716
|
+
exports.ImportExportService = ImportExportService = ImportExportService_1 = __decorate([
|
|
2717
|
+
(0, common_1.Injectable)(),
|
|
2718
|
+
__param(3, (0, mongoose_1.InjectModel)("import_export")),
|
|
2719
|
+
__metadata("design:paramtypes", [nestjs_cls_1.ClsService,
|
|
2720
|
+
entities_service_1.EntitiesService,
|
|
2721
|
+
import_export_log_service_1.ImportExportLogService, mongoose.Model])
|
|
2722
|
+
], ImportExportService);
|
|
2723
|
+
//# sourceMappingURL=import_export.service.js.map
|