@yrpri/api 9.0.109 → 9.0.111
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/active-citizen/controllers/activities.d.cts +2 -0
- package/active-citizen/controllers/news_feeds.d.cts +2 -0
- package/active-citizen/controllers/notifications.d.cts +2 -0
- package/active-citizen/controllers/recommendations.d.cts +2 -0
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts +22 -0
- package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.d.ts +13 -0
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts +7 -0
- package/active-citizen/engine/analytics/export_anon_community_activities.d.ts +1 -0
- package/active-citizen/engine/analytics/importer.d.ts +1 -0
- package/active-citizen/engine/analytics/manager.d.cts +6 -0
- package/active-citizen/engine/analytics/plausible/manager.d.cts +5 -0
- package/active-citizen/engine/analytics/statsCalc.d.cts +94 -0
- package/active-citizen/engine/analytics/utils.d.cts +5 -0
- package/active-citizen/engine/marketing/campaign.d.cts +1 -0
- package/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.d.cts +1 -0
- package/active-citizen/engine/moderation/fraud/FraudBase.d.cts +31 -0
- package/active-citizen/engine/moderation/fraud/FraudDeleteBase.d.cts +21 -0
- package/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.d.cts +8 -0
- package/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.d.cts +6 -0
- package/active-citizen/engine/moderation/fraud/FraudDeletePoints.d.cts +6 -0
- package/active-citizen/engine/moderation/fraud/FraudDeletePosts.d.cts +4 -0
- package/active-citizen/engine/moderation/fraud/FraudDeleteRatings.d.cts +4 -0
- package/active-citizen/engine/moderation/fraud/FraudGetBase.d.cts +8 -0
- package/active-citizen/engine/moderation/fraud/FraudGetEndorsements.d.cts +7 -0
- package/active-citizen/engine/moderation/fraud/FraudGetPointQualities.d.cts +7 -0
- package/active-citizen/engine/moderation/fraud/FraudGetPoints.d.cts +6 -0
- package/active-citizen/engine/moderation/fraud/FraudGetPosts.d.cts +6 -0
- package/active-citizen/engine/moderation/fraud/FraudGetRatings.d.cts +5 -0
- package/active-citizen/engine/moderation/fraud/FraudScannerNotifier.d.cts +1 -0
- package/active-citizen/engine/moderation/get_moderation_items.d.cts +55 -0
- package/active-citizen/engine/moderation/image_labeling/CommunityLabeling.d.cts +6 -0
- package/active-citizen/engine/moderation/image_labeling/GroupLabeling.d.cts +6 -0
- package/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.d.cts +30 -0
- package/active-citizen/engine/moderation/image_labeling/PointLabeling.d.cts +6 -0
- package/active-citizen/engine/moderation/image_labeling/PostLabeling.d.cts +6 -0
- package/active-citizen/engine/moderation/perspective_api_client.d.cts +33 -0
- package/active-citizen/engine/moderation/process_moderation_items.d.cts +2 -0
- package/active-citizen/engine/moderation/toxicity_analysis.d.cts +3 -0
- package/active-citizen/engine/news_feeds/activity_and_item_index_definitions.d.cts +7 -0
- package/active-citizen/engine/news_feeds/generate_dynamically.d.cts +2 -0
- package/active-citizen/engine/news_feeds/generate_from_notifications.d.cts +2 -0
- package/active-citizen/engine/news_feeds/news_feeds_utils.d.cts +99 -0
- package/active-citizen/engine/notifications/emails_utils.d.cts +2 -0
- package/active-citizen/engine/notifications/generate_point_notifications.d.cts +2 -0
- package/active-citizen/engine/notifications/generate_post_notifications.d.cts +2 -0
- package/active-citizen/engine/notifications/generate_post_status_change_notifications.d.cts +2 -0
- package/active-citizen/engine/notifications/notifications_utils.d.cts +3 -0
- package/active-citizen/engine/notifications/point_delivery.d.cts +2 -0
- package/active-citizen/engine/notifications/post_delivery.d.cts +2 -0
- package/active-citizen/engine/notifications/process_delayed_notifications.d.cts +1 -0
- package/active-citizen/engine/notifications/process_general_notifications.d.cts +2 -0
- package/active-citizen/engine/old/exporters/categories_dataset.d.ts +1 -0
- package/active-citizen/engine/old/exporters/dataset_tools.d.ts +3 -0
- package/active-citizen/engine/old/exporters/sentiment_dataset.d.ts +1 -0
- package/active-citizen/engine/recommendations/events_importer.d.cts +1 -0
- package/active-citizen/engine/recommendations/events_manager.d.cts +5 -0
- package/active-citizen/engine/reports/add_points_to_sheet.d.cts +1 -0
- package/active-citizen/engine/reports/commonUtils.d.ts +5 -0
- package/active-citizen/engine/reports/common_utils.d.cts +44 -0
- package/active-citizen/engine/reports/docx_group_report.d.cts +1 -0
- package/active-citizen/engine/reports/xlsAllOurIdeasExport.d.ts +1 -0
- package/active-citizen/engine/reports/xls_community_users_report.d.cts +2 -0
- package/active-citizen/engine/reports/xls_group_report.d.cts +1 -0
- package/active-citizen/llms/baseChatBot.d.ts +33 -0
- package/active-citizen/llms/imageGeneration/chatGptImageGenerator.d.ts +13 -0
- package/active-citizen/llms/imageGeneration/collectionImageGenerator.d.ts +23 -0
- package/active-citizen/llms/imageGeneration/dalleImageGenerator.d.ts +10 -0
- package/active-citizen/llms/imageGeneration/fluxImageGenerator.d.ts +9 -0
- package/active-citizen/llms/imageGeneration/iImageGenerator.d.ts +7 -0
- package/active-citizen/llms/imageGeneration/imageProcessorService.d.ts +12 -0
- package/active-citizen/llms/imageGeneration/imagenImageGenerator.d.ts +16 -0
- package/active-citizen/llms/imageGeneration/s3Service.d.ts +12 -0
- package/active-citizen/llms/llmTranslation.d.ts +26 -0
- package/active-citizen/models/ac_activity.d.cts +2 -0
- package/active-citizen/models/ac_background_job.d.cts +2 -0
- package/active-citizen/models/ac_campaign.d.cts +2 -0
- package/active-citizen/models/ac_client_activity.d.cts +2 -0
- package/active-citizen/models/ac_delayed_notification.d.cts +2 -0
- package/active-citizen/models/ac_following.d.cts +2 -0
- package/active-citizen/models/ac_list.d.cts +2 -0
- package/active-citizen/models/ac_list_users.d.cts +2 -0
- package/active-citizen/models/ac_mute.d.cts +2 -0
- package/active-citizen/models/ac_news_feed_item.d.cts +2 -0
- package/active-citizen/models/ac_news_feed_processed_range.d.cts +2 -0
- package/active-citizen/models/ac_notification.d.cts +2 -0
- package/active-citizen/models/ac_translation_cache.d.cts +2 -0
- package/active-citizen/models/ac_watching.d.cts +2 -0
- package/active-citizen/scripts/analytics/setup_all_plausible_goals.d.cts +1 -0
- package/active-citizen/scripts/fix_old_delayed_notifications.d.ts +1 -0
- package/active-citizen/scripts/kue_status.d.ts +2 -0
- package/active-citizen/scripts/kue_watch_stuck_jobs.d.ts +2 -0
- package/active-citizen/scripts/translation_clear_language.d.ts +1 -0
- package/active-citizen/scripts/translation_delete.d.ts +1 -0
- package/active-citizen/scripts/translation_replace_text_from_url.d.ts +1 -0
- package/active-citizen/scripts/translation_update.d.ts +1 -0
- package/active-citizen/scripts/translations_list.d.ts +1 -0
- package/active-citizen/utils/airbrake.d.cts +2 -0
- package/active-citizen/utils/get_anonymous_system_user.d.cts +2 -0
- package/active-citizen/utils/i18n.d.cts +2 -0
- package/active-citizen/utils/logger.d.cts +2 -0
- package/active-citizen/utils/redisConnection.d.cts +2 -0
- package/active-citizen/utils/to_json.d.cts +2 -0
- package/active-citizen/utils/translation_cloning.d.cts +5 -0
- package/active-citizen/utils/translation_helpers.d.cts +8 -0
- package/active-citizen/utils/truncate_text.d.cts +2 -0
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts +20 -0
- package/active-citizen/utils/updateLocaleFolders.d.ts +1 -0
- package/active-citizen/workers/activity.cjs +13 -2
- package/active-citizen/workers/activity.d.cts +16 -0
- package/active-citizen/workers/anonymizations.cjs +13 -2
- package/active-citizen/workers/anonymizations.d.cts +16 -0
- package/active-citizen/workers/bulk_status_update.cjs +12 -1
- package/active-citizen/workers/bulk_status_update.d.cts +16 -0
- package/active-citizen/workers/delayed_jobs.cjs +13 -2
- package/active-citizen/workers/delayed_jobs.d.cts +16 -0
- package/active-citizen/workers/deletions.cjs +14 -3
- package/active-citizen/workers/deletions.d.cts +16 -0
- package/active-citizen/workers/email.cjs +12 -1
- package/active-citizen/workers/email.d.cts +16 -0
- package/active-citizen/workers/fraud_management.cjs +13 -2
- package/active-citizen/workers/fraud_management.d.cts +16 -0
- package/active-citizen/workers/generativeAi.d.ts +3 -0
- package/active-citizen/workers/main.d.cts +1 -0
- package/active-citizen/workers/marketing.cjs +13 -2
- package/active-citizen/workers/marketing.d.cts +16 -0
- package/active-citizen/workers/moderation.cjs +13 -2
- package/active-citizen/workers/moderation.d.cts +16 -0
- package/active-citizen/workers/notification_delivery.cjs +12 -1
- package/active-citizen/workers/notification_delivery.d.cts +16 -0
- package/active-citizen/workers/notification_news_feed.cjs +12 -1
- package/active-citizen/workers/notification_news_feed.d.cts +16 -0
- package/active-citizen/workers/queue.d.cts +21 -0
- package/active-citizen/workers/recount.d.cts +1 -0
- package/active-citizen/workers/reports.d.cts +2 -0
- package/active-citizen/workers/similarities.cjs +13 -2
- package/active-citizen/workers/similarities.d.cts +16 -0
- package/active-citizen/workers/speech_to_text.cjs +13 -2
- package/active-citizen/workers/speech_to_text.d.cts +16 -0
- package/agents/assistants/agentAssistant.d.ts +27 -0
- package/agents/assistants/baseAssistant.d.ts +115 -0
- package/agents/assistants/baseAssistantWithVoice.d.ts +18 -0
- package/agents/assistants/modes/agentDirectConnection.d.ts +16 -0
- package/agents/assistants/modes/agentSelectionMode.d.ts +12 -0
- package/agents/assistants/modes/baseAssistantMode.d.ts +10 -0
- package/agents/assistants/modes/tools/agentTools.d.ts +100 -0
- package/agents/assistants/modes/tools/baseTools.d.ts +21 -0
- package/agents/assistants/modes/tools/loginTools.d.ts +51 -0
- package/agents/assistants/modes/tools/models/agents.d.ts +27 -0
- package/agents/assistants/modes/tools/models/subscriptions.d.ts +13 -0
- package/agents/assistants/modes/tools/models/users.d.ts +7 -0
- package/agents/assistants/modes/tools/navigationTools.d.ts +33 -0
- package/agents/assistants/modes/tools/subscriptionTools.d.ts +53 -0
- package/agents/assistants/modes/tools/workflowConverstationTools.d.ts +49 -0
- package/agents/assistants/voiceAssistant.d.ts +78 -0
- package/agents/controllers/agentProductController.d.ts +23 -0
- package/agents/controllers/agentSubscriptionController.d.ts +30 -0
- package/agents/controllers/assistantsController.d.ts +47 -0
- package/agents/controllers/policySynthAgents.d.ts +49 -0
- package/agents/managers/agentProductManager.d.ts +12 -0
- package/agents/managers/emailInvitesManager.d.ts +6 -0
- package/agents/managers/emailTemplateRenderer.d.ts +25 -0
- package/agents/managers/newAiModelSetup.d.ts +37 -0
- package/agents/managers/newAiModelSetup.js +14 -6
- package/agents/managers/notificationAgentQueueManager.d.ts +23 -0
- package/agents/managers/subscriptionManager.d.ts +29 -0
- package/agents/managers/workflowConversationManager.d.ts +14 -0
- package/agents/models/agentProduct.d.ts +31 -0
- package/agents/models/agentProductBoosterPurchase.d.ts +27 -0
- package/agents/models/agentProductBundle.d.ts +12 -0
- package/agents/models/agentProductRun.d.ts +23 -0
- package/agents/models/discount.d.ts +21 -0
- package/agents/models/subscription.d.ts +26 -0
- package/agents/models/subscriptionPlan.d.ts +17 -0
- package/agents/models/subscriptionUser.d.ts +11 -0
- package/agents/models/testData/createEvolyAgentProduct.d.ts +1 -0
- package/agents/models/testData/old/updateAgentWorkflowConfiguration.d.ts +1 -0
- package/agents/models/testData/setupEvolyAgentProductConfig.d.ts +1 -0
- package/agents/models/testData/updateAgentWorkflowConfiguration.d.ts +1 -0
- package/agents/models/workflowConversation.d.ts +11 -0
- package/agents/tools/setTemplateWorkflowCommunityId.d.ts +1 -0
- package/app.d.ts +53 -0
- package/authorization.d.cts +1 -0
- package/bot_control.d.ts +4 -0
- package/controllers/allOurIdeas.d.ts +40 -0
- package/controllers/audios.d.cts +2 -0
- package/controllers/bulkStatusUpdates.d.cts +2 -0
- package/controllers/categories.d.cts +2 -0
- package/controllers/communities.d.cts +2 -0
- package/controllers/domains.d.cts +2 -0
- package/controllers/externalIds.d.cts +2 -0
- package/controllers/groups.d.cts +2 -0
- package/controllers/images.d.cts +2 -0
- package/controllers/index.d.cts +2 -0
- package/controllers/legacyPages.d.cts +2 -0
- package/controllers/legacyPosts.d.cts +2 -0
- package/controllers/legacyUsers.d.cts +2 -0
- package/controllers/nonSpa.d.cts +2 -0
- package/controllers/organizations.d.cts +2 -0
- package/controllers/points.d.cts +2 -0
- package/controllers/posts.d.cts +2 -0
- package/controllers/ratings.d.cts +2 -0
- package/controllers/users.d.cts +2 -0
- package/controllers/videos.d.cts +2 -0
- package/deleteUnwantedDeclerations.d.cts +1 -0
- package/migrations/agentAuditLogs.d.cts +1 -0
- package/migrations/agentClasses.d.cts +1 -0
- package/migrations/agentConnectorClasses.d.cts +1 -0
- package/migrations/agentConnectors.d.cts +1 -0
- package/migrations/agentEvals.d.cts +1 -0
- package/migrations/agentRegistries.d.cts +1 -0
- package/migrations/agents.d.cts +1 -0
- package/migrations/aiModels.d.cts +1 -0
- package/migrations/apiUsage.d.cts +1 -0
- package/migrations/apis.d.cts +1 -0
- package/migrations/groupPrivateData.d.cts +2 -0
- package/migrations/modelUsage.d.cts +2 -0
- package/migrations/privateAccessStore.d.cts +1 -0
- package/migrations/zzz_associations.d.cts +1 -0
- package/migrations/zzzz_createUsersAndAdminsForClasses.d.cts +1 -0
- package/migrations/zzzzz_create_agent_runs.d.cts +2 -0
- package/migrations/zzzzzz_create_agent_runs_fix.d.cts +2 -0
- package/migrations/zzzzzzz_create_trees.d.cts +2 -0
- package/models/audio.d.cts +2 -0
- package/models/bulk_status_update.d.cts +2 -0
- package/models/campaign.d.cts +2 -0
- package/models/category.d.cts +2 -0
- package/models/community.d.cts +2 -0
- package/models/domain.d.cts +2 -0
- package/models/endorsement.d.cts +2 -0
- package/models/general_data_store.d.cts +2 -0
- package/models/group.d.cts +2 -0
- package/models/image.d.cts +2 -0
- package/models/index.cjs +2 -2
- package/models/index.d.cts +3 -0
- package/models/invite.d.cts +2 -0
- package/models/iso_country.d.cts +2 -0
- package/models/organization.d.cts +2 -0
- package/models/page.d.cts +2 -0
- package/models/point.d.cts +2 -0
- package/models/point_quality.d.cts +2 -0
- package/models/point_revision.d.cts +2 -0
- package/models/post.d.cts +2 -0
- package/models/post_revision.d.cts +2 -0
- package/models/post_status_change.d.cts +2 -0
- package/models/promotion.d.cts +2 -0
- package/models/rating.d.cts +2 -0
- package/models/relationship.d.cts +2 -0
- package/models/request_to_join.d.cts +2 -0
- package/models/user.d.cts +2 -0
- package/models/user_legacy_password.d.cts +2 -0
- package/models/video.d.cts +2 -0
- package/package.json +3 -1
- package/publish.d.ts +1 -0
- package/repack.d.ts +1 -0
- package/scripts/addRatingUsersToGroup.d.ts +1 -0
- package/scripts/addUserToOrganization.d.ts +1 -0
- package/scripts/analyseRatingsForCommunity.d.ts +1 -0
- package/scripts/analyzeAndFixBrokenPointUsers.d.ts +1 -0
- package/scripts/analyzeEndorsementsByCountry.d.ts +1 -0
- package/scripts/analyzePostsForCommunity.d.ts +1 -0
- package/scripts/bulkStatusUpdates/listUpdates.d.ts +1 -0
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.d.ts +1 -0
- package/scripts/bulkStatusUpdates/performUpdate.d.ts +1 -0
- package/scripts/bulkStatusUpdates/performUpdateForGroup.d.cts +1 -0
- package/scripts/bulkStatusUpdates/performUpdateForStatus.d.ts +1 -0
- package/scripts/change/changeVideoAspectTo.d.ts +1 -0
- package/scripts/change/setUseNewVersion.d.cts +1 -0
- package/scripts/changeCommunityGroupcount.d.ts +1 -0
- package/scripts/changeCommunityPostCount.d.ts +1 -0
- package/scripts/changeGroupPostCount.d.ts +1 -0
- package/scripts/changeLanguage.d.ts +1 -0
- package/scripts/changeOfficalStatus.d.ts +1 -0
- package/scripts/cleanups/deleteAnonNotifications.d.cts +1 -0
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.d.ts +1 -0
- package/scripts/cleanups/deleteYearOldNotifications.d.cts +1 -0
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.d.ts +1 -0
- package/scripts/clearAllEndorsementInGroup.d.ts +1 -0
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.d.ts +1 -0
- package/scripts/cloning/cloneFromUrlScript.d.ts +1 -0
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.d.ts +1 -0
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.d.ts +1 -0
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.d.ts +1 -0
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.d.ts +1 -0
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.d.ts +1 -0
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.d.ts +1 -0
- package/scripts/cloning/copyCommunityToDomainWithEverything.d.ts +1 -0
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.d.ts +1 -0
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.d.ts +1 -0
- package/scripts/cloning/copyPostToGroupOld.d.ts +1 -0
- package/scripts/cloning/copyPostVideosFromURL.d.ts +1 -0
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.d.ts +1 -0
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.d.ts +1 -0
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.d.ts +1 -0
- package/scripts/cloning/setAdminsFromURL.d.ts +1 -0
- package/scripts/cloning/setExternalIdsFromURL.d.ts +1 -0
- package/scripts/countCommunity.d.ts +1 -0
- package/scripts/countCommunityUsers.d.ts +1 -0
- package/scripts/countDelayedNotifications.d.ts +1 -0
- package/scripts/countGroup.d.ts +1 -0
- package/scripts/countStuff.d.ts +1 -0
- package/scripts/countUniqueVotersInAGroup.d.ts +1 -0
- package/scripts/createInvitesAndShow.d.ts +1 -0
- package/scripts/database/sync_database.d.ts +1 -0
- package/scripts/database/sync_dev_database.d.ts +1 -0
- package/scripts/debugNotifications.d.ts +1 -0
- package/scripts/deleteAllNewsFeeds.d.ts +1 -0
- package/scripts/deleteCategory.d.ts +1 -0
- package/scripts/deleteOldAppActivities.d.ts +1 -0
- package/scripts/deletePostContactDataForCommunity.d.ts +1 -0
- package/scripts/destroy/destroy_all_but_one_domain.d.ts +1 -0
- package/scripts/displayAuthorForPost.d.ts +1 -0
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.d.ts +1 -0
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.d.ts +1 -0
- package/scripts/exportAllStatusChanges.d.ts +1 -0
- package/scripts/exportClientAcitivity.d.ts +1 -0
- package/scripts/exportEndorsementsForCommunity.d.ts +1 -0
- package/scripts/exportPointQualitiesForCommunity.d.ts +1 -0
- package/scripts/exportPostsAndPointsForCommunity.d.ts +1 -0
- package/scripts/exportPostsDataSetForDomain.d.ts +1 -0
- package/scripts/exportPostsForGroup.d.ts +1 -0
- package/scripts/exportRatingsForPost.d.ts +1 -0
- package/scripts/exportUserEndorsementsWithUserAnalysis.d.ts +1 -0
- package/scripts/exportUsersForCommunity.d.ts +1 -0
- package/scripts/exportUsersForDomain.d.ts +1 -0
- package/scripts/exportUsersForGroup.d.ts +1 -0
- package/scripts/exports/ratingDistribution.d.ts +1 -0
- package/scripts/exports/whoEndorsedWhatByCommunity.d.ts +1 -0
- package/scripts/findUnusedClientImports.d.ts +1 -0
- package/scripts/fixAllPostPointCounts.d.ts +1 -0
- package/scripts/fixAnonNotificationsSettings.d.ts +1 -0
- package/scripts/fixCountKopavogur.d.ts +1 -0
- package/scripts/fixEndorsementsAfterCopyPostToGroup.d.ts +1 -0
- package/scripts/fixExternalUserId.d.ts +1 -0
- package/scripts/fixGroupAccess.d.ts +1 -0
- package/scripts/fixGroupIdeasAndPointsCount.d.ts +1 -0
- package/scripts/fixNotificationSettings.d.ts +1 -0
- package/scripts/fixSurveyRadioBakedInSubCodes.d.ts +1 -0
- package/scripts/fixWrongUserIdForStatusUpdates.d.ts +1 -0
- package/scripts/gallery/exportGalleryData.d.ts +1 -0
- package/scripts/gallery/importGalleryForCommunity.d.ts +1 -0
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.d.ts +1 -0
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.d.ts +1 -0
- package/scripts/genderAnalysis.d.ts +1 -0
- package/scripts/genderAnalysisByStatus.d.ts +1 -0
- package/scripts/importAllLocalesFromLocalFolders.d.ts +1 -0
- package/scripts/importDomain.d.ts +1 -0
- package/scripts/keys/addOidcToDomain.d.cts +1 -0
- package/scripts/landUseGame/export3Ddata.d.ts +1 -0
- package/scripts/listLanguagesForGroup.d.ts +1 -0
- package/scripts/loadTestCreateDummyContentForGroup.d.ts +1 -0
- package/scripts/makeRecursiveMapData.d.ts +1 -0
- package/scripts/mapping/community_map_csv.d.ts +1 -0
- package/scripts/moveCommunityToDomain.d.ts +1 -0
- package/scripts/moveGroupToCommunity.d.ts +1 -0
- package/scripts/movePostToGroup.d.ts +1 -0
- package/scripts/movePostsToGroupsRecountGroupFromUrl.d.ts +1 -0
- package/scripts/oldMovePostToGroup.d.ts +1 -0
- package/scripts/processCsvForPdfUrls.d.ts +1 -0
- package/scripts/processCsvForTranslationAndToxicity.d.ts +1 -0
- package/scripts/recount/recount_recursive_communities.d.ts +1 -0
- package/scripts/recountALLCommunityGroupCounts.d.ts +1 -0
- package/scripts/recountAll.d.ts +1 -0
- package/scripts/recountCommunitesFromUrl.d.ts +1 -0
- package/scripts/recountCommunity.d.ts +1 -0
- package/scripts/recountGroup.d.ts +1 -0
- package/scripts/recountGroupNoUserChange.d.ts +1 -0
- package/scripts/resetAllEndorsementsForGroup.d.ts +1 -0
- package/scripts/resetEnTranslationForGroup.d.ts +1 -0
- package/scripts/setAdminOnAll.d.cts +1 -0
- package/scripts/setDomainAdmin.d.cts +1 -0
- package/scripts/setDomainLocales.d.ts +1 -0
- package/scripts/setEarlQuestionIdOnGroup.d.cts +1 -0
- package/scripts/setLanguageOnGroupCommunitesFromUrl.d.ts +1 -0
- package/scripts/setMemberOfAll.d.ts +1 -0
- package/scripts/setNewUserForContentOfCommunity.d.ts +1 -0
- package/scripts/setOfficialStatusOnAllPostsForCommunity.d.ts +1 -0
- package/scripts/setUserOnAll.d.ts +1 -0
- package/scripts/showCategoryForGroup.d.ts +1 -0
- package/scripts/showOldActivityTypes.d.ts +1 -0
- package/scripts/showPostsMissingCategoryForGroup.d.ts +1 -0
- package/scripts/showStatuses.d.ts +1 -0
- package/scripts/showUniqueVotersInCommunity.d.ts +1 -0
- package/scripts/showUserAgentsAndIpsForEmails.d.ts +1 -0
- package/scripts/simpleExportForGroupsForCommunity.d.ts +1 -0
- package/scripts/simpleExportForPointsForCommunity.d.ts +1 -0
- package/scripts/simpleExportForPostsForCommunity.d.ts +1 -0
- package/scripts/testForEndorsments.d.ts +1 -0
- package/scripts/undeleteGroupAndAllContent.d.ts +1 -0
- package/scripts/undeletePost.d.ts +1 -0
- package/scripts/unlinkSsn.d.ts +1 -0
- package/scripts/updateFromAlthingi.d.ts +1 -0
- package/server.d.ts +1 -104
- package/utils/airbrake.d.cts +2 -0
- package/utils/cjsCodeReview.d.ts +13 -0
- package/utils/community_mapping_tools.d.cts +1 -0
- package/utils/copy_utils.d.cts +11 -0
- package/utils/docx_utils.d.cts +1 -0
- package/utils/export_utils.d.cts +21 -0
- package/utils/i18n.d.cts +2 -0
- package/utils/is_valid_db_id.d.cts +1 -0
- package/utils/logger.d.cts +2 -0
- package/utils/loggerTs.d.ts +3 -0
- package/utils/manifest_generator.d.cts +2 -0
- package/utils/manifest_generator.d.ts +1 -3
- package/utils/parse_domain.d.cts +6 -0
- package/utils/recount_utils.d.cts +7 -0
- package/utils/seedModels.d.ts +2 -0
- package/utils/seedModels.js +388 -0
- package/utils/sharing_parameters.d.cts +8 -0
- package/utils/sitemap_generator.d.cts +2 -0
- package/utils/to_json.d.cts +2 -0
- package/utils/ypLanguages.d.ts +16 -0
- package/webSockets.d.ts +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/server.d.ts
CHANGED
|
@@ -1,104 +1 @@
|
|
|
1
|
-
|
|
2
|
-
declare module 'iso-639-1';
|
|
3
|
-
declare module 'newrelic';
|
|
4
|
-
declare module 'html-to-docx';
|
|
5
|
-
|
|
6
|
-
interface Logger {
|
|
7
|
-
debug(text: string): void;
|
|
8
|
-
info(text: string): void;
|
|
9
|
-
warn(text: string): void;
|
|
10
|
-
error(text: string): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface Models {
|
|
14
|
-
[key: string]: typeof DbData; // Assuming all models extend DbData
|
|
15
|
-
Post?: typeof PostData;
|
|
16
|
-
Domain?: typeof DomainData;
|
|
17
|
-
User?: typeof UserData;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface DbData extends Model {
|
|
21
|
-
created_at: string;
|
|
22
|
-
updated_at: string;
|
|
23
|
-
id: number;
|
|
24
|
-
static findOne(options: any): Promise<any>;
|
|
25
|
-
static findAll(options: any): Promise<any>;
|
|
26
|
-
static destroy(options: any): Promise<any>;
|
|
27
|
-
static update(options: any, data: any): Promise<any>;
|
|
28
|
-
static create(options: any): Promise<any>;
|
|
29
|
-
static count(options: any | undefined = undefined): Promise<any>;
|
|
30
|
-
static build(options: any): Promise<any>;
|
|
31
|
-
save(): Promise<any>;
|
|
32
|
-
set(col: string, value: any): void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface DomainClass extends DbData {
|
|
36
|
-
configuration: {
|
|
37
|
-
ltp?: {
|
|
38
|
-
crt?: LtpCurrentRealityTreeData
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface CommunityClass extends DbData {
|
|
44
|
-
Domain: DomainClass;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface PostClass extends DbData {
|
|
48
|
-
data?: {
|
|
49
|
-
crt?: LtpCurrentRealityTreeData
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface GroupClass extends DbData {
|
|
54
|
-
description: string;
|
|
55
|
-
configuration: YpGroupConfiguration;
|
|
56
|
-
hasGroupAdmins(user: UserClass): Promise<boolean>;
|
|
57
|
-
addGroupAdmins(user: UserClass): Promise<void>;
|
|
58
|
-
hasGroupUsers(user: UserClass): Promise<boolean>;
|
|
59
|
-
addGroupUsers(user: UserClass): Promise<void>;
|
|
60
|
-
changed(field: string, value: any): void;
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface UserClass extends DbData {
|
|
65
|
-
email: string;
|
|
66
|
-
name: string;
|
|
67
|
-
new (): Promise<UserClass>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
interface AcBackgroundJobClass extends DbData {
|
|
72
|
-
static updateDataAsync(jobId: number, data: any): Promise<any>;
|
|
73
|
-
static updateErrorAsync(jobId: number, error: string): Promise<any>;
|
|
74
|
-
static createJob(data: any, dataTwo: any, done: Function): Promise<any>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface AcXlsExportJobData {
|
|
78
|
-
jobId: number;
|
|
79
|
-
userId: number;
|
|
80
|
-
exportType: string;
|
|
81
|
-
fileName: string;
|
|
82
|
-
utmSource: string;
|
|
83
|
-
questionId: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface ImageClass extends DbData {
|
|
87
|
-
formats: string[];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type YpChatBotMemoryStageTypes = PsMemoryStageTypes | "chatbot-conversation";
|
|
91
|
-
|
|
92
|
-
interface PsChatBotMemoryData extends PsBaseMemoryData {
|
|
93
|
-
stages: Record<any, any>;
|
|
94
|
-
chatLog?: YpSimpleChatLog[];
|
|
95
|
-
problemStatement?: PsProblemStatement;
|
|
96
|
-
currentStage: YpChatBotMemoryStageTypes;
|
|
97
|
-
groupId?: number;
|
|
98
|
-
communityId?: number;
|
|
99
|
-
domainId?: number;
|
|
100
|
-
totalCost?: number;
|
|
101
|
-
customInstructions?: object,
|
|
102
|
-
subProblems?: IEngineSubProblem[],
|
|
103
|
-
currentStageData?: undefined;
|
|
104
|
-
}
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OpenAI } from "openai";
|
|
2
|
+
export declare class YpCjsCodeReview {
|
|
3
|
+
openaiClient: OpenAI;
|
|
4
|
+
modelName: string;
|
|
5
|
+
maxTokens: number;
|
|
6
|
+
temperature: number;
|
|
7
|
+
constructor();
|
|
8
|
+
readFilesRecursively(dir: string): Promise<string[]>;
|
|
9
|
+
reviewCjsFiles(): Promise<void>;
|
|
10
|
+
renderSystemPrompt(): string;
|
|
11
|
+
renderUserMessage(codeToReview: string): string;
|
|
12
|
+
callLlm(codeToReview: string): Promise<string | undefined | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getMapForCommunity(communityId: any, options: any): Promise<any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function copyCommunityNoUsersNoEndorsementsOneGroup(communityId: any, groupId: any, toDomainId: any, done: any): void;
|
|
2
|
+
export function copyCommunityNoUsersNoEndorsements(communityId: any, toDomainId: any, done: any): void;
|
|
3
|
+
export function copyCommunityNoUsersNoEndorsementsNoPoints(communityId: any, toDomainId: any, done: any): void;
|
|
4
|
+
export function copyCommunityWithEverything(communityId: any, toDomainId: any, options: any, done: any): void;
|
|
5
|
+
export function clonePagesForGroup(inGroup: any, outGroup: any, done: any): void;
|
|
6
|
+
export function deepCopyCommunityOnlyStructureWithAdminsAndPosts(communityId: any, toDomainId: any, done: any): void;
|
|
7
|
+
export function clonePagesForCommunity(inCommunity: any, outCommunity: any, done: any): void;
|
|
8
|
+
export function copyCommunity(fromCommunityId: any, toDomainId: any, options: any, linkFromOptions: any, done: any): void;
|
|
9
|
+
export function copyCommunityOnlyGroups(communityId: any, toDomainId: any, done: any): void;
|
|
10
|
+
export function copyGroup(fromGroupId: any, toCommunityIn: any, toDomainId: any, options: any, done: any): void;
|
|
11
|
+
export function copyPost(fromPostId: any, toGroupId: any, options: any, done: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function exportGroupToDocx(group: any, hostName: any, targetLanguage: any, callback: any): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function getExportFileDataForGroup(group: any, hostName: any, callback: any): void;
|
|
2
|
+
export function getLoginsExportDataForCommunity(communityId: any, hostName: any, callback: any): void;
|
|
3
|
+
export function getLoginsExportDataForDomain(domainId: any, hostName: any, callback: any): void;
|
|
4
|
+
export function getGroupPosts(group: any, hostName: any, callback: any): void;
|
|
5
|
+
export function getUsersForCommunity(communityId: any, callback: any): void;
|
|
6
|
+
export function getDescriptionHeaders(group: any): string;
|
|
7
|
+
export function getPostUrl(post: any, hostname: any): string;
|
|
8
|
+
export function getCategory(post: any): any;
|
|
9
|
+
export function getImages(post: any): string;
|
|
10
|
+
export function clean(text: any): any;
|
|
11
|
+
export function getDescriptionColumns(group: any, post: any): string;
|
|
12
|
+
export function getPointsDown(post: any): string;
|
|
13
|
+
export function getPointsUp(post: any): string;
|
|
14
|
+
export function getUserEmail(post: any): any;
|
|
15
|
+
export function getRatingHeaders(customRatings: any): string;
|
|
16
|
+
export function getContactData(post: any): string;
|
|
17
|
+
export function getLocation(post: any): string;
|
|
18
|
+
export function getAttachmentData(post: any): string;
|
|
19
|
+
export function getMediaURLs(post: any): string;
|
|
20
|
+
export function getMediaTranscripts(post: any): string;
|
|
21
|
+
export function getPostRatings(customRatings: any, postRatings: any): string;
|
package/utils/i18n.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isValidDbId(dbId: any): boolean;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
|
|
3
|
-
// Define the module path based on convention from other .d.ts files
|
|
4
1
|
declare module '@yrpri/api/utils/manifest_generator.cjs' {
|
|
2
|
+
import { Request, Response } from 'express';
|
|
5
3
|
|
|
6
4
|
interface YpRequest extends Request {
|
|
7
5
|
ypCommunity?: YpCommunity;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function recountCommunity(communityId: any, callback: any): void;
|
|
2
|
+
export function recountGroup(groupId: any, callback: any): void;
|
|
3
|
+
export function recountPost(postId: any, done: any): void;
|
|
4
|
+
export function recountPosts(postIds: any, done: any): void;
|
|
5
|
+
export function recountPoint(pointId: any, done: any): void;
|
|
6
|
+
export function recountPoints(pointIds: any, done: any): void;
|
|
7
|
+
export function countUsersInGroup(groupId: any, done: any): void;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
import bcrypt from 'bcrypt';
|
|
6
|
+
import { Sequelize, DataTypes, Op } from "sequelize";
|
|
7
|
+
import { sequelize as psSequelize } from "@policysynth/agents/dbModels/index.js";
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
// PolicySynth Models
|
|
11
|
+
import { PsAiModel } from "@policysynth/agents/dbModels/aiModel.js";
|
|
12
|
+
import { PsAgentClass } from "@policysynth/agents/dbModels/agentClass.js";
|
|
13
|
+
import { PsExternalApiUsage } from "@policysynth/agents/dbModels/externalApiUsage.js";
|
|
14
|
+
import { PsExternalApi } from "@policysynth/agents/dbModels/externalApis.js";
|
|
15
|
+
import { PsModelUsage } from "@policysynth/agents/dbModels/modelUsage.js";
|
|
16
|
+
import { PsAgent } from "@policysynth/agents/dbModels/agent.js";
|
|
17
|
+
import { PsAgentAuditLog } from "@policysynth/agents/dbModels/agentAuditLog.js";
|
|
18
|
+
import { PsAgentConnector } from "@policysynth/agents/dbModels/agentConnector.js";
|
|
19
|
+
import { PsAgentConnectorClass } from "@policysynth/agents/dbModels/agentConnectorClass.js";
|
|
20
|
+
import { PsAgentRegistry } from "@policysynth/agents/dbModels/agentRegistry.js";
|
|
21
|
+
const psModels = {
|
|
22
|
+
PsAgentClass,
|
|
23
|
+
PsExternalApiUsage,
|
|
24
|
+
PsModelUsage,
|
|
25
|
+
PsAgentConnector,
|
|
26
|
+
PsAgent,
|
|
27
|
+
PsAgentAuditLog,
|
|
28
|
+
PsAgentConnectorClass,
|
|
29
|
+
PsAgentRegistry,
|
|
30
|
+
PsAiModel,
|
|
31
|
+
PsExternalApi,
|
|
32
|
+
};
|
|
33
|
+
const env = process.env.NODE_ENV || "development";
|
|
34
|
+
let mainSequelize;
|
|
35
|
+
// Operator aliases from server_api/models/index.cjs
|
|
36
|
+
const mainOperatorsAliases = {
|
|
37
|
+
$gt: Op.gt,
|
|
38
|
+
$gte: Op.gte,
|
|
39
|
+
$lt: Op.lt,
|
|
40
|
+
$lte: Op.lte,
|
|
41
|
+
$in: Op.in,
|
|
42
|
+
$and: Op.and,
|
|
43
|
+
$or: Op.or,
|
|
44
|
+
$eq: Op.eq,
|
|
45
|
+
$ne: Op.ne,
|
|
46
|
+
$is: Op.is,
|
|
47
|
+
$not: Op.not,
|
|
48
|
+
$between: Op.between,
|
|
49
|
+
$notBetween: Op.notBetween,
|
|
50
|
+
$like: Op.like,
|
|
51
|
+
$contains: Op.contains,
|
|
52
|
+
$any: Op.any,
|
|
53
|
+
};
|
|
54
|
+
if (env === "production") {
|
|
55
|
+
if (!process.env.DATABASE_URL) {
|
|
56
|
+
console.error("DATABASE_URL environment variable is not set for production.");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
if (process.env.DISABLE_PG_SSL) {
|
|
60
|
+
mainSequelize = new Sequelize(process.env.DATABASE_URL, {
|
|
61
|
+
dialect: "postgres",
|
|
62
|
+
minifyAliases: true,
|
|
63
|
+
logging: false,
|
|
64
|
+
operatorsAliases: mainOperatorsAliases,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
mainSequelize = new Sequelize(process.env.DATABASE_URL, {
|
|
69
|
+
dialect: "postgres",
|
|
70
|
+
dialectOptions: {
|
|
71
|
+
ssl: {
|
|
72
|
+
rejectUnauthorized: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
minifyAliases: true,
|
|
76
|
+
logging: false,
|
|
77
|
+
operatorsAliases: mainOperatorsAliases,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (!process.env.YP_DEV_DATABASE_NAME ||
|
|
83
|
+
!process.env.YP_DEV_DATABASE_USERNAME ||
|
|
84
|
+
!process.env.YP_DEV_DATABASE_PASSWORD ||
|
|
85
|
+
!process.env.YP_DEV_DATABASE_HOST ||
|
|
86
|
+
!process.env.YP_DEV_DATABASE_PORT) {
|
|
87
|
+
console.error("One or more YP_DEV_DATABASE environment variables are not set for development.");
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
mainSequelize = new Sequelize(process.env.YP_DEV_DATABASE_NAME, process.env.YP_DEV_DATABASE_USERNAME, process.env.YP_DEV_DATABASE_PASSWORD, {
|
|
92
|
+
dialect: "postgres",
|
|
93
|
+
protocol: "postgres",
|
|
94
|
+
host: process.env.YP_DEV_DATABASE_HOST,
|
|
95
|
+
port: parseInt(process.env.YP_DEV_DATABASE_PORT, 10),
|
|
96
|
+
minifyAliases: true,
|
|
97
|
+
dialectOptions: {
|
|
98
|
+
ssl: false,
|
|
99
|
+
rejectUnauthorized: false,
|
|
100
|
+
},
|
|
101
|
+
logging: false, // Set to console.log for verbose output during seeding
|
|
102
|
+
operatorsAliases: mainOperatorsAliases,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error("Error initializing Sequelize for development:", error);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const mainDb = {};
|
|
111
|
+
// Compound index commands from server_api/models/index.cjs
|
|
112
|
+
const mainCompoundIndexCommands = [
|
|
113
|
+
'CREATE INDEX domainheaderimage_idx2_domain_id ON "DomainHeaderImage" (domain_id)',
|
|
114
|
+
'CREATE INDEX domainlogoimage_idx2_domain_id ON "DomainLogoImage" (domain_id)',
|
|
115
|
+
'CREATE INDEX domainlogovideo_idx2_domain_id ON "DomainLogoVideo" (domain_id)',
|
|
116
|
+
'CREATE INDEX domainheaderimage_idx2_domain_id_u ON "DomainHeaderImage" (domain_id, updated_at)',
|
|
117
|
+
'CREATE INDEX domainlogoimage_idx2_domain_id_u ON "DomainLogoImage" (domain_id, updated_at)',
|
|
118
|
+
'CREATE INDEX domainlogovideo_idx2_domain_id_u ON "DomainLogoVideo" (domain_id, updated_at)',
|
|
119
|
+
'CREATE INDEX domainheaderimage_idx2_domain_id_c ON "DomainHeaderImage" (domain_id, created_at)',
|
|
120
|
+
'CREATE INDEX domainlogoimage_idx2_domain_id_c ON "DomainLogoImage" (domain_id, created_at)',
|
|
121
|
+
'CREATE INDEX domainlogovideo_idx2_domain_id_c ON "DomainLogoVideo" (domain_id, created_at)',
|
|
122
|
+
'CREATE INDEX communityheaderimage_idx2_community_id ON "CommunityHeaderImage" (community_id)',
|
|
123
|
+
'CREATE INDEX communitylogoimage_idx2_community_id ON "CommunityLogoImage" (community_id)',
|
|
124
|
+
'CREATE INDEX communitylogovideo_idx2_community_id ON "CommunityLogoVideo" (community_id)',
|
|
125
|
+
'CREATE INDEX communityheaderimage_idx2_community_id_u ON "CommunityHeaderImage" (community_id, updated_at)',
|
|
126
|
+
'CREATE INDEX communitylogoimage_idx2_community_id_u ON "CommunityLogoImage" (community_id, updated_at)',
|
|
127
|
+
'CREATE INDEX communitylogovideo_idx2_community_id_u ON "CommunityLogoVideo" (community_id, updated_at)',
|
|
128
|
+
'CREATE INDEX communityheaderimage_idx2_community_id_c ON "CommunityHeaderImage" (community_id, created_at)',
|
|
129
|
+
'CREATE INDEX communitylogoimage_idx2_community_id_c ON "CommunityLogoImage" (community_id, created_at)',
|
|
130
|
+
'CREATE INDEX communitylogovideo_idx2_community_id_c ON "CommunityLogoVideo" (community_id, created_at)',
|
|
131
|
+
'CREATE INDEX groupheaderimage_idx2_group_id_u ON "GroupHeaderImage" (group_id, updated_at)',
|
|
132
|
+
'CREATE INDEX grouplogoimage_idx2_group_id_u ON "GroupLogoImage" (group_id, updated_at)',
|
|
133
|
+
'CREATE INDEX grouplogovideo_idx2_group_id_u ON "GroupLogoVideo" (group_id, updated_at)',
|
|
134
|
+
'CREATE INDEX groupheaderimage_idx2_group_id_c ON "GroupHeaderImage" (group_id, created_at)',
|
|
135
|
+
'CREATE INDEX grouplogoimage_idx2_group_id_c ON "GroupLogoImage" (group_id, created_at)',
|
|
136
|
+
'CREATE INDEX grouplogovideo_idx2_group_id_c ON "GroupLogoVideo" (group_id, created_at)',
|
|
137
|
+
'CREATE INDEX idx2_group_categories_name ON Categories (group_id, name)',
|
|
138
|
+
'CREATE INDEX organizationlogoimag_idx_organization_id ON "OrganizationLogoImage" (organization_id)',
|
|
139
|
+
'CREATE INDEX organizationlogoimag_idx_organization_id_u ON "OrganizationLogoImage" (organization_id, updated_at)',
|
|
140
|
+
'CREATE INDEX organizationlogoimag_idx_organization_id_c ON "OrganizationLogoImage" (organization_id, created_at)',
|
|
141
|
+
'CREATE INDEX organizationuser_idx2_user_id ON "OrganizationUser" (user_id)',
|
|
142
|
+
'CREATE INDEX pointaudio_idx2_point_id ON "PointAudio" (point_id)',
|
|
143
|
+
'CREATE INDEX pointvideo_idx2_point_id ON "PointVideo" (point_id)',
|
|
144
|
+
'CREATE INDEX pointaudio_idx2_point_id_u ON "PointAudio" (point_id, updated_at)',
|
|
145
|
+
'CREATE INDEX pointvideo_idx2_point_id_u ON "PointVideo" (point_id, updated_at)',
|
|
146
|
+
'CREATE INDEX pointaudio_idx2_point_id_c ON "PointAudio" (point_id, created_at)',
|
|
147
|
+
'CREATE INDEX pointvideo_idx2_point_id_c ON "PointVideo" (point_id, created_at)',
|
|
148
|
+
'CREATE INDEX points_idx2_counter_sum_post_id_status_value_deleted ON points ((counter_quality_up-counter_quality_down), post_id, status, value, deleted)',
|
|
149
|
+
'CREATE INDEX userprofileimage_idx2_user_id ON "UserProfileImage" (user_id)',
|
|
150
|
+
'CREATE INDEX userprofileimage_idx2_user_id_u ON "UserProfileImage" (user_id, updated_at)',
|
|
151
|
+
'CREATE INDEX userprofileimage_idx2_user_id_c ON "UserProfileImage" (user_id, created_at)',
|
|
152
|
+
'CREATE INDEX categoryiconimage_idx2_category_id ON "CategoryIconImage" (category_id)',
|
|
153
|
+
'CREATE INDEX idx2_category_icon_images ON "CategoryIconImage" (category_id, updated_at)',
|
|
154
|
+
'CREATE INDEX idx2_category_icon_images_c ON "CategoryIconImage" (category_id, created_at)',
|
|
155
|
+
'CREATE INDEX videoimage_idx2_video_id ON "VideoImage" (video_id)',
|
|
156
|
+
'CREATE INDEX videoimage_idx2_video_id_u ON "VideoImage" (video_id, updated_at)',
|
|
157
|
+
'CREATE INDEX videoimage_idx2_video_id_c ON "VideoImage" (video_id, created_at)',
|
|
158
|
+
'CREATE INDEX postaudio_idx2_post_id ON "PostAudio" (post_id)',
|
|
159
|
+
'CREATE INDEX postvideo_idx2_post_id ON "PostVideo" (post_id)',
|
|
160
|
+
'CREATE INDEX postheaderimage_idx2_post_id ON "PostHeaderImage" (post_id)',
|
|
161
|
+
'CREATE INDEX posimage_idx2_post_id ON "PostImage" (post_id)',
|
|
162
|
+
'CREATE INDEX idx2_post_header_images_u ON "PostHeaderImage" (post_id, updated_at)',
|
|
163
|
+
'CREATE INDEX idx2_post_images_u ON "PostImage" (post_id, updated_at)',
|
|
164
|
+
'CREATE INDEX idx2_post_audios_u ON "PostAudio" (post_id, updated_at)',
|
|
165
|
+
'CREATE INDEX idx2_post_videos_u ON "PostVideo" (post_id, updated_at)',
|
|
166
|
+
'CREATE INDEX idx2_post_header_images_c ON "PostHeaderImage" (post_id, created_at)',
|
|
167
|
+
'CREATE INDEX idx2_post_images_c ON "PostImage" (post_id, created_at)',
|
|
168
|
+
'CREATE INDEX idx2_post_audios_c ON "PostAudio" (post_id, created_at)',
|
|
169
|
+
'CREATE INDEX idx2_post_videos_c ON "PostVideo" (post_id, created_at)',
|
|
170
|
+
'CREATE INDEX posts_idx2_counter_sum_group_id_deleted ON posts ((counter_endorsements_up-counter_endorsements_down),group_id,deleted)',
|
|
171
|
+
'CREATE INDEX posts_idx2_counter_sum_group_id_category_id_deleted ON posts ((counter_endorsements_up-counter_endorsements_down),group_id,category_id,deleted)',
|
|
172
|
+
];
|
|
173
|
+
async function createMainCompoundIndexes(sequelizeInstance, indexCommands) {
|
|
174
|
+
for (const command of indexCommands) {
|
|
175
|
+
try {
|
|
176
|
+
await sequelizeInstance.query(command);
|
|
177
|
+
console.log(`Successfully created main index: ${command.substring(0, 100)}...`);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (error.message && error.message.indexOf("already exists") > -1) {
|
|
181
|
+
// console.log(`Main index already exists: ${command.substring(0,100)}...`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
console.error(`Error creating main index with command: ${command}`);
|
|
185
|
+
console.error(error.message);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function syncMainDatabase() {
|
|
191
|
+
console.log("Starting main database synchronization...");
|
|
192
|
+
const modelsPath = path.join(__dirname, "../models");
|
|
193
|
+
const modelFiles = fs.readdirSync(modelsPath)
|
|
194
|
+
.filter((file) => file.indexOf(".") !== 0 &&
|
|
195
|
+
file.endsWith(".cjs") &&
|
|
196
|
+
!file.endsWith(".d.cjs") &&
|
|
197
|
+
!file.endsWith(".d.cts") &&
|
|
198
|
+
file !== "index.cjs");
|
|
199
|
+
for (const file of modelFiles) {
|
|
200
|
+
const filePath = path.join(modelsPath, file);
|
|
201
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
202
|
+
try {
|
|
203
|
+
const module = await import(fileUrl);
|
|
204
|
+
const modelFactory = module.default; // Assuming the .cjs files use module.exports = ...
|
|
205
|
+
const model = modelFactory(mainSequelize, DataTypes);
|
|
206
|
+
mainDb[model.name] = model;
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
console.error(`Error importing model ${file}:`, err);
|
|
210
|
+
throw err; // Re-throw to stop the process if a model fails to load
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const acModelsPath = path.join(__dirname, "../active-citizen/models");
|
|
214
|
+
if (fs.existsSync(acModelsPath)) {
|
|
215
|
+
const acModelFiles = fs.readdirSync(acModelsPath)
|
|
216
|
+
.filter((file) => file.indexOf(".") !== 0 &&
|
|
217
|
+
file.endsWith(".cjs") &&
|
|
218
|
+
!file.endsWith(".d.cjs") &&
|
|
219
|
+
!file.endsWith(".d.cts"));
|
|
220
|
+
for (const file of acModelFiles) {
|
|
221
|
+
const filePath = path.join(acModelsPath, file);
|
|
222
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
223
|
+
try {
|
|
224
|
+
const module = await import(fileUrl);
|
|
225
|
+
const modelFactory = module.default; // Assuming the .cjs files use module.exports = ...
|
|
226
|
+
const model = modelFactory(mainSequelize, DataTypes);
|
|
227
|
+
mainDb[model.name] = model;
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
console.error(`Error importing active-citizen model ${file}:`, err);
|
|
231
|
+
throw err; // Re-throw to stop the process if a model fails to load
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
console.warn(`Directory not found, skipping active-citizen models: ${acModelsPath}`);
|
|
237
|
+
}
|
|
238
|
+
Object.keys(mainDb).forEach((modelName) => {
|
|
239
|
+
if (mainDb[modelName] && typeof mainDb[modelName].associate === "function") {
|
|
240
|
+
mainDb[modelName].associate(mainDb);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// This script is intended for creating a new database, so always force sync.
|
|
244
|
+
await mainSequelize.sync({ force: true });
|
|
245
|
+
console.log("Main database schema forcefully synchronized (tables dropped and recreated).");
|
|
246
|
+
await createMainCompoundIndexes(mainSequelize, mainCompoundIndexCommands);
|
|
247
|
+
if (mainDb.Post && typeof mainDb.Post.addFullTextIndex === "function") {
|
|
248
|
+
console.log("Adding full text index for Post model...");
|
|
249
|
+
await mainDb.Post.addFullTextIndex();
|
|
250
|
+
console.log("Full text index for Post model added.");
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
console.warn("Post model or addFullTextIndex method not found in mainDb. Skipping full text index.");
|
|
254
|
+
}
|
|
255
|
+
console.log("Main database synchronization finished.");
|
|
256
|
+
}
|
|
257
|
+
async function syncPolicySynthDatabase() {
|
|
258
|
+
console.log("Starting PolicySynth database synchronization...");
|
|
259
|
+
try {
|
|
260
|
+
// This script is intended for creating a new database, so always force sync.
|
|
261
|
+
await psSequelize.sync({ force: true });
|
|
262
|
+
console.log("PolicySynth database schema forcefully synchronized (tables dropped and recreated).");
|
|
263
|
+
console.log("Associating PolicySynth models...");
|
|
264
|
+
for (const modelName of Object.keys(psModels)) {
|
|
265
|
+
const model = psModels[modelName];
|
|
266
|
+
if (model && typeof model.associate === "function") {
|
|
267
|
+
model.associate(psSequelize.models);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
console.log("PolicySynth models associated successfully.");
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
console.error("Error during PolicySynth database synchronization:", error);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
console.log("PolicySynth database synchronization finished.");
|
|
277
|
+
}
|
|
278
|
+
async function seedAllModels() {
|
|
279
|
+
console.log("--- Starting Database Seeding and Synchronization ---");
|
|
280
|
+
console.log("NOTE: This script will forcefully synchronize the database (drop and recreate tables).");
|
|
281
|
+
console.log("NODE_ENV:", env);
|
|
282
|
+
// The following environment variables are logged for informational purposes,
|
|
283
|
+
// but this script will always force database synchronization.
|
|
284
|
+
console.log("FORCE_DB_SYNC (ignored, always true for this script):", process.env.FORCE_DB_SYNC);
|
|
285
|
+
console.log("FORCE_DB_INDEX_SYNC (ignored, indexes created after forced sync):", process.env.FORCE_DB_INDEX_SYNC);
|
|
286
|
+
const args = process.argv.slice(2);
|
|
287
|
+
if (args.length < 2) {
|
|
288
|
+
console.error("Usage: node <script_path> <username/email> <password>");
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
const userEmail = args[0].toLowerCase();
|
|
292
|
+
const userName = args[0]; // Using email as name for simplicity, or a fixed name
|
|
293
|
+
const userPassword = args[1];
|
|
294
|
+
// Check for main database config outside of production if not using DATABASE_URL
|
|
295
|
+
if (env !== "production") {
|
|
296
|
+
if (!process.env.YP_DEV_DATABASE_NAME ||
|
|
297
|
+
!process.env.YP_DEV_DATABASE_USERNAME ||
|
|
298
|
+
!process.env.YP_DEV_DATABASE_PASSWORD ||
|
|
299
|
+
!process.env.YP_DEV_DATABASE_HOST ||
|
|
300
|
+
!process.env.YP_DEV_DATABASE_PORT) {
|
|
301
|
+
console.error("Missing YP_DEV_DATABASE environment variables for main database in non-production.");
|
|
302
|
+
process.exit(1);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
if (!process.env.DATABASE_URL) {
|
|
307
|
+
console.error("Missing DATABASE_URL for production environment.");
|
|
308
|
+
process.exit(1);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
await syncMainDatabase();
|
|
313
|
+
await syncPolicySynthDatabase();
|
|
314
|
+
console.log("--- Databases Synchronized ---");
|
|
315
|
+
console.log("--- Creating User and Domain ---");
|
|
316
|
+
if (!mainDb.User) {
|
|
317
|
+
console.error("User model (mainDb.User) not found after sync.");
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
if (!mainDb.Domain) {
|
|
321
|
+
console.error("Domain model (mainDb.Domain) not found after sync.");
|
|
322
|
+
process.exit(1);
|
|
323
|
+
}
|
|
324
|
+
// Create User
|
|
325
|
+
console.log(`Attempting to create user: ${userEmail}`);
|
|
326
|
+
const newUser = mainDb.User.build({
|
|
327
|
+
email: userEmail,
|
|
328
|
+
name: userName, // Or a dedicated name argument if preferred
|
|
329
|
+
status: 'active',
|
|
330
|
+
// Attempt to set default notifications, fallback if AcNotification not on mainDb
|
|
331
|
+
notifications_settings: mainDb.AcNotification ? mainDb.AcNotification.defaultNotificationSettings : { email: true },
|
|
332
|
+
});
|
|
333
|
+
// createPasswordHash is an instance method on User model from user.cjs
|
|
334
|
+
const salt = bcrypt.genSaltSync(10);
|
|
335
|
+
newUser.encrypted_password = bcrypt.hashSync(userPassword, salt);
|
|
336
|
+
await newUser.save();
|
|
337
|
+
console.log(`User ${newUser.email} created with ID: ${newUser.id}`);
|
|
338
|
+
// Create Domain
|
|
339
|
+
const randomDomainName = crypto.randomBytes(8).toString('hex') + ".seed.local"; // Shorter and identifiable
|
|
340
|
+
console.log(`Attempting to create domain: ${randomDomainName} for user ${newUser.id}`);
|
|
341
|
+
const newDomain = mainDb.Domain.build({
|
|
342
|
+
name: `Default Domain for ${userName}`,
|
|
343
|
+
domain_name: randomDomainName,
|
|
344
|
+
access: mainDb.Domain.ACCESS_PUBLIC !== undefined ? mainDb.Domain.ACCESS_PUBLIC : 0, // Use constant if available
|
|
345
|
+
default_locale: "en",
|
|
346
|
+
ip_address: "::1",
|
|
347
|
+
user_agent: "seedModelsScript/1.0",
|
|
348
|
+
user_id: newUser.id, // Associate domain with the new user
|
|
349
|
+
configuration: {},
|
|
350
|
+
// Fill other required non-nullable fields based on domain.cjs definition if any
|
|
351
|
+
// deleted: false, (already defaults to false)
|
|
352
|
+
});
|
|
353
|
+
await newDomain.save();
|
|
354
|
+
console.log(`Domain ${newDomain.name} created with ID: ${newDomain.id} and domain_name: ${newDomain.domain_name}`);
|
|
355
|
+
// Associate User with Domain
|
|
356
|
+
if (typeof newDomain.addDomainUsers === 'function') {
|
|
357
|
+
await newDomain.addDomainUsers(newUser);
|
|
358
|
+
console.log(`User ${newUser.email} added to domain ${newDomain.domain_name} as a user.`);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
console.warn(`newDomain.addDomainUsers is not a function. Skipping adding user to domain users.`);
|
|
362
|
+
}
|
|
363
|
+
if (typeof newDomain.addDomainAdmins === 'function') {
|
|
364
|
+
await newDomain.addDomainAdmins(newUser);
|
|
365
|
+
console.log(`User ${newUser.email} added to domain ${newDomain.domain_name} as an admin.`);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
console.warn(`newDomain.addDomainAdmins is not a function. Skipping adding user to domain admins.`);
|
|
369
|
+
}
|
|
370
|
+
console.log("--- User and Domain Creation Complete ---");
|
|
371
|
+
console.log("--- All model seeding and synchronization complete. ---");
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
console.error("Unhandled error during seeding process:", error);
|
|
375
|
+
process.exit(1);
|
|
376
|
+
}
|
|
377
|
+
finally {
|
|
378
|
+
console.log("Closing database connections...");
|
|
379
|
+
await mainSequelize.close();
|
|
380
|
+
await psSequelize.close();
|
|
381
|
+
console.log("Database connections closed.");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
seedAllModels().catch((error) => {
|
|
385
|
+
console.error("Fatal error running seedAllModels:", error);
|
|
386
|
+
process.exit(1);
|
|
387
|
+
});
|
|
388
|
+
export { seedAllModels }; // Export if you plan to import and run this elsewhere
|