@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,222 @@
|
|
|
1
|
+
import { map } from '../db/pg/map/index.js';
|
|
2
|
+
import { postFilters } from '../db/pg/filters/index.js';
|
|
3
|
+
import { postDerived } from '../db/pg/queries/index.js';
|
|
4
|
+
import { collectionInfos } from '../db/index.js';
|
|
5
|
+
import { groupsMapping } from '../groups/mapping.js';
|
|
6
|
+
const seenByCurrentProfileDerivedProperty = (profile) => ({
|
|
7
|
+
alias: 'seen',
|
|
8
|
+
resolve: postDerived.seen(profile === null || profile === void 0 ? void 0 : profile.id),
|
|
9
|
+
});
|
|
10
|
+
const seenBatchByCurrentProfileDerivedProperty = (profile) => postDerived.seenBatch(profile === null || profile === void 0 ? void 0 : profile.id);
|
|
11
|
+
export const entriesRelation = {
|
|
12
|
+
alias: 'entries',
|
|
13
|
+
edgeCollection: 'entries',
|
|
14
|
+
direction: 'INBOUND',
|
|
15
|
+
vertexAlias: 'profile',
|
|
16
|
+
// Keep create/edit authors even after the profile is soft-deleted so
|
|
17
|
+
// historical posts (and nested replyTo) still serialize for API output.
|
|
18
|
+
mapping: {
|
|
19
|
+
collection: 'profiles',
|
|
20
|
+
softDelete: false,
|
|
21
|
+
},
|
|
22
|
+
cardinality: 'many',
|
|
23
|
+
};
|
|
24
|
+
export const groupRelation = {
|
|
25
|
+
alias: 'group',
|
|
26
|
+
edgeCollection: 'postGroups',
|
|
27
|
+
direction: 'OUTBOUND',
|
|
28
|
+
skipEdge: true,
|
|
29
|
+
cardinality: 'one',
|
|
30
|
+
mapping: groupsMapping.data(),
|
|
31
|
+
};
|
|
32
|
+
const replyCountRelation = {
|
|
33
|
+
alias: 'replyCount',
|
|
34
|
+
edgeCollection: 'replyTo',
|
|
35
|
+
direction: 'INBOUND',
|
|
36
|
+
count: true,
|
|
37
|
+
cardinality: 'one',
|
|
38
|
+
mapping: {
|
|
39
|
+
collection: 'posts',
|
|
40
|
+
softDelete: true,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const repostCountRelation = {
|
|
44
|
+
alias: 'repostCount',
|
|
45
|
+
edgeCollection: 'repost',
|
|
46
|
+
direction: 'INBOUND',
|
|
47
|
+
skipEdge: true,
|
|
48
|
+
count: true,
|
|
49
|
+
cardinality: 'one',
|
|
50
|
+
mapping: {
|
|
51
|
+
collection: 'posts',
|
|
52
|
+
softDelete: true,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const reactionsRelation = {
|
|
56
|
+
alias: 'reactions',
|
|
57
|
+
vertexAlias: 'profile',
|
|
58
|
+
edgeCollection: 'reactions',
|
|
59
|
+
direction: 'INBOUND',
|
|
60
|
+
cardinality: 'many',
|
|
61
|
+
mapping: {
|
|
62
|
+
collection: 'profiles',
|
|
63
|
+
softDelete: true,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const audienceRelation = {
|
|
67
|
+
alias: 'audience',
|
|
68
|
+
edgeCollection: 'audience',
|
|
69
|
+
direction: 'OUTBOUND',
|
|
70
|
+
skipEdge: true,
|
|
71
|
+
cardinality: 'many',
|
|
72
|
+
mapping: {
|
|
73
|
+
collection: 'profiles',
|
|
74
|
+
softDelete: true,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const mentionsRelation = {
|
|
78
|
+
alias: 'mentions',
|
|
79
|
+
edgeCollection: 'mentions',
|
|
80
|
+
direction: 'OUTBOUND',
|
|
81
|
+
vertexAlias: 'profile',
|
|
82
|
+
cardinality: 'many',
|
|
83
|
+
mapping: {
|
|
84
|
+
collection: 'profiles',
|
|
85
|
+
softDelete: true,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
const tagsRelation = {
|
|
89
|
+
alias: 'tags',
|
|
90
|
+
edgeCollection: 'postHashtags',
|
|
91
|
+
direction: 'OUTBOUND',
|
|
92
|
+
skipEdge: true,
|
|
93
|
+
cardinality: 'many',
|
|
94
|
+
};
|
|
95
|
+
const basePostFilterRelations = [
|
|
96
|
+
entriesRelation,
|
|
97
|
+
audienceRelation,
|
|
98
|
+
groupRelation,
|
|
99
|
+
replyCountRelation,
|
|
100
|
+
repostCountRelation,
|
|
101
|
+
reactionsRelation,
|
|
102
|
+
tagsRelation,
|
|
103
|
+
mentionsRelation,
|
|
104
|
+
];
|
|
105
|
+
const preFilterMapData = {
|
|
106
|
+
collection: 'posts',
|
|
107
|
+
softDelete: true,
|
|
108
|
+
};
|
|
109
|
+
const basePostMapData = Object.assign(Object.assign({}, preFilterMapData), { postFilterRelations: basePostFilterRelations, postFilterDerivedProperties: [
|
|
110
|
+
{
|
|
111
|
+
alias: 'inReplyToId',
|
|
112
|
+
resolve: postDerived.inReplyToId,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
alias: 'groupId',
|
|
116
|
+
resolve: postDerived.groupId,
|
|
117
|
+
},
|
|
118
|
+
] });
|
|
119
|
+
const basePostMapDataForProfile = (profile) => (Object.assign(Object.assign({}, basePostMapData), { postFilterDerivedProperties: [
|
|
120
|
+
...(basePostMapData.postFilterDerivedProperties || []),
|
|
121
|
+
seenByCurrentProfileDerivedProperty(profile),
|
|
122
|
+
] }));
|
|
123
|
+
const replyPostMapData = Object.assign(Object.assign({}, preFilterMapData), { postFilterRelations: [entriesRelation] });
|
|
124
|
+
const replyToRelation = {
|
|
125
|
+
alias: 'replyTo',
|
|
126
|
+
edgeCollection: 'replyTo',
|
|
127
|
+
direction: 'OUTBOUND',
|
|
128
|
+
skipEdge: true,
|
|
129
|
+
cardinality: 'one',
|
|
130
|
+
mapping: replyPostMapData,
|
|
131
|
+
};
|
|
132
|
+
export const repostRelation = {
|
|
133
|
+
alias: 'repost',
|
|
134
|
+
edgeCollection: 'repost',
|
|
135
|
+
direction: 'OUTBOUND',
|
|
136
|
+
skipEdge: true,
|
|
137
|
+
cardinality: 'one',
|
|
138
|
+
mapping: Object.assign(Object.assign({}, basePostMapData), { postFilterRelations: [...basePostFilterRelations, replyToRelation] }),
|
|
139
|
+
};
|
|
140
|
+
export const repostRelationForProfile = (profile) => (Object.assign(Object.assign({}, repostRelation), { mapping: Object.assign(Object.assign({}, basePostMapDataForProfile(profile)), { postFilterRelations: [...basePostFilterRelations, replyToRelation] }) }));
|
|
141
|
+
export const repostsOfPostRelation = {
|
|
142
|
+
alias: 'reposts',
|
|
143
|
+
edgeCollection: 'repost',
|
|
144
|
+
direction: 'INBOUND',
|
|
145
|
+
skipEdge: true,
|
|
146
|
+
cardinality: 'many',
|
|
147
|
+
mapping: Object.assign(Object.assign({}, basePostMapData), { postFilterRelations: [
|
|
148
|
+
...basePostFilterRelations,
|
|
149
|
+
repostRelation,
|
|
150
|
+
replyToRelation,
|
|
151
|
+
] }),
|
|
152
|
+
};
|
|
153
|
+
export const repostsOfPostRelationForProfile = (profile) => (Object.assign(Object.assign({}, repostsOfPostRelation), { mapping: Object.assign(Object.assign({}, basePostMapDataForProfile(profile)), { postFilterRelations: [
|
|
154
|
+
...basePostFilterRelations,
|
|
155
|
+
repostRelationForProfile(profile),
|
|
156
|
+
replyToRelation,
|
|
157
|
+
] }) }));
|
|
158
|
+
export const postsWithReplyCountMapping = map({
|
|
159
|
+
collection: 'posts',
|
|
160
|
+
relations: [replyCountRelation],
|
|
161
|
+
});
|
|
162
|
+
export const postsWithReplyToCountMapping = map({
|
|
163
|
+
collection: 'posts',
|
|
164
|
+
relations: [
|
|
165
|
+
{
|
|
166
|
+
alias: 'replyToCount',
|
|
167
|
+
edgeCollection: 'replyTo',
|
|
168
|
+
direction: 'OUTBOUND',
|
|
169
|
+
skipEdge: true,
|
|
170
|
+
cardinality: 'one',
|
|
171
|
+
count: true,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
export const postsMapping = map(Object.assign(Object.assign({}, basePostMapData), { postFilterRelations: [
|
|
176
|
+
...basePostFilterRelations,
|
|
177
|
+
repostRelation,
|
|
178
|
+
replyToRelation,
|
|
179
|
+
] }));
|
|
180
|
+
export const postsMappingForProfile = (profile) => map(Object.assign(Object.assign({}, basePostMapDataForProfile(profile)), { postFilterRelations: [
|
|
181
|
+
...basePostFilterRelations,
|
|
182
|
+
repostRelationForProfile(profile),
|
|
183
|
+
replyToRelation,
|
|
184
|
+
] }));
|
|
185
|
+
/** Lean mapping for post detail context — skips audience + nested repost. */
|
|
186
|
+
const contextPostFilterRelations = [
|
|
187
|
+
entriesRelation,
|
|
188
|
+
groupRelation,
|
|
189
|
+
replyCountRelation,
|
|
190
|
+
repostCountRelation,
|
|
191
|
+
reactionsRelation,
|
|
192
|
+
tagsRelation,
|
|
193
|
+
mentionsRelation,
|
|
194
|
+
replyToRelation,
|
|
195
|
+
];
|
|
196
|
+
export const postContextMappingForProfile = (profile) => map(Object.assign(Object.assign({}, preFilterMapData), { postFilterRelations: contextPostFilterRelations, postFilterDerivedProperties: [
|
|
197
|
+
{
|
|
198
|
+
alias: 'inReplyToId',
|
|
199
|
+
resolve: postDerived.inReplyToId,
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
alias: 'groupId',
|
|
203
|
+
resolve: postDerived.groupId,
|
|
204
|
+
},
|
|
205
|
+
seenBatchByCurrentProfileDerivedProperty(profile),
|
|
206
|
+
], limit: 100 }));
|
|
207
|
+
export const contextRelation = (depth, direction, contextMapping = postsMapping) => ({
|
|
208
|
+
alias: 'context',
|
|
209
|
+
edgeCollection: collectionInfos.repliesCollection.name,
|
|
210
|
+
direction: direction === 'ancestors' ? 'OUTBOUND' : 'INBOUND',
|
|
211
|
+
maxDepth: depth,
|
|
212
|
+
cardinality: 'many',
|
|
213
|
+
skipEdge: true,
|
|
214
|
+
mapping: contextMapping.data(),
|
|
215
|
+
});
|
|
216
|
+
const conversationLeafFilters = [
|
|
217
|
+
postFilters.replyCountZero(),
|
|
218
|
+
postFilters.isDirect(),
|
|
219
|
+
];
|
|
220
|
+
export const conversationLeavesMapping = map(Object.assign(Object.assign({}, basePostMapData), { relations: [replyCountRelation], filters: conversationLeafFilters }));
|
|
221
|
+
export const conversationLeavesMappingForProfile = (profile) => map(Object.assign(Object.assign({}, basePostMapDataForProfile(profile)), { relations: [replyCountRelation], filters: conversationLeafFilters }));
|
|
222
|
+
export const postIdsMapping = map(preFilterMapData);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthorizationData, Answer, PostWithMeta, PostData, Profile, ReactionData, RSVP, RsvpResponse } from '@openpeepshq/common/types';
|
|
2
|
+
import { PostDataUnion } from '@openpeepshq/common/types';
|
|
3
|
+
export declare const createPost: (data: PostDataUnion, profile: Profile, postData: PostData, relations?: {
|
|
4
|
+
inReplyToId?: string | null;
|
|
5
|
+
repostId?: string;
|
|
6
|
+
audience?: Profile[] | null;
|
|
7
|
+
groupId?: string | null;
|
|
8
|
+
}) => Promise<PostWithMeta>;
|
|
9
|
+
export declare const updatePost: (post: PostWithMeta, profile: Profile, data: PostDataUnion) => Promise<PostWithMeta>;
|
|
10
|
+
export declare const reactToPost: (post: PostWithMeta, profile: Profile, data: ReactionData) => Promise<void>;
|
|
11
|
+
export declare const retractReaction: (post: PostWithMeta, profile: Profile) => Promise<void>;
|
|
12
|
+
export declare const bookmarkPost: (post: PostWithMeta, profile: Profile) => Promise<void>;
|
|
13
|
+
export declare const unbookmarkPost: (post: PostWithMeta, profile: Profile) => Promise<void>;
|
|
14
|
+
export declare const markPostsSeen: (posts: PostWithMeta[], profile: Profile) => Promise<void>;
|
|
15
|
+
export declare const markGroupPostsSeen: (authData: AuthorizationData, groupId: string) => Promise<void>;
|
|
16
|
+
export declare const deletePost: (post: PostWithMeta, profile: Profile) => Promise<import("@openpeepshq/common").DbPost | undefined>;
|
|
17
|
+
export declare const vote: (profile: Profile, post: PostWithMeta, data: Answer) => Promise<void>;
|
|
18
|
+
export declare const rsvpRespond: (profile: Profile, post: PostWithMeta, data: RSVP) => Promise<void>;
|
|
19
|
+
export declare const rsvpManageByOrganizer: (actingProfile: Profile, targetProfile: Profile, post: PostWithMeta, response: Extract<RsvpResponse, "removed" | "yes">) => Promise<void>;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { allpeepDb } from '../db/index.js';
|
|
2
|
+
import { audienceConnector, bookmarkConnector, bookmarkDisconnector, entryConnector, extractHashtags, groupConnector, hashtagConnector, hashtagDisconnector, mentionConnector, postSeenConnector, reactionConnector, reactionDisconnector, replyConnector, repostConnector, resolveMentionsForPost, transformPost, } from './helpers/index.js';
|
|
3
|
+
import { postsMapping, repostRelation } from './mapping.js';
|
|
4
|
+
import { findGroup } from '../groups/finders.js';
|
|
5
|
+
import { findOrCreateHashtag } from '../hashtags/index.js';
|
|
6
|
+
import { hub } from '../events/index.js';
|
|
7
|
+
import { listPostsByGroup } from './finders.js';
|
|
8
|
+
import { canManageEventRsvps, countYesRsvps, eventDataForDbUpdate, getEffectiveRsvp, normalizeEventDataForSave, passThroughUndefined, } from '@openpeepshq/common/lib';
|
|
9
|
+
import { forbidden, unprocessableRequest } from '../errors/index.js';
|
|
10
|
+
export const createPost = async (data, profile, postData, relations = {}) => {
|
|
11
|
+
if (data.type === 'event') {
|
|
12
|
+
data = normalizeEventDataForSave(data);
|
|
13
|
+
}
|
|
14
|
+
const { db } = await allpeepDb();
|
|
15
|
+
const repostedPost = relations.repostId
|
|
16
|
+
? await postsMapping.find(db, relations.repostId)
|
|
17
|
+
: undefined;
|
|
18
|
+
const repliedToPost = relations.inReplyToId
|
|
19
|
+
? await postsMapping.find(db, relations.inReplyToId)
|
|
20
|
+
: undefined;
|
|
21
|
+
if (repliedToPost) {
|
|
22
|
+
postData.visibility = repliedToPost.visibility;
|
|
23
|
+
}
|
|
24
|
+
const group = await ((repliedToPost === null || repliedToPost === void 0 ? void 0 : repliedToPost.group) ||
|
|
25
|
+
(relations.groupId ? findGroup(relations.groupId) : undefined));
|
|
26
|
+
// Group-linked posts always use visibility=group so community/local feeds
|
|
27
|
+
// (which only include public/local) never surface them incorrectly.
|
|
28
|
+
if (group) {
|
|
29
|
+
postData = Object.assign(Object.assign({}, postData), { visibility: 'group' });
|
|
30
|
+
}
|
|
31
|
+
const hashtags = extractHashtags(data);
|
|
32
|
+
const post = await postsMapping
|
|
33
|
+
.removeDefaultFilter()
|
|
34
|
+
.create(db, Object.assign(Object.assign({}, postData), { data, type: data.type, creatorId: profile.id }));
|
|
35
|
+
await entryConnector(db, profile, post, {
|
|
36
|
+
type: 'create',
|
|
37
|
+
data,
|
|
38
|
+
});
|
|
39
|
+
if (repliedToPost) {
|
|
40
|
+
await replyConnector(db, post, repliedToPost);
|
|
41
|
+
}
|
|
42
|
+
if (group) {
|
|
43
|
+
await groupConnector(db, post, group);
|
|
44
|
+
}
|
|
45
|
+
if (repostedPost && !repostedPost.repost) {
|
|
46
|
+
await repostConnector(db, post, repostedPost);
|
|
47
|
+
}
|
|
48
|
+
await Promise.all(hashtags.map(async (tag) => {
|
|
49
|
+
const hashtag = await findOrCreateHashtag(tag);
|
|
50
|
+
await hashtagConnector(db, post, hashtag);
|
|
51
|
+
}));
|
|
52
|
+
const mentions = await resolveMentionsForPost(data);
|
|
53
|
+
if (mentions.length) {
|
|
54
|
+
await Promise.all(mentions.map(async (mention) => mentionConnector(db, post, mention.profile, { text: mention.text })));
|
|
55
|
+
}
|
|
56
|
+
if (relations.audience) {
|
|
57
|
+
await Promise.all(relations.audience.map(async (profile) => {
|
|
58
|
+
await audienceConnector(db, post, profile);
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
const newPost = await postsMapping.find(db, post.id);
|
|
62
|
+
const transformedPost = await transformPost(newPost);
|
|
63
|
+
hub.emit('postCreated', transformedPost);
|
|
64
|
+
return transformedPost;
|
|
65
|
+
};
|
|
66
|
+
export const updatePost = async (post, profile, data) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const previousEvent = ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? post.data : undefined;
|
|
69
|
+
const normalized = data.type === 'event' ? normalizeEventDataForSave(data) : data;
|
|
70
|
+
const dataForDb = normalized.type === 'event'
|
|
71
|
+
? eventDataForDbUpdate(previousEvent, normalized)
|
|
72
|
+
: normalized;
|
|
73
|
+
const { db } = await allpeepDb();
|
|
74
|
+
post.tags.forEach((hashtag) => hashtagDisconnector(db, post, hashtag));
|
|
75
|
+
const hashtags = extractHashtags(normalized);
|
|
76
|
+
await Promise.all(hashtags.map(async (tag) => {
|
|
77
|
+
const hashtag = await findOrCreateHashtag(tag);
|
|
78
|
+
await hashtagConnector(db, post, hashtag);
|
|
79
|
+
}));
|
|
80
|
+
await entryConnector(db, profile, post, {
|
|
81
|
+
type: 'edit',
|
|
82
|
+
data: normalized,
|
|
83
|
+
});
|
|
84
|
+
await postsMapping.update(db, post.id, {
|
|
85
|
+
data: dataForDb,
|
|
86
|
+
});
|
|
87
|
+
const newPost = await postsMapping
|
|
88
|
+
.find(db, post.id)
|
|
89
|
+
.then(passThroughUndefined(transformPost));
|
|
90
|
+
hub.emit('postUpdated', newPost);
|
|
91
|
+
return newPost;
|
|
92
|
+
};
|
|
93
|
+
export const reactToPost = async (post, profile, data) => allpeepDb().then(({ db }) => reactionConnector(db, profile, post, data).then(() => hub.emit('reactionCreated', profile, post, Object.assign({ type: 'reaction' }, data))));
|
|
94
|
+
export const retractReaction = async (post, profile) => allpeepDb().then(({ db }) => reactionDisconnector(db, profile, post));
|
|
95
|
+
export const bookmarkPost = async (post, profile) => allpeepDb().then(({ db }) => bookmarkConnector(db, profile, post).then(() => hub.emit('bookmarkCreated', profile, post)));
|
|
96
|
+
export const unbookmarkPost = async (post, profile) => allpeepDb().then(({ db }) => bookmarkDisconnector(db, profile, post));
|
|
97
|
+
export const markPostsSeen = async (posts, profile) => {
|
|
98
|
+
const { db } = await allpeepDb();
|
|
99
|
+
await Promise.all(posts.map((post) => postSeenConnector(db, profile, post)));
|
|
100
|
+
};
|
|
101
|
+
export const markGroupPostsSeen = async (authData, groupId) => {
|
|
102
|
+
if (!authData.profile) {
|
|
103
|
+
throw new Error('Profile required');
|
|
104
|
+
}
|
|
105
|
+
const profile = authData.profile;
|
|
106
|
+
const posts = await listPostsByGroup(authData, groupId, { limit: 9999 });
|
|
107
|
+
const unseen = posts.filter((post) => post.seen === false && post.profile.id !== profile.id);
|
|
108
|
+
if (unseen.length > 0) {
|
|
109
|
+
await markPostsSeen(unseen, profile);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export const deletePost = async (post, profile) => {
|
|
113
|
+
const { db } = await allpeepDb();
|
|
114
|
+
await entryConnector(db, profile, post, {
|
|
115
|
+
type: 'delete',
|
|
116
|
+
data: {
|
|
117
|
+
type: 'tombstone',
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
await Promise.all(post.reactions.map(async (reaction) => {
|
|
121
|
+
await reactionDisconnector(db, reaction.profile, post);
|
|
122
|
+
}));
|
|
123
|
+
await postsMapping.deleteRelations(db, post.id, Object.assign(Object.assign({}, repostRelation), { direction: 'INBOUND' }));
|
|
124
|
+
await postsMapping.delete(db, post.id);
|
|
125
|
+
return postsMapping.find(db, post.id);
|
|
126
|
+
};
|
|
127
|
+
export const vote = (profile, post, data) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
|
|
128
|
+
type: 'answer',
|
|
129
|
+
data,
|
|
130
|
+
}).then(() => hub.emit('entryCreated', profile, post, { type: 'answer', data })));
|
|
131
|
+
export const rsvpRespond = async (profile, post, data) => {
|
|
132
|
+
var _a, _b, _c, _d;
|
|
133
|
+
if (profile.id === post.profile.id) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (post.type !== 'event' || ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
|
|
137
|
+
throw unprocessableRequest({ errorKey: 'error.unprocessableRequest' });
|
|
138
|
+
}
|
|
139
|
+
// `removed` is an organizer-only status; users cannot set it on themselves,
|
|
140
|
+
// and once removed they may not change their own RSVP — only the owner or a
|
|
141
|
+
// moderator can restore it (see `rsvpManageByOrganizer`).
|
|
142
|
+
if (data.response === 'removed') {
|
|
143
|
+
throw forbidden({ errorKey: 'error.rsvpRemovedForbidden' });
|
|
144
|
+
}
|
|
145
|
+
if (((_b = getEffectiveRsvp(post, profile.id)) === null || _b === void 0 ? void 0 : _b.response) === 'removed') {
|
|
146
|
+
throw forbidden({ errorKey: 'error.rsvpRemoved' });
|
|
147
|
+
}
|
|
148
|
+
const maxAttendees = post.data.maxAttendees;
|
|
149
|
+
if (maxAttendees) {
|
|
150
|
+
if (data.response === 'tentative') {
|
|
151
|
+
throw unprocessableRequest({
|
|
152
|
+
errorKey: 'error.eventTentativeNotAllowed',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (data.response === 'yes') {
|
|
156
|
+
const currentRsvp = getEffectiveRsvp(post, profile.id);
|
|
157
|
+
if ((currentRsvp === null || currentRsvp === void 0 ? void 0 : currentRsvp.response) !== 'yes' &&
|
|
158
|
+
countYesRsvps(post) >= maxAttendees) {
|
|
159
|
+
throw unprocessableRequest({ errorKey: 'error.eventAtCapacity' });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const { db } = await allpeepDb();
|
|
164
|
+
const previousResponse = (_d = [...((_c = post.rsvps) !== null && _c !== void 0 ? _c : [])]
|
|
165
|
+
.filter((rsvp) => rsvp.profile.id === profile.id)
|
|
166
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]) === null || _d === void 0 ? void 0 : _d.response;
|
|
167
|
+
await entryConnector(db, profile, post, {
|
|
168
|
+
type: 'rsvp',
|
|
169
|
+
data,
|
|
170
|
+
});
|
|
171
|
+
hub.emit('rsvpCreated', profile, post, {
|
|
172
|
+
type: 'rsvp',
|
|
173
|
+
data,
|
|
174
|
+
previousResponse,
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post, response) => {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
if (!canManageEventRsvps(actingProfile, post)) {
|
|
180
|
+
throw forbidden({ errorKey: 'forbidden' });
|
|
181
|
+
}
|
|
182
|
+
if (targetProfile.id === post.profile.id) {
|
|
183
|
+
throw forbidden({ errorKey: 'forbidden' });
|
|
184
|
+
}
|
|
185
|
+
if (post.type !== 'event') {
|
|
186
|
+
throw unprocessableRequest({ errorKey: 'error.unprocessableRequest' });
|
|
187
|
+
}
|
|
188
|
+
const data = { response };
|
|
189
|
+
const { db } = await allpeepDb();
|
|
190
|
+
const previousResponse = (_b = [...((_a = post.rsvps) !== null && _a !== void 0 ? _a : [])]
|
|
191
|
+
.filter((rsvp) => rsvp.profile.id === targetProfile.id)
|
|
192
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]) === null || _b === void 0 ? void 0 : _b.response;
|
|
193
|
+
await entryConnector(db, targetProfile, post, {
|
|
194
|
+
type: 'rsvp',
|
|
195
|
+
data,
|
|
196
|
+
});
|
|
197
|
+
hub.emit('rsvpCreated', targetProfile, post, {
|
|
198
|
+
type: 'rsvp',
|
|
199
|
+
data,
|
|
200
|
+
previousResponse,
|
|
201
|
+
});
|
|
202
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { buildEventIcs } from '@openpeepshq/common/lib';
|
|
2
|
+
import { hub } from '../events/index.js';
|
|
3
|
+
import { emailService } from '../email/index.js';
|
|
4
|
+
import { findByProfile } from '../accounts/index.js';
|
|
5
|
+
import { serverRootUrl } from '../server/index.js';
|
|
6
|
+
import { logger } from '../log/index.js';
|
|
7
|
+
const log = logger('openpeeps:rsvp-email');
|
|
8
|
+
const attendingResponses = ['yes', 'tentative'];
|
|
9
|
+
/**
|
|
10
|
+
* Emails the responder an .ics file when they newly RSVP "yes" or "maybe" to an
|
|
11
|
+
* event so they can add it to their calendar (see issue #645). We only send on
|
|
12
|
+
* the transition into attending (the previous response was "no" or unset) to
|
|
13
|
+
* avoid re-sending when someone toggles between yes/maybe.
|
|
14
|
+
*/
|
|
15
|
+
const handleRsvpCreated = async (profileArg, postArg, payloadArg) => {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
17
|
+
const profile = profileArg;
|
|
18
|
+
const post = postArg;
|
|
19
|
+
const payload = payloadArg;
|
|
20
|
+
if ((payload === null || payload === void 0 ? void 0 : payload.type) !== 'rsvp') {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const response = (_a = payload.data) === null || _a === void 0 ? void 0 : _a.response;
|
|
24
|
+
if (!response || !attendingResponses.includes(response)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (payload.previousResponse &&
|
|
28
|
+
attendingResponses.includes(payload.previousResponse)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (post.type !== 'event' || ((_b = post.data) === null || _b === void 0 ? void 0 : _b.type) !== 'event') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const rootUrl = await serverRootUrl();
|
|
35
|
+
const postUrl = `${rootUrl}/posts/${post.id}`;
|
|
36
|
+
const ics = buildEventIcs(post, { postUrl });
|
|
37
|
+
if (!ics) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const accounts = await findByProfile(profile);
|
|
41
|
+
if (!accounts.length) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const event = post.data;
|
|
45
|
+
const mailer = await emailService();
|
|
46
|
+
for (const account of accounts) {
|
|
47
|
+
if (!account.email) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
await mailer
|
|
51
|
+
.send({
|
|
52
|
+
to: account.email,
|
|
53
|
+
template: 'eventRsvpConfirmation',
|
|
54
|
+
locals: {
|
|
55
|
+
eventName: ((_c = event.name) === null || _c === void 0 ? void 0 : _c.trim()) || 'Event',
|
|
56
|
+
eventUrl: postUrl,
|
|
57
|
+
response,
|
|
58
|
+
start: event.start,
|
|
59
|
+
end: (_d = event.end) !== null && _d !== void 0 ? _d : null,
|
|
60
|
+
location: (_f = (_e = event.physicalLocation) === null || _e === void 0 ? void 0 : _e.text) !== null && _f !== void 0 ? _f : null,
|
|
61
|
+
allDay: (_g = event.wholeDay) !== null && _g !== void 0 ? _g : false,
|
|
62
|
+
},
|
|
63
|
+
attachments: [
|
|
64
|
+
{
|
|
65
|
+
filename: 'event.ics',
|
|
66
|
+
content: ics,
|
|
67
|
+
contentType: 'text/calendar; method=PUBLISH; charset=utf-8',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
})
|
|
71
|
+
.catch((err) => log.error(err));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
let registered = false;
|
|
75
|
+
/** Subscribes the RSVP confirmation email handler to the `rsvpCreated` event. */
|
|
76
|
+
export const registerRsvpConfirmationEmail = () => {
|
|
77
|
+
if (registered) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
registered = true;
|
|
81
|
+
hub.once('rsvpCreated', handleRsvpCreated);
|
|
82
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProcessingStats } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const processingStatsMapping: import("../db/pg/map").Mapping<{
|
|
3
|
+
mediaAttachmentId: string;
|
|
4
|
+
filesize: number;
|
|
5
|
+
filetype: string;
|
|
6
|
+
durationMs: number;
|
|
7
|
+
}, ProcessingStats, ProcessingStats>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { processingStatsMapping } from './mapping.js';
|
|
2
|
+
import { allpeepDb } from '../db/index.js';
|
|
3
|
+
import { sorts } from '../db/pg/queries/index.js';
|
|
4
|
+
const HISTORY_SAMPLE_SIZE = 50;
|
|
5
|
+
const FILETYPE_DEFAULTS_MS = {
|
|
6
|
+
image: 2000,
|
|
7
|
+
audio: 8000,
|
|
8
|
+
video: 30000,
|
|
9
|
+
document: 1500,
|
|
10
|
+
};
|
|
11
|
+
const GENERIC_DEFAULT_MS = 5000;
|
|
12
|
+
const median = (values) => {
|
|
13
|
+
if (!values.length)
|
|
14
|
+
return 0;
|
|
15
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
16
|
+
const mid = Math.floor(sorted.length / 2);
|
|
17
|
+
return sorted.length % 2 === 0
|
|
18
|
+
? (sorted[mid - 1] + sorted[mid]) / 2
|
|
19
|
+
: sorted[mid];
|
|
20
|
+
};
|
|
21
|
+
const findRecent = async (filter) => {
|
|
22
|
+
const db = await allpeepDb().then((db) => db.db);
|
|
23
|
+
return processingStatsMapping
|
|
24
|
+
.filter({ matches: filter })
|
|
25
|
+
.sort(sorts.createdAtDesc)
|
|
26
|
+
.limit(HISTORY_SAMPLE_SIZE)
|
|
27
|
+
.all(db);
|
|
28
|
+
};
|
|
29
|
+
export const estimateProcessingDuration = async ({ filetype, filesize, }) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const lower = filesize * 0.5;
|
|
32
|
+
const upper = filesize * 2;
|
|
33
|
+
const sized = await findRecent({ filetype })
|
|
34
|
+
.then((rows) => rows.filter((r) => r.filesize >= lower && r.filesize <= upper))
|
|
35
|
+
.catch(() => []);
|
|
36
|
+
if (sized.length >= 3) {
|
|
37
|
+
return median(sized.map((r) => r.durationMs));
|
|
38
|
+
}
|
|
39
|
+
const allByType = await findRecent({ filetype }).catch(() => []);
|
|
40
|
+
if (allByType.length) {
|
|
41
|
+
const scaledMedian = median(allByType.map((r) => (r.durationMs / Math.max(1, r.filesize)) * filesize));
|
|
42
|
+
if (scaledMedian > 0)
|
|
43
|
+
return scaledMedian;
|
|
44
|
+
}
|
|
45
|
+
return (_a = FILETYPE_DEFAULTS_MS[filetype]) !== null && _a !== void 0 ? _a : GENERIC_DEFAULT_MS;
|
|
46
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createCache } from 'cache-manager';
|
|
2
|
+
import { allpeepDb } from '../db/index.js';
|
|
3
|
+
import { hub } from '../events/index.js';
|
|
4
|
+
import { profileSettingsMapping } from './mapping.js';
|
|
5
|
+
export const profileSettingsCache = createCache({
|
|
6
|
+
ttl: 60 * 60 * 1000 * 24,
|
|
7
|
+
refreshThreshold: 60 * 60 * 1000,
|
|
8
|
+
});
|
|
9
|
+
// Settings updates run in the API process; notification email delivery runs in
|
|
10
|
+
// the worker with its own in-memory cache. Invalidate across processes via Redis.
|
|
11
|
+
hub.on('profileSettingsUpdated', (profileId) => {
|
|
12
|
+
void profileSettingsCache.del(profileId);
|
|
13
|
+
});
|
|
14
|
+
export const getProfileSettings = async (id) => profileSettingsCache.wrap(id, async () => {
|
|
15
|
+
const { db } = await allpeepDb();
|
|
16
|
+
const foundSettings = await profileSettingsMapping.find(db, id);
|
|
17
|
+
if (foundSettings) {
|
|
18
|
+
return foundSettings;
|
|
19
|
+
}
|
|
20
|
+
const newSettings = await profileSettingsMapping.create(db, {
|
|
21
|
+
id,
|
|
22
|
+
});
|
|
23
|
+
return newSettings;
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findProfileSettings: (id: string) => Promise<import("@openpeepshq/common").ProfileSettings>;
|