skyeye-svc-common-utils 2.0.0-dev0.20 → 2.0.0-dev0.22
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/dist/index.d.ts +32 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/apiResponse.d.ts +7 -0
- package/dist/interfaces/apiResponse.js +3 -0
- package/dist/interfaces/apiResponse.js.map +1 -0
- package/dist/interfaces/grpcListRequest.d.ts +6 -0
- package/dist/interfaces/grpcListRequest.js +3 -0
- package/dist/interfaces/grpcListRequest.js.map +1 -0
- package/dist/interfaces/grpcServiceResponse.d.ts +8 -0
- package/dist/interfaces/grpcServiceResponse.js +3 -0
- package/dist/interfaces/grpcServiceResponse.js.map +1 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.js +26 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/internalHttp/request/index.d.ts +1 -0
- package/dist/interfaces/internalHttp/request/index.js +18 -0
- package/dist/interfaces/internalHttp/request/index.js.map +1 -0
- package/dist/interfaces/internalHttp/request/search.d.ts +9 -0
- package/dist/interfaces/internalHttp/request/search.js +3 -0
- package/dist/interfaces/internalHttp/request/search.js.map +1 -0
- package/dist/interfaces/internalHttp/response/index.d.ts +1 -0
- package/dist/interfaces/internalHttp/response/index.js +18 -0
- package/dist/interfaces/internalHttp/response/index.js.map +1 -0
- package/dist/interfaces/internalHttp/response/search.d.ts +10 -0
- package/dist/interfaces/internalHttp/response/search.js +3 -0
- package/dist/interfaces/internalHttp/response/search.js.map +1 -0
- package/dist/interfaces/pagination.d.ts +6 -0
- package/dist/interfaces/pagination.js +12 -0
- package/dist/interfaces/pagination.js.map +1 -0
- package/dist/interfaces/serviceResponse.d.ts +8 -0
- package/dist/interfaces/serviceResponse.js +3 -0
- package/dist/interfaces/serviceResponse.js.map +1 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.d.ts +8 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.js +14 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.js.map +1 -0
- package/dist/interfaces/userInfo.d.ts +17 -0
- package/dist/interfaces/userInfo.js +21 -0
- package/dist/interfaces/userInfo.js.map +1 -0
- package/dist/lib/azure/azureBlobStorage.d.ts +4 -0
- package/dist/lib/azure/azureBlobStorage.js +137 -0
- package/dist/lib/azure/azureBlobStorage.js.map +1 -0
- package/dist/lib/azure/azureKeyVault.d.ts +11 -0
- package/dist/lib/azure/azureKeyVault.js +65 -0
- package/dist/lib/azure/azureKeyVault.js.map +1 -0
- package/dist/lib/azure/azureServiceBusClient.d.ts +47 -0
- package/dist/lib/azure/azureServiceBusClient.js +139 -0
- package/dist/lib/azure/azureServiceBusClient.js.map +1 -0
- package/dist/lib/azure/azureServiceBusQueue.d.ts +1 -0
- package/dist/lib/azure/azureServiceBusQueue.js +42 -0
- package/dist/lib/azure/azureServiceBusQueue.js.map +1 -0
- package/dist/lib/azure/azureStorageQueue.d.ts +1 -0
- package/dist/lib/azure/azureStorageQueue.js +26 -0
- package/dist/lib/azure/azureStorageQueue.js.map +1 -0
- package/dist/lib/azure/azureTableStorage.d.ts +4 -0
- package/dist/lib/azure/azureTableStorage.js +67 -0
- package/dist/lib/azure/azureTableStorage.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/QueryType.d.ts +8 -0
- package/dist/lib/azure/cognitiveSearch/QueryType.js +13 -0
- package/dist/lib/azure/cognitiveSearch/QueryType.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchClient.d.ts +42 -0
- package/dist/lib/azure/cognitiveSearch/SearchClient.js +161 -0
- package/dist/lib/azure/cognitiveSearch/SearchClient.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchFacets.d.ts +16 -0
- package/dist/lib/azure/cognitiveSearch/SearchFacets.js +3 -0
- package/dist/lib/azure/cognitiveSearch/SearchFacets.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchFilter.d.ts +68 -0
- package/dist/lib/azure/cognitiveSearch/SearchFilter.js +125 -0
- package/dist/lib/azure/cognitiveSearch/SearchFilter.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchMode.d.ts +9 -0
- package/dist/lib/azure/cognitiveSearch/SearchMode.js +14 -0
- package/dist/lib/azure/cognitiveSearch/SearchMode.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchOption.d.ts +88 -0
- package/dist/lib/azure/cognitiveSearch/SearchOption.js +104 -0
- package/dist/lib/azure/cognitiveSearch/SearchOption.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/SearchOrder.d.ts +9 -0
- package/dist/lib/azure/cognitiveSearch/SearchOrder.js +3 -0
- package/dist/lib/azure/cognitiveSearch/SearchOrder.js.map +1 -0
- package/dist/lib/azure/cognitiveSearch/index.d.ts +7 -0
- package/dist/lib/azure/cognitiveSearch/index.js +24 -0
- package/dist/lib/azure/cognitiveSearch/index.js.map +1 -0
- package/dist/lib/azure/index.d.ts +7 -0
- package/dist/lib/azure/index.js +24 -0
- package/dist/lib/azure/index.js.map +1 -0
- package/dist/lib/fetch/index.d.ts +2 -0
- package/dist/lib/fetch/index.js +19 -0
- package/dist/lib/fetch/index.js.map +1 -0
- package/dist/lib/fetch/sendRequest.d.ts +8 -0
- package/dist/lib/fetch/sendRequest.js +25 -0
- package/dist/lib/fetch/sendRequest.js.map +1 -0
- package/dist/lib/fetch/sendRequestWithTimeout.d.ts +9 -0
- package/dist/lib/fetch/sendRequestWithTimeout.js +53 -0
- package/dist/lib/fetch/sendRequestWithTimeout.js.map +1 -0
- package/dist/lib/httpClient.d.ts +4 -0
- package/dist/lib/httpClient.js +55 -0
- package/dist/lib/httpClient.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/redisClient.d.ts +45 -0
- package/dist/lib/redisClient.js +153 -0
- package/dist/lib/redisClient.js.map +1 -0
- package/dist/lib/sendGridClient.d.ts +27 -0
- package/dist/lib/sendGridClient.js +62 -0
- package/dist/lib/sendGridClient.js.map +1 -0
- package/dist/lib/teams/broadcastLogMessage.d.ts +8 -0
- package/dist/lib/teams/broadcastLogMessage.js +81 -0
- package/dist/lib/teams/broadcastLogMessage.js.map +1 -0
- package/dist/lib/teams/index.d.ts +2 -0
- package/dist/lib/teams/index.js +19 -0
- package/dist/lib/teams/index.js.map +1 -0
- package/dist/lib/teams/logMessage.d.ts +51 -0
- package/dist/lib/teams/logMessage.js +33 -0
- package/dist/lib/teams/logMessage.js.map +1 -0
- package/dist/models/baseControllerParameter.d.ts +9 -0
- package/dist/models/baseControllerParameter.js +24 -0
- package/dist/models/baseControllerParameter.js.map +1 -0
- package/dist/models/campaign/grpcCampaignEventModel.d.ts +18 -0
- package/dist/models/campaign/grpcCampaignEventModel.js +24 -0
- package/dist/models/campaign/grpcCampaignEventModel.js.map +1 -0
- package/dist/models/campaign/grpcCampaignEventUserModel.d.ts +13 -0
- package/dist/models/campaign/grpcCampaignEventUserModel.js +19 -0
- package/dist/models/campaign/grpcCampaignEventUserModel.js.map +1 -0
- package/dist/models/campaign/grpcCampaignUserModel.d.ts +12 -0
- package/dist/models/campaign/grpcCampaignUserModel.js +16 -0
- package/dist/models/campaign/grpcCampaignUserModel.js.map +1 -0
- package/dist/models/campaign/index.d.ts +4 -0
- package/dist/models/campaign/index.js +10 -0
- package/dist/models/campaign/index.js.map +1 -0
- package/dist/models/emailtemplate/grpcEmailTemplateModel.d.ts +10 -0
- package/dist/models/emailtemplate/grpcEmailTemplateModel.js +16 -0
- package/dist/models/emailtemplate/grpcEmailTemplateModel.js.map +1 -0
- package/dist/models/emailtemplate/index.d.ts +2 -0
- package/dist/models/emailtemplate/index.js +6 -0
- package/dist/models/emailtemplate/index.js.map +1 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +28 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/organisation/grpcOrganisationModel.d.ts +15 -0
- package/dist/models/organisation/grpcOrganisationModel.js +21 -0
- package/dist/models/organisation/grpcOrganisationModel.js.map +1 -0
- package/dist/models/organisation/index.d.ts +2 -0
- package/dist/models/organisation/index.js +6 -0
- package/dist/models/organisation/index.js.map +1 -0
- package/dist/models/rbac/grpcRoleModel.d.ts +9 -0
- package/dist/models/rbac/grpcRoleModel.js +15 -0
- package/dist/models/rbac/grpcRoleModel.js.map +1 -0
- package/dist/models/rbac/index.d.ts +2 -0
- package/dist/models/rbac/index.js +6 -0
- package/dist/models/rbac/index.js.map +1 -0
- package/dist/models/scoutai/grpcAIDETrainingResultListModel.d.ts +8 -0
- package/dist/models/scoutai/grpcAIDETrainingResultListModel.js +14 -0
- package/dist/models/scoutai/grpcAIDETrainingResultListModel.js.map +1 -0
- package/dist/models/scoutai/grpcNerlCorrectionModel.d.ts +11 -0
- package/dist/models/scoutai/grpcNerlCorrectionModel.js +16 -0
- package/dist/models/scoutai/grpcNerlCorrectionModel.js.map +1 -0
- package/dist/models/scoutai/grpcScoutAIListReq.d.ts +12 -0
- package/dist/models/scoutai/grpcScoutAIListReq.js +17 -0
- package/dist/models/scoutai/grpcScoutAIListReq.js.map +1 -0
- package/dist/models/scoutai/grpcScoutAIModel.d.ts +10 -0
- package/dist/models/scoutai/grpcScoutAIModel.js +16 -0
- package/dist/models/scoutai/grpcScoutAIModel.js.map +1 -0
- package/dist/models/scoutai/grpcScoutAIResult.d.ts +10 -0
- package/dist/models/scoutai/grpcScoutAIResult.js +16 -0
- package/dist/models/scoutai/grpcScoutAIResult.js.map +1 -0
- package/dist/models/scoutai/grpcTaasConfigAIModel.d.ts +6 -0
- package/dist/models/scoutai/grpcTaasConfigAIModel.js +12 -0
- package/dist/models/scoutai/grpcTaasConfigAIModel.js.map +1 -0
- package/dist/models/scoutai/grpcTaasConfigModel.d.ts +11 -0
- package/dist/models/scoutai/grpcTaasConfigModel.js +15 -0
- package/dist/models/scoutai/grpcTaasConfigModel.js.map +1 -0
- package/dist/models/scoutai/grpcTaasConfigUserModel.d.ts +8 -0
- package/dist/models/scoutai/grpcTaasConfigUserModel.js +14 -0
- package/dist/models/scoutai/grpcTaasConfigUserModel.js.map +1 -0
- package/dist/models/scoutai/grpcTagItemModel.d.ts +9 -0
- package/dist/models/scoutai/grpcTagItemModel.js +15 -0
- package/dist/models/scoutai/grpcTagItemModel.js.map +1 -0
- package/dist/models/scoutai/grpcVisualisationModel.d.ts +11 -0
- package/dist/models/scoutai/grpcVisualisationModel.js +15 -0
- package/dist/models/scoutai/grpcVisualisationModel.js.map +1 -0
- package/dist/models/scoutai/grpcVisualisationPositionModel.d.ts +6 -0
- package/dist/models/scoutai/grpcVisualisationPositionModel.js +11 -0
- package/dist/models/scoutai/grpcVisualisationPositionModel.js.map +1 -0
- package/dist/models/scoutai/index.d.ts +10 -0
- package/dist/models/scoutai/index.js +22 -0
- package/dist/models/scoutai/index.js.map +1 -0
- package/dist/models/search/grpcAggregation.d.ts +9 -0
- package/dist/models/search/grpcAggregation.js +14 -0
- package/dist/models/search/grpcAggregation.js.map +1 -0
- package/dist/models/search/grpcCmsModel.d.ts +5 -0
- package/dist/models/search/grpcCmsModel.js +11 -0
- package/dist/models/search/grpcCmsModel.js.map +1 -0
- package/dist/models/search/grpcCommonModels.d.ts +109 -0
- package/dist/models/search/grpcCommonModels.js +80 -0
- package/dist/models/search/grpcCommonModels.js.map +1 -0
- package/dist/models/search/grpcCompanyAggregation.d.ts +14 -0
- package/dist/models/search/grpcCompanyAggregation.js +16 -0
- package/dist/models/search/grpcCompanyAggregation.js.map +1 -0
- package/dist/models/search/grpcCompanyConnectModel.d.ts +14 -0
- package/dist/models/search/grpcCompanyConnectModel.js +18 -0
- package/dist/models/search/grpcCompanyConnectModel.js.map +1 -0
- package/dist/models/search/grpcCompanyListReq.d.ts +36 -0
- package/dist/models/search/grpcCompanyListReq.js +42 -0
- package/dist/models/search/grpcCompanyListReq.js.map +1 -0
- package/dist/models/search/grpcCompanyModel.d.ts +43 -0
- package/dist/models/search/grpcCompanyModel.js +46 -0
- package/dist/models/search/grpcCompanyModel.js.map +1 -0
- package/dist/models/search/grpcCompanyNewsCountModel.d.ts +9 -0
- package/dist/models/search/grpcCompanyNewsCountModel.js +14 -0
- package/dist/models/search/grpcCompanyNewsCountModel.js.map +1 -0
- package/dist/models/search/grpcCompanyPeriodMentionModel.d.ts +18 -0
- package/dist/models/search/grpcCompanyPeriodMentionModel.js +22 -0
- package/dist/models/search/grpcCompanyPeriodMentionModel.js.map +1 -0
- package/dist/models/search/grpcCompanyPreviewModel.d.ts +26 -0
- package/dist/models/search/grpcCompanyPreviewModel.js +31 -0
- package/dist/models/search/grpcCompanyPreviewModel.js.map +1 -0
- package/dist/models/search/grpcContentAggregation.d.ts +8 -0
- package/dist/models/search/grpcContentAggregation.js +7 -0
- package/dist/models/search/grpcContentAggregation.js.map +1 -0
- package/dist/models/search/grpcContentListReq.d.ts +16 -0
- package/dist/models/search/grpcContentListReq.js +22 -0
- package/dist/models/search/grpcContentListReq.js.map +1 -0
- package/dist/models/search/grpcContentModel.d.ts +32 -0
- package/dist/models/search/grpcContentModel.js +37 -0
- package/dist/models/search/grpcContentModel.js.map +1 -0
- package/dist/models/search/grpcContentPreviewModel.d.ts +28 -0
- package/dist/models/search/grpcContentPreviewModel.js +33 -0
- package/dist/models/search/grpcContentPreviewModel.js.map +1 -0
- package/dist/models/search/grpcContentTabsModel.d.ts +10 -0
- package/dist/models/search/grpcContentTabsModel.js +15 -0
- package/dist/models/search/grpcContentTabsModel.js.map +1 -0
- package/dist/models/search/grpcCountryModel.d.ts +13 -0
- package/dist/models/search/grpcCountryModel.js +19 -0
- package/dist/models/search/grpcCountryModel.js.map +1 -0
- package/dist/models/search/grpcFinancialModel.d.ts +292 -0
- package/dist/models/search/grpcFinancialModel.js +7 -0
- package/dist/models/search/grpcFinancialModel.js.map +1 -0
- package/dist/models/search/grpcMarketModel.d.ts +16 -0
- package/dist/models/search/grpcMarketModel.js +6 -0
- package/dist/models/search/grpcMarketModel.js.map +1 -0
- package/dist/models/search/grpcMentionContentCountModel.d.ts +5 -0
- package/dist/models/search/grpcMentionContentCountModel.js +7 -0
- package/dist/models/search/grpcMentionContentCountModel.js.map +1 -0
- package/dist/models/search/index.d.ts +16 -0
- package/dist/models/search/index.js +44 -0
- package/dist/models/search/index.js.map +1 -0
- package/dist/models/subscription/applicationFeatureModel.d.ts +7 -0
- package/dist/models/subscription/applicationFeatureModel.js +12 -0
- package/dist/models/subscription/applicationFeatureModel.js.map +1 -0
- package/dist/models/subscription/featureModel.d.ts +7 -0
- package/dist/models/subscription/featureModel.js +13 -0
- package/dist/models/subscription/featureModel.js.map +1 -0
- package/dist/models/subscription/grpcSubscriptionModel.d.ts +6 -0
- package/dist/models/subscription/grpcSubscriptionModel.js +12 -0
- package/dist/models/subscription/grpcSubscriptionModel.js.map +1 -0
- package/dist/models/subscription/index.d.ts +10 -0
- package/dist/models/subscription/index.js +22 -0
- package/dist/models/subscription/index.js.map +1 -0
- package/dist/models/subscription/licenseModel.d.ts +6 -0
- package/dist/models/subscription/licenseModel.js +12 -0
- package/dist/models/subscription/licenseModel.js.map +1 -0
- package/dist/models/subscription/licenseUserModel.d.ts +5 -0
- package/dist/models/subscription/licenseUserModel.js +11 -0
- package/dist/models/subscription/licenseUserModel.js.map +1 -0
- package/dist/models/subscription/subscriptionFeatureModel.d.ts +6 -0
- package/dist/models/subscription/subscriptionFeatureModel.js +12 -0
- package/dist/models/subscription/subscriptionFeatureModel.js.map +1 -0
- package/dist/models/subscription/subscriptionModel.d.ts +14 -0
- package/dist/models/subscription/subscriptionModel.js +19 -0
- package/dist/models/subscription/subscriptionModel.js.map +1 -0
- package/dist/models/subscription/subscriptionPlanFeatureModel.d.ts +5 -0
- package/dist/models/subscription/subscriptionPlanFeatureModel.js +11 -0
- package/dist/models/subscription/subscriptionPlanFeatureModel.js.map +1 -0
- package/dist/models/subscription/subscriptionPlanModel.d.ts +15 -0
- package/dist/models/subscription/subscriptionPlanModel.js +20 -0
- package/dist/models/subscription/subscriptionPlanModel.js.map +1 -0
- package/dist/models/user/grpcAccountInfoModel.d.ts +5 -0
- package/dist/models/user/grpcAccountInfoModel.js +7 -0
- package/dist/models/user/grpcAccountInfoModel.js.map +1 -0
- package/dist/models/user/grpcAppUserModel.d.ts +15 -0
- package/dist/models/user/grpcAppUserModel.js +20 -0
- package/dist/models/user/grpcAppUserModel.js.map +1 -0
- package/dist/models/user/grpcAppUserOrganisationStatistic.d.ts +6 -0
- package/dist/models/user/grpcAppUserOrganisationStatistic.js +12 -0
- package/dist/models/user/grpcAppUserOrganisationStatistic.js.map +1 -0
- package/dist/models/user/grpcAppUserRoleModel.d.ts +5 -0
- package/dist/models/user/grpcAppUserRoleModel.js +11 -0
- package/dist/models/user/grpcAppUserRoleModel.js.map +1 -0
- package/dist/models/user/grpcBrowseHistoryModel.d.ts +8 -0
- package/dist/models/user/grpcBrowseHistoryModel.js +14 -0
- package/dist/models/user/grpcBrowseHistoryModel.js.map +1 -0
- package/dist/models/user/grpcDailyDigestUserModel.d.ts +10 -0
- package/dist/models/user/grpcDailyDigestUserModel.js +15 -0
- package/dist/models/user/grpcDailyDigestUserModel.js.map +1 -0
- package/dist/models/user/grpcNotificationSettingModel.d.ts +11 -0
- package/dist/models/user/grpcNotificationSettingModel.js +17 -0
- package/dist/models/user/grpcNotificationSettingModel.js.map +1 -0
- package/dist/models/user/grpcSavedSearchModel.d.ts +8 -0
- package/dist/models/user/grpcSavedSearchModel.js +14 -0
- package/dist/models/user/grpcSavedSearchModel.js.map +1 -0
- package/dist/models/user/grpcSearchHistoryModel.d.ts +7 -0
- package/dist/models/user/grpcSearchHistoryModel.js +13 -0
- package/dist/models/user/grpcSearchHistoryModel.js.map +1 -0
- package/dist/models/user/grpcTargetListEntityModel.d.ts +5 -0
- package/dist/models/user/grpcTargetListEntityModel.js +7 -0
- package/dist/models/user/grpcTargetListEntityModel.js.map +1 -0
- package/dist/models/user/grpcTargetListExportModel.d.ts +8 -0
- package/dist/models/user/grpcTargetListExportModel.js +14 -0
- package/dist/models/user/grpcTargetListExportModel.js.map +1 -0
- package/dist/models/user/grpcTargetListItemModel.d.ts +7 -0
- package/dist/models/user/grpcTargetListItemModel.js +13 -0
- package/dist/models/user/grpcTargetListItemModel.js.map +1 -0
- package/dist/models/user/grpcTargetListModel.d.ts +9 -0
- package/dist/models/user/grpcTargetListModel.js +14 -0
- package/dist/models/user/grpcTargetListModel.js.map +1 -0
- package/dist/models/user/index.d.ts +14 -0
- package/dist/models/user/index.js +30 -0
- package/dist/models/user/index.js.map +1 -0
- package/dist/utils/appConfig.d.ts +45 -0
- package/dist/utils/appConfig.js +57 -0
- package/dist/utils/appConfig.js.map +1 -0
- package/dist/utils/appConst.d.ts +196 -0
- package/dist/utils/appConst.js +214 -0
- package/dist/utils/appConst.js.map +1 -0
- package/dist/utils/authentication/auth.d.ts +2 -0
- package/dist/utils/authentication/auth.js +163 -0
- package/dist/utils/authentication/auth.js.map +1 -0
- package/dist/utils/authentication/role.d.ts +7 -0
- package/dist/utils/authentication/role.js +139 -0
- package/dist/utils/authentication/role.js.map +1 -0
- package/dist/utils/baseClass/appDataSource.d.ts +7 -0
- package/dist/utils/baseClass/appDataSource.js +31 -0
- package/dist/utils/baseClass/appDataSource.js.map +1 -0
- package/dist/utils/baseClass/baseController.d.ts +12 -0
- package/dist/utils/baseClass/baseController.js +176 -0
- package/dist/utils/baseClass/baseController.js.map +1 -0
- package/dist/utils/baseClass/baseService.d.ts +7 -0
- package/dist/utils/baseClass/baseService.js +11 -0
- package/dist/utils/baseClass/baseService.js.map +1 -0
- package/dist/utils/commonUtils/appConfigKeyRetriever.d.ts +7 -0
- package/dist/utils/commonUtils/appConfigKeyRetriever.js +43 -0
- package/dist/utils/commonUtils/appConfigKeyRetriever.js.map +1 -0
- package/dist/utils/commonUtils/appUtils.d.ts +41 -0
- package/dist/utils/commonUtils/appUtils.js +236 -0
- package/dist/utils/commonUtils/appUtils.js.map +1 -0
- package/dist/utils/commonUtils/cronUtils.d.ts +9 -0
- package/dist/utils/commonUtils/cronUtils.js +32 -0
- package/dist/utils/commonUtils/cronUtils.js.map +1 -0
- package/dist/utils/commonUtils/index.d.ts +6 -0
- package/dist/utils/commonUtils/index.js +23 -0
- package/dist/utils/commonUtils/index.js.map +1 -0
- package/dist/utils/commonUtils/jwtUtils.d.ts +3 -0
- package/dist/utils/commonUtils/jwtUtils.js +83 -0
- package/dist/utils/commonUtils/jwtUtils.js.map +1 -0
- package/dist/utils/commonUtils/responseUtils.d.ts +7 -0
- package/dist/utils/commonUtils/responseUtils.js +131 -0
- package/dist/utils/commonUtils/responseUtils.js.map +1 -0
- package/dist/utils/commonUtils/validation.d.ts +6 -0
- package/dist/utils/commonUtils/validation.js +92 -0
- package/dist/utils/commonUtils/validation.js.map +1 -0
- package/dist/utils/documentation/swagger.d.ts +1 -0
- package/dist/utils/documentation/swagger.js +44 -0
- package/dist/utils/documentation/swagger.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger/logger.d.ts +1 -0
- package/dist/utils/logger/logger.js +58 -0
- package/dist/utils/logger/logger.js.map +1 -0
- package/dist/utils/logger/morganLogger.d.ts +2 -0
- package/dist/utils/logger/morganLogger.js +41 -0
- package/dist/utils/logger/morganLogger.js.map +1 -0
- package/dist/utils/middleware/handleError.d.ts +2 -0
- package/dist/utils/middleware/handleError.js +12 -0
- package/dist/utils/middleware/handleError.js.map +1 -0
- package/dist/utils/middleware/isPublicUser.d.ts +2 -0
- package/dist/utils/middleware/isPublicUser.js +35 -0
- package/dist/utils/middleware/isPublicUser.js.map +1 -0
- package/dist/utils/middleware/loadConfig.d.ts +128 -0
- package/dist/utils/middleware/loadConfig.js +143 -0
- package/dist/utils/middleware/loadConfig.js.map +1 -0
- package/dist/utils/middleware/overwriteConst.d.ts +1 -0
- package/dist/utils/middleware/overwriteConst.js +84 -0
- package/dist/utils/middleware/overwriteConst.js.map +1 -0
- package/dist/utils/monitoring/apm.d.ts +6 -0
- package/dist/utils/monitoring/apm.js +99 -0
- package/dist/utils/monitoring/apm.js.map +1 -0
- package/package.json +3 -5
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getValidFeaturesFromInputFeatures = exports.getValidUserSubscriptionFeature = exports.getInternalClient = exports.userInfoFetcher = exports.userInfoSimplifier = exports.userInfoToFeatureListByName = exports.getUnlockedCode = exports.getLockedCode = exports.buildPaginationModel = exports.mappingToServiceResponse = exports.mappingToStringList = exports.mappingToModelList = exports.mappingToModel = void 0;
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
14
|
+
const logger_1 = require("../logger/logger");
|
|
15
|
+
const interfaces_1 = require("../../interfaces");
|
|
16
|
+
const appConst_1 = require("../../utils/appConst");
|
|
17
|
+
const skyeye_common_const_1 = require("skyeye-common-const");
|
|
18
|
+
const appConfig_1 = require("../appConfig");
|
|
19
|
+
const httpClient_1 = require("../../lib/httpClient");
|
|
20
|
+
const azureKeyVault_1 = require("../../lib/azure/azureKeyVault");
|
|
21
|
+
function mappingToModel(input, output) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (input !== undefined && input !== null) {
|
|
24
|
+
for (let key in output) {
|
|
25
|
+
if (input.hasOwnProperty(key) && (input[key] !== null && input[key] !== undefined)) {
|
|
26
|
+
output[key] = input[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return output;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.mappingToModel = mappingToModel;
|
|
34
|
+
function mappingToModelList(inputs, type) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
let outputs = new Array();
|
|
37
|
+
if (inputs !== undefined && inputs !== null) {
|
|
38
|
+
outputs = yield Promise.all(inputs.map((i) => __awaiter(this, void 0, void 0, function* () { return yield mappingToModel(i, new type()); })));
|
|
39
|
+
}
|
|
40
|
+
return outputs;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.mappingToModelList = mappingToModelList;
|
|
44
|
+
function mappingToStringList(inputs, attribute) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
let outputs = new Array();
|
|
47
|
+
if (inputs !== undefined && inputs !== null) {
|
|
48
|
+
outputs = yield Promise.all(inputs.map(i => { if (i.hasOwnProperty(attribute))
|
|
49
|
+
return i[attribute]; return ""; }));
|
|
50
|
+
outputs = outputs.filter(o => o !== "");
|
|
51
|
+
outputs = Array.from(new Set(outputs));
|
|
52
|
+
}
|
|
53
|
+
return outputs;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.mappingToStringList = mappingToStringList;
|
|
57
|
+
function mappingToServiceResponse(input) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
let serviceResponse = { isSuccess: false, message: null, data: null };
|
|
60
|
+
if (input) {
|
|
61
|
+
serviceResponse = yield mappingToModel(input, serviceResponse);
|
|
62
|
+
}
|
|
63
|
+
return serviceResponse;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.mappingToServiceResponse = mappingToServiceResponse;
|
|
67
|
+
function buildPaginationModel(params, defaultOrderBy, defaultOrder) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
let paginationModel = new interfaces_1.Pagination();
|
|
70
|
+
paginationModel.take = Number(params.select) || 20;
|
|
71
|
+
paginationModel.skip = Number(params.skip) || 0;
|
|
72
|
+
let orderBy = params.orderBy || defaultOrderBy || appConst_1.commonAppConst.orderAttribute.id;
|
|
73
|
+
let order = params.order || defaultOrder || appConst_1.commonAppConst.order.ASC;
|
|
74
|
+
paginationModel.order = JSON.parse(`{"${orderBy}":"${order}"}`);
|
|
75
|
+
return paginationModel;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.buildPaginationModel = buildPaginationModel;
|
|
79
|
+
function getLockedCode(code) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (code.endsWith(skyeye_common_const_1.commonAppConst.lockedFeature)) {
|
|
82
|
+
return code;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return code + skyeye_common_const_1.commonAppConst.lockedFeature;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.getLockedCode = getLockedCode;
|
|
90
|
+
function getUnlockedCode(code) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
if (code.endsWith(skyeye_common_const_1.commonAppConst.lockedFeature)) {
|
|
93
|
+
return code.slice(0, -skyeye_common_const_1.commonAppConst.lockedFeature.length);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return code;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.getUnlockedCode = getUnlockedCode;
|
|
101
|
+
function userInfoToFeatureListByName(userInfo, featureName) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
let res = [];
|
|
105
|
+
let featurePool = skyeye_common_const_1.allApplicationFeatures.find((i) => {
|
|
106
|
+
return i.featureName === featureName;
|
|
107
|
+
});
|
|
108
|
+
if (featurePool === null || featurePool === undefined) {
|
|
109
|
+
logger_1.logger.error(`missing featureName mapping: ${featureName}`);
|
|
110
|
+
return res;
|
|
111
|
+
}
|
|
112
|
+
for (let sub of userInfo.subcriptionFeaturePermissionModel) {
|
|
113
|
+
if (!!sub.featureList && sub.featureList.length > 0) {
|
|
114
|
+
sub.featureList.forEach(userOwnedFeature => {
|
|
115
|
+
let find = featurePool.features.find((f) => {
|
|
116
|
+
return f.featureCode === userOwnedFeature;
|
|
117
|
+
});
|
|
118
|
+
if (!!find) {
|
|
119
|
+
res.push(find);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
logger_1.logger.error(err);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.userInfoToFeatureListByName = userInfoToFeatureListByName;
|
|
132
|
+
function userInfoSimplifier(userInfo, select) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
let data = {};
|
|
135
|
+
const defaultSelect = Object.keys(userInfo).filter(k => k != appConst_1.commonAppConst.user.info.subcriptionFeaturePermissionModel && k != appConst_1.commonAppConst.user.info.subKeys);
|
|
136
|
+
select = select || defaultSelect;
|
|
137
|
+
select.forEach(x => {
|
|
138
|
+
if (userInfo.hasOwnProperty(x)) {
|
|
139
|
+
data[x] = userInfo[x];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
data.internalUsage = true;
|
|
143
|
+
return data;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.userInfoSimplifier = userInfoSimplifier;
|
|
147
|
+
function userInfoFetcher(mode, userInfo, authorizationHeader, subKey, userGuid) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
let userRetrieveURL = appConfig_1.commonAppConfig.UserPublicRetrieve;
|
|
150
|
+
let header = {};
|
|
151
|
+
if (mode == appConst_1.commonAppConst.user.mode.jwt) {
|
|
152
|
+
userRetrieveURL = userInfo.isPublicUser ? appConfig_1.commonAppConfig.UserPublicRetrieve : appConfig_1.commonAppConfig.UserInternalRetrieve;
|
|
153
|
+
header = { 'Content-Type': 'application/json', 'Authorization': authorizationHeader };
|
|
154
|
+
}
|
|
155
|
+
else if (mode == appConst_1.commonAppConst.user.mode.api) {
|
|
156
|
+
header = { 'Content-Type': 'application/json', 'subscription-key': subKey, 'user-id': userGuid };
|
|
157
|
+
}
|
|
158
|
+
const response = yield (0, httpClient_1.httpRequest)(appConst_1.commonAppConst.httpMethod.POST, userRetrieveURL, null, header);
|
|
159
|
+
const data = yield response.json();
|
|
160
|
+
let result = data.data;
|
|
161
|
+
if (mode == appConst_1.commonAppConst.user.mode.api) {
|
|
162
|
+
result.subcriptionFeaturePermissionModel = result.subcriptionFeaturePermissionModel.filter(s => s.featureList.indexOf(skyeye_common_const_1.FeatureCodeConst.APIM) !== -1);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
result.subcriptionFeaturePermissionModel = result.subcriptionFeaturePermissionModel.filter(s => s.featureList.indexOf(skyeye_common_const_1.FeatureCodeConst.APIM) === -1);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
exports.userInfoFetcher = userInfoFetcher;
|
|
171
|
+
function getInternalClient(client) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
const internalClient = appConfig_1.commonAppConfig[client] ? yield (0, azureKeyVault_1.getKey)(appConfig_1.commonAppConfig[client]) : appConst_1.commonAppConst.default[client];
|
|
174
|
+
return internalClient;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
exports.getInternalClient = getInternalClient;
|
|
178
|
+
/**
|
|
179
|
+
* The function `getValidUserSubscriptionFeature` takes in a list of user subscription features,
|
|
180
|
+
* optional feature names, and a boolean flag indicating whether to include postfixes, and
|
|
181
|
+
* returns a list of valid features based on the user subscription.
|
|
182
|
+
* @param {string[]} userSubscriptionFeatures - An array of strings representing the features that the
|
|
183
|
+
* user has subscribed to.
|
|
184
|
+
* @param {string[]} [targetFeatureNames] - An optional array of feature list names. If provided, only
|
|
185
|
+
* the features from these feature lists will be considered. If not provided, all features will be
|
|
186
|
+
* considered.
|
|
187
|
+
* @param {boolean} [isPostfixNeeded=false] - A boolean flag indicating whether or not to include the
|
|
188
|
+
* postfix "|" in the returned valid features. If set to true, the valid features will include the
|
|
189
|
+
* postfix. If set to false, the valid features will not include the postfix.
|
|
190
|
+
* @returns an array of valid features from the user's subscription.
|
|
191
|
+
*/
|
|
192
|
+
function getValidUserSubscriptionFeature(userSubscriptionFeatures, targetFeatureNames, isPostfixNeeded = false) {
|
|
193
|
+
if (userSubscriptionFeatures.length === 0)
|
|
194
|
+
return [];
|
|
195
|
+
// Get list of feature list with feature list name(s) if provided, else include all feature list
|
|
196
|
+
const availableFeatureList = targetFeatureNames ? skyeye_common_const_1.allApplicationFeatures.filter(o => targetFeatureNames.includes(o.featureName)) : skyeye_common_const_1.allApplicationFeatures;
|
|
197
|
+
// Flatten list of feature list to get featureCode only, and push to a set for easy read
|
|
198
|
+
const availableFeatures = new Set((0, lodash_1.flatten)(availableFeatureList.map(o => o.features)).map(o => o.featureCode));
|
|
199
|
+
// User feature is valid only if it can be found in the available features
|
|
200
|
+
const userValidFeatures = [];
|
|
201
|
+
for (const userFeature of userSubscriptionFeatures) {
|
|
202
|
+
const [featureCode, postfix] = userFeature.split("|");
|
|
203
|
+
/**
|
|
204
|
+
* for feature with locked postfix e.g. "AntaraNews|LOCKED",
|
|
205
|
+
* take both feature code and postfix for comparison;
|
|
206
|
+
*
|
|
207
|
+
* for features without postfix e.g. "AntaraNews"
|
|
208
|
+
* OR, feature with number postfix e.g. "RADAR_COUNT|3",
|
|
209
|
+
* only take feature code for comparison
|
|
210
|
+
*/
|
|
211
|
+
let isValid = skyeye_common_const_1.commonAppConst.lockedFeature.endsWith(postfix) ? availableFeatures.has(userFeature) : availableFeatures.has(featureCode);
|
|
212
|
+
if (isValid)
|
|
213
|
+
userValidFeatures.push(isPostfixNeeded ? userFeature : featureCode);
|
|
214
|
+
}
|
|
215
|
+
return userValidFeatures;
|
|
216
|
+
}
|
|
217
|
+
exports.getValidUserSubscriptionFeature = getValidUserSubscriptionFeature;
|
|
218
|
+
/**
|
|
219
|
+
* The function `getValidFeaturesFromInputFeatures` returns a list of valid features based on the
|
|
220
|
+
* intersection of userFeatures and inputFeatures, with an option to return all userFeatures if no
|
|
221
|
+
* intersection is found and isdefaultAll is true.
|
|
222
|
+
* @param {string[]} userFeatures - An array of features that the user has.
|
|
223
|
+
* @param {string[]} inputFeatures - An array of features that are requested.
|
|
224
|
+
* @param {boolean} [isdefaultAll=true] - A boolean flag indicating whether all user features should be
|
|
225
|
+
* returned if there are no valid features found in the intersection of userFeatures and inputFeatures.
|
|
226
|
+
* If isdefaultAll is set to true and there are no valid features found, the function will return all
|
|
227
|
+
* userFeatures. If isdefaultAll is set to false
|
|
228
|
+
* @returns an array of valid features.
|
|
229
|
+
*/
|
|
230
|
+
function getValidFeaturesFromInputFeatures(userFeatures, inputFeatures, isdefaultAll = true) {
|
|
231
|
+
// Get the intersection of userFeature and inputFeatures
|
|
232
|
+
const targetFeatures = inputFeatures.filter(o => userFeatures.includes(o));
|
|
233
|
+
return (targetFeatures.length == 0) && isdefaultAll ? userFeatures : targetFeatures;
|
|
234
|
+
}
|
|
235
|
+
exports.getValidFeaturesFromInputFeatures = getValidFeaturesFromInputFeatures;
|
|
236
|
+
//# sourceMappingURL=appUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/appUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAiC;AACjC,6CAA0C;AAC1C,iDAAyE;AACzE,mDAAsD;AACtD,6DAA+I;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AG,CAAC,CAAC;QACtD;;;;;;;WAOG;QACH,IAAI,OAAO,GAAG,oCAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACxI,IAAI,OAAO;YAAE,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC7B,CAAC;AAzBD,0EAyBC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,iCAAiC,CAAC,YAAsB,EAAE,aAAuB,EAAE,eAAwB,IAAI;IAC3H,wDAAwD;IACxD,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;AACxF,CAAC;AAJD,8EAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Get previous or next date given start date, cron expression and flag
|
|
3
|
+
* @param {string} cron - Cron expression
|
|
4
|
+
* @param {Date} [startDate] - a starting date
|
|
5
|
+
* @param {boolean} [getNext] - boolean value to indicate getting previous or next date
|
|
6
|
+
* @returns {Date} - the resultant date
|
|
7
|
+
* @throws Unexpected error
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDateFromCron(cron: string, startDate?: Date, getNext?: boolean): Date | never;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDateFromCron = void 0;
|
|
7
|
+
const cron_parser_1 = __importDefault(require("cron-parser"));
|
|
8
|
+
const logger_1 = require("../logger/logger");
|
|
9
|
+
/**
|
|
10
|
+
* @description Get previous or next date given start date, cron expression and flag
|
|
11
|
+
* @param {string} cron - Cron expression
|
|
12
|
+
* @param {Date} [startDate] - a starting date
|
|
13
|
+
* @param {boolean} [getNext] - boolean value to indicate getting previous or next date
|
|
14
|
+
* @returns {Date} - the resultant date
|
|
15
|
+
* @throws Unexpected error
|
|
16
|
+
*/
|
|
17
|
+
function getDateFromCron(cron, startDate = new Date(), getNext = false) {
|
|
18
|
+
let options = {
|
|
19
|
+
currentDate: startDate
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const interval = cron_parser_1.default.parseExpression(cron, options);
|
|
23
|
+
const val = getNext ? interval.next() : interval.prev();
|
|
24
|
+
return val.toDate();
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
logger_1.logger.error(`getDateFromCron with error, ${err}`);
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.getDateFromCron = getDateFromCron;
|
|
32
|
+
//# sourceMappingURL=cronUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/cronUtils.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAoE;AACpE,6CAA0C;AAE1C;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,IAAY,EAAE,YAAkB,IAAI,IAAI,EAAE,EAAE,UAAmB,KAAK;IAEhG,IAAI,OAAO,GAAkB;QACzB,WAAW,EAAE,SAAS;KACzB,CAAC;IACF,IAAI,CAAC;QACD,MAAM,QAAQ,GAAmB,qBAAM,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxD,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,eAAM,CAAC,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;QACnD,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC;AAbD,0CAaC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./appUtils"), exports);
|
|
18
|
+
__exportStar(require("./responseUtils"), exports);
|
|
19
|
+
__exportStar(require("./validation"), exports);
|
|
20
|
+
__exportStar(require("./jwtUtils"), exports);
|
|
21
|
+
__exportStar(require("./cronUtils"), exports);
|
|
22
|
+
__exportStar(require("./appConfigKeyRetriever"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,8CAA4B;AAC5B,0DAAwC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.verifyJWT = exports.generateJWT = void 0;
|
|
36
|
+
const jsonwebtoken_1 = __importStar(require("jsonwebtoken"));
|
|
37
|
+
const appConfigKeyRetriever_1 = require("./appConfigKeyRetriever");
|
|
38
|
+
function generateJWT(userInfo) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const publicJwtSecretValue = yield appConfigKeyRetriever_1.AppConfigKeyRetriever.getPublicJwtSecret();
|
|
41
|
+
const internalJwtSecretValue = yield appConfigKeyRetriever_1.AppConfigKeyRetriever.getInternalJwtSecret();
|
|
42
|
+
let secret = userInfo.isPublicUser ? publicJwtSecretValue : internalJwtSecretValue;
|
|
43
|
+
return jsonwebtoken_1.default.sign(Object.assign({}, userInfo), secret);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.generateJWT = generateJWT;
|
|
47
|
+
function verifyJWT(token, ignoreExp = false) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
let userInfo = jsonwebtoken_1.default.decode(token);
|
|
50
|
+
const publicJwtSecretValue = yield appConfigKeyRetriever_1.AppConfigKeyRetriever.getPublicJwtSecret();
|
|
51
|
+
const internalJwtSecretValue = yield appConfigKeyRetriever_1.AppConfigKeyRetriever.getInternalJwtSecret();
|
|
52
|
+
if (userInfo) {
|
|
53
|
+
let secret = userInfo.isPublicUser ? publicJwtSecretValue : internalJwtSecretValue;
|
|
54
|
+
try {
|
|
55
|
+
userInfo = yield veriftJWTWithSecret(token, secret, ignoreExp);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
if (userInfo.isPublicUser) {
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
userInfo = yield veriftJWTWithSecret(token, publicJwtSecretValue, ignoreExp);
|
|
63
|
+
userInfo.isPublicUser = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new jsonwebtoken_1.JsonWebTokenError("Invalid Token");
|
|
69
|
+
}
|
|
70
|
+
return userInfo;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.verifyJWT = verifyJWT;
|
|
74
|
+
function veriftJWTWithSecret(token, secret, ignoreExp = false) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
let userInfo = jsonwebtoken_1.default.verify(token, secret, { ignoreExpiration: ignoreExp });
|
|
77
|
+
if ((typeof userInfo.subcriptionFeaturePermissionModel) === 'string') {
|
|
78
|
+
userInfo.subcriptionFeaturePermissionModel = JSON.parse(userInfo.subcriptionFeaturePermissionModel.toString());
|
|
79
|
+
}
|
|
80
|
+
return userInfo;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=jwtUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwtUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/jwtUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAsD;AAEtD,mEAAgE;AAEhE,SAAsB,WAAW,CAAC,QAAkB;;QAChD,MAAM,oBAAoB,GAAW,MAAM,6CAAqB,CAAC,kBAAkB,EAAE,CAAC;QACtF,MAAM,sBAAsB,GAAW,MAAM,6CAAqB,CAAC,oBAAoB,EAAE,CAAC;QAC1F,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,sBAAsB,CAAC;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,CAAC,iCAAiC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACnE,QAAQ,CAAC,iCAAiC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,iCAAiC,CAAC,QAAQ,EAAE,CAAC,CAAA;QAClH,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserInfo, ServiceResponse } from '../../interfaces';
|
|
2
|
+
import { Response, NextFunction } from 'express';
|
|
3
|
+
export declare function successResponse(res: Response, next: NextFunction, result: ServiceResponse): Promise<void>;
|
|
4
|
+
export declare function failResponse(res: Response, message?: string, statusCode?: number): Promise<void>;
|
|
5
|
+
export declare function messageParser(message?: string): boolean;
|
|
6
|
+
export declare function sendResponse(res: Response, next: NextFunction, result: ServiceResponse): Promise<void>;
|
|
7
|
+
export declare function getUserInfo(res: Response): UserInfo;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.getUserInfo = exports.sendResponse = exports.messageParser = exports.failResponse = exports.successResponse = void 0;
|
|
36
|
+
// import { apmEndTransaction } from '../monitoring/apm';
|
|
37
|
+
const logger_1 = require("../logger/logger");
|
|
38
|
+
const appConst_1 = require("../appConst");
|
|
39
|
+
const _ = __importStar(require("lodash"));
|
|
40
|
+
function successResponse(res, next, result) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
let fields = res.req.body.fields ? res.req.body.fields : [];
|
|
43
|
+
if (fields.length > 0) {
|
|
44
|
+
result.data = yield filterHandler(result.data, fields);
|
|
45
|
+
}
|
|
46
|
+
let response = {
|
|
47
|
+
isSuccess: true,
|
|
48
|
+
message: result.message,
|
|
49
|
+
data: result.data,
|
|
50
|
+
totalCount: result.totalCount,
|
|
51
|
+
aggregation: result.aggregation
|
|
52
|
+
};
|
|
53
|
+
// await apmEndTransaction(res);
|
|
54
|
+
res.send(response);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.successResponse = successResponse;
|
|
58
|
+
function filterHandler(data, fields) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const nestfields = fields.filter((f) => f.indexOf(".") !== -1);
|
|
61
|
+
let nestparentitems = {};
|
|
62
|
+
let nestparents = [];
|
|
63
|
+
if (nestfields.length) {
|
|
64
|
+
nestfields.forEach(f => {
|
|
65
|
+
const [fs, ...rs] = f.split(".");
|
|
66
|
+
let rm = '';
|
|
67
|
+
rm = rs.join('.');
|
|
68
|
+
if (!fields.includes(fs)) {
|
|
69
|
+
if (Object.keys(nestparentitems).indexOf(fs) == -1) {
|
|
70
|
+
nestparentitems[fs] = [];
|
|
71
|
+
nestparents.push(fs);
|
|
72
|
+
}
|
|
73
|
+
nestparentitems[fs].push(rm);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
data = yield Promise.all(data.map((r) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let descendantobj = {};
|
|
79
|
+
descendantobj = _.pick(r, fields);
|
|
80
|
+
if (nestparents.length > 0) {
|
|
81
|
+
for (const p of nestparents) {
|
|
82
|
+
if (Array.isArray(r[p])) {
|
|
83
|
+
if (!descendantobj[p]) {
|
|
84
|
+
descendantobj[p] = [];
|
|
85
|
+
}
|
|
86
|
+
descendantobj[p] = yield filterHandler(r[p], nestparentitems[p]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return descendantobj;
|
|
91
|
+
})));
|
|
92
|
+
return data;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function failResponse(res, message = "", statusCode = 200) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
let response = { isSuccess: false, message: message };
|
|
98
|
+
// await apmEndTransaction(res);
|
|
99
|
+
res.status(statusCode).send(response);
|
|
100
|
+
if (messageParser(message)) {
|
|
101
|
+
logger_1.logger.error(`shut down by process.exit`);
|
|
102
|
+
process.exit();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
exports.failResponse = failResponse;
|
|
107
|
+
function messageParser(message = "") {
|
|
108
|
+
for (let k in appConst_1.exitErrorMessage) {
|
|
109
|
+
if (message.includes(appConst_1.exitErrorMessage[k])) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
exports.messageParser = messageParser;
|
|
116
|
+
function sendResponse(res, next, result) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
if (result.isSuccess) {
|
|
119
|
+
yield successResponse(res, next, result);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
yield failResponse(res, result.message);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
exports.sendResponse = sendResponse;
|
|
127
|
+
function getUserInfo(res) {
|
|
128
|
+
return res.locals.userInfo;
|
|
129
|
+
}
|
|
130
|
+
exports.getUserInfo = getUserInfo;
|
|
131
|
+
//# sourceMappingURL=responseUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/responseUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAAyD;AACzD,6CAA0C;AAC1C,0CAA+C;AAC/C,0CAA4B;AAG5B,SAAsB,eAAe,CAAC,GAAa,EAAE,IAAkB,EAAE,MAAuB;;QAC5F,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;QAC1D,IAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,G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I,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CAAA;AARD,oCAQC;AAED,SAAgB,aAAa,CAAC,UAAkB,EAAE;IAC9C,KAAK,IAAI,CAAC,IAAI,2BAAgB,EAAE,CAAC;QAC7B,IAAG,OAAO,CAAC,QAAQ,CAAC,2BAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAPD,sCAOC;AAED,SAAsB,YAAY,CAAC,GAAa,EAAE,IAAkB,EAAE,MAAuB;;QACzF,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;aACI,CAAC;YACF,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;CAAA;AAPD,oCAOC;AAED,SAAgB,WAAW,CAAC,GAAa;IACrC,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC/B,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function isEmptyString(str: any): Promise<boolean>;
|
|
2
|
+
export declare function isGuid(guid: string): Promise<boolean>;
|
|
3
|
+
export declare function isGuids(guids: string[]): Promise<boolean>;
|
|
4
|
+
export declare function isEmail(email: string): Promise<boolean>;
|
|
5
|
+
export declare function isEmailList(emails: string[]): Promise<boolean>;
|
|
6
|
+
export declare function isValidDate(date: string, notNull?: boolean): Promise<boolean>;
|