@openpeepshq/core 0.1.31
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/LICENSE +674 -0
- package/dist/accessTokens/finders.d.ts +11 -0
- package/dist/accessTokens/finders.js +43 -0
- package/dist/accessTokens/helpers.d.ts +13 -0
- package/dist/accessTokens/helpers.js +15 -0
- package/dist/accessTokens/index.d.ts +4 -0
- package/dist/accessTokens/index.js +4 -0
- package/dist/accessTokens/mapping.d.ts +10 -0
- package/dist/accessTokens/mapping.js +25 -0
- package/dist/accessTokens/mutations.d.ts +4 -0
- package/dist/accessTokens/mutations.js +24 -0
- package/dist/accessTokens/revokations.d.ts +2 -0
- package/dist/accessTokens/revokations.js +18 -0
- package/dist/accessTokens/tokens.d.ts +31 -0
- package/dist/accessTokens/tokens.js +174 -0
- package/dist/accounts/cache.d.ts +3 -0
- package/dist/accounts/cache.js +13 -0
- package/dist/accounts/finders.d.ts +6 -0
- package/dist/accounts/finders.js +17 -0
- package/dist/accounts/helpers.d.ts +7 -0
- package/dist/accounts/helpers.js +36 -0
- package/dist/accounts/index.d.ts +6 -0
- package/dist/accounts/index.js +6 -0
- package/dist/accounts/mapping.d.ts +10 -0
- package/dist/accounts/mapping.js +28 -0
- package/dist/accounts/mutations.d.ts +21 -0
- package/dist/accounts/mutations.js +204 -0
- package/dist/analytics/cache.d.ts +6 -0
- package/dist/analytics/cache.js +29 -0
- package/dist/analytics/compile.d.ts +4 -0
- package/dist/analytics/compile.js +296 -0
- package/dist/analytics/dateRange.d.ts +39 -0
- package/dist/analytics/dateRange.js +181 -0
- package/dist/analytics/index.d.ts +8 -0
- package/dist/analytics/index.js +8 -0
- package/dist/analytics/jobs.d.ts +20 -0
- package/dist/analytics/jobs.js +84 -0
- package/dist/analytics/metrics.d.ts +4 -0
- package/dist/analytics/metrics.js +13 -0
- package/dist/analytics/pdfReport.d.ts +8 -0
- package/dist/analytics/pdfReport.js +821 -0
- package/dist/analytics/read.d.ts +6 -0
- package/dist/analytics/read.js +696 -0
- package/dist/analytics/report.d.ts +293 -0
- package/dist/analytics/report.js +153 -0
- package/dist/analytics/settings.d.ts +3 -0
- package/dist/analytics/settings.js +37 -0
- package/dist/backups/index.d.ts +5 -0
- package/dist/backups/index.js +260 -0
- package/dist/backups/metadata.d.ts +9 -0
- package/dist/backups/metadata.js +2 -0
- package/dist/config/db.d.ts +7 -0
- package/dist/config/db.js +26 -0
- package/dist/config/defaults/capabilities.d.ts +2 -0
- package/dist/config/defaults/capabilities.js +47 -0
- package/dist/config/defaults/community.d.ts +2 -0
- package/dist/config/defaults/community.js +41 -0
- package/dist/config/defaults/core.d.ts +2 -0
- package/dist/config/defaults/core.js +113 -0
- package/dist/config/defaults/db.d.ts +6 -0
- package/dist/config/defaults/db.js +8 -0
- package/dist/config/defaults/logs.d.ts +6 -0
- package/dist/config/defaults/logs.js +7 -0
- package/dist/config/defaults/redis.d.ts +4 -0
- package/dist/config/defaults/redis.js +5 -0
- package/dist/config/helpers.d.ts +11 -0
- package/dist/config/helpers.js +31 -0
- package/dist/config/index.d.ts +392 -0
- package/dist/config/index.js +83 -0
- package/dist/config/pruneEmptyConfigStrings.d.ts +7 -0
- package/dist/config/pruneEmptyConfigStrings.js +29 -0
- package/dist/db/aql.d.ts +0 -0
- package/dist/db/aql.js +1 -0
- package/dist/db/arango.d.ts +2 -0
- package/dist/db/arango.js +110 -0
- package/dist/db/bootMigrate.d.ts +1 -0
- package/dist/db/bootMigrate.js +15 -0
- package/dist/db/examples.d.ts +1 -0
- package/dist/db/examples.js +13 -0
- package/dist/db/explorer/csv.d.ts +1 -0
- package/dist/db/explorer/csv.js +18 -0
- package/dist/db/explorer/index.d.ts +6 -0
- package/dist/db/explorer/index.js +5 -0
- package/dist/db/explorer/mutate.d.ts +6 -0
- package/dist/db/explorer/mutate.js +66 -0
- package/dist/db/explorer/query.d.ts +17 -0
- package/dist/db/explorer/query.js +48 -0
- package/dist/db/explorer/sql.d.ts +11 -0
- package/dist/db/explorer/sql.js +42 -0
- package/dist/db/explorer/tables.d.ts +9 -0
- package/dist/db/explorer/tables.js +65 -0
- package/dist/db/helpers.d.ts +64 -0
- package/dist/db/helpers.js +240 -0
- package/dist/db/index.d.ts +13 -0
- package/dist/db/index.js +15 -0
- package/dist/db/init.d.ts +2 -0
- package/dist/db/init.js +10 -0
- package/dist/db/migration/autoMigrate.d.ts +2 -0
- package/dist/db/migration/autoMigrate.js +111 -0
- package/dist/db/migration/cli.d.ts +1 -0
- package/dist/db/migration/cli.js +56 -0
- package/dist/db/migration/detect.d.ts +6 -0
- package/dist/db/migration/detect.js +87 -0
- package/dist/db/migration/exportArango.d.ts +4 -0
- package/dist/db/migration/exportArango.js +80 -0
- package/dist/db/migration/importCollections.d.ts +19 -0
- package/dist/db/migration/importCollections.js +280 -0
- package/dist/db/migration/importPostgres.d.ts +3 -0
- package/dist/db/migration/importPostgres.js +18 -0
- package/dist/db/migration/shared.d.ts +39 -0
- package/dist/db/migration/shared.js +158 -0
- package/dist/db/migration/transform.d.ts +18 -0
- package/dist/db/migration/transform.js +209 -0
- package/dist/db/migration/validate.d.ts +18 -0
- package/dist/db/migration/validate.js +69 -0
- package/dist/db/pg/client.d.ts +35 -0
- package/dist/db/pg/client.js +126 -0
- package/dist/db/pg/collections.d.ts +48 -0
- package/dist/db/pg/collections.js +53 -0
- package/dist/db/pg/filters/common.d.ts +21 -0
- package/dist/db/pg/filters/common.js +48 -0
- package/dist/db/pg/filters/edges.d.ts +9 -0
- package/dist/db/pg/filters/edges.js +10 -0
- package/dist/db/pg/filters/groups.d.ts +7 -0
- package/dist/db/pg/filters/groups.js +15 -0
- package/dist/db/pg/filters/index.d.ts +22 -0
- package/dist/db/pg/filters/index.js +35 -0
- package/dist/db/pg/filters/notifications.d.ts +6 -0
- package/dist/db/pg/filters/notifications.js +10 -0
- package/dist/db/pg/filters/posts.d.ts +18 -0
- package/dist/db/pg/filters/posts.js +25 -0
- package/dist/db/pg/filters/profiles.d.ts +6 -0
- package/dist/db/pg/filters/profiles.js +9 -0
- package/dist/db/pg/filters/types.d.ts +7 -0
- package/dist/db/pg/filters/types.js +5 -0
- package/dist/db/pg/helpers.d.ts +19 -0
- package/dist/db/pg/helpers.js +67 -0
- package/dist/db/pg/map/filters.d.ts +22 -0
- package/dist/db/pg/map/filters.js +566 -0
- package/dist/db/pg/map/helpers.d.ts +2 -0
- package/dist/db/pg/map/helpers.js +2 -0
- package/dist/db/pg/map/index.d.ts +46 -0
- package/dist/db/pg/map/index.js +93 -0
- package/dist/db/pg/map/mutations.d.ts +11 -0
- package/dist/db/pg/map/mutations.js +135 -0
- package/dist/db/pg/map/queryTypes.d.ts +115 -0
- package/dist/db/pg/map/queryTypes.js +1 -0
- package/dist/db/pg/map/registry.d.ts +29 -0
- package/dist/db/pg/map/registry.js +413 -0
- package/dist/db/pg/map/relations.d.ts +28 -0
- package/dist/db/pg/map/relations.js +399 -0
- package/dist/db/pg/map/search.d.ts +6 -0
- package/dist/db/pg/map/search.js +190 -0
- package/dist/db/pg/map/types.d.ts +11 -0
- package/dist/db/pg/map/types.js +1 -0
- package/dist/db/pg/mappers.d.ts +28 -0
- package/dist/db/pg/mappers.js +29 -0
- package/dist/db/pg/migrate.d.ts +14 -0
- package/dist/db/pg/migrate.js +134 -0
- package/dist/db/pg/queries/activity.d.ts +10 -0
- package/dist/db/pg/queries/activity.js +47 -0
- package/dist/db/pg/queries/computed.d.ts +7 -0
- package/dist/db/pg/queries/computed.js +19 -0
- package/dist/db/pg/queries/derived.d.ts +22 -0
- package/dist/db/pg/queries/derived.js +100 -0
- package/dist/db/pg/queries/index.d.ts +4 -0
- package/dist/db/pg/queries/index.js +4 -0
- package/dist/db/pg/queries/sorts.d.ts +10 -0
- package/dist/db/pg/queries/sorts.js +9 -0
- package/dist/db/pg/schema/analytics.d.ts +998 -0
- package/dist/db/pg/schema/analytics.js +110 -0
- package/dist/db/pg/schema/base.d.ts +36 -0
- package/dist/db/pg/schema/base.js +23 -0
- package/dist/db/pg/schema/documents.d.ts +2002 -0
- package/dist/db/pg/schema/documents.js +40 -0
- package/dist/db/pg/schema/edges.d.ts +2725 -0
- package/dist/db/pg/schema/edges.js +34 -0
- package/dist/db/pg/schema/index.d.ts +5724 -0
- package/dist/db/pg/schema/index.js +7 -0
- package/dist/db/pg/sql/0000_bizarre_chat.sql +456 -0
- package/dist/db/pg/sql/0001_search_vector.sql +122 -0
- package/dist/db/pg/sql/0002_data_migrations_id_text.sql +1 -0
- package/dist/db/pg/sql/0003_fix_group_post_visibility.sql +4 -0
- package/dist/db/pg/sql/0004_analytics.sql +90 -0
- package/dist/db/pg/sql/meta/0000_snapshot.json +3380 -0
- package/dist/db/pg/sql/meta/0004_snapshot.json +4114 -0
- package/dist/db/pg/sql/meta/_journal.json +41 -0
- package/dist/db/replaceHostname.d.ts +1 -0
- package/dist/db/replaceHostname.js +88 -0
- package/dist/db/types.d.ts +17 -0
- package/dist/db/types.js +1 -0
- package/dist/email/index.d.ts +9 -0
- package/dist/email/index.js +19 -0
- package/dist/email/jobs.d.ts +3 -0
- package/dist/email/jobs.js +13 -0
- package/dist/email/queueStats.d.ts +2 -0
- package/dist/email/queueStats.js +27 -0
- package/dist/email/registry.d.ts +3 -0
- package/dist/email/registry.js +4 -0
- package/dist/email/render.d.ts +8 -0
- package/dist/email/render.js +34 -0
- package/dist/email/send.d.ts +9 -0
- package/dist/email/send.js +97 -0
- package/dist/email/smtpTest.d.ts +2 -0
- package/dist/email/smtpTest.js +26 -0
- package/dist/errors/index.d.ts +8 -0
- package/dist/errors/index.js +13 -0
- package/dist/events/index.d.ts +31 -0
- package/dist/events/index.js +66 -0
- package/dist/events/once.d.ts +4 -0
- package/dist/events/once.js +23 -0
- package/dist/groups/finders.d.ts +125 -0
- package/dist/groups/finders.js +18 -0
- package/dist/groups/helpers.d.ts +227 -0
- package/dist/groups/helpers.js +17 -0
- package/dist/groups/index.d.ts +3 -0
- package/dist/groups/index.js +3 -0
- package/dist/groups/mapping.d.ts +188 -0
- package/dist/groups/mapping.js +47 -0
- package/dist/groups/mutations.d.ts +26 -0
- package/dist/groups/mutations.js +41 -0
- package/dist/hashtags/finders.d.ts +3 -0
- package/dist/hashtags/finders.js +22 -0
- package/dist/hashtags/index.d.ts +2 -0
- package/dist/hashtags/index.js +2 -0
- package/dist/hashtags/mapping.d.ts +4 -0
- package/dist/hashtags/mapping.js +5 -0
- package/dist/hashtags/mutations.d.ts +0 -0
- package/dist/hashtags/mutations.js +1 -0
- package/dist/i18n/index.d.ts +14 -0
- package/dist/i18n/index.js +53 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -0
- package/dist/inviteLinks/finders.d.ts +3 -0
- package/dist/inviteLinks/finders.js +5 -0
- package/dist/inviteLinks/helpers.d.ts +20 -0
- package/dist/inviteLinks/helpers.js +4 -0
- package/dist/inviteLinks/index.d.ts +3 -0
- package/dist/inviteLinks/index.js +3 -0
- package/dist/inviteLinks/mapping.d.ts +10 -0
- package/dist/inviteLinks/mapping.js +35 -0
- package/dist/inviteLinks/mutations.d.ts +4 -0
- package/dist/inviteLinks/mutations.js +39 -0
- package/dist/jams/cache.d.ts +9 -0
- package/dist/jams/cache.js +13 -0
- package/dist/jams/finders.d.ts +23 -0
- package/dist/jams/finders.js +24 -0
- package/dist/jams/helpers.d.ts +70 -0
- package/dist/jams/helpers.js +29 -0
- package/dist/jams/index.d.ts +15 -0
- package/dist/jams/index.js +108 -0
- package/dist/jams/jobs.d.ts +9 -0
- package/dist/jams/jobs.js +42 -0
- package/dist/jams/livekit.d.ts +24 -0
- package/dist/jams/livekit.js +220 -0
- package/dist/jams/mapping.d.ts +137 -0
- package/dist/jams/mapping.js +35 -0
- package/dist/jams/mutations.d.ts +40 -0
- package/dist/jams/mutations.js +4 -0
- package/dist/jams/recording.d.ts +8 -0
- package/dist/jams/recording.js +67 -0
- package/dist/jams/recordingUploadAuth.d.ts +9 -0
- package/dist/jams/recordingUploadAuth.js +19 -0
- package/dist/jams/token.d.ts +4 -0
- package/dist/jams/token.js +129 -0
- package/dist/jams/waitingRoom.d.ts +5 -0
- package/dist/jams/waitingRoom.js +71 -0
- package/dist/jobs/index.d.ts +10 -0
- package/dist/jobs/index.js +60 -0
- package/dist/jobs/jobDetail.d.ts +2 -0
- package/dist/jobs/jobDetail.js +31 -0
- package/dist/jobs/jobLog.d.ts +18 -0
- package/dist/jobs/jobLog.js +61 -0
- package/dist/jwt/index.d.ts +10 -0
- package/dist/jwt/index.js +43 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/streams.d.ts +2 -0
- package/dist/lib/streams.js +56 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +17 -0
- package/dist/lib/zodDeepPartial.d.ts +3 -0
- package/dist/lib/zodDeepPartial.js +26 -0
- package/dist/location/index.d.ts +2 -0
- package/dist/location/index.js +28 -0
- package/dist/log/index.d.ts +3 -0
- package/dist/log/index.js +97 -0
- package/dist/mastodon/index.d.ts +4 -0
- package/dist/mastodon/index.js +51 -0
- package/dist/mastodon/types.d.ts +7579 -0
- package/dist/mastodon/types.js +523 -0
- package/dist/mastodon/typescript.d.ts +1578 -0
- package/dist/mastodon/typescript.js +1 -0
- package/dist/media/index.d.ts +40 -0
- package/dist/media/index.js +248 -0
- package/dist/media/ipfs/index.d.ts +0 -0
- package/dist/media/ipfs/index.js +39 -0
- package/dist/media/jobs.d.ts +19 -0
- package/dist/media/jobs.js +90 -0
- package/dist/media/openpeeps/index.d.ts +3 -0
- package/dist/media/openpeeps/index.js +131 -0
- package/dist/media/processing.d.ts +19 -0
- package/dist/media/processing.js +83 -0
- package/dist/media/streaming.d.ts +77 -0
- package/dist/media/streaming.js +257 -0
- package/dist/media/streamingCleanupJobs.d.ts +14 -0
- package/dist/media/streamingCleanupJobs.js +47 -0
- package/dist/media/streamingJobs.d.ts +5 -0
- package/dist/media/streamingJobs.js +329 -0
- package/dist/media/streamingPrewarm.d.ts +36 -0
- package/dist/media/streamingPrewarm.js +109 -0
- package/dist/mediaAttachments/finders.d.ts +1 -0
- package/dist/mediaAttachments/finders.js +3 -0
- package/dist/mediaAttachments/index.d.ts +5 -0
- package/dist/mediaAttachments/index.js +12 -0
- package/dist/mediaAttachments/mapping.d.ts +21 -0
- package/dist/mediaAttachments/mapping.js +4 -0
- package/dist/mediaAttachments/mutations.d.ts +3 -0
- package/dist/mediaAttachments/mutations.js +10 -0
- package/dist/notifications/defaultNotifications/announcement/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/announcement/index.js +42 -0
- package/dist/notifications/defaultNotifications/directMessage/index.d.ts +28 -0
- package/dist/notifications/defaultNotifications/directMessage/index.js +69 -0
- package/dist/notifications/defaultNotifications/follow/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/follow/index.js +31 -0
- package/dist/notifications/defaultNotifications/groupAdded/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/groupAdded/index.js +33 -0
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +36 -0
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +36 -0
- package/dist/notifications/defaultNotifications/index.d.ts +3 -0
- package/dist/notifications/defaultNotifications/index.js +43 -0
- package/dist/notifications/defaultNotifications/jamModerator/index.d.ts +23 -0
- package/dist/notifications/defaultNotifications/jamModerator/index.js +49 -0
- package/dist/notifications/defaultNotifications/jamSpeaker/index.d.ts +23 -0
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +47 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.js +82 -0
- package/dist/notifications/defaultNotifications/mention/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/mention/index.js +89 -0
- package/dist/notifications/defaultNotifications/newGroupPost/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +47 -0
- package/dist/notifications/defaultNotifications/newProfile/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/newProfile/index.js +40 -0
- package/dist/notifications/defaultNotifications/pollVote/index.d.ts +19 -0
- package/dist/notifications/defaultNotifications/pollVote/index.js +40 -0
- package/dist/notifications/defaultNotifications/reaction/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/reaction/index.js +43 -0
- package/dist/notifications/defaultNotifications/reply/index.d.ts +25 -0
- package/dist/notifications/defaultNotifications/reply/index.js +57 -0
- package/dist/notifications/defaultNotifications/repost/index.d.ts +18 -0
- package/dist/notifications/defaultNotifications/repost/index.js +42 -0
- package/dist/notifications/defaultNotifications/rsvp/index.d.ts +19 -0
- package/dist/notifications/defaultNotifications/rsvp/index.js +40 -0
- package/dist/notifications/fcmCredential.d.ts +14 -0
- package/dist/notifications/fcmCredential.js +68 -0
- package/dist/notifications/finders.d.ts +7 -0
- package/dist/notifications/finders.js +13 -0
- package/dist/notifications/firebase.d.ts +1 -0
- package/dist/notifications/firebase.js +33 -0
- package/dist/notifications/handlers.d.ts +3 -0
- package/dist/notifications/handlers.js +6 -0
- package/dist/notifications/helpers.d.ts +7 -0
- package/dist/notifications/helpers.js +31 -0
- package/dist/notifications/index.d.ts +9 -0
- package/dist/notifications/index.js +43 -0
- package/dist/notifications/jobs.d.ts +2 -0
- package/dist/notifications/jobs.js +75 -0
- package/dist/notifications/mapping.d.ts +25 -0
- package/dist/notifications/mapping.js +25 -0
- package/dist/notifications/mutations.d.ts +6 -0
- package/dist/notifications/mutations.js +40 -0
- package/dist/notifications/push.d.ts +9 -0
- package/dist/notifications/push.js +261 -0
- package/dist/notifications/pushInvalidation.d.ts +10 -0
- package/dist/notifications/pushInvalidation.js +10 -0
- package/dist/performance/index.d.ts +24 -0
- package/dist/performance/index.js +61 -0
- package/dist/plugins/helpers.d.ts +3 -0
- package/dist/plugins/helpers.js +72 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.js +84 -0
- package/dist/plugins/pluginAuth.d.ts +30 -0
- package/dist/plugins/pluginAuth.js +44 -0
- package/dist/posts/contextClosure.d.ts +16 -0
- package/dist/posts/contextClosure.js +66 -0
- package/dist/posts/finders.d.ts +298 -0
- package/dist/posts/finders.js +259 -0
- package/dist/posts/helpers/filters.d.ts +14 -0
- package/dist/posts/helpers/filters.js +39 -0
- package/dist/posts/helpers/index.d.ts +837 -0
- package/dist/posts/helpers/index.js +117 -0
- package/dist/posts/index.d.ts +6 -0
- package/dist/posts/index.js +6 -0
- package/dist/posts/mapping.d.ts +2187 -0
- package/dist/posts/mapping.js +222 -0
- package/dist/posts/mutations.d.ts +19 -0
- package/dist/posts/mutations.js +202 -0
- package/dist/posts/rsvpConfirmationEmail.d.ts +2 -0
- package/dist/posts/rsvpConfirmationEmail.js +82 -0
- package/dist/processingStats/index.d.ts +3 -0
- package/dist/processingStats/index.js +3 -0
- package/dist/processingStats/mapping.d.ts +7 -0
- package/dist/processingStats/mapping.js +4 -0
- package/dist/processingStats/mutations.d.ts +2 -0
- package/dist/processingStats/mutations.js +6 -0
- package/dist/processingStats/queries.d.ts +4 -0
- package/dist/processingStats/queries.js +46 -0
- package/dist/profileSettings/cache.d.ts +2 -0
- package/dist/profileSettings/cache.js +24 -0
- package/dist/profileSettings/finders.d.ts +1 -0
- package/dist/profileSettings/finders.js +2 -0
- package/dist/profileSettings/index.d.ts +3 -0
- package/dist/profileSettings/index.js +3 -0
- package/dist/profileSettings/mapping.d.ts +38 -0
- package/dist/profileSettings/mapping.js +5 -0
- package/dist/profileSettings/mutations.d.ts +3 -0
- package/dist/profileSettings/mutations.js +24 -0
- package/dist/profiles/cache.d.ts +5 -0
- package/dist/profiles/cache.js +19 -0
- package/dist/profiles/capacity.d.ts +2 -0
- package/dist/profiles/capacity.js +20 -0
- package/dist/profiles/export.d.ts +3 -0
- package/dist/profiles/export.js +85 -0
- package/dist/profiles/finders.d.ts +11 -0
- package/dist/profiles/finders.js +39 -0
- package/dist/profiles/helpers.d.ts +35 -0
- package/dist/profiles/helpers.js +10 -0
- package/dist/profiles/index.d.ts +5 -0
- package/dist/profiles/index.js +18 -0
- package/dist/profiles/mapping.d.ts +157 -0
- package/dist/profiles/mapping.js +132 -0
- package/dist/profiles/mutations.d.ts +9 -0
- package/dist/profiles/mutations.js +75 -0
- package/dist/pushSubscriptions/finders.d.ts +187 -0
- package/dist/pushSubscriptions/finders.js +6 -0
- package/dist/pushSubscriptions/helpers.d.ts +99 -0
- package/dist/pushSubscriptions/helpers.js +3 -0
- package/dist/pushSubscriptions/index.d.ts +3 -0
- package/dist/pushSubscriptions/index.js +3 -0
- package/dist/pushSubscriptions/mapping.d.ts +261 -0
- package/dist/pushSubscriptions/mapping.js +6 -0
- package/dist/pushSubscriptions/mutations.d.ts +95 -0
- package/dist/pushSubscriptions/mutations.js +21 -0
- package/dist/redis/connection.d.ts +4 -0
- package/dist/redis/connection.js +17 -0
- package/dist/redis/index.d.ts +1 -0
- package/dist/redis/index.js +1 -0
- package/dist/reports/finders.d.ts +6 -0
- package/dist/reports/finders.js +44 -0
- package/dist/reports/helpers.d.ts +21 -0
- package/dist/reports/helpers.js +12 -0
- package/dist/reports/index.d.ts +3 -0
- package/dist/reports/index.js +3 -0
- package/dist/reports/mapping.d.ts +9 -0
- package/dist/reports/mapping.js +34 -0
- package/dist/reports/mutations.d.ts +5 -0
- package/dist/reports/mutations.js +16 -0
- package/dist/roles/defaults.d.ts +2 -0
- package/dist/roles/defaults.js +94 -0
- package/dist/roles/finders.d.ts +5 -0
- package/dist/roles/finders.js +9 -0
- package/dist/roles/index.d.ts +4 -0
- package/dist/roles/index.js +4 -0
- package/dist/roles/mapping.d.ts +11 -0
- package/dist/roles/mapping.js +5 -0
- package/dist/roles/mutations.d.ts +4 -0
- package/dist/roles/mutations.js +30 -0
- package/dist/search/finders.d.ts +47 -0
- package/dist/search/finders.js +59 -0
- package/dist/search/helpers.d.ts +3 -0
- package/dist/search/helpers.js +1 -0
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.js +1 -0
- package/dist/search/mapping.d.ts +40 -0
- package/dist/search/mapping.js +43 -0
- package/dist/sentry/index.d.ts +34 -0
- package/dist/sentry/index.js +113 -0
- package/dist/server/helpers.d.ts +0 -0
- package/dist/server/helpers.js +1 -0
- package/dist/server/index.d.ts +105 -0
- package/dist/server/index.js +64 -0
- package/dist/stats/finders.d.ts +16156 -0
- package/dist/stats/finders.js +167 -0
- package/dist/stats/helpers.d.ts +17 -0
- package/dist/stats/helpers.js +34 -0
- package/dist/stats/index.d.ts +1 -0
- package/dist/stats/index.js +1 -0
- package/dist/stats/mapping.d.ts +188 -0
- package/dist/stats/mapping.js +19 -0
- package/dist/stripe/cache.d.ts +30 -0
- package/dist/stripe/cache.js +37 -0
- package/dist/stripe/connection.d.ts +5 -0
- package/dist/stripe/connection.js +23 -0
- package/dist/stripe/helpers.d.ts +25 -0
- package/dist/stripe/helpers.js +211 -0
- package/dist/stripe/index.d.ts +3 -0
- package/dist/stripe/index.js +3 -0
- package/package.json +99 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { AnalyticsDateQuery } from '@openpeepshq/common/types';
|
|
2
|
+
/** Board-ready report: plain-text email body + visual multi-page PDF. */
|
|
3
|
+
export declare const buildAnalyticsBoardReport: (query?: AnalyticsDateQuery) => Promise<{
|
|
4
|
+
text: string;
|
|
5
|
+
pdf: Buffer<ArrayBufferLike>;
|
|
6
|
+
overview: {
|
|
7
|
+
range: {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
previousFrom: string;
|
|
11
|
+
previousTo: string;
|
|
12
|
+
compiledAt: string | null;
|
|
13
|
+
preset?: "all" | "7d" | "30d" | "3m" | "6m" | "12m" | undefined;
|
|
14
|
+
};
|
|
15
|
+
metrics: {
|
|
16
|
+
totalPosts: {
|
|
17
|
+
key: string;
|
|
18
|
+
value: number;
|
|
19
|
+
previousValue: number;
|
|
20
|
+
deltaPct: number | null;
|
|
21
|
+
series?: {
|
|
22
|
+
day: string;
|
|
23
|
+
value: number;
|
|
24
|
+
}[] | undefined;
|
|
25
|
+
};
|
|
26
|
+
allTimePosts: {
|
|
27
|
+
key: string;
|
|
28
|
+
value: number;
|
|
29
|
+
previousValue: number;
|
|
30
|
+
deltaPct: number | null;
|
|
31
|
+
series?: {
|
|
32
|
+
day: string;
|
|
33
|
+
value: number;
|
|
34
|
+
}[] | undefined;
|
|
35
|
+
};
|
|
36
|
+
totalMembers: {
|
|
37
|
+
key: string;
|
|
38
|
+
value: number;
|
|
39
|
+
previousValue: number;
|
|
40
|
+
deltaPct: number | null;
|
|
41
|
+
series?: {
|
|
42
|
+
day: string;
|
|
43
|
+
value: number;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
};
|
|
46
|
+
activeMembers: {
|
|
47
|
+
key: string;
|
|
48
|
+
value: number;
|
|
49
|
+
previousValue: number;
|
|
50
|
+
deltaPct: number | null;
|
|
51
|
+
series?: {
|
|
52
|
+
day: string;
|
|
53
|
+
value: number;
|
|
54
|
+
}[] | undefined;
|
|
55
|
+
};
|
|
56
|
+
totalGroups: {
|
|
57
|
+
key: string;
|
|
58
|
+
value: number;
|
|
59
|
+
previousValue: number;
|
|
60
|
+
deltaPct: number | null;
|
|
61
|
+
series?: {
|
|
62
|
+
day: string;
|
|
63
|
+
value: number;
|
|
64
|
+
}[] | undefined;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
postsOverTime: {
|
|
68
|
+
day: string;
|
|
69
|
+
label: string;
|
|
70
|
+
jam: number;
|
|
71
|
+
article: number;
|
|
72
|
+
note: number;
|
|
73
|
+
poll: number;
|
|
74
|
+
event: number;
|
|
75
|
+
}[];
|
|
76
|
+
postTypes: {
|
|
77
|
+
type: "jam" | "poll" | "note" | "event" | "article";
|
|
78
|
+
count: number;
|
|
79
|
+
}[];
|
|
80
|
+
activeUsersSeries: {
|
|
81
|
+
day: string;
|
|
82
|
+
label: string;
|
|
83
|
+
value: number;
|
|
84
|
+
}[];
|
|
85
|
+
topMembers: {
|
|
86
|
+
profileId: string;
|
|
87
|
+
handle: string;
|
|
88
|
+
joinedAt: string;
|
|
89
|
+
contributions: number;
|
|
90
|
+
displayName?: string | undefined;
|
|
91
|
+
role?: string | undefined;
|
|
92
|
+
}[];
|
|
93
|
+
topPosts: {
|
|
94
|
+
postId: string;
|
|
95
|
+
uniqueViewers: number;
|
|
96
|
+
snippet?: string | undefined;
|
|
97
|
+
authorHandle?: string | undefined;
|
|
98
|
+
authorDisplayName?: string | undefined;
|
|
99
|
+
postType?: string | undefined;
|
|
100
|
+
likes?: number | undefined;
|
|
101
|
+
comments?: number | undefined;
|
|
102
|
+
reposts?: number | undefined;
|
|
103
|
+
viewEvents?: number | undefined;
|
|
104
|
+
}[];
|
|
105
|
+
activitySeries: {
|
|
106
|
+
day: string;
|
|
107
|
+
value: number;
|
|
108
|
+
}[];
|
|
109
|
+
engagementRateSeries: {
|
|
110
|
+
day: string;
|
|
111
|
+
value: number;
|
|
112
|
+
}[];
|
|
113
|
+
topGroups: {
|
|
114
|
+
groupId: string;
|
|
115
|
+
posts: number;
|
|
116
|
+
likes: number;
|
|
117
|
+
comments: number;
|
|
118
|
+
uniqueViewers: number;
|
|
119
|
+
activity: number;
|
|
120
|
+
visibility: "public" | "private";
|
|
121
|
+
members: number;
|
|
122
|
+
activeMembers: number;
|
|
123
|
+
engagementRate: number;
|
|
124
|
+
growth: number;
|
|
125
|
+
dailyVisits: number;
|
|
126
|
+
handle?: string | undefined;
|
|
127
|
+
name?: string | undefined;
|
|
128
|
+
}[];
|
|
129
|
+
groupGrowthSeries: {
|
|
130
|
+
key: string;
|
|
131
|
+
groupId: string;
|
|
132
|
+
name: string;
|
|
133
|
+
}[];
|
|
134
|
+
groupGrowthOverTime: {
|
|
135
|
+
day: string;
|
|
136
|
+
label: string;
|
|
137
|
+
values: Record<string, number>;
|
|
138
|
+
}[];
|
|
139
|
+
};
|
|
140
|
+
growth: {
|
|
141
|
+
range: {
|
|
142
|
+
from: string;
|
|
143
|
+
to: string;
|
|
144
|
+
previousFrom: string;
|
|
145
|
+
previousTo: string;
|
|
146
|
+
compiledAt: string | null;
|
|
147
|
+
preset?: "all" | "7d" | "30d" | "3m" | "6m" | "12m" | undefined;
|
|
148
|
+
};
|
|
149
|
+
metrics: {
|
|
150
|
+
newSignups: {
|
|
151
|
+
key: string;
|
|
152
|
+
value: number;
|
|
153
|
+
previousValue: number;
|
|
154
|
+
deltaPct: number | null;
|
|
155
|
+
series?: {
|
|
156
|
+
day: string;
|
|
157
|
+
value: number;
|
|
158
|
+
}[] | undefined;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
signupsByDay: {
|
|
162
|
+
day: string;
|
|
163
|
+
value: number;
|
|
164
|
+
}[];
|
|
165
|
+
recentSignups: {
|
|
166
|
+
profileId: string;
|
|
167
|
+
handle: string;
|
|
168
|
+
joinedAt: string;
|
|
169
|
+
channel: string;
|
|
170
|
+
displayName?: string | undefined;
|
|
171
|
+
}[];
|
|
172
|
+
};
|
|
173
|
+
engagement: {
|
|
174
|
+
range: {
|
|
175
|
+
from: string;
|
|
176
|
+
to: string;
|
|
177
|
+
previousFrom: string;
|
|
178
|
+
previousTo: string;
|
|
179
|
+
compiledAt: string | null;
|
|
180
|
+
preset?: "all" | "7d" | "30d" | "3m" | "6m" | "12m" | undefined;
|
|
181
|
+
};
|
|
182
|
+
metrics: {
|
|
183
|
+
likes: {
|
|
184
|
+
key: string;
|
|
185
|
+
value: number;
|
|
186
|
+
previousValue: number;
|
|
187
|
+
deltaPct: number | null;
|
|
188
|
+
series?: {
|
|
189
|
+
day: string;
|
|
190
|
+
value: number;
|
|
191
|
+
}[] | undefined;
|
|
192
|
+
};
|
|
193
|
+
comments: {
|
|
194
|
+
key: string;
|
|
195
|
+
value: number;
|
|
196
|
+
previousValue: number;
|
|
197
|
+
deltaPct: number | null;
|
|
198
|
+
series?: {
|
|
199
|
+
day: string;
|
|
200
|
+
value: number;
|
|
201
|
+
}[] | undefined;
|
|
202
|
+
};
|
|
203
|
+
reposts: {
|
|
204
|
+
key: string;
|
|
205
|
+
value: number;
|
|
206
|
+
previousValue: number;
|
|
207
|
+
deltaPct: number | null;
|
|
208
|
+
series?: {
|
|
209
|
+
day: string;
|
|
210
|
+
value: number;
|
|
211
|
+
}[] | undefined;
|
|
212
|
+
};
|
|
213
|
+
bookmarks: {
|
|
214
|
+
key: string;
|
|
215
|
+
value: number;
|
|
216
|
+
previousValue: number;
|
|
217
|
+
deltaPct: number | null;
|
|
218
|
+
series?: {
|
|
219
|
+
day: string;
|
|
220
|
+
value: number;
|
|
221
|
+
}[] | undefined;
|
|
222
|
+
};
|
|
223
|
+
dms: {
|
|
224
|
+
key: string;
|
|
225
|
+
value: number;
|
|
226
|
+
previousValue: number;
|
|
227
|
+
deltaPct: number | null;
|
|
228
|
+
series?: {
|
|
229
|
+
day: string;
|
|
230
|
+
value: number;
|
|
231
|
+
}[] | undefined;
|
|
232
|
+
};
|
|
233
|
+
uniqueViewers: {
|
|
234
|
+
key: string;
|
|
235
|
+
value: number;
|
|
236
|
+
previousValue: number;
|
|
237
|
+
deltaPct: number | null;
|
|
238
|
+
series?: {
|
|
239
|
+
day: string;
|
|
240
|
+
value: number;
|
|
241
|
+
}[] | undefined;
|
|
242
|
+
};
|
|
243
|
+
impressions: {
|
|
244
|
+
key: string;
|
|
245
|
+
value: number;
|
|
246
|
+
previousValue: number;
|
|
247
|
+
deltaPct: number | null;
|
|
248
|
+
series?: {
|
|
249
|
+
day: string;
|
|
250
|
+
value: number;
|
|
251
|
+
}[] | undefined;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
engagementOverTime: {
|
|
255
|
+
day: string;
|
|
256
|
+
label: string;
|
|
257
|
+
likes: number;
|
|
258
|
+
comments: number;
|
|
259
|
+
reposts: number;
|
|
260
|
+
bookmarks: number;
|
|
261
|
+
}[];
|
|
262
|
+
impressionsByPeriod: {
|
|
263
|
+
day: string;
|
|
264
|
+
label: string;
|
|
265
|
+
value: number;
|
|
266
|
+
}[];
|
|
267
|
+
postsByGroup: {
|
|
268
|
+
groupId: string;
|
|
269
|
+
posts: number;
|
|
270
|
+
likes: number;
|
|
271
|
+
comments: number;
|
|
272
|
+
uniqueViewers: number;
|
|
273
|
+
activity: number;
|
|
274
|
+
visibility: "public" | "private";
|
|
275
|
+
members: number;
|
|
276
|
+
activeMembers: number;
|
|
277
|
+
engagementRate: number;
|
|
278
|
+
growth: number;
|
|
279
|
+
dailyVisits: number;
|
|
280
|
+
handle?: string | undefined;
|
|
281
|
+
name?: string | undefined;
|
|
282
|
+
}[];
|
|
283
|
+
};
|
|
284
|
+
}>;
|
|
285
|
+
/** @deprecated Prefer buildAnalyticsBoardReport().pdf — kept for tests. */
|
|
286
|
+
export declare const buildSimplePdf: (text: string) => Buffer;
|
|
287
|
+
export declare const sendMonthlyAnalyticsReport: (overridePeriod?: {
|
|
288
|
+
from: string;
|
|
289
|
+
to: string;
|
|
290
|
+
}) => Promise<{
|
|
291
|
+
sent: boolean;
|
|
292
|
+
recipients: string[];
|
|
293
|
+
}>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { endOfMonth, formatISO, startOfMonth, subMonths } from 'date-fns';
|
|
2
|
+
import { eq } from 'drizzle-orm';
|
|
3
|
+
import { uuidv7 } from 'uuidv7';
|
|
4
|
+
import { sendEmailQueue } from '../email/index.js';
|
|
5
|
+
import { database } from '../db/index.js';
|
|
6
|
+
import { analyticsReportDeliveries } from '../db/pg/schema/analytics.js';
|
|
7
|
+
import { logger } from '../log/index.js';
|
|
8
|
+
import { buildAnalyticsPdf } from './pdfReport.js';
|
|
9
|
+
import { getAnalyticsEngagement, getAnalyticsGrowth, getAnalyticsOverview, } from './read.js';
|
|
10
|
+
import { getAnalyticsReportSettings } from './settings.js';
|
|
11
|
+
const log = logger('app:analytics:report');
|
|
12
|
+
const dayString = (d) => formatISO(d, { representation: 'date' });
|
|
13
|
+
const formatDelta = (deltaPct) => deltaPct == null ? 'n/a' : `${deltaPct > 0 ? '+' : ''}${deltaPct}%`;
|
|
14
|
+
const narrativeSentence = (label, value, deltaPct) => {
|
|
15
|
+
if (deltaPct == null) {
|
|
16
|
+
return `${label} stood at ${value} for the period.`;
|
|
17
|
+
}
|
|
18
|
+
if (deltaPct > 0) {
|
|
19
|
+
return `${label} rose to ${value} (${formatDelta(deltaPct)} vs the prior period).`;
|
|
20
|
+
}
|
|
21
|
+
if (deltaPct < 0) {
|
|
22
|
+
return `${label} was ${value} (${formatDelta(deltaPct)} vs the prior period).`;
|
|
23
|
+
}
|
|
24
|
+
return `${label} held steady at ${value} versus the prior period.`;
|
|
25
|
+
};
|
|
26
|
+
/** Board-ready report: plain-text email body + visual multi-page PDF. */
|
|
27
|
+
export const buildAnalyticsBoardReport = async (query = {}) => {
|
|
28
|
+
const [overview, growth, engagement] = await Promise.all([
|
|
29
|
+
getAnalyticsOverview(query),
|
|
30
|
+
getAnalyticsGrowth(query),
|
|
31
|
+
getAnalyticsEngagement(query),
|
|
32
|
+
]);
|
|
33
|
+
const from = overview.range.from;
|
|
34
|
+
const to = overview.range.to;
|
|
35
|
+
const total = overview.metrics.totalMembers.value;
|
|
36
|
+
const active = overview.metrics.activeMembers.value;
|
|
37
|
+
const activeShare = total > 0 ? Math.round((active / total) * 1000) / 10 : 0;
|
|
38
|
+
const summary = [
|
|
39
|
+
`Executive summary (${from} → ${to})`,
|
|
40
|
+
'',
|
|
41
|
+
narrativeSentence('Total membership', overview.metrics.totalMembers.value, overview.metrics.totalMembers.deltaPct),
|
|
42
|
+
narrativeSentence('Active members', overview.metrics.activeMembers.value, overview.metrics.activeMembers.deltaPct),
|
|
43
|
+
`${activeShare}% of members were active in this period.`,
|
|
44
|
+
narrativeSentence('Posts published', overview.metrics.totalPosts.value, overview.metrics.totalPosts.deltaPct),
|
|
45
|
+
narrativeSentence('Groups', overview.metrics.totalGroups.value, overview.metrics.totalGroups.deltaPct),
|
|
46
|
+
narrativeSentence('Content impressions', engagement.metrics.impressions.value, engagement.metrics.impressions.deltaPct),
|
|
47
|
+
];
|
|
48
|
+
const text = [
|
|
49
|
+
`Community analytics report`,
|
|
50
|
+
`Period: ${from} → ${to}`,
|
|
51
|
+
'',
|
|
52
|
+
...summary,
|
|
53
|
+
].join('\n');
|
|
54
|
+
const pdf = await buildAnalyticsPdf({ overview, growth, engagement });
|
|
55
|
+
return { text, pdf, overview, growth, engagement };
|
|
56
|
+
};
|
|
57
|
+
/** @deprecated Prefer buildAnalyticsBoardReport().pdf — kept for tests. */
|
|
58
|
+
export const buildSimplePdf = (text) => {
|
|
59
|
+
const escapedLines = text
|
|
60
|
+
.replace(/\\/g, '\\\\')
|
|
61
|
+
.replace(/\(/g, '\\(')
|
|
62
|
+
.replace(/\)/g, '\\)')
|
|
63
|
+
.split('\n');
|
|
64
|
+
const linesPerPage = 48;
|
|
65
|
+
const pages = [];
|
|
66
|
+
for (let i = 0; i < escapedLines.length; i += linesPerPage) {
|
|
67
|
+
pages.push(escapedLines.slice(i, i + linesPerPage));
|
|
68
|
+
}
|
|
69
|
+
if (pages.length === 0) {
|
|
70
|
+
pages.push(['']);
|
|
71
|
+
}
|
|
72
|
+
const pageContentStreams = pages.map((pageLines) => pageLines
|
|
73
|
+
.map((line, i) => `BT /F1 10 Tf 50 ${750 - i * 14} Td (${line}) Tj ET`)
|
|
74
|
+
.join('\n'));
|
|
75
|
+
const pageCount = pages.length;
|
|
76
|
+
const pageDictStart = 3;
|
|
77
|
+
const contentStart = pageDictStart + pageCount;
|
|
78
|
+
const fontObjNum = contentStart + pageCount;
|
|
79
|
+
const kids = pages.map((_, i) => `${pageDictStart + i} 0 R`).join(' ');
|
|
80
|
+
const objects = [
|
|
81
|
+
'1 0 obj<< /Type /Catalog /Pages 2 0 R >>endobj\n',
|
|
82
|
+
`2 0 obj<< /Type /Pages /Kids [${kids}] /Count ${pageCount} >>endobj\n`,
|
|
83
|
+
];
|
|
84
|
+
for (let i = 0; i < pageCount; i++) {
|
|
85
|
+
objects.push(`${pageDictStart + i} 0 obj<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents ${contentStart + i} 0 R /Resources << /Font << /F1 ${fontObjNum} 0 R >> >> >>endobj\n`);
|
|
86
|
+
}
|
|
87
|
+
for (let i = 0; i < pageCount; i++) {
|
|
88
|
+
const stream = pageContentStreams[i];
|
|
89
|
+
objects.push(`${contentStart + i} 0 obj<< /Length ${Buffer.byteLength(stream)} >>stream\n${stream}\nendstream\nendobj\n`);
|
|
90
|
+
}
|
|
91
|
+
objects.push(`${fontObjNum} 0 obj<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>endobj\n`);
|
|
92
|
+
let pdf = '%PDF-1.4\n';
|
|
93
|
+
const offsets = [0];
|
|
94
|
+
for (const obj of objects) {
|
|
95
|
+
offsets.push(Buffer.byteLength(pdf));
|
|
96
|
+
pdf += obj;
|
|
97
|
+
}
|
|
98
|
+
const xrefStart = Buffer.byteLength(pdf);
|
|
99
|
+
pdf += `xref\n0 ${objects.length + 1}\n`;
|
|
100
|
+
pdf += '0000000000 65535 f \n';
|
|
101
|
+
for (let i = 1; i < offsets.length; i++) {
|
|
102
|
+
pdf += `${String(offsets[i]).padStart(10, '0')} 00000 n \n`;
|
|
103
|
+
}
|
|
104
|
+
pdf += `trailer<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xrefStart}\n%%EOF`;
|
|
105
|
+
return Buffer.from(pdf);
|
|
106
|
+
};
|
|
107
|
+
export const sendMonthlyAnalyticsReport = async (overridePeriod) => {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
const settings = await getAnalyticsReportSettings();
|
|
110
|
+
if (!settings.enabled || settings.recipients.length === 0) {
|
|
111
|
+
log.info('Monthly analytics report skipped (disabled or no recipients)');
|
|
112
|
+
return { sent: false, recipients: [] };
|
|
113
|
+
}
|
|
114
|
+
const previousMonth = subMonths(new Date(), 1);
|
|
115
|
+
const from = (_a = overridePeriod === null || overridePeriod === void 0 ? void 0 : overridePeriod.from) !== null && _a !== void 0 ? _a : dayString(startOfMonth(previousMonth));
|
|
116
|
+
const to = (_b = overridePeriod === null || overridePeriod === void 0 ? void 0 : overridePeriod.to) !== null && _b !== void 0 ? _b : dayString(endOfMonth(previousMonth));
|
|
117
|
+
const { text, pdf } = await buildAnalyticsBoardReport({ from, to });
|
|
118
|
+
const filename = `analytics-${from}-${to}.pdf`;
|
|
119
|
+
const db = await database();
|
|
120
|
+
const deliveryId = uuidv7();
|
|
121
|
+
await db.insert(analyticsReportDeliveries).values({
|
|
122
|
+
id: deliveryId,
|
|
123
|
+
periodStart: from,
|
|
124
|
+
periodEnd: to,
|
|
125
|
+
recipients: settings.recipients,
|
|
126
|
+
status: 'sending',
|
|
127
|
+
body: { text, pdfAttached: true, filename },
|
|
128
|
+
});
|
|
129
|
+
const queue = sendEmailQueue();
|
|
130
|
+
await Promise.all(settings.recipients.map((toAddr) => queue.add('analytics-monthly-report', {
|
|
131
|
+
to: toAddr,
|
|
132
|
+
template: 'analyticsMonthlyReport',
|
|
133
|
+
locals: {
|
|
134
|
+
periodFrom: from,
|
|
135
|
+
periodTo: to,
|
|
136
|
+
reportText: text,
|
|
137
|
+
},
|
|
138
|
+
attachments: [
|
|
139
|
+
{
|
|
140
|
+
filename,
|
|
141
|
+
content: pdf.toString('base64'),
|
|
142
|
+
contentType: 'application/pdf',
|
|
143
|
+
encoding: 'base64',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
})));
|
|
147
|
+
await db
|
|
148
|
+
.update(analyticsReportDeliveries)
|
|
149
|
+
.set({ status: 'sent' })
|
|
150
|
+
.where(eq(analyticsReportDeliveries.id, deliveryId));
|
|
151
|
+
log.info(`Monthly analytics report sent to ${settings.recipients.length} recipients`);
|
|
152
|
+
return { sent: true, recipients: settings.recipients };
|
|
153
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AnalyticsReportSettings } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const getAnalyticsReportSettings: () => Promise<AnalyticsReportSettings>;
|
|
3
|
+
export declare const setAnalyticsReportSettings: (settings: AnalyticsReportSettings) => Promise<AnalyticsReportSettings>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { database } from '../db/index.js';
|
|
3
|
+
import { analyticsSettings } from '../db/pg/schema/analytics.js';
|
|
4
|
+
const DEFAULT_SETTINGS = {
|
|
5
|
+
enabled: false,
|
|
6
|
+
recipients: [],
|
|
7
|
+
};
|
|
8
|
+
export const getAnalyticsReportSettings = async () => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
const db = await database();
|
|
11
|
+
const rows = await db
|
|
12
|
+
.select()
|
|
13
|
+
.from(analyticsSettings)
|
|
14
|
+
.where(eq(analyticsSettings.id, 'default'))
|
|
15
|
+
.limit(1);
|
|
16
|
+
const body = ((_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.body) !== null && _b !== void 0 ? _b : {});
|
|
17
|
+
return {
|
|
18
|
+
enabled: (_c = body.enabled) !== null && _c !== void 0 ? _c : DEFAULT_SETTINGS.enabled,
|
|
19
|
+
recipients: (_d = body.recipients) !== null && _d !== void 0 ? _d : DEFAULT_SETTINGS.recipients,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const setAnalyticsReportSettings = async (settings) => {
|
|
23
|
+
const db = await database();
|
|
24
|
+
const now = new Date().toISOString();
|
|
25
|
+
await db
|
|
26
|
+
.insert(analyticsSettings)
|
|
27
|
+
.values({
|
|
28
|
+
id: 'default',
|
|
29
|
+
body: settings,
|
|
30
|
+
updatedAt: now,
|
|
31
|
+
})
|
|
32
|
+
.onConflictDoUpdate({
|
|
33
|
+
target: analyticsSettings.id,
|
|
34
|
+
set: { body: settings, updatedAt: now },
|
|
35
|
+
});
|
|
36
|
+
return settings;
|
|
37
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { resolveBackupDatabaseType } from './metadata';
|
|
2
|
+
export declare const createBackup: () => Promise<string | undefined>;
|
|
3
|
+
export declare const downloadBackup: (name: string) => Promise<string>;
|
|
4
|
+
export declare const listAllBackups: () => Promise<string[]>;
|
|
5
|
+
export declare const restoreBackups: (zipFilePath: string) => Promise<void>;
|