@yrpri/api 9.0.103 → 9.0.105
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/package.json +1 -2
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
var models = require('../models/index.cjs');
|
|
2
|
-
var async = require('async');
|
|
3
|
-
var _ = require('lodash');
|
|
4
|
-
var http = require('http');
|
|
5
|
-
//var parseString = require('xml2js').parseString;
|
|
6
|
-
var concat = require('concat-stream');
|
|
7
|
-
var SESSION_ID = process.argv[2]; // 146;
|
|
8
|
-
var DOMAIN_ID = process.argv[3]; // 2
|
|
9
|
-
var CRAWLER_USER_ID = process.argv[4]; // 29887
|
|
10
|
-
var groupsConfigString = process.argv[5]; // "1=911:2=908:3=905:4=910:5=912:6=907:7=903:8=902:9=904:10=909:11=906"; //
|
|
11
|
-
var createActivityEnabled = process.argv[6] && process.argv[6] == "activityEnabled";
|
|
12
|
-
var baseIssueListURL = "http://www.althingi.is/altext/xml/thingmalalisti/?lthing=";
|
|
13
|
-
var baseIssueURL = "http://www.althingi.is/altext/xml/thingmalalisti/thingmal/?lthing=";
|
|
14
|
-
var USER_AGENT = 'Betra Ísland - Kæra Alþingi - Íbúar ses';
|
|
15
|
-
var lawTopCategories = {
|
|
16
|
-
'Atvinnuvegir': 1,
|
|
17
|
-
'Erlend samskipti': 2,
|
|
18
|
-
'Hagstjórn': 3,
|
|
19
|
-
'Heilsa og heilbrigði': 4,
|
|
20
|
-
'Lög og réttur': 5,
|
|
21
|
-
'Mennta- og menningarmál': 6,
|
|
22
|
-
'Samfélagsmál': 7,
|
|
23
|
-
'Samgöngumál': 8,
|
|
24
|
-
'Stjórnarskipan og stjórnsýsla': 9,
|
|
25
|
-
'Trúmál og kirkja': 10,
|
|
26
|
-
'Umhverfismál': 11
|
|
27
|
-
};
|
|
28
|
-
var getJsonFromXml = function (url, callback) {
|
|
29
|
-
var opts = require('url').parse(url);
|
|
30
|
-
opts.headers = {
|
|
31
|
-
'User-Agent': USER_AGENT
|
|
32
|
-
};
|
|
33
|
-
http.get(opts, function (res) {
|
|
34
|
-
res.setEncoding('utf8');
|
|
35
|
-
res.pipe(concat(function (data) {
|
|
36
|
-
callback(null, JSON.parse(JSON.stringify(data)));
|
|
37
|
-
// Removed parseString
|
|
38
|
-
//parseString(data, function (err, result) {
|
|
39
|
-
// callback(null, JSON.parse(JSON.stringify(result)));
|
|
40
|
-
//});
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var getIssueList = function (callback) {
|
|
45
|
-
getJsonFromXml(baseIssueListURL + SESSION_ID, function (error, jsonResults) {
|
|
46
|
-
callback(error, jsonResults);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var topCategoryIdToGroup = {};
|
|
50
|
-
var capitalize = function (string) {
|
|
51
|
-
string = string || '';
|
|
52
|
-
string = string.trim();
|
|
53
|
-
if (string[0]) {
|
|
54
|
-
string = string[0].toUpperCase() + string.substr(1).toLowerCase();
|
|
55
|
-
}
|
|
56
|
-
return string;
|
|
57
|
-
};
|
|
58
|
-
var setPostOfficialStatus = function (post, dbIssue) {
|
|
59
|
-
if (dbIssue.issueStatus) {
|
|
60
|
-
if (dbIssue.issueStatus.indexOf("Samþykkt") > -1) {
|
|
61
|
-
post.set('official_status', 2);
|
|
62
|
-
}
|
|
63
|
-
else if (dbIssue.issueStatus.indexOf("Fellt") > -1) {
|
|
64
|
-
post.set('official_status', -2);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
post.set('official_status', -1);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var addPost = function (dbIssue, userId, groupImageId, domain, callback) {
|
|
72
|
-
var post = models.Post.build({
|
|
73
|
-
name: dbIssue.name,
|
|
74
|
-
description: dbIssue.description,
|
|
75
|
-
group_id: dbIssue.groupId,
|
|
76
|
-
cover_media_type: groupImageId ? 'image' : 'none',
|
|
77
|
-
user_id: userId,
|
|
78
|
-
status: 'published',
|
|
79
|
-
counter_endorsements_up: 0,
|
|
80
|
-
content_type: models.Post.CONTENT_IDEA,
|
|
81
|
-
user_agent: USER_AGENT,
|
|
82
|
-
ip_address: '127.0.0.1'
|
|
83
|
-
});
|
|
84
|
-
post.set('public_data.law_issue', dbIssue);
|
|
85
|
-
setPostOfficialStatus(post, dbIssue);
|
|
86
|
-
post.save().then(function (post) {
|
|
87
|
-
async.series([
|
|
88
|
-
function (seriesCallback) {
|
|
89
|
-
models.PostRevision.build({
|
|
90
|
-
name: post.name,
|
|
91
|
-
description: post.description,
|
|
92
|
-
group_id: post.group_id,
|
|
93
|
-
user_id: userId,
|
|
94
|
-
this_id: post.id,
|
|
95
|
-
status: post.status,
|
|
96
|
-
user_agent: post.user_agent,
|
|
97
|
-
ip_address: post.ip_address
|
|
98
|
-
}).save().then(function () {
|
|
99
|
-
post.updateAllExternalCounters({ ypDomain: domain }, 'up', 'counter_posts', function () {
|
|
100
|
-
seriesCallback();
|
|
101
|
-
});
|
|
102
|
-
}).catch(function (error) {
|
|
103
|
-
seriesCallback(error);
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
function (seriesCallback) {
|
|
107
|
-
if (createActivityEnabled) {
|
|
108
|
-
models.AcActivity.createActivity({
|
|
109
|
-
type: 'activity.post.new',
|
|
110
|
-
userId: post.user_id,
|
|
111
|
-
domainId: domain.id,
|
|
112
|
-
groupId: post.group_id,
|
|
113
|
-
// communityId: req.ypCommunity ? req.ypCommunity.id : null,
|
|
114
|
-
postId: post.id,
|
|
115
|
-
access: models.AcActivity.ACCESS_PUBLIC
|
|
116
|
-
}, function (error) {
|
|
117
|
-
seriesCallback(error);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
seriesCallback();
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
function (seriesCallback) {
|
|
125
|
-
if (groupImageId) {
|
|
126
|
-
models.Image.findOne({
|
|
127
|
-
where: { id: groupImageId }
|
|
128
|
-
}).then(function (image) {
|
|
129
|
-
if (image) {
|
|
130
|
-
post.addPostHeaderImage(image).then(function (error) {
|
|
131
|
-
seriesCallback();
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
seriesCallback();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
seriesCallback();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
], function (error) {
|
|
144
|
-
callback(error);
|
|
145
|
-
});
|
|
146
|
-
}).catch(function (error) {
|
|
147
|
-
callback(error);
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
var saveIssueIfNeeded = function (dbIssue, userId, callback) {
|
|
151
|
-
models.Post.findOne({ where: {
|
|
152
|
-
$and: [
|
|
153
|
-
{
|
|
154
|
-
"public_data.law_issue.sessionId": SESSION_ID
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"public_data.law_issue.issueId": dbIssue.issueId
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
}).then(function (post) {
|
|
162
|
-
if (!post) {
|
|
163
|
-
models.Domain.findOne({
|
|
164
|
-
where: {
|
|
165
|
-
id: DOMAIN_ID
|
|
166
|
-
}
|
|
167
|
-
}).then(function (domain) {
|
|
168
|
-
models.Group.findOne({
|
|
169
|
-
where: {
|
|
170
|
-
id: dbIssue.groupId
|
|
171
|
-
}
|
|
172
|
-
}).then(function (group) {
|
|
173
|
-
if (group) {
|
|
174
|
-
var defaultImageId = null;
|
|
175
|
-
if (group.configuration.defaultDataImageId) {
|
|
176
|
-
defaultImageId = group.configuration.defaultDataImageId;
|
|
177
|
-
}
|
|
178
|
-
addPost(dbIssue, userId, defaultImageId, domain, callback);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
console.error("Cant find group id: " + dbIssue.groupId);
|
|
182
|
-
callback('Cant find group');
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
console.log("Already saved issue id: " + dbIssue.issueId);
|
|
189
|
-
if (post.public_data.law_issue.issueStatus != dbIssue.issueStatus) {
|
|
190
|
-
post.set('public_data.law_issue.issueStatus', dbIssue.issueStatus);
|
|
191
|
-
setPostOfficialStatus(post, dbIssue);
|
|
192
|
-
post.save().then(function (post) {
|
|
193
|
-
callback();
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
callback();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}).catch(function (error) {
|
|
201
|
-
callback(error);
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
var getIssueStatusFromVotes = function (votingSessions) {
|
|
205
|
-
if (!votingSessions || (votingSessions.length == 0 || votingSessions[0] == "")) {
|
|
206
|
-
return "Lagt fram";
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
var statusValue = "";
|
|
210
|
-
if (votingSessions[0]['atkvæðagreiðsla'] && votingSessions[0]['atkvæðagreiðsla'].length > 0) {
|
|
211
|
-
_.each(votingSessions[0]['atkvæðagreiðsla'], function (votingSession) {
|
|
212
|
-
var tegund = votingSession['tegund'][0];
|
|
213
|
-
if (tegund == "Till.") {
|
|
214
|
-
var resolution = votingSession['samantekt'][0]['afgreiðsla'][0];
|
|
215
|
-
if (resolution == "samþykkt") {
|
|
216
|
-
statusValue = "Samþykkt";
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
statusValue = "Fellt";
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
statusValue = "Í ferli";
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return statusValue;
|
|
229
|
-
};
|
|
230
|
-
groupsConfigString.split(":").forEach(function (pair) {
|
|
231
|
-
var splitPair = pair.split("=");
|
|
232
|
-
topCategoryIdToGroup[splitPair[0]] = splitPair[1];
|
|
233
|
-
});
|
|
234
|
-
getIssueList(function (error, issueList) {
|
|
235
|
-
if (error) {
|
|
236
|
-
console.error(error);
|
|
237
|
-
process.exit();
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
var issues = [];
|
|
241
|
-
async.eachSeries(issueList['málaskrá']['mál'], function (issue, callback) {
|
|
242
|
-
getJsonFromXml(issue['xml'][0], function (error, issueDetail) {
|
|
243
|
-
var dbIssue = { dataType: 'lawIssue', sessionId: SESSION_ID, issueId: issue.$['málsnúmer'], name: capitalize(issue['málsheiti'][0]),
|
|
244
|
-
externalHtmlLink: issue['html'][0], xmlLink: issue['xml'][0], issueType: issue['málstegund'][0]['heiti'][0] };
|
|
245
|
-
if (error) {
|
|
246
|
-
console.error(error);
|
|
247
|
-
callback(error);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
var topCategory, subCategory;
|
|
251
|
-
if (issueDetail['þingmál'] && issueDetail['þingmál']['efnisflokkar']) {
|
|
252
|
-
if (issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'] && issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'][1]) {
|
|
253
|
-
topCategory = issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'][1]['heiti'][0];
|
|
254
|
-
subCategory = issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'][1]['efnisflokkur'][0]['heiti'][0];
|
|
255
|
-
}
|
|
256
|
-
else if (issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur']) {
|
|
257
|
-
topCategory = issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'][0]['heiti'][0];
|
|
258
|
-
subCategory = issueDetail['þingmál']['efnisflokkar'][0]['yfirflokkur'][0]['efnisflokkur'][0]['heiti'][0];
|
|
259
|
-
}
|
|
260
|
-
else if (SESSION_ID == 146 && (dbIssue.issueId == 1 || dbIssue.issueId == 2)) {
|
|
261
|
-
topCategory = "Hagstjórn";
|
|
262
|
-
subCategory = "Fjárreiður ríkisins";
|
|
263
|
-
}
|
|
264
|
-
if (topCategory) {
|
|
265
|
-
var issueStatus = null;
|
|
266
|
-
if (issueDetail['þingmál']['mál'][0]['staðamáls']) {
|
|
267
|
-
issueStatus = issueDetail['þingmál']['mál'][0]['staðamáls'][0];
|
|
268
|
-
}
|
|
269
|
-
if (!issueStatus) {
|
|
270
|
-
issueStatus = getIssueStatusFromVotes(issueDetail['þingmál']['atkvæðagreiðslur']);
|
|
271
|
-
}
|
|
272
|
-
dbIssue = _.merge(dbIssue, { topCategory: topCategory, subCategory: subCategory, issueStatus: issueStatus });
|
|
273
|
-
dbIssue = _.merge(dbIssue, { topCategoryId: lawTopCategories[dbIssue.topCategory] });
|
|
274
|
-
var description = capitalize(dbIssue.issueType) + ". " + dbIssue.name + ". " + dbIssue.topCategory + ". " + dbIssue.subCategory +
|
|
275
|
-
". Málið á Alþingi: " + dbIssue.externalHtmlLink;
|
|
276
|
-
dbIssue = _.merge(dbIssue, { groupId: topCategoryIdToGroup[dbIssue.topCategoryId], description: description });
|
|
277
|
-
if (capitalize(dbIssue.issueType).indexOf("Fyrirspurn") > -1 || capitalize(dbIssue.issueType).indexOf("Beiðni um skýrslu") > -1) {
|
|
278
|
-
console.log("Not doing questions or reports for now for " + dbIssue.issueId);
|
|
279
|
-
callback();
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
saveIssueIfNeeded(dbIssue, CRAWLER_USER_ID, callback);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
console.error("No topCategory");
|
|
287
|
-
callback();
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
console.error("No thingmal field");
|
|
292
|
-
callback();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}, function (error) {
|
|
297
|
-
if (error)
|
|
298
|
-
console.error(error);
|
|
299
|
-
process.exit();
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
export {};
|
package/dist/server.js
DELETED
package/dist/utils/airbrake.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
if (process.env.AIRBRAKE_PROJECT_ID) {
|
|
3
|
-
const Airbrake = require('@airbrake/node');
|
|
4
|
-
let airBrake = null;
|
|
5
|
-
try {
|
|
6
|
-
airBrake = new Airbrake.Notifier({
|
|
7
|
-
projectId: process.env.AIRBRAKE_PROJECT_ID,
|
|
8
|
-
projectKey: process.env.AIRBRAKE_API_KEY,
|
|
9
|
-
performanceStats: false
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
airBrake = null;
|
|
14
|
-
console.error(error);
|
|
15
|
-
}
|
|
16
|
-
module.exports = airBrake;
|
|
17
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from "openai";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import { promisify } from "util";
|
|
5
|
-
const readFilePromise = promisify(fs.readFile);
|
|
6
|
-
export class YpCjsCodeReview {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.modelName = "gpt-4o";
|
|
9
|
-
this.maxTokens = 4000;
|
|
10
|
-
this.temperature = 0.0;
|
|
11
|
-
this.openaiClient = new OpenAI({
|
|
12
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async readFilesRecursively(dir) {
|
|
16
|
-
let results = [];
|
|
17
|
-
const list = fs.readdirSync(dir);
|
|
18
|
-
for (const file of list) {
|
|
19
|
-
if (file === 'node_modules')
|
|
20
|
-
continue;
|
|
21
|
-
if (file === 'ts-out')
|
|
22
|
-
continue;
|
|
23
|
-
const filePath = path.resolve(dir, file);
|
|
24
|
-
const stat = fs.statSync(filePath);
|
|
25
|
-
if (stat && stat.isDirectory()) {
|
|
26
|
-
results = results.concat(await this.readFilesRecursively(filePath));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (filePath.endsWith('.cjs')) {
|
|
30
|
-
results.push(filePath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return results;
|
|
35
|
-
}
|
|
36
|
-
async reviewCjsFiles() {
|
|
37
|
-
const files = await this.readFilesRecursively("./");
|
|
38
|
-
for (const file of files) {
|
|
39
|
-
console.log(`Reviewing file: ${file}`);
|
|
40
|
-
const content = await readFilePromise(file, "utf8");
|
|
41
|
-
const review = await this.callLlm(content);
|
|
42
|
-
console.log(`\n-----------------\nReview for file ${file}:\n${review}\n-----------------\n\n`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
renderSystemPrompt() {
|
|
46
|
-
return `You are an export Common module Javascript CJS code reviewer looking for any potential issues in the code that could cause a crash.
|
|
47
|
-
Instructions:
|
|
48
|
-
Review the code for all potential crash situations. Do not provide feedback on anything else than issues that could cause the code to crash.
|
|
49
|
-
If there are no crash related issues just output: No crash issues found.`;
|
|
50
|
-
}
|
|
51
|
-
renderUserMessage(codeToReview) {
|
|
52
|
-
return `Common module CJS Javascript code to review for crashes: ${codeToReview}
|
|
53
|
-
|
|
54
|
-
Your review results:`;
|
|
55
|
-
}
|
|
56
|
-
async callLlm(codeToReview) {
|
|
57
|
-
const messages = [
|
|
58
|
-
{
|
|
59
|
-
role: "system",
|
|
60
|
-
content: this.renderSystemPrompt(),
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
role: "user",
|
|
64
|
-
content: this.renderUserMessage(codeToReview),
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
const maxRetries = 3;
|
|
68
|
-
let retries = 0;
|
|
69
|
-
let running = true;
|
|
70
|
-
while (running) {
|
|
71
|
-
try {
|
|
72
|
-
//console.log(`Messages ${retries}:`, messages);
|
|
73
|
-
const results = await this.openaiClient.chat.completions.create({
|
|
74
|
-
model: this.modelName,
|
|
75
|
-
messages,
|
|
76
|
-
max_tokens: this.maxTokens,
|
|
77
|
-
temperature: this.temperature,
|
|
78
|
-
});
|
|
79
|
-
//console.log("Results:", results);
|
|
80
|
-
const textReview = results.choices[0].message.content;
|
|
81
|
-
return textReview;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error("Error:", error);
|
|
85
|
-
retries++;
|
|
86
|
-
if (retries > maxRetries) {
|
|
87
|
-
console.error("Max retries reached");
|
|
88
|
-
running = false;
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
(async () => {
|
|
97
|
-
const translator = new YpCjsCodeReview();
|
|
98
|
-
await translator.reviewCjsFiles();
|
|
99
|
-
})();
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const models = require('../models/index.cjs');
|
|
3
|
-
async function getTranslationForMap(textType, model, targetLanguage) {
|
|
4
|
-
return await new Promise((resolve, reject) => {
|
|
5
|
-
models.AcTranslationCache.getTranslation({ query: { textType, targetLanguage } }, model, async (error, translation) => {
|
|
6
|
-
if (!error && translation) {
|
|
7
|
-
resolve(translation.content);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
resolve();
|
|
11
|
-
console.log("No translation");
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
const truncate = (input, length, killwords, end) => {
|
|
17
|
-
length = length || 255;
|
|
18
|
-
if (input.length <= length)
|
|
19
|
-
return input;
|
|
20
|
-
if (killwords) {
|
|
21
|
-
input = input.substring(0, length);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
let idx = input.lastIndexOf(' ', length);
|
|
25
|
-
if (idx === -1) {
|
|
26
|
-
idx = length;
|
|
27
|
-
}
|
|
28
|
-
input = input.substring(0, idx);
|
|
29
|
-
}
|
|
30
|
-
input += (end !== undefined && end !== null) ? end : '...';
|
|
31
|
-
return input;
|
|
32
|
-
};
|
|
33
|
-
const getCommunityMap = async (communityId, map, options) => {
|
|
34
|
-
return await new Promise((resolve, reject) => {
|
|
35
|
-
models.Community.findOne({
|
|
36
|
-
where: {
|
|
37
|
-
id: communityId
|
|
38
|
-
},
|
|
39
|
-
attributes: ['id', 'name'],
|
|
40
|
-
include: [
|
|
41
|
-
{
|
|
42
|
-
model: models.Group,
|
|
43
|
-
attributes: ['id', 'name', 'configuration'],
|
|
44
|
-
required: false
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}).then(async (community) => {
|
|
48
|
-
if (community) {
|
|
49
|
-
let communityName;
|
|
50
|
-
if (options.targetLocale) {
|
|
51
|
-
communityName = await getTranslationForMap("communityName", community, "en");
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
communityName = community.name;
|
|
55
|
-
}
|
|
56
|
-
if (!communityName) {
|
|
57
|
-
communityName = community.name;
|
|
58
|
-
}
|
|
59
|
-
const newCommunity = {
|
|
60
|
-
name: truncate(communityName, 25) + ` (C-${community.id})`,
|
|
61
|
-
link: "/community/" + community.id,
|
|
62
|
-
type: "Community", children: []
|
|
63
|
-
};
|
|
64
|
-
for (const group of community.Groups) {
|
|
65
|
-
let groupName;
|
|
66
|
-
if (options.targetLocale) {
|
|
67
|
-
groupName = await getTranslationForMap("groupName", group, "en");
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
groupName = group.name;
|
|
71
|
-
}
|
|
72
|
-
if (!groupName) {
|
|
73
|
-
groupName = group.name;
|
|
74
|
-
}
|
|
75
|
-
groupName = truncate(groupName, 25) + ` (G-${group.id})`;
|
|
76
|
-
if (group.configuration.actAsLinkToCommunityId) {
|
|
77
|
-
await getCommunityMap(group.configuration.actAsLinkToCommunityId, newCommunity, options);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const newEntry = {
|
|
81
|
-
name: groupName,
|
|
82
|
-
link: "/group/" + group.id,
|
|
83
|
-
children: []
|
|
84
|
-
};
|
|
85
|
-
newCommunity.children.push(newEntry);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
map.children.push(newCommunity);
|
|
89
|
-
resolve();
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
console.error("Cant find community " + communityId);
|
|
93
|
-
map.children.push({ name: "Not found community id " + communityId, children: [] });
|
|
94
|
-
resolve();
|
|
95
|
-
}
|
|
96
|
-
}).catch(error => {
|
|
97
|
-
reject(error);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
const getMapForCommunity = async (communityId, options) => {
|
|
102
|
-
return await new Promise((resolve, reject) => {
|
|
103
|
-
models.Community.findOne({
|
|
104
|
-
where: {
|
|
105
|
-
id: communityId
|
|
106
|
-
},
|
|
107
|
-
attributes: ['name', 'id']
|
|
108
|
-
}).then(async (community) => {
|
|
109
|
-
let map = { name: community.name, children: [] };
|
|
110
|
-
try {
|
|
111
|
-
await getCommunityMap(communityId, map, options);
|
|
112
|
-
resolve(map);
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
reject(error);
|
|
116
|
-
}
|
|
117
|
-
}).catch(error => {
|
|
118
|
-
reject(error);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
module.exports = {
|
|
123
|
-
getMapForCommunity
|
|
124
|
-
};
|