@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,329 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { createWriteStream } from 'node:fs';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { Readable } from 'node:stream';
|
|
7
|
+
import { pipeline } from 'node:stream/promises';
|
|
8
|
+
import ffmpeg from 'fluent-ffmpeg';
|
|
9
|
+
import { queueAndWorker } from '../jobs/index.js';
|
|
10
|
+
import { logger } from '../log/index.js';
|
|
11
|
+
import { mediaStorage } from './index.js';
|
|
12
|
+
import { ensureStreamDir, HLS_ERRORS_LOG, HLS_MASTER_PLAYLIST, } from './streaming.js';
|
|
13
|
+
const log = logger('app:media:streamingJobs');
|
|
14
|
+
const VARIANT_PLAYLIST = 'stream.m3u8';
|
|
15
|
+
const SEGMENT_PATTERN = 'segment_%05d.ts';
|
|
16
|
+
const HLS_SEGMENT_DURATION_SEC = 6;
|
|
17
|
+
// ffmpeg writes the master playlist incrementally during VOD encodes, so we
|
|
18
|
+
// can't rely on its presence as a "done" marker. Have ffmpeg write to a
|
|
19
|
+
// non-final name and rename atomically to `hls.m3u8` after the encode
|
|
20
|
+
// completes successfully.
|
|
21
|
+
const MASTER_PLAYLIST_TEMP_NAME = '_master.m3u8';
|
|
22
|
+
const AUDIO_BITRATE_KBPS = 128;
|
|
23
|
+
/**
|
|
24
|
+
* Bitrate ladder roughly following the Apple HLS Authoring Spec. Each rung
|
|
25
|
+
* targets the shorter side of the frame so the rule works for both landscape
|
|
26
|
+
* and portrait sources (a "720p" rung means the shorter side is 720, with the
|
|
27
|
+
* longer side scaled to match the source aspect ratio).
|
|
28
|
+
*/
|
|
29
|
+
const LADDER = [
|
|
30
|
+
{ shorterSide: 1080, videoBitrateKbps: 4500, maxBitrateKbps: 6750 },
|
|
31
|
+
{ shorterSide: 720, videoBitrateKbps: 2800, maxBitrateKbps: 4200 },
|
|
32
|
+
{ shorterSide: 480, videoBitrateKbps: 1000, maxBitrateKbps: 1500 },
|
|
33
|
+
{ shorterSide: 360, videoBitrateKbps: 500, maxBitrateKbps: 750 },
|
|
34
|
+
];
|
|
35
|
+
const SOURCE_BITRATE_FALLBACK_KBPS = {
|
|
36
|
+
// Rough defaults if ffprobe can't tell us the source video bitrate (e.g.
|
|
37
|
+
// weird containers). Indexed by shorter-side resolution.
|
|
38
|
+
2160: 16000,
|
|
39
|
+
1440: 9000,
|
|
40
|
+
1080: 5000,
|
|
41
|
+
720: 3000,
|
|
42
|
+
480: 1500,
|
|
43
|
+
360: 800,
|
|
44
|
+
240: 500,
|
|
45
|
+
};
|
|
46
|
+
const probeSource = (inputPath) => new Promise((resolve, reject) => {
|
|
47
|
+
ffmpeg.ffprobe(inputPath, (err, metadata) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (err) {
|
|
50
|
+
reject(err);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const video = metadata.streams.find((s) => s.codec_type === 'video');
|
|
54
|
+
if (!video || !video.width || !video.height) {
|
|
55
|
+
reject(new Error('No video stream found in source'));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const hasAudio = metadata.streams.some((s) => s.codec_type === 'audio');
|
|
59
|
+
// `bit_rate` on the video stream is the most accurate signal. Fall back
|
|
60
|
+
// to the container-level bitrate (which includes audio) minus a rough
|
|
61
|
+
// audio allowance, then to a resolution-based heuristic.
|
|
62
|
+
const streamBitrate = Number(video.bit_rate);
|
|
63
|
+
let videoBitrateKbps = Number.isFinite(streamBitrate) && streamBitrate > 0
|
|
64
|
+
? Math.round(streamBitrate / 1000)
|
|
65
|
+
: 0;
|
|
66
|
+
if (!videoBitrateKbps) {
|
|
67
|
+
const formatBitrate = Number(metadata.format.bit_rate);
|
|
68
|
+
if (Number.isFinite(formatBitrate) && formatBitrate > 0) {
|
|
69
|
+
videoBitrateKbps = Math.max(100, Math.round(formatBitrate / 1000) -
|
|
70
|
+
(hasAudio ? AUDIO_BITRATE_KBPS : 0));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!videoBitrateKbps) {
|
|
74
|
+
const shorter = Math.min(video.width, video.height);
|
|
75
|
+
const fallback = (_b = (_a = Object.entries(SOURCE_BITRATE_FALLBACK_KBPS)
|
|
76
|
+
.map(([s, kbps]) => ({ s: Number(s), kbps }))
|
|
77
|
+
.filter(({ s }) => s <= shorter)
|
|
78
|
+
.sort((a, b) => b.s - a.s)[0]) === null || _a === void 0 ? void 0 : _a.kbps) !== null && _b !== void 0 ? _b : 500;
|
|
79
|
+
videoBitrateKbps = fallback;
|
|
80
|
+
}
|
|
81
|
+
resolve({
|
|
82
|
+
width: video.width,
|
|
83
|
+
height: video.height,
|
|
84
|
+
videoBitrateKbps,
|
|
85
|
+
hasAudio,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const roundEven = (n) => {
|
|
90
|
+
const r = Math.round(n);
|
|
91
|
+
return r % 2 === 0 ? r : r + (r > 0 ? 1 : -1);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Scales `src` so the shorter side equals `targetShorter`, preserving the
|
|
95
|
+
* source aspect ratio and rounding both dimensions to even numbers (required
|
|
96
|
+
* by libx264). Returns the source unchanged if it's already at-or-below the
|
|
97
|
+
* target (we never upscale).
|
|
98
|
+
*/
|
|
99
|
+
const scaleToShorterSide = (srcWidth, srcHeight, targetShorter) => {
|
|
100
|
+
const srcShorter = Math.min(srcWidth, srcHeight);
|
|
101
|
+
if (targetShorter >= srcShorter) {
|
|
102
|
+
return { width: roundEven(srcWidth), height: roundEven(srcHeight) };
|
|
103
|
+
}
|
|
104
|
+
const ratio = targetShorter / srcShorter;
|
|
105
|
+
return {
|
|
106
|
+
width: roundEven(srcWidth * ratio),
|
|
107
|
+
height: roundEven(srcHeight * ratio),
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Picks the set of variants to encode based on the source resolution and
|
|
112
|
+
* bitrate.
|
|
113
|
+
*
|
|
114
|
+
* Rules:
|
|
115
|
+
* - Never upscale (rung's shorter side must be ≤ source shorter side).
|
|
116
|
+
* - Always include the highest ladder rung that fits the source resolution,
|
|
117
|
+
* using ladder bitrates (screen recordings often under-report average bitrate
|
|
118
|
+
* in ffprobe while still needing a full-res encode for legible text).
|
|
119
|
+
* - Include lower rungs only when their target bitrate is ≤ ~85% of the probed
|
|
120
|
+
* source bitrate (avoids redundant encodes on genuinely low-bitrate sources).
|
|
121
|
+
* - If the source is below the smallest ladder rung, produce a single
|
|
122
|
+
* source-quality variant so the output is always playable.
|
|
123
|
+
*/
|
|
124
|
+
const rungToVariant = (source, rung) => {
|
|
125
|
+
const { width, height } = scaleToShorterSide(source.width, source.height, rung.shorterSide);
|
|
126
|
+
return {
|
|
127
|
+
width,
|
|
128
|
+
height,
|
|
129
|
+
videoBitrateKbps: rung.videoBitrateKbps,
|
|
130
|
+
maxBitrateKbps: rung.maxBitrateKbps,
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const pickVariants = (source) => {
|
|
134
|
+
const srcShorter = Math.min(source.width, source.height);
|
|
135
|
+
const fitsSource = LADDER.filter((r) => r.shorterSide <= srcShorter);
|
|
136
|
+
const topRung = fitsSource[0];
|
|
137
|
+
if (!topRung) {
|
|
138
|
+
const bitrate = Math.max(400, source.videoBitrateKbps);
|
|
139
|
+
return [
|
|
140
|
+
{
|
|
141
|
+
width: roundEven(source.width),
|
|
142
|
+
height: roundEven(source.height),
|
|
143
|
+
videoBitrateKbps: bitrate,
|
|
144
|
+
maxBitrateKbps: Math.round(bitrate * 1.5),
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
const lowerRungs = LADDER.filter((r) => r.shorterSide < topRung.shorterSide &&
|
|
149
|
+
r.shorterSide <= srcShorter &&
|
|
150
|
+
r.videoBitrateKbps <= source.videoBitrateKbps * 0.85);
|
|
151
|
+
return [topRung, ...lowerRungs].map((rung) => rungToVariant(source, rung));
|
|
152
|
+
};
|
|
153
|
+
const buildFilterComplex = (variants) => {
|
|
154
|
+
if (variants.length === 1) {
|
|
155
|
+
return `[0:v]scale=${variants[0].width}:${variants[0].height}[v0]`;
|
|
156
|
+
}
|
|
157
|
+
const splitLabels = variants.map((_, i) => `[s${i}]`).join('');
|
|
158
|
+
const split = `[0:v]split=${variants.length}${splitLabels}`;
|
|
159
|
+
const scales = variants
|
|
160
|
+
.map((v, i) => `[s${i}]scale=${v.width}:${v.height}:flags=lanczos[v${i}]`)
|
|
161
|
+
.join('; ');
|
|
162
|
+
return `${split}; ${scales}`;
|
|
163
|
+
};
|
|
164
|
+
const buildVariantOutputOptions = (variants, hasAudio) => {
|
|
165
|
+
const opts = [];
|
|
166
|
+
variants.forEach((v, i) => {
|
|
167
|
+
opts.push(`-map`, `[v${i}]`);
|
|
168
|
+
opts.push(`-c:v:${i}`, 'libx264');
|
|
169
|
+
opts.push(`-b:v:${i}`, `${v.videoBitrateKbps}k`);
|
|
170
|
+
opts.push(`-maxrate:v:${i}`, `${v.maxBitrateKbps}k`);
|
|
171
|
+
// 2-second buffer at maxrate is a reasonable default for VOD ABR.
|
|
172
|
+
opts.push(`-bufsize:v:${i}`, `${v.maxBitrateKbps * 2}k`);
|
|
173
|
+
});
|
|
174
|
+
if (hasAudio) {
|
|
175
|
+
variants.forEach((_, i) => {
|
|
176
|
+
opts.push(`-map`, 'a:0');
|
|
177
|
+
opts.push(`-c:a:${i}`, 'aac');
|
|
178
|
+
opts.push(`-b:a:${i}`, `${AUDIO_BITRATE_KBPS}k`);
|
|
179
|
+
// The `a:` prefix is critical here. Without it, `-ac:${i}` targets the
|
|
180
|
+
// i-th output stream of ANY type — which is one of the video variants,
|
|
181
|
+
// not the audio. ffmpeg responds to that with a generic "Conversion
|
|
182
|
+
// failed!" with no useful detail.
|
|
183
|
+
opts.push(`-ac:a:${i}`, '2');
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return opts;
|
|
187
|
+
};
|
|
188
|
+
const runHls = async (inputPath, streamDir, source, variants) => {
|
|
189
|
+
// Each variant gets its own subdirectory so segment filenames never collide.
|
|
190
|
+
await Promise.all(variants.map((_, i) => fs.mkdir(join(streamDir, `v${i}`), { recursive: true })));
|
|
191
|
+
const segmentTemplate = join(streamDir, `v%v`, SEGMENT_PATTERN);
|
|
192
|
+
const variantPlaylistTemplate = join(streamDir, `v%v`, VARIANT_PLAYLIST);
|
|
193
|
+
// `var_stream_map` tells the HLS muxer which (video, audio) pairs to bundle
|
|
194
|
+
// into each variant. Audio is duplicated per-variant (a:0, a:1, …) because
|
|
195
|
+
// we want each variant to carry its own audio track for simplicity.
|
|
196
|
+
const streamMap = variants
|
|
197
|
+
.map((_, i) => (source.hasAudio ? `v:${i},a:${i}` : `v:${i}`))
|
|
198
|
+
.join(' ');
|
|
199
|
+
const outputOptions = [
|
|
200
|
+
'-filter_complex',
|
|
201
|
+
buildFilterComplex(variants),
|
|
202
|
+
...buildVariantOutputOptions(variants, source.hasAudio),
|
|
203
|
+
// Encoder presets — applied to every video output. `main` profile is a
|
|
204
|
+
// good balance between device compatibility and compression efficiency.
|
|
205
|
+
'-profile:v',
|
|
206
|
+
'main',
|
|
207
|
+
'-pix_fmt',
|
|
208
|
+
'yuv420p',
|
|
209
|
+
'-preset',
|
|
210
|
+
'veryfast',
|
|
211
|
+
// Keyframe alignment: place an IDR every `HLS_SEGMENT_DURATION_SEC`
|
|
212
|
+
// seconds so segments are independently decodable.
|
|
213
|
+
'-g',
|
|
214
|
+
String(HLS_SEGMENT_DURATION_SEC * 30),
|
|
215
|
+
'-keyint_min',
|
|
216
|
+
String(HLS_SEGMENT_DURATION_SEC * 30),
|
|
217
|
+
'-sc_threshold',
|
|
218
|
+
'0',
|
|
219
|
+
'-f',
|
|
220
|
+
'hls',
|
|
221
|
+
`-hls_time`,
|
|
222
|
+
String(HLS_SEGMENT_DURATION_SEC),
|
|
223
|
+
'-hls_playlist_type',
|
|
224
|
+
'vod',
|
|
225
|
+
'-hls_flags',
|
|
226
|
+
'independent_segments',
|
|
227
|
+
'-hls_segment_filename',
|
|
228
|
+
segmentTemplate,
|
|
229
|
+
'-master_pl_name',
|
|
230
|
+
MASTER_PLAYLIST_TEMP_NAME,
|
|
231
|
+
// NOTE: `-var_stream_map` is passed separately below. fluent-ffmpeg splits
|
|
232
|
+
// any single array element containing exactly one space into two argv
|
|
233
|
+
// tokens, which breaks values like `v:0,a:0 v:1,a:1` and makes ffmpeg
|
|
234
|
+
// treat `v:1,a:1` as an output filename.
|
|
235
|
+
];
|
|
236
|
+
await new Promise((resolve, reject) => {
|
|
237
|
+
ffmpeg(inputPath)
|
|
238
|
+
.outputOptions(outputOptions)
|
|
239
|
+
// Two-arg form disables fluent-ffmpeg's space-splitting heuristic.
|
|
240
|
+
.outputOptions('-var_stream_map', streamMap)
|
|
241
|
+
.output(variantPlaylistTemplate)
|
|
242
|
+
.on('start', (cmd) => log.debug(`ffmpeg command: ${cmd}`))
|
|
243
|
+
.on('end', () => resolve())
|
|
244
|
+
.on('error', (err, _stdout, stderr) => {
|
|
245
|
+
// fluent-ffmpeg's `err.message` is just "ffmpeg exited with code N:
|
|
246
|
+
// Conversion failed!" — the actual diagnostic is in stderr. We attach
|
|
247
|
+
// the last ~40 lines so the worker log (and errors.log) show what
|
|
248
|
+
// ffmpeg actually complained about instead of a useless exit code.
|
|
249
|
+
const tail = String(stderr !== null && stderr !== void 0 ? stderr : '')
|
|
250
|
+
.trim()
|
|
251
|
+
.split(/\r?\n/)
|
|
252
|
+
.slice(-40)
|
|
253
|
+
.join('\n');
|
|
254
|
+
const detail = tail
|
|
255
|
+
? `${err.message}\n--- ffmpeg stderr (tail) ---\n${tail}`
|
|
256
|
+
: err.message;
|
|
257
|
+
const wrapped = new Error(detail);
|
|
258
|
+
// Preserve the original stack for debugging while keeping the rich
|
|
259
|
+
// message on `.message` for log lines.
|
|
260
|
+
if (err.stack)
|
|
261
|
+
wrapped.stack = err.stack;
|
|
262
|
+
reject(wrapped);
|
|
263
|
+
})
|
|
264
|
+
.run();
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const finalizeMasterPlaylist = async (streamDir) => {
|
|
268
|
+
const tempPath = join(streamDir, MASTER_PLAYLIST_TEMP_NAME);
|
|
269
|
+
const finalPath = join(streamDir, HLS_MASTER_PLAYLIST);
|
|
270
|
+
// Atomic rename so consumers polling for `hls.m3u8` only ever see the
|
|
271
|
+
// playlist once the encode is fully complete.
|
|
272
|
+
await fs.rename(tempPath, finalPath);
|
|
273
|
+
};
|
|
274
|
+
const writeFileFromStorageToTemp = async (storageId) => {
|
|
275
|
+
const storage = await mediaStorage();
|
|
276
|
+
const tempPath = join(tmpdir(), `hls-input-${storageId}-${randomBytes(8).toString('hex')}`);
|
|
277
|
+
const webStream = (await storage.getStream(storageId));
|
|
278
|
+
if (!webStream) {
|
|
279
|
+
throw new Error(`Source file not found in storage: ${storageId}`);
|
|
280
|
+
}
|
|
281
|
+
await pipeline(Readable.fromWeb(webStream), createWriteStream(tempPath));
|
|
282
|
+
return tempPath;
|
|
283
|
+
};
|
|
284
|
+
const writeErrorsLog = async (streamDir, message) => {
|
|
285
|
+
const errorsPath = join(streamDir, HLS_ERRORS_LOG);
|
|
286
|
+
try {
|
|
287
|
+
await fs.writeFile(errorsPath, message + '\n', 'utf8');
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
log.error(`Failed to write ${errorsPath}: ${e.message}`);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const [mediaStreamingQueue, mediaStreamingWorker] = queueAndWorker('media-streaming', async (job) => {
|
|
294
|
+
const { storageId } = job.data;
|
|
295
|
+
log.info(`Starting HLS transcoding for ${storageId}`);
|
|
296
|
+
const streamDir = await ensureStreamDir(storageId);
|
|
297
|
+
let inputPath;
|
|
298
|
+
try {
|
|
299
|
+
await fs.unlink(join(streamDir, HLS_ERRORS_LOG)).catch(() => { });
|
|
300
|
+
inputPath = await writeFileFromStorageToTemp(storageId);
|
|
301
|
+
const source = await probeSource(inputPath);
|
|
302
|
+
const variants = pickVariants(source);
|
|
303
|
+
log.info(`HLS for ${storageId}: source ${source.width}x${source.height} ` +
|
|
304
|
+
`@${source.videoBitrateKbps}kbps → ${variants.length} variant(s): ` +
|
|
305
|
+
variants
|
|
306
|
+
.map((v) => `${v.width}x${v.height}@${v.videoBitrateKbps}kbps`)
|
|
307
|
+
.join(', '));
|
|
308
|
+
await runHls(inputPath, streamDir, source, variants);
|
|
309
|
+
await finalizeMasterPlaylist(streamDir);
|
|
310
|
+
log.info(`HLS transcoding for ${storageId} finished`);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
314
|
+
log.error(`HLS transcoding for ${storageId} failed: ${message}`);
|
|
315
|
+
await writeErrorsLog(streamDir, message);
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
finally {
|
|
319
|
+
if (inputPath) {
|
|
320
|
+
await fs.unlink(inputPath).catch(() => { });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}, {
|
|
324
|
+
defaultJobOptions: {
|
|
325
|
+
removeOnComplete: { age: 3600 },
|
|
326
|
+
removeOnFail: { age: 86400 * 7, count: 50 },
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
export { mediaStreamingQueue, mediaStreamingWorker };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MediaStream } from '@openpeepshq/common/types';
|
|
2
|
+
/**
|
|
3
|
+
* Idempotent helper that ensures an HLS transcoding job exists for the given
|
|
4
|
+
* `storageId`. Three cases:
|
|
5
|
+
*
|
|
6
|
+
* - If the stream is already on disk in any state (`ready`, `processing`, or
|
|
7
|
+
* `error`), returns the current status without enqueuing.
|
|
8
|
+
* - Otherwise, creates the stream directory and enqueues a fresh transcoding
|
|
9
|
+
* job, defensively removing any stale BullMQ entry that would otherwise be
|
|
10
|
+
* silently deduplicated by `jobId`.
|
|
11
|
+
*
|
|
12
|
+
* Used by both the on-demand POST endpoint and the `postCreated`
|
|
13
|
+
* pre-warm handler so the two paths share identical "is this stream really
|
|
14
|
+
* being created right now?" semantics.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ensureStreamingJob: (storageId: string) => Promise<MediaStream>;
|
|
17
|
+
/**
|
|
18
|
+
* Walks the attachments on a freshly-created post and pre-warms HLS streams
|
|
19
|
+
* for any local-storage-hosted videos, so that by the time anyone tries to
|
|
20
|
+
* play them the transcoded ladder is already (or nearly) ready.
|
|
21
|
+
*/
|
|
22
|
+
export declare const prewarmPostStreams: (rawPost: unknown) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-warms HLS for a completed jam recording's video attachment as soon as
|
|
25
|
+
* the egress upload lands, so playback is ready before anyone opens the
|
|
26
|
+
* recording post.
|
|
27
|
+
*/
|
|
28
|
+
export declare const prewarmJamRecordingStream: (rawRecording: unknown) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Registers event handlers that pre-warm HLS streams for post videos and
|
|
31
|
+
* completed jam recordings. Uses `hub.once` (BullMQ-backed) so the work
|
|
32
|
+
* survives worker restarts.
|
|
33
|
+
*
|
|
34
|
+
* Should be invoked exactly once at worker boot.
|
|
35
|
+
*/
|
|
36
|
+
export declare const registerStreamingPrewarmHandlers: () => void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { hub } from '../events/index.js';
|
|
2
|
+
import { logger } from '../log/index.js';
|
|
3
|
+
import { buildStream, ensureStreamDir, getStreamStatus, parseLocalStorageUrl, recordStreamAccess, } from './streaming.js';
|
|
4
|
+
import { mediaStreamingQueue } from './streamingJobs.js';
|
|
5
|
+
const log = logger('app:media:streamingPrewarm');
|
|
6
|
+
/**
|
|
7
|
+
* Idempotent helper that ensures an HLS transcoding job exists for the given
|
|
8
|
+
* `storageId`. Three cases:
|
|
9
|
+
*
|
|
10
|
+
* - If the stream is already on disk in any state (`ready`, `processing`, or
|
|
11
|
+
* `error`), returns the current status without enqueuing.
|
|
12
|
+
* - Otherwise, creates the stream directory and enqueues a fresh transcoding
|
|
13
|
+
* job, defensively removing any stale BullMQ entry that would otherwise be
|
|
14
|
+
* silently deduplicated by `jobId`.
|
|
15
|
+
*
|
|
16
|
+
* Used by both the on-demand POST endpoint and the `postCreated`
|
|
17
|
+
* pre-warm handler so the two paths share identical "is this stream really
|
|
18
|
+
* being created right now?" semantics.
|
|
19
|
+
*/
|
|
20
|
+
export const ensureStreamingJob = async (storageId) => {
|
|
21
|
+
var _a;
|
|
22
|
+
// Refresh the last-access marker so the daily cleanup job doesn't evict a
|
|
23
|
+
// stream that someone just expressed interest in. Fire-and-forget and
|
|
24
|
+
// debounced; safe to call from many sites.
|
|
25
|
+
void recordStreamAccess(storageId);
|
|
26
|
+
const existing = await getStreamStatus(storageId);
|
|
27
|
+
if (existing) {
|
|
28
|
+
return Object.assign({ storageId }, existing);
|
|
29
|
+
}
|
|
30
|
+
// Create the directory before enqueueing so any subsequent caller hitting
|
|
31
|
+
// this code path immediately observes `processing` via `getStreamStatus`
|
|
32
|
+
// rather than racing to enqueue a duplicate job.
|
|
33
|
+
await ensureStreamDir(storageId);
|
|
34
|
+
const queue = mediaStreamingQueue();
|
|
35
|
+
const jobId = `stream:${storageId}`;
|
|
36
|
+
// Adding a job whose id already exists is a silent no-op in BullMQ. If a
|
|
37
|
+
// previous attempt failed and is being kept around for visibility (see the
|
|
38
|
+
// `removeOnFail` config), the new add would be discarded and the directory
|
|
39
|
+
// would stay stuck in `processing` forever. Removing first is idempotent —
|
|
40
|
+
// a currently-locked (active) job rejects removal which is fine; that
|
|
41
|
+
// means another worker is already on it and the directory check on the
|
|
42
|
+
// next POST will report it as `processing`.
|
|
43
|
+
await queue.remove(jobId).catch(() => undefined);
|
|
44
|
+
await queue.add('transcode', { storageId }, { jobId });
|
|
45
|
+
return (_a = (await buildStream(storageId))) !== null && _a !== void 0 ? _a : { storageId, status: 'processing' };
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Pre-warms HLS streams for any local-storage-hosted videos in the given
|
|
49
|
+
* attachments. Federated videos and non-video attachments are silently
|
|
50
|
+
* skipped.
|
|
51
|
+
*/
|
|
52
|
+
const prewarmVideoAttachments = async (attachments, context) => {
|
|
53
|
+
var _a;
|
|
54
|
+
for (const attachment of attachments) {
|
|
55
|
+
if (!attachment || attachment.type !== 'video' || !attachment.url) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const storageId = await parseLocalStorageUrl(attachment.url);
|
|
60
|
+
if (!storageId) {
|
|
61
|
+
// Federated or otherwise non-local — nothing to pre-warm.
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const result = await ensureStreamingJob(storageId);
|
|
65
|
+
log.info(`Prewarmed HLS for ${context} attachment ${storageId}: ${result.status}`);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// A single bad attachment shouldn't block prewarming siblings.
|
|
69
|
+
log.warn(`Failed to prewarm HLS for ${context} attachment ${(_a = attachment.url) !== null && _a !== void 0 ? _a : '?'}: ${e.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Walks the attachments on a freshly-created post and pre-warms HLS streams
|
|
75
|
+
* for any local-storage-hosted videos, so that by the time anyone tries to
|
|
76
|
+
* play them the transcoded ladder is already (or nearly) ready.
|
|
77
|
+
*/
|
|
78
|
+
export const prewarmPostStreams = async (rawPost) => {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
const post = rawPost;
|
|
81
|
+
const attachments = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.attachments;
|
|
82
|
+
if (!attachments || attachments.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
await prewarmVideoAttachments(attachments, `post ${(_b = post === null || post === void 0 ? void 0 : post.id) !== null && _b !== void 0 ? _b : '?'}`);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pre-warms HLS for a completed jam recording's video attachment as soon as
|
|
88
|
+
* the egress upload lands, so playback is ready before anyone opens the
|
|
89
|
+
* recording post.
|
|
90
|
+
*/
|
|
91
|
+
export const prewarmJamRecordingStream = async (rawRecording) => {
|
|
92
|
+
var _a;
|
|
93
|
+
const recording = rawRecording;
|
|
94
|
+
const attachment = recording === null || recording === void 0 ? void 0 : recording.attachment;
|
|
95
|
+
if (!attachment)
|
|
96
|
+
return;
|
|
97
|
+
await prewarmVideoAttachments([attachment], `jam recording ${(_a = recording === null || recording === void 0 ? void 0 : recording.id) !== null && _a !== void 0 ? _a : '?'}`);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Registers event handlers that pre-warm HLS streams for post videos and
|
|
101
|
+
* completed jam recordings. Uses `hub.once` (BullMQ-backed) so the work
|
|
102
|
+
* survives worker restarts.
|
|
103
|
+
*
|
|
104
|
+
* Should be invoked exactly once at worker boot.
|
|
105
|
+
*/
|
|
106
|
+
export const registerStreamingPrewarmHandlers = () => {
|
|
107
|
+
hub.once('postCreated', (post) => prewarmPostStreams(post));
|
|
108
|
+
hub.once('jamRecordingCompleted', (recording) => prewarmJamRecordingStream(recording));
|
|
109
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findMediaAttachment: (id: string) => Promise<import("@openpeepshq/common").MediaAttachment | undefined>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { config } from '../config/index.js';
|
|
2
|
+
export * from './mutations.js';
|
|
3
|
+
export * from './finders.js';
|
|
4
|
+
export * from './mapping.js';
|
|
5
|
+
const setUrlToCurrentHost = async (url) => {
|
|
6
|
+
const parsedUrl = new URL(url);
|
|
7
|
+
parsedUrl.host = (await config()).server.host;
|
|
8
|
+
return parsedUrl.toString();
|
|
9
|
+
};
|
|
10
|
+
export const convertUrls = async (data) => (Object.assign(Object.assign({}, data), { url: await setUrlToCurrentHost(data.url), previewUrl: data.previewUrl
|
|
11
|
+
? await setUrlToCurrentHost(data.previewUrl)
|
|
12
|
+
: null }));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MediaAttachment } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const mediaAttachmentsMapping: import("../db/pg/map").Mapping<{
|
|
3
|
+
type: string;
|
|
4
|
+
url: string;
|
|
5
|
+
previewUrl: string | null;
|
|
6
|
+
textUrl: null;
|
|
7
|
+
filename: string;
|
|
8
|
+
meta: {
|
|
9
|
+
usage?: string | undefined;
|
|
10
|
+
focus?: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
mimetype?: string | undefined;
|
|
15
|
+
size?: number | undefined;
|
|
16
|
+
};
|
|
17
|
+
description?: string | undefined;
|
|
18
|
+
blurhash?: string | undefined;
|
|
19
|
+
status?: "ready" | "failed" | "processing" | undefined;
|
|
20
|
+
error?: string | undefined;
|
|
21
|
+
}, MediaAttachment, MediaAttachment>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MediaAttachmentData } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const createMediaAttachment: (data: MediaAttachmentData) => Promise<import("@openpeepshq/common").MediaAttachment>;
|
|
3
|
+
export declare const updateMediaAttachment: (mediaAttachmentId: string, data: Partial<MediaAttachmentData>) => Promise<import("@openpeepshq/common").MediaAttachment>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mediaAttachmentsMapping } from './mapping.js';
|
|
2
|
+
import { allpeepDb } from '../db/index.js';
|
|
3
|
+
export const createMediaAttachment = async (data) => {
|
|
4
|
+
const db = await allpeepDb().then((db) => db.db);
|
|
5
|
+
return mediaAttachmentsMapping.create(db, data);
|
|
6
|
+
};
|
|
7
|
+
export const updateMediaAttachment = async (mediaAttachmentId, data) => {
|
|
8
|
+
const db = await allpeepDb().then((db) => db.db);
|
|
9
|
+
return mediaAttachmentsMapping.update(db, mediaAttachmentId, data);
|
|
10
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ExpandedNotification } from '@openpeepshq/common/types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
type: string;
|
|
4
|
+
event: string;
|
|
5
|
+
eventHandler: (data: unknown) => Promise<void>;
|
|
6
|
+
pushRenderer: (notification: ExpandedNotification) => Promise<{
|
|
7
|
+
title: string;
|
|
8
|
+
options: {
|
|
9
|
+
body: string | undefined;
|
|
10
|
+
icon: string;
|
|
11
|
+
actions: {
|
|
12
|
+
action: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
invalidateQueries: string[][];
|
|
17
|
+
}>;
|
|
18
|
+
defaultSettings: {
|
|
19
|
+
readonly create: true;
|
|
20
|
+
readonly push: true;
|
|
21
|
+
readonly email: true;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { notificationAll, } from '@openpeepshq/common/types';
|
|
2
|
+
import { listProfiles } from '@openpeepshq/core/profiles';
|
|
3
|
+
import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
4
|
+
import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
|
|
5
|
+
import { communityConfig } from '../../../config/index.js';
|
|
6
|
+
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
|
+
const eventHandler = async (data) => {
|
|
8
|
+
const post = data;
|
|
9
|
+
for (const recipientProfile of await listProfiles()) {
|
|
10
|
+
if (post.profile.id !== (recipientProfile === null || recipientProfile === void 0 ? void 0 : recipientProfile.id)) {
|
|
11
|
+
await maybeCreateNotification(recipientProfile, {
|
|
12
|
+
type: 'announcement',
|
|
13
|
+
postId: post.id,
|
|
14
|
+
fromProfileId: post.profile.id,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const pushRenderer = async (notification) => {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
return ({
|
|
22
|
+
title: `${profileName((_a = notification.post) === null || _a === void 0 ? void 0 : _a.profile)} posted an announcement`,
|
|
23
|
+
options: {
|
|
24
|
+
body: (_c = (_b = notification.post) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.content,
|
|
25
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
action: `goto:/posts/${(_d = notification.post) === null || _d === void 0 ? void 0 : _d.id}`,
|
|
29
|
+
title: 'Go to announcement',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export default {
|
|
37
|
+
type: 'announcement',
|
|
38
|
+
event: 'postAnnounced',
|
|
39
|
+
eventHandler,
|
|
40
|
+
pushRenderer,
|
|
41
|
+
defaultSettings: notificationAll,
|
|
42
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ExpandedNotification } from '@openpeepshq/common/types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
type: string;
|
|
4
|
+
event: string;
|
|
5
|
+
eventHandler: (data: unknown) => Promise<void>;
|
|
6
|
+
expander: (notification: ExpandedNotification) => Promise<ExpandedNotification>;
|
|
7
|
+
pushRenderer: (notification: ExpandedNotification) => Promise<{
|
|
8
|
+
title: string;
|
|
9
|
+
options: {
|
|
10
|
+
body: string | undefined;
|
|
11
|
+
icon: string;
|
|
12
|
+
data: {
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
actions: {
|
|
16
|
+
action: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
invalidateQueries: string[][];
|
|
21
|
+
}>;
|
|
22
|
+
defaultSettings: {
|
|
23
|
+
readonly create: true;
|
|
24
|
+
readonly push: true;
|
|
25
|
+
readonly email: true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|