@yrpri/api 9.0.139 → 9.0.141
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/agents/assistants/agentAssistant.js +4 -3
- package/agents/assistants/baseAssistant.js +72 -71
- package/agents/assistants/baseAssistantWithVoice.js +6 -5
- package/agents/assistants/modes/agentDirectConnection.js +8 -7
- package/agents/assistants/modes/agentSelectionMode.js +2 -1
- package/agents/assistants/modes/baseAssistantMode.js +3 -2
- package/agents/assistants/modes/tools/agentTools.js +11 -10
- package/agents/assistants/modes/tools/loginTools.js +7 -6
- package/agents/assistants/modes/tools/models/agents.js +6 -5
- package/agents/assistants/modes/tools/models/subscriptions.js +7 -6
- package/agents/assistants/modes/tools/navigationTools.js +7 -6
- package/agents/assistants/modes/tools/subscriptionTools.js +12 -11
- package/agents/assistants/modes/tools/workflowConverstationTools.js +7 -6
- package/agents/assistants/voiceAssistant.js +45 -44
- package/agents/controllers/agentProductController.js +8 -7
- package/agents/controllers/agentSubscriptionController.js +13 -12
- package/agents/controllers/assistantsController.js +45 -44
- package/agents/controllers/policySynthAgents.js +33 -32
- package/agents/managers/emailInvitesManager.js +4 -3
- package/agents/managers/newAiModelSetup.js +46 -45
- package/agents/managers/notificationAgentQueueManager.js +55 -54
- package/agents/managers/subscriptionManager.js +24 -23
- package/agents/models/agentProduct.js +2 -1
- package/agents/models/agentProductBoosterPurchase.js +2 -1
- package/agents/models/testData/createEvolyAgentProduct.js +7 -6
- package/agents/models/testData/old/updateAgentWorkflowConfiguration.js +5 -4
- package/agents/models/testData/updateAgentWorkflowConfiguration.js +5 -4
- package/agents/tools/setTemplateWorkflowCommunityId.js +6 -5
- package/app.d.ts +2 -1
- package/app.js +60 -34
- package/authorization.cjs +4 -4
- package/controllers/allOurIdeas.js +45 -44
- package/controllers/groups.cjs +4 -9
- package/controllers/images.cjs +8 -8
- package/controllers/index.cjs +1 -1
- package/controllers/points.cjs +1 -1
- package/controllers/posts.cjs +3 -3
- package/deleteUnwantedDeclerations.cjs +6 -5
- package/models/community.cjs +1 -1
- package/models/domain.cjs +7 -7
- package/models/image.cjs +2 -2
- package/models/index.cjs +8 -4
- package/models/post.cjs +10 -10
- package/models/user.cjs +1 -1
- package/models/video.cjs +4 -4
- package/package.json +5 -5
- package/scripts/addRatingUsersToGroup.js +1 -1
- package/scripts/addUserToOrganization.js +8 -8
- package/scripts/agents/changeModelForWorkflowGroupTemplate.js +13 -12
- package/scripts/agents/generateAgentWorkflowTemplateFromAgentClass.js +5 -4
- package/scripts/analyseRatingsForCommunity.js +2 -2
- package/scripts/analyzeAndFixBrokenPointUsers.js +3 -3
- package/scripts/analyzeEndorsementsByCountry.js +7 -7
- package/scripts/analyzePostsForCommunity.js +1 -1
- package/scripts/bulkStatusUpdates/listUpdates.js +2 -2
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +5 -5
- package/scripts/bulkStatusUpdates/performUpdate.js +9 -9
- package/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +12 -11
- package/scripts/bulkStatusUpdates/performUpdateForStatus.js +15 -15
- package/scripts/change/changeVideoAspectTo.js +3 -3
- package/scripts/change/setUseNewVersion.cjs +5 -4
- package/scripts/changeCommunityGroupcount.js +3 -3
- package/scripts/changeCommunityPostCount.js +3 -3
- package/scripts/changeGroupPostCount.js +3 -3
- package/scripts/changeLanguage.js +4 -4
- package/scripts/changeOfficalStatus.js +3 -3
- package/scripts/cleanups/deleteAnonNotifications.cjs +8 -7
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +8 -8
- package/scripts/cleanups/deleteYearOldNotifications.cjs +6 -5
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +5 -5
- package/scripts/clearAllEndorsementInGroup.js +5 -5
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.js +3 -3
- package/scripts/cloning/cloneFromUrlScript.js +4 -4
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +6 -6
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +3 -3
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +2 -2
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +2 -2
- package/scripts/cloning/copyCommunityToDomainWithEverything.js +2 -2
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +3 -3
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +3 -3
- package/scripts/cloning/copyPostToGroupOld.js +12 -12
- package/scripts/cloning/copyPostVideosFromURL.js +3 -3
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +2 -2
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +7 -7
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/setAdminsFromURL.js +5 -5
- package/scripts/cloning/setExternalIdsFromURL.js +3 -3
- package/scripts/countCommunity.js +11 -11
- package/scripts/countCommunityUsers.js +4 -4
- package/scripts/countDelayedNotifications.js +3 -3
- package/scripts/countGroup.js +11 -11
- package/scripts/countStuff.js +3 -3
- package/scripts/countUniqueVotersInAGroup.js +3 -3
- package/scripts/createInvitesAndShow.js +2 -2
- package/scripts/database/sync_database.js +2 -2
- package/scripts/database/sync_dev_database.js +3 -3
- package/scripts/debugNotifications.js +5 -5
- package/scripts/deleteAllNewsFeeds.js +2 -2
- package/scripts/deleteCategory.js +1 -1
- package/scripts/deleteOldAppActivities.js +5 -4
- package/scripts/deletePostContactDataForCommunity.js +5 -4
- package/scripts/destroy/destroy_all_but_one_domain.js +59 -59
- package/scripts/displayAuthorForPost.js +1 -1
- package/scripts/domains/createDomain.js +5 -4
- package/scripts/domains/importDomainsFromXls.js +7 -6
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +2 -2
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +9 -9
- package/scripts/exportAllStatusChanges.js +5 -5
- package/scripts/exportEndorsementsForCommunity.js +5 -5
- package/scripts/exportPointQualitiesForCommunity.js +5 -5
- package/scripts/exportPostsAndPointsForCommunity.js +9 -9
- package/scripts/exportPostsDataSetForDomain.js +12 -12
- package/scripts/exportPostsForGroup.js +7 -7
- package/scripts/exportRatingsForPost.js +2 -2
- package/scripts/exportUserEndorsementsWithUserAnalysis.js +6 -6
- package/scripts/exportUsersForCommunity.js +3 -3
- package/scripts/exportUsersForDomain.js +3 -3
- package/scripts/exportUsersForGroup.js +3 -3
- package/scripts/exports/ratingDistribution.js +6 -6
- package/scripts/exports/whoEndorsedWhatByCommunity.js +2 -2
- package/scripts/findUnusedClientImports.js +2 -2
- package/scripts/fixAllPostPointCounts.js +1 -1
- package/scripts/fixAnonNotificationsSettings.js +5 -5
- package/scripts/fixCountKopavogur.js +1 -1
- package/scripts/fixEndorsementsAfterCopyPostToGroup.js +10 -10
- package/scripts/fixExternalUserId.js +2 -2
- package/scripts/fixGroupAccess.js +3 -3
- package/scripts/fixGroupIdeasAndPointsCount.js +2 -2
- package/scripts/fixNotificationSettings.js +4 -4
- package/scripts/fixSurveyRadioBakedInSubCodes.js +6 -6
- package/scripts/fixWrongUserIdForStatusUpdates.js +6 -5
- package/scripts/gallery/exportGalleryData.js +2 -2
- package/scripts/gallery/importGalleryForCommunity.js +14 -14
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.js +6 -6
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.js +5 -5
- package/scripts/genderAnalysis.js +10 -10
- package/scripts/genderAnalysisByStatus.js +4 -4
- package/scripts/importAllLocalesFromLocalFolders.js +7 -7
- package/scripts/importDomain.js +131 -131
- package/scripts/keys/addOidcToDomain.cjs +10 -9
- package/scripts/landUseGame/export3Ddata.js +15 -15
- package/scripts/listLanguagesForGroup.js +6 -6
- package/scripts/loadTestCreateDummyContentForGroup.js +2 -2
- package/scripts/makeRecursiveMapData.js +4 -4
- package/scripts/mapping/community_map_csv.js +5 -5
- package/scripts/moveCommunityToDomain.js +3 -3
- package/scripts/moveGroupToCommunity.js +3 -3
- package/scripts/movePostToGroup.js +5 -5
- package/scripts/movePostsToGroupsRecountGroupFromUrl.js +6 -6
- package/scripts/oldMovePostToGroup.js +9 -9
- package/scripts/processCsvForPdfUrls.js +2 -2
- package/scripts/processCsvForTranslationAndToxicity.js +10 -10
- package/scripts/recount/recount_recursive_communities.js +6 -6
- package/scripts/recountALLCommunityGroupCounts.js +4 -4
- package/scripts/recountAll.js +3 -3
- package/scripts/recountCommunitesFromUrl.js +3 -3
- package/scripts/recountCommunity.js +2 -2
- package/scripts/recountGroup.js +5 -5
- package/scripts/recountGroupNoUserChange.js +5 -5
- package/scripts/resetAllEndorsementsForGroup.js +3 -3
- package/scripts/resetEnTranslationForGroup.js +5 -5
- package/scripts/setAdminOnAll.cjs +15 -14
- package/scripts/setDomainAdmin.cjs +7 -6
- package/scripts/setDomainLocales.js +2 -2
- package/scripts/setEarlQuestionIdOnGroup.cjs +5 -4
- package/scripts/setLanguageOnGroupCommunitesFromUrl.js +3 -3
- package/scripts/setMemberOfAll.js +14 -14
- package/scripts/setNewUserForContentOfCommunity.js +9 -9
- package/scripts/setOfficialStatusOnAllPostsForCommunity.js +1 -1
- package/scripts/setUserOnAll.js +14 -14
- package/scripts/showCategoryForGroup.js +1 -1
- package/scripts/showOldActivityTypes.js +3 -3
- package/scripts/showPostsMissingCategoryForGroup.js +2 -2
- package/scripts/showStatuses.js +4 -4
- package/scripts/showUniqueVotersInCommunity.js +4 -4
- package/scripts/showUserAgentsAndIpsForEmails.js +4 -4
- package/scripts/simpleExportForGroupsForCommunity.js +5 -5
- package/scripts/simpleExportForPointsForCommunity.js +5 -5
- package/scripts/simpleExportForPostsForCommunity.js +5 -5
- package/scripts/testForEndorsments.js +4 -4
- package/scripts/undeleteGroupAndAllContent.js +8 -8
- package/scripts/undeletePost.js +7 -7
- package/scripts/unlinkSsn.js +4 -4
- package/scripts/updateFromAlthingi.js +8 -8
- package/scripts/users/createUserAddDomain.js +6 -5
- package/scripts/users/importUsersForDomainsFromXls.js +4 -3
- package/scripts/users/listDomainUsersWithSsn.js +6 -5
- package/scripts/users/removeUserFromDomain.js +6 -5
- package/scripts/users/updatePasswordFromSsn.js +5 -4
- package/scripts/users/updateUserSsnFromEmail.js +5 -4
- package/services/controllers/activities.cjs +1 -1
- package/services/controllers/news_feeds.cjs +1 -1
- package/services/controllers/notifications.cjs +1 -1
- package/services/controllers/recommendations.cjs +1 -1
- package/services/engine/allOurIdeas/aiHelper.js +10 -9
- package/services/engine/analytics/export_anon_community_activities.js +3 -3
- package/services/engine/analytics/importer.js +10 -10
- package/services/engine/analytics/plausible/manager.cjs +4 -4
- package/services/engine/analytics/statsCalc.cjs +1 -1
- package/services/engine/analytics/utils.cjs +11 -10
- package/services/engine/marketing/campaign.cjs +1 -0
- package/services/engine/moderation/fraud/CreateFraudAuditReport.cjs +2 -1
- package/services/engine/moderation/fraud/FraudBase.cjs +3 -2
- package/services/engine/moderation/fraud/FraudDeleteBase.cjs +5 -4
- package/services/engine/moderation/fraud/FraudGetBase.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetEndorsements.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPointQualities.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPoints.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPosts.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetRatings.cjs +2 -1
- package/services/engine/moderation/fraud/FraudScannerNotifier.cjs +10 -9
- package/services/engine/moderation/get_moderation_items.cjs +1 -1
- package/services/engine/moderation/image_labeling/ImageLabelingBase.cjs +1 -1
- package/services/engine/moderation/process_moderation_items.cjs +1 -1
- package/services/engine/moderation/toxicity_analysis.cjs +1 -1
- package/services/engine/news_feeds/generate_dynamically.cjs +1 -1
- package/services/engine/news_feeds/generate_from_notifications.cjs +1 -1
- package/services/engine/notifications/emails_utils.cjs +2 -2
- package/services/engine/notifications/generate_point_notifications.cjs +1 -1
- package/services/engine/notifications/generate_post_notifications.cjs +1 -1
- package/services/engine/notifications/process_delayed_notifications.cjs +38 -38
- package/services/engine/notifications/process_general_notifications.cjs +1 -0
- package/services/engine/old/exporters/categories_dataset.js +11 -11
- package/services/engine/old/exporters/sentiment_dataset.js +12 -12
- package/services/engine/recommendations/events_importer.cjs +5 -5
- package/services/engine/recommendations/events_manager.cjs +1 -1
- package/services/engine/reports/add_points_to_sheet.cjs +3 -2
- package/services/engine/reports/commonUtils.js +3 -2
- package/services/engine/reports/common_utils.cjs +8 -8
- package/services/engine/reports/docx_group_report.cjs +1 -1
- package/services/engine/reports/xlsAllOurIdeasExport.js +16 -15
- package/services/engine/reports/xls_community_users_report.cjs +2 -2
- package/services/engine/reports/xls_group_report.cjs +1 -1
- package/services/llms/baseChatBot.js +12 -11
- package/services/llms/imageGeneration/chatGptImageGenerator.js +3 -2
- package/services/llms/imageGeneration/collectionImageGenerator.js +7 -6
- package/services/llms/imageGeneration/dalleImageGenerator.js +6 -5
- package/services/llms/imageGeneration/fluxImageGenerator.js +5 -4
- package/services/llms/imageGeneration/imageProcessorService.js +2 -1
- package/services/llms/imageGeneration/imagenImageGenerator.js +8 -7
- package/services/llms/imageGeneration/s3Service.js +12 -11
- package/services/llms/llmTranslation.js +30 -29
- package/services/models/ac_activity.cjs +1 -1
- package/services/models/ac_notification.cjs +1 -1
- package/services/models/ac_translation_cache.cjs +11 -11
- package/services/scripts/analytics/setup_all_plausible_goals.cjs +3 -2
- package/services/scripts/fix_old_delayed_notifications.js +3 -3
- package/services/scripts/kue_status.js +11 -11
- package/services/scripts/kue_watch_stuck_jobs.js +6 -6
- package/services/scripts/translation_clear_language.js +21 -21
- package/services/scripts/translation_delete.js +4 -4
- package/services/scripts/translation_replace_text_from_url.js +4 -4
- package/services/scripts/translation_update.js +4 -4
- package/services/scripts/translations_list.js +5 -5
- package/services/utils/airbrake.cjs +2 -1
- package/services/utils/redisConnection.cjs +6 -5
- package/services/utils/translation_helpers.cjs +3 -2
- package/services/utils/updateAllLocalesFromEn.js +20 -19
- package/services/utils/updateLocaleFolders.js +7 -6
- package/services/workers/activity.cjs +1 -1
- package/services/workers/anonymizations.cjs +1 -1
- package/services/workers/bulk_status_update.cjs +2 -2
- package/services/workers/delayed_jobs.cjs +1 -1
- package/services/workers/deletions.cjs +1 -1
- package/services/workers/email.cjs +1 -1
- package/services/workers/fraud_management.cjs +3 -3
- package/services/workers/generativeAi.js +6 -5
- package/services/workers/main.cjs +1 -1
- package/services/workers/marketing.cjs +1 -1
- package/services/workers/moderation.cjs +1 -1
- package/services/workers/notification_delivery.cjs +1 -1
- package/services/workers/notification_news_feed.cjs +1 -1
- package/services/workers/queue.cjs +2 -2
- package/services/workers/recount.cjs +1 -1
- package/services/workers/reports.cjs +1 -1
- package/services/workers/similarities.cjs +4 -2
- package/services/workers/speech_to_text.cjs +1 -1
- package/utils/airbrake.cjs +2 -1
- package/utils/cjsCodeReview.js +7 -6
- package/utils/community_mapping_tools.cjs +3 -2
- package/utils/copy_utils.cjs +32 -31
- package/utils/export_utils.cjs +7 -7
- package/utils/generateDocumentation.js +10 -9
- package/utils/logger.cjs +2 -23
- package/utils/logger.d.cts +1 -1
- package/utils/loggerAirbrakeTransport.cjs +52 -0
- package/utils/loggerAirbrakeTransport.d.cts +15 -0
- package/utils/loggerAirbrakeTransportTs.d.ts +15 -0
- package/utils/loggerAirbrakeTransportTs.js +45 -0
- package/utils/loggerCore.cjs +29 -0
- package/utils/loggerCore.d.cts +2 -0
- package/utils/loggerCoreTs.d.ts +2 -0
- package/utils/loggerCoreTs.js +23 -0
- package/utils/loggerTs.d.ts +1 -2
- package/utils/loggerTs.js +2 -25
- package/utils/manifest_generator.cjs +1 -0
- package/utils/recount_utils.cjs +6 -5
- package/utils/seedModels.js +50 -49
- package/utils/sitemap_generator.cjs +4 -4
- package/utils/ypLanguages.js +2 -2
- package/webSockets.js +8 -7
- package/services/utils/logger.cjs +0 -25
- package/services/utils/logger.d.cts +0 -2
- package/src/agents/assistants/assistant.d.ts +0 -156
- package/src/controllers/audios.d.ts +0 -5
- package/src/controllers/categories.d.ts +0 -5
- package/src/controllers/communities.d.ts +0 -5
- package/src/controllers/domains.d.ts +0 -5
- package/src/controllers/groups.d.ts +0 -5
- package/src/controllers/images.d.ts +0 -5
- package/src/controllers/points.d.ts +0 -5
- package/src/controllers/posts.d.ts +0 -5
- package/src/controllers/ratings.d.ts +0 -5
- package/src/controllers/users.d.ts +0 -5
- package/src/controllers/videos.d.ts +0 -5
- package/src/models/index.d.ts +0 -84
- package/src/services/controllers/activities.d.ts +0 -5
- package/src/services/controllers/notifications.d.ts +0 -5
- package/src/utils/copy_utils.d.ts +0 -4
- package/src/utils/manifest_generator.d.ts +0 -18
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { YpAgentProduct } from "../../agentProduct.js";
|
|
2
2
|
import { YpSubscriptionPlan } from "../../subscriptionPlan.js";
|
|
3
|
+
import log from "../../../../utils/loggerTs.js";
|
|
3
4
|
async function setupAgentProductsConfiguration() {
|
|
4
5
|
const competitionAgentWorkflow = {
|
|
5
6
|
currentStepIndex: 0,
|
|
@@ -69,7 +70,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
69
70
|
await competitorAgentFreeTrial.save();
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
|
-
|
|
73
|
+
log.info("CompetitorAgentFreeTrial not found");
|
|
73
74
|
}
|
|
74
75
|
const competitorAgentPaid = await YpAgentProduct.findByPk(2);
|
|
75
76
|
if (competitorAgentPaid) {
|
|
@@ -186,7 +187,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
186
187
|
await fundingSubscriptionPlan.save();
|
|
187
188
|
}
|
|
188
189
|
else {
|
|
189
|
-
|
|
190
|
+
log.info("FundingSubscriptionPlan not found");
|
|
190
191
|
}
|
|
191
192
|
// Update subscription plans 2-5 to coming_soon
|
|
192
193
|
for (let planId = 2; planId <= 5; planId++) {
|
|
@@ -200,7 +201,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
200
201
|
await subscriptionPlan.save();
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
|
-
|
|
204
|
+
log.info(`SubscriptionPlan ${planId} not found`);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
for (let planId = 1; planId <= 2; planId++) {
|
|
@@ -223,7 +224,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
223
224
|
await subscriptionPlan.save();
|
|
224
225
|
}
|
|
225
226
|
else {
|
|
226
|
-
|
|
227
|
+
log.info(`SubscriptionPlan ${planId} not found`);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { YpAgentProduct } from "../agentProduct.js";
|
|
2
2
|
import { YpSubscriptionPlan } from "../subscriptionPlan.js";
|
|
3
|
+
import log from "../../../utils/loggerTs.js";
|
|
3
4
|
async function setupAgentProductsConfiguration() {
|
|
4
5
|
const competitionAgentWorkflow = {
|
|
5
6
|
currentStepIndex: 0,
|
|
@@ -69,7 +70,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
69
70
|
await competitorAgentFreeTrial.save();
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
|
-
|
|
73
|
+
log.info("CompetitorAgentFreeTrial not found");
|
|
73
74
|
}
|
|
74
75
|
const competitorAgentPaid = await YpAgentProduct.findByPk(2);
|
|
75
76
|
if (competitorAgentPaid) {
|
|
@@ -186,7 +187,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
186
187
|
await fundingSubscriptionPlan.save();
|
|
187
188
|
}
|
|
188
189
|
else {
|
|
189
|
-
|
|
190
|
+
log.info("FundingSubscriptionPlan not found");
|
|
190
191
|
}
|
|
191
192
|
// Update subscription plans 2-5 to coming_soon
|
|
192
193
|
for (let planId = 2; planId <= 5; planId++) {
|
|
@@ -200,7 +201,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
200
201
|
await subscriptionPlan.save();
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
|
-
|
|
204
|
+
log.info(`SubscriptionPlan ${planId} not found`);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
for (let planId = 1; planId <= 2; planId++) {
|
|
@@ -223,7 +224,7 @@ async function setupAgentProductsConfiguration() {
|
|
|
223
224
|
await subscriptionPlan.save();
|
|
224
225
|
}
|
|
225
226
|
else {
|
|
226
|
-
|
|
227
|
+
log.info(`SubscriptionPlan ${planId} not found`);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sequelize } from "@policysynth/agents/dbModels/index.js";
|
|
2
2
|
import { YpAgentProduct } from "../models/agentProduct.js";
|
|
3
|
+
import log from "../../utils/loggerTs.js";
|
|
3
4
|
/**
|
|
4
5
|
* Updates the templateWorkflowCommunityId in the configuration of a specific agent product.
|
|
5
6
|
*
|
|
@@ -11,7 +12,7 @@ async function setTemplateWorkflowCommunityId(agentProductId, templateWorkflowCo
|
|
|
11
12
|
// Find the Agent Product by ID
|
|
12
13
|
const agentProduct = await YpAgentProduct.findByPk(agentProductId);
|
|
13
14
|
if (!agentProduct) {
|
|
14
|
-
|
|
15
|
+
log.error(`Agent Product with ID ${agentProductId} not found.`);
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
// If the product is found, update its configuration
|
|
@@ -21,10 +22,10 @@ async function setTemplateWorkflowCommunityId(agentProductId, templateWorkflowCo
|
|
|
21
22
|
agentProduct.configuration = currentConfig;
|
|
22
23
|
agentProduct.changed('configuration', true);
|
|
23
24
|
await agentProduct.save();
|
|
24
|
-
|
|
25
|
+
log.info(`Successfully updated Agent Product ${agentProductId} with templateWorkflowCommunityId = ${templateWorkflowCommunityId}`);
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
27
|
-
|
|
28
|
+
log.error(`Error updating templateWorkflowCommunityId for Agent Product ${agentProductId}:`, error);
|
|
28
29
|
}
|
|
29
30
|
finally {
|
|
30
31
|
// Close the database connection
|
|
@@ -34,12 +35,12 @@ async function setTemplateWorkflowCommunityId(agentProductId, templateWorkflowCo
|
|
|
34
35
|
// --- Parse command line arguments ---
|
|
35
36
|
const args = process.argv.slice(2);
|
|
36
37
|
if (args.length !== 2) {
|
|
37
|
-
|
|
38
|
+
log.error("Usage: ts-node setTemplateWorkflowCommunityId.ts <agentProductId> <templateWorkflowCommunityId>");
|
|
38
39
|
process.exit(1);
|
|
39
40
|
}
|
|
40
41
|
const [agentProductId, templateWorkflowCommunityId] = args.map((arg) => Number(arg));
|
|
41
42
|
if (isNaN(agentProductId) || isNaN(templateWorkflowCommunityId)) {
|
|
42
|
-
|
|
43
|
+
log.error("Both arguments must be valid numbers.");
|
|
43
44
|
process.exit(1);
|
|
44
45
|
}
|
|
45
46
|
// --- Run the function ---
|
package/app.d.ts
CHANGED
|
@@ -35,8 +35,9 @@ export declare class YourPrioritiesApi {
|
|
|
35
35
|
setupDomainAndCommunity(): void;
|
|
36
36
|
initializeRateLimiting(): Promise<void>;
|
|
37
37
|
setupSitemapRoute(): void;
|
|
38
|
-
bearerCallback: () =>
|
|
38
|
+
bearerCallback: () => import("winston").Logger;
|
|
39
39
|
checkAuthForSsoInit(): void;
|
|
40
|
+
setupExpresLogger: (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
40
41
|
initializeMiddlewares(): void;
|
|
41
42
|
initializeEsControllers(): Promise<void>;
|
|
42
43
|
setupStaticFileServing(): void;
|
package/app.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
import session from "express-session";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import morgan from "morgan";
|
|
5
4
|
import bodyParser from "body-parser";
|
|
6
5
|
import { RedisStore } from "connect-redis";
|
|
7
6
|
import useragent from "express-useragent";
|
|
@@ -14,10 +13,10 @@ import models from "./models/index.cjs";
|
|
|
14
13
|
if (process.env.NEW_RELIC_APP_NAME) {
|
|
15
14
|
import("newrelic")
|
|
16
15
|
.then((newrelic) => {
|
|
17
|
-
|
|
16
|
+
log.info("New Relic imported", newrelic);
|
|
18
17
|
})
|
|
19
18
|
.catch((err) => {
|
|
20
|
-
|
|
19
|
+
log.error("Failed to import New Relic", err);
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
import auth from "./authorization.cjs";
|
|
@@ -64,10 +63,10 @@ if (process.env.AIRBRAKE_PROJECT_ID && process.env.AIRBRAKE_API_KEY) {
|
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
process.on("uncaughtException", (err) => {
|
|
67
|
-
|
|
66
|
+
log.error("There was an uncaught error", err);
|
|
68
67
|
log.error("There was an uncaught error", err);
|
|
69
68
|
if (err.stack) {
|
|
70
|
-
|
|
69
|
+
log.error(err.stack);
|
|
71
70
|
log.error(err.stack);
|
|
72
71
|
}
|
|
73
72
|
if (airbrake) {
|
|
@@ -85,10 +84,10 @@ process.on("uncaughtException", (err) => {
|
|
|
85
84
|
process.exit(1);
|
|
86
85
|
});
|
|
87
86
|
process.on("unhandledRejection", (reason, promise) => {
|
|
88
|
-
|
|
87
|
+
log.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
89
88
|
log.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
90
89
|
if (reason.stack) {
|
|
91
|
-
|
|
90
|
+
log.error(reason.stack);
|
|
92
91
|
log.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
93
92
|
}
|
|
94
93
|
if (airbrake) {
|
|
@@ -130,7 +129,31 @@ export class YourPrioritiesApi {
|
|
|
130
129
|
return false;
|
|
131
130
|
};
|
|
132
131
|
this.bearerCallback = function () {
|
|
133
|
-
return
|
|
132
|
+
return log.info("The user has tried to authenticate with a bearer token");
|
|
133
|
+
};
|
|
134
|
+
this.setupExpresLogger = (req, res, next) => {
|
|
135
|
+
const start = Date.now();
|
|
136
|
+
// run after response is finished
|
|
137
|
+
res.on("finish", () => {
|
|
138
|
+
const duration = Date.now() - start;
|
|
139
|
+
// Pick level based on status code
|
|
140
|
+
const level = res.statusCode >= 500
|
|
141
|
+
? "error"
|
|
142
|
+
: res.statusCode >= 400
|
|
143
|
+
? "warn"
|
|
144
|
+
: "info";
|
|
145
|
+
log[level](`${req.method} ${req.originalUrl}`, {
|
|
146
|
+
component: "express",
|
|
147
|
+
method: req.method,
|
|
148
|
+
url: req.originalUrl,
|
|
149
|
+
status: res.statusCode,
|
|
150
|
+
bytes: res.get("content-length") || 0,
|
|
151
|
+
duration,
|
|
152
|
+
ip: req.ip,
|
|
153
|
+
ua: req.headers["user-agent"],
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
next();
|
|
134
157
|
};
|
|
135
158
|
this.completeRegisterUserLogin = (user, // Replace 'any' with the actual user type
|
|
136
159
|
loginType, req, // Replace 'any' with 'YpRequest' if it's the correct type
|
|
@@ -235,7 +258,7 @@ export class YourPrioritiesApi {
|
|
|
235
258
|
req.session.useNewVersion = req.useNewVersion;
|
|
236
259
|
}
|
|
237
260
|
else {
|
|
238
|
-
|
|
261
|
+
log.error("Session not found in request");
|
|
239
262
|
}
|
|
240
263
|
next();
|
|
241
264
|
});
|
|
@@ -260,22 +283,22 @@ export class YourPrioritiesApi {
|
|
|
260
283
|
this.redisClient = createClient({ legacyMode: false });
|
|
261
284
|
}
|
|
262
285
|
this.redisClient.on("error", (err) => {
|
|
263
|
-
|
|
286
|
+
log.error("App Redis client error", err);
|
|
264
287
|
});
|
|
265
288
|
this.redisClient.on("connect", () => {
|
|
266
|
-
|
|
289
|
+
log.info("App Redis client is connected");
|
|
267
290
|
});
|
|
268
291
|
this.redisClient.on("reconnecting", () => {
|
|
269
|
-
|
|
292
|
+
log.info("App Redis client is reconnecting");
|
|
270
293
|
});
|
|
271
294
|
this.redisClient.on("ready", () => {
|
|
272
|
-
|
|
295
|
+
log.info("App Redis client is ready");
|
|
273
296
|
});
|
|
274
297
|
try {
|
|
275
298
|
await this.redisClient.connect();
|
|
276
299
|
}
|
|
277
300
|
catch (err) {
|
|
278
|
-
|
|
301
|
+
log.error("App Failed to connect Redis client", err);
|
|
279
302
|
}
|
|
280
303
|
}
|
|
281
304
|
addRedisToRequest() {
|
|
@@ -353,15 +376,15 @@ export class YourPrioritiesApi {
|
|
|
353
376
|
// Mark invite as used
|
|
354
377
|
invite.joined_at = new Date();
|
|
355
378
|
await invite.save();
|
|
356
|
-
|
|
379
|
+
log.info("Invite joined at", invite.joined_at);
|
|
357
380
|
await new Promise((resolve, reject) => {
|
|
358
381
|
req.logIn(user, (error) => (error ? reject(error) : resolve()));
|
|
359
382
|
});
|
|
360
|
-
|
|
383
|
+
log.info("User logged in for anon invite");
|
|
361
384
|
return next();
|
|
362
385
|
}
|
|
363
386
|
else {
|
|
364
|
-
|
|
387
|
+
log.error("Invite not found");
|
|
365
388
|
return next();
|
|
366
389
|
}
|
|
367
390
|
}
|
|
@@ -498,7 +521,7 @@ export class YourPrioritiesApi {
|
|
|
498
521
|
});
|
|
499
522
|
}
|
|
500
523
|
initializeMiddlewares() {
|
|
501
|
-
this.app.use(
|
|
524
|
+
this.app.use(this.setupExpresLogger);
|
|
502
525
|
this.app.use(useragent.express());
|
|
503
526
|
this.app.use(requestIp.mw());
|
|
504
527
|
this.app.use(bodyParser.json({ limit: "100mb", strict: false }));
|
|
@@ -543,11 +566,11 @@ export class YourPrioritiesApi {
|
|
|
543
566
|
this.app.use(session(sessionConfig));
|
|
544
567
|
}
|
|
545
568
|
async initializeEsControllers() {
|
|
546
|
-
|
|
569
|
+
log.info("Initializing ES controllers");
|
|
547
570
|
const { AllOurIdeasController } = await import("./controllers/allOurIdeas.js");
|
|
548
|
-
|
|
571
|
+
log.info("Initializing ES controllers 2 " + this.wsClients);
|
|
549
572
|
const aoiController = new AllOurIdeasController(this.wsClients);
|
|
550
|
-
|
|
573
|
+
log.info(`Controller path: ${aoiController.path} ${aoiController.router}`);
|
|
551
574
|
this.app.use(aoiController.path, aoiController.router);
|
|
552
575
|
const { PolicySynthAgentsController } = await import("./agents/controllers/policySynthAgents.js");
|
|
553
576
|
const policySynthAgentsController = new PolicySynthAgentsController(this.wsClients);
|
|
@@ -608,7 +631,7 @@ export class YourPrioritiesApi {
|
|
|
608
631
|
const staticPath = req.path.startsWith("/admin")
|
|
609
632
|
? req.adminAppPath
|
|
610
633
|
: req.clientAppPath;
|
|
611
|
-
//
|
|
634
|
+
//log.info("Static path", staticPath);
|
|
612
635
|
// Check if the request is for index.html
|
|
613
636
|
if (req.path === "/" || req.path === "/index.html") {
|
|
614
637
|
index(req, res, next); // Use your dynamic handler
|
|
@@ -629,7 +652,7 @@ export class YourPrioritiesApi {
|
|
|
629
652
|
this.app.use("/post", index);
|
|
630
653
|
this.app.use("/user", index);
|
|
631
654
|
this.app.use("/admin", index);
|
|
632
|
-
this.app.use(
|
|
655
|
+
this.app.use("/survey*splat", index);
|
|
633
656
|
this.app.use("/api/domains", domains);
|
|
634
657
|
this.app.use("/api/organizations", organizations);
|
|
635
658
|
this.app.use("/api/communities", communities);
|
|
@@ -653,24 +676,24 @@ export class YourPrioritiesApi {
|
|
|
653
676
|
this.app.use("/pages", legacyPages);
|
|
654
677
|
// Additional routes for authentication and other functionalities
|
|
655
678
|
this.app.post("/authenticate_from_island_is", (req, res) => {
|
|
656
|
-
|
|
679
|
+
log.info("SAML SAML 1", { domainId: req.ypDomain.id });
|
|
657
680
|
req.sso.authenticate(`saml-strategy-${req.ypDomain.id}`, {}, req, res, (error) => {
|
|
658
|
-
|
|
681
|
+
log.info("SAML SAML 2", {
|
|
659
682
|
domainId: req.ypDomain.id,
|
|
660
683
|
err: error,
|
|
661
684
|
});
|
|
662
685
|
if (error) {
|
|
663
|
-
|
|
686
|
+
log.error("Error from SAML login", { err: error });
|
|
664
687
|
error.url = req.url;
|
|
665
688
|
res.sendStatus(401);
|
|
666
689
|
}
|
|
667
690
|
else {
|
|
668
691
|
if (req.user.DestinationSSN === "6012101260") {
|
|
669
|
-
|
|
692
|
+
log.info("SAML SAML 3", { domainId: req.ypDomain.id });
|
|
670
693
|
res.render("samlLoginComplete", {});
|
|
671
694
|
}
|
|
672
695
|
else {
|
|
673
|
-
|
|
696
|
+
log.error("Error from SAML login", {
|
|
674
697
|
err: "Failed DestinationSSN check",
|
|
675
698
|
});
|
|
676
699
|
res.sendStatus(401);
|
|
@@ -679,14 +702,14 @@ export class YourPrioritiesApi {
|
|
|
679
702
|
});
|
|
680
703
|
});
|
|
681
704
|
this.app.post("/saml_assertion", (req, res) => {
|
|
682
|
-
|
|
705
|
+
log.info("SAML SAML 1 General", { domainId: req.ypDomain.id });
|
|
683
706
|
req.sso.authenticate(`saml-strategy-${req.ypDomain.id}`, {}, req, res, (error, user) => {
|
|
684
|
-
|
|
707
|
+
log.info("SAML SAML 2 General", {
|
|
685
708
|
domainId: req.ypDomain.id,
|
|
686
709
|
err: error,
|
|
687
710
|
});
|
|
688
711
|
if (error) {
|
|
689
|
-
|
|
712
|
+
log.error("Error from SAML General login", { err: error });
|
|
690
713
|
if (error === "customError") {
|
|
691
714
|
res.render("samlCustomError", {
|
|
692
715
|
customErrorHTML: req.ypDomain.configuration.customSAMLErrorHTML,
|
|
@@ -695,12 +718,12 @@ export class YourPrioritiesApi {
|
|
|
695
718
|
}
|
|
696
719
|
else {
|
|
697
720
|
error.url = req.url;
|
|
698
|
-
|
|
721
|
+
log.error("Error from SAML General login", { err: error });
|
|
699
722
|
res.sendStatus(500);
|
|
700
723
|
}
|
|
701
724
|
}
|
|
702
725
|
else {
|
|
703
|
-
|
|
726
|
+
log.info("SAML SAML 3 General", { domainId: req.ypDomain.id });
|
|
704
727
|
res.render("samlLoginComplete", {});
|
|
705
728
|
}
|
|
706
729
|
});
|
|
@@ -961,7 +984,10 @@ export class YourPrioritiesApi {
|
|
|
961
984
|
});
|
|
962
985
|
}
|
|
963
986
|
else {
|
|
964
|
-
server = this.app.listen(portNumber, function () {
|
|
987
|
+
server = this.app.listen(portNumber, function (err) {
|
|
988
|
+
if (err) {
|
|
989
|
+
log.error("Error listening on port", { err });
|
|
990
|
+
}
|
|
965
991
|
log.info("Your Priorities Platform API Server listening on port " +
|
|
966
992
|
server.address().port +
|
|
967
993
|
` on ${process.env.NODE_ENV}`);
|
package/authorization.cjs
CHANGED
|
@@ -1647,13 +1647,13 @@ auth.entity("createGroupPoint", function (req, done) {
|
|
|
1647
1647
|
});
|
|
1648
1648
|
// Create group
|
|
1649
1649
|
auth.role("createCommunityGroup.createGroup", function (community, req, done) {
|
|
1650
|
-
|
|
1650
|
+
log.error(`createCommunityGroup.createGroup`);
|
|
1651
1651
|
models.Community.findOne({
|
|
1652
1652
|
where: { id: community.id },
|
|
1653
1653
|
})
|
|
1654
1654
|
.then(function (community) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1655
|
+
log.info(`community`, community);
|
|
1656
|
+
log.info(`XXX: ${auth.isAuthenticated(req)} ${process.env.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY}`);
|
|
1657
1657
|
if (!auth.isAuthenticated(req) &&
|
|
1658
1658
|
//TODO: Come up with a better way to handle this than a master API key
|
|
1659
1659
|
!process.env.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY) {
|
|
@@ -1661,7 +1661,7 @@ auth.role("createCommunityGroup.createGroup", function (community, req, done) {
|
|
|
1661
1661
|
}
|
|
1662
1662
|
else if (!auth.isAuthenticated(req) &&
|
|
1663
1663
|
process.env.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY) {
|
|
1664
|
-
|
|
1664
|
+
log.info(`XXXY: ${req.headers["x-api-key"]}`);
|
|
1665
1665
|
if (req.headers["x-api-key"] ===
|
|
1666
1666
|
process.env.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY) {
|
|
1667
1667
|
done(null, true);
|