@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,129 @@
|
|
|
1
|
+
import { publicProfileSchema, } from '@openpeepshq/common/types';
|
|
2
|
+
import { canModerateJam, countYesRsvps, getEffectiveRsvp, } from '@openpeepshq/common/lib';
|
|
3
|
+
import { authNeeded, forbidden, notFound } from '../errors/index.js';
|
|
4
|
+
import { config } from '../config/index.js';
|
|
5
|
+
import { AccessToken, TrackSource } from 'livekit-server-sdk';
|
|
6
|
+
import { hub } from '../events/index.js';
|
|
7
|
+
import { JAM_ROOM_DEPARTURE_TIMEOUT_SEC, JAM_ROOM_EMPTY_TIMEOUT_SEC, roomService, } from './livekit.js';
|
|
8
|
+
import { localInstanceDomain } from './helpers.js';
|
|
9
|
+
import { createJamEvent } from './mutations.js';
|
|
10
|
+
import { uuidv7 } from 'uuidv7';
|
|
11
|
+
const calculateSources = (jam, profile) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const sources = [TrackSource.MICROPHONE];
|
|
14
|
+
if (jam.videoEnabled) {
|
|
15
|
+
sources.push(TrackSource.CAMERA, TrackSource.SCREEN_SHARE, TrackSource.SCREEN_SHARE_AUDIO);
|
|
16
|
+
}
|
|
17
|
+
if ((_a = jam.presenters) === null || _a === void 0 ? void 0 : _a.includes(profile.id)) {
|
|
18
|
+
sources.push(TrackSource.SCREEN_SHARE, TrackSource.SCREEN_SHARE_AUDIO);
|
|
19
|
+
}
|
|
20
|
+
return sources;
|
|
21
|
+
};
|
|
22
|
+
export const assertJamRsvpAllowed = (event, profile) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const eventData = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? event.data : undefined;
|
|
25
|
+
if (!(eventData === null || eventData === void 0 ? void 0 : eventData.maxAttendees)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (canModerateJam(profile, event)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (((_b = getEffectiveRsvp(event, profile.id)) === null || _b === void 0 ? void 0 : _b.response) === 'yes') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (countYesRsvps(event) >= eventData.maxAttendees) {
|
|
35
|
+
throw forbidden({ errorKey: 'error.eventAtCapacity' });
|
|
36
|
+
}
|
|
37
|
+
throw forbidden({ errorKey: 'error.jamRsvpRequired' });
|
|
38
|
+
};
|
|
39
|
+
export const createJamEgressToken = async (event) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const jamId = event.id;
|
|
42
|
+
const jam = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.jam);
|
|
43
|
+
if (!jam) {
|
|
44
|
+
throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
|
|
45
|
+
}
|
|
46
|
+
const { apiKey, apiSecret } = (await config()).jams.livekit;
|
|
47
|
+
const accessToken = new AccessToken(apiKey, apiSecret, {
|
|
48
|
+
identity: `EG_${uuidv7()}`,
|
|
49
|
+
metadata: JSON.stringify({
|
|
50
|
+
observer: true,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
accessToken.addGrant({
|
|
54
|
+
room: jamId,
|
|
55
|
+
hidden: true,
|
|
56
|
+
roomJoin: true,
|
|
57
|
+
roomRecord: true,
|
|
58
|
+
canSubscribe: true,
|
|
59
|
+
});
|
|
60
|
+
return accessToken.toJwt();
|
|
61
|
+
};
|
|
62
|
+
export const createJamToken = async (event, profile, external = false) => {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
if (!profile.id)
|
|
65
|
+
throw authNeeded({ errorKey: 'error.profileRequired' });
|
|
66
|
+
const jamId = event.id;
|
|
67
|
+
const jam = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.jam);
|
|
68
|
+
if (!jam) {
|
|
69
|
+
throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
|
|
70
|
+
}
|
|
71
|
+
assertJamRsvpAllowed(event, profile);
|
|
72
|
+
const rs = await roomService();
|
|
73
|
+
if (rs === undefined) {
|
|
74
|
+
throw forbidden({ errorKey: 'error.jamNotOpen' });
|
|
75
|
+
}
|
|
76
|
+
const rooms = await rs.listRooms([jamId]);
|
|
77
|
+
const jamOpen = rooms.length === 1;
|
|
78
|
+
if (!jamOpen && !(jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id))) {
|
|
79
|
+
throw forbidden({ errorKey: 'error.jamNotOpen' });
|
|
80
|
+
}
|
|
81
|
+
if (!jamOpen) {
|
|
82
|
+
// Stamp community domain so Cockpit can attribute shared-SFU webhooks.
|
|
83
|
+
const instanceDomain = await localInstanceDomain();
|
|
84
|
+
if (instanceDomain) {
|
|
85
|
+
try {
|
|
86
|
+
await rs.createRoom({
|
|
87
|
+
name: jamId,
|
|
88
|
+
metadata: JSON.stringify({ instanceDomain }),
|
|
89
|
+
emptyTimeout: JAM_ROOM_EMPTY_TIMEOUT_SEC,
|
|
90
|
+
departureTimeout: JAM_ROOM_DEPARTURE_TIMEOUT_SEC,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (_d) {
|
|
94
|
+
// Concurrent open may have created the room already.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
createJamEvent({
|
|
98
|
+
id: uuidv7(),
|
|
99
|
+
jamId,
|
|
100
|
+
type: 'start',
|
|
101
|
+
profileId: profile.id,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const { apiKey, apiSecret } = (await config()).jams.livekit;
|
|
105
|
+
const accessToken = new AccessToken(apiKey, apiSecret, {
|
|
106
|
+
identity: profile.id,
|
|
107
|
+
metadata: JSON.stringify({
|
|
108
|
+
profile: publicProfileSchema.parse(profile),
|
|
109
|
+
handRaised: undefined,
|
|
110
|
+
external,
|
|
111
|
+
observer: false,
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
accessToken.addGrant({
|
|
115
|
+
room: jamId,
|
|
116
|
+
roomJoin: true,
|
|
117
|
+
roomAdmin: jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id),
|
|
118
|
+
roomRecord: jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id),
|
|
119
|
+
canPublish: (jam === null || jam === void 0 ? void 0 : jam.type) === 'video-call' || !!((_c = jam === null || jam === void 0 ? void 0 : jam.speakers) === null || _c === void 0 ? void 0 : _c.includes(profile.id)),
|
|
120
|
+
canPublishSources: calculateSources(jam, profile),
|
|
121
|
+
canPublishData: true,
|
|
122
|
+
canSubscribe: true,
|
|
123
|
+
canUpdateOwnMetadata: true,
|
|
124
|
+
});
|
|
125
|
+
if (!jamOpen) {
|
|
126
|
+
hub.emit('jamStarted', profile, event);
|
|
127
|
+
}
|
|
128
|
+
return accessToken.toJwt();
|
|
129
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PublicProfile, type PostWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const currentWaitingRoomWatch: (jamEvent: PostWithMeta, onChange: (waitingRoom: Record<string, PublicProfile>) => void | Promise<void>) => Promise<() => Promise<void>>;
|
|
3
|
+
export declare const admittanceWatch: (jamEvent: PostWithMeta, profileId: string, onToken: (token: string) => Promise<void> | void) => Promise<() => Promise<void>>;
|
|
4
|
+
export declare const joinWaitingRoom: (event: PostWithMeta, profile: PublicProfile) => Promise<void>;
|
|
5
|
+
export declare const acceptFromWaitingRoom: (event: PostWithMeta, profileId: string) => Promise<undefined>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { publicProfileSchema, } from '@openpeepshq/common/types';
|
|
2
|
+
import { assertJamRsvpAllowed, createJamToken } from './token.js';
|
|
3
|
+
import { disconnect, getConnection, getSharedConnection, } from '../redis/connection.js';
|
|
4
|
+
const waitingRoomKey = (event) => `jams:waiting-room:${event.id}`;
|
|
5
|
+
const admittanceKey = (event) => `jams:admitted:${event.id}`;
|
|
6
|
+
const currentWaitingRoom = (event) => getSharedConnection()
|
|
7
|
+
.then((conn) => conn.hGetAll(waitingRoomKey(event)))
|
|
8
|
+
.then((wrRaw) => Object.entries(wrRaw))
|
|
9
|
+
.then((entries) => entries.filter((e) => e[0] && e[1]))
|
|
10
|
+
.then((entries) => entries.map(([key, value]) => [
|
|
11
|
+
key,
|
|
12
|
+
publicProfileSchema.partial().parse(JSON.parse(value)),
|
|
13
|
+
]))
|
|
14
|
+
.then((entries) => Object.fromEntries(entries));
|
|
15
|
+
const currentAdmittance = (event) => getSharedConnection().then((conn) => conn.hGetAll(admittanceKey(event)));
|
|
16
|
+
export const currentWaitingRoomWatch = (jamEvent, onChange) => currentWaitingRoom(jamEvent)
|
|
17
|
+
.then(onChange)
|
|
18
|
+
.then(() => getConnection())
|
|
19
|
+
.then((conn) => conn
|
|
20
|
+
.subscribe(`__keyspace@0__:${waitingRoomKey(jamEvent)}`, (event) => {
|
|
21
|
+
if (['hset', 'hdel'].includes(event)) {
|
|
22
|
+
currentWaitingRoom(jamEvent).then(onChange);
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
.then(() => () => disconnect(conn)));
|
|
26
|
+
export const admittanceWatch = (jamEvent, profileId, onToken) => currentAdmittance(jamEvent)
|
|
27
|
+
.then((admittance) => {
|
|
28
|
+
if (admittance[profileId]) {
|
|
29
|
+
return onToken(admittance[profileId]);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.then(() => getConnection())
|
|
33
|
+
.then((conn) => conn
|
|
34
|
+
.subscribe(`__keyspace@0__:${admittanceKey(jamEvent)}`, async (event) => {
|
|
35
|
+
if ('hset' === event) {
|
|
36
|
+
const token = await getSharedConnection().then((c) => c.hGet(admittanceKey(jamEvent), profileId));
|
|
37
|
+
if (token) {
|
|
38
|
+
await disconnect(conn);
|
|
39
|
+
return onToken(token);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.then(() => async () => {
|
|
44
|
+
await getSharedConnection().then((c) => c.hDel(waitingRoomKey(jamEvent), profileId));
|
|
45
|
+
await disconnect(conn);
|
|
46
|
+
}));
|
|
47
|
+
export const joinWaitingRoom = async (event, profile) => {
|
|
48
|
+
assertJamRsvpAllowed(event, profile);
|
|
49
|
+
const conn = await getSharedConnection();
|
|
50
|
+
const multi = conn.multi();
|
|
51
|
+
const wrKey = waitingRoomKey(event);
|
|
52
|
+
const aKey = admittanceKey(event);
|
|
53
|
+
multi.hDel(aKey, profile.id);
|
|
54
|
+
multi.hSet(wrKey, { [profile.id]: JSON.stringify(profile) });
|
|
55
|
+
await multi.exec();
|
|
56
|
+
};
|
|
57
|
+
export const acceptFromWaitingRoom = async (event, profileId) => {
|
|
58
|
+
const conn = await getSharedConnection();
|
|
59
|
+
const wrKey = waitingRoomKey(event);
|
|
60
|
+
const profile = await publicProfileSchema
|
|
61
|
+
.parseAsync(JSON.parse((await conn.hGet(wrKey, profileId)) || 'undefined'))
|
|
62
|
+
.catch(() => undefined);
|
|
63
|
+
await conn.hDel(wrKey, profileId);
|
|
64
|
+
if (!event || !profile) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const aKey = admittanceKey(event);
|
|
68
|
+
await conn.hSet(aKey, {
|
|
69
|
+
[profile.id]: await createJamToken(event, profile),
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Processor, Queue, QueueOptions, Worker } from 'bullmq';
|
|
2
|
+
export declare const connection: {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const queues: Record<string, Queue>;
|
|
7
|
+
export declare const closeQueues: () => Promise<void>;
|
|
8
|
+
export declare const queueAndWorker: <Input, Output = undefined>(queueName: string, processor: Processor<Input, Output>, queueOptions?: Omit<QueueOptions, "connection">) => [() => Queue, () => Worker];
|
|
9
|
+
export { getJobDetail } from './jobDetail';
|
|
10
|
+
export { jobLogger, logStep, logFailure, formatErrorDetail, type JobLog, } from './jobLog';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Queue, Worker } from 'bullmq';
|
|
2
|
+
export const connection = {
|
|
3
|
+
host: process.env.REDIS_HOST || 'localhost',
|
|
4
|
+
port: Number(process.env.REDIS_PORT) || 6379,
|
|
5
|
+
};
|
|
6
|
+
export const queues = {};
|
|
7
|
+
export const closeQueues = async () => {
|
|
8
|
+
const queueEntries = Object.entries(queues);
|
|
9
|
+
await Promise.all(queueEntries.map(async ([queueName, queue]) => {
|
|
10
|
+
try {
|
|
11
|
+
await queue.close();
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
delete queues[queueName];
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
export const queueAndWorker = (queueName, processor, queueOptions) => [
|
|
19
|
+
() => {
|
|
20
|
+
if (!queues[queueName]) {
|
|
21
|
+
const queue = new Queue(queueName, Object.assign({ connection }, queueOptions));
|
|
22
|
+
queues[queueName] = queue;
|
|
23
|
+
// Clean up existing jobs based on defaultJobOptions retention settings
|
|
24
|
+
const defaultJobOptions = queueOptions === null || queueOptions === void 0 ? void 0 : queueOptions.defaultJobOptions;
|
|
25
|
+
if (defaultJobOptions) {
|
|
26
|
+
void (async () => {
|
|
27
|
+
try {
|
|
28
|
+
// Clean completed jobs if removeOnComplete has age setting
|
|
29
|
+
if (defaultJobOptions.removeOnComplete &&
|
|
30
|
+
typeof defaultJobOptions.removeOnComplete === 'object' &&
|
|
31
|
+
'age' in defaultJobOptions.removeOnComplete &&
|
|
32
|
+
typeof defaultJobOptions.removeOnComplete.age === 'number') {
|
|
33
|
+
const ageMs = defaultJobOptions.removeOnComplete.age * 1000;
|
|
34
|
+
await queue.clean(ageMs, 1000, 'completed');
|
|
35
|
+
}
|
|
36
|
+
// Clean failed jobs if removeOnFail has age setting
|
|
37
|
+
if (defaultJobOptions.removeOnFail &&
|
|
38
|
+
typeof defaultJobOptions.removeOnFail === 'object' &&
|
|
39
|
+
'age' in defaultJobOptions.removeOnFail &&
|
|
40
|
+
typeof defaultJobOptions.removeOnFail.age === 'number') {
|
|
41
|
+
const ageMs = defaultJobOptions.removeOnFail.age * 1000;
|
|
42
|
+
await queue.clean(ageMs, 1000, 'failed');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// Silently fail cleanup to not block queue initialization
|
|
47
|
+
console.error(`Failed to clean old jobs for queue "${queueName}":`, error);
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return queues[queueName];
|
|
53
|
+
},
|
|
54
|
+
() => new Worker(queueName, processor, {
|
|
55
|
+
connection,
|
|
56
|
+
concurrency: 5,
|
|
57
|
+
}),
|
|
58
|
+
];
|
|
59
|
+
export { getJobDetail } from './jobDetail.js';
|
|
60
|
+
export { jobLogger, logStep, logFailure, formatErrorDetail, } from './jobLog.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Queue } from 'bullmq';
|
|
2
|
+
import { connection, queues } from './index.js';
|
|
3
|
+
const getOrCreateQueue = (queueName) => {
|
|
4
|
+
var _a;
|
|
5
|
+
return (_a = queues[queueName]) !== null && _a !== void 0 ? _a : (queues[queueName] = new Queue(queueName, { connection }));
|
|
6
|
+
};
|
|
7
|
+
export const getJobDetail = async (queueName, jobId) => {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
const queue = getOrCreateQueue(queueName);
|
|
10
|
+
const job = await queue.getJob(jobId);
|
|
11
|
+
if (!job || job.id == null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const [state, { logs, count }] = await Promise.all([
|
|
15
|
+
job.getState(),
|
|
16
|
+
queue.getJobLogs(jobId, 0, 500),
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
queue: queueName,
|
|
20
|
+
id: String(job.id),
|
|
21
|
+
name: job.name,
|
|
22
|
+
state,
|
|
23
|
+
failedReason: (_a = job.failedReason) !== null && _a !== void 0 ? _a : null,
|
|
24
|
+
finishedOn: (_b = job.finishedOn) !== null && _b !== void 0 ? _b : null,
|
|
25
|
+
processedOn: (_c = job.processedOn) !== null && _c !== void 0 ? _c : null,
|
|
26
|
+
timestamp: (_d = job.timestamp) !== null && _d !== void 0 ? _d : null,
|
|
27
|
+
data: (_e = job.data) !== null && _e !== void 0 ? _e : null,
|
|
28
|
+
logs,
|
|
29
|
+
logCount: count,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Job } from 'bullmq';
|
|
2
|
+
import type { Logger } from '@openpeepshq/common/types';
|
|
3
|
+
export type JobLog = (message: string) => Promise<void>;
|
|
4
|
+
/** Wraps `job.log` so callers get a simple `(message) => Promise<void>`. */
|
|
5
|
+
export declare const jobLogger: (job: Job) => JobLog;
|
|
6
|
+
/**
|
|
7
|
+
* Best-effort, human-readable rendering of an error. Pulls the fields that the
|
|
8
|
+
* push backends attach (web-push `statusCode`/`body`, APNs `reason`, FCM
|
|
9
|
+
* `code`) so failed deliveries are diagnosable from the job log alone.
|
|
10
|
+
*/
|
|
11
|
+
export declare const formatErrorDetail: (error: unknown) => string;
|
|
12
|
+
/** Log a normal progress step to the job log (if present) and the logger. */
|
|
13
|
+
export declare const logStep: (jobLog: JobLog | undefined, log: Logger, message: string) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Log a failure to the job log (if present) and the logger with `FAILED —`
|
|
16
|
+
* emphasis, including the formatted error detail and stack when available.
|
|
17
|
+
*/
|
|
18
|
+
export declare const logFailure: (jobLog: JobLog | undefined, log: Logger, message: string, error?: unknown) => Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Wraps `job.log` so callers get a simple `(message) => Promise<void>`. */
|
|
2
|
+
export const jobLogger = (job) => (message) => job.log(message).then(() => undefined);
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort, human-readable rendering of an error. Pulls the fields that the
|
|
5
|
+
* push backends attach (web-push `statusCode`/`body`, APNs `reason`, FCM
|
|
6
|
+
* `code`) so failed deliveries are diagnosable from the job log alone.
|
|
7
|
+
*/
|
|
8
|
+
export const formatErrorDetail = (error) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (error instanceof Error) {
|
|
11
|
+
const e = error;
|
|
12
|
+
const parts = [e.message];
|
|
13
|
+
if (e.code != null)
|
|
14
|
+
parts.push(`code=${e.code}`);
|
|
15
|
+
if (e.statusCode != null)
|
|
16
|
+
parts.push(`statusCode=${e.statusCode}`);
|
|
17
|
+
if (e.reason)
|
|
18
|
+
parts.push(`reason=${e.reason}`);
|
|
19
|
+
if (e.body) {
|
|
20
|
+
const body = typeof e.body === 'string' ? e.body : JSON.stringify(e.body);
|
|
21
|
+
parts.push(`body=${body.slice(0, 300)}`);
|
|
22
|
+
}
|
|
23
|
+
return parts.join(' | ');
|
|
24
|
+
}
|
|
25
|
+
if (error && typeof error === 'object') {
|
|
26
|
+
const e = error;
|
|
27
|
+
const reason = (_b = (_a = e.reason) !== null && _a !== void 0 ? _a : e.code) !== null && _b !== void 0 ? _b : e.message;
|
|
28
|
+
if (reason != null)
|
|
29
|
+
return String(reason);
|
|
30
|
+
try {
|
|
31
|
+
return JSON.stringify(error);
|
|
32
|
+
}
|
|
33
|
+
catch (_c) {
|
|
34
|
+
return String(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return String(error);
|
|
38
|
+
};
|
|
39
|
+
/** Log a normal progress step to the job log (if present) and the logger. */
|
|
40
|
+
export const logStep = async (jobLog, log, message) => {
|
|
41
|
+
if (jobLog)
|
|
42
|
+
await jobLog(message);
|
|
43
|
+
log.info(message);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Log a failure to the job log (if present) and the logger with `FAILED —`
|
|
47
|
+
* emphasis, including the formatted error detail and stack when available.
|
|
48
|
+
*/
|
|
49
|
+
export const logFailure = async (jobLog, log, message, error) => {
|
|
50
|
+
const line = error === undefined
|
|
51
|
+
? `FAILED — ${message}`
|
|
52
|
+
: `FAILED — ${message}: ${formatErrorDetail(error)}`;
|
|
53
|
+
if (jobLog)
|
|
54
|
+
await jobLog(line);
|
|
55
|
+
log.error(line);
|
|
56
|
+
if (error instanceof Error && error.stack) {
|
|
57
|
+
if (jobLog)
|
|
58
|
+
await jobLog(error.stack);
|
|
59
|
+
log.error(error.stack);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JWTPayload } from 'jose';
|
|
2
|
+
export declare const jwtUtil: () => Promise<{
|
|
3
|
+
publicKey: string;
|
|
4
|
+
sign: ({ payload, expirationTime, id, }: {
|
|
5
|
+
payload: unknown;
|
|
6
|
+
expirationTime: string;
|
|
7
|
+
id: string;
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
verify: (token: string) => Promise<import("jose").JWTVerifyResult<JWTPayload> | undefined>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import { SignJWT, jwtVerify, importJWK } from 'jose';
|
|
3
|
+
import { config } from '../config/index.js';
|
|
4
|
+
import nacl from 'tweetnacl';
|
|
5
|
+
const toJWK = async (keyPair) => {
|
|
6
|
+
const encode = (uint8Array) => Buffer.from(uint8Array).toString('base64url');
|
|
7
|
+
const jwkPublicKey = await importJWK({
|
|
8
|
+
kty: 'OKP',
|
|
9
|
+
crv: 'Ed25519',
|
|
10
|
+
x: encode(keyPair.publicKey),
|
|
11
|
+
});
|
|
12
|
+
const jwkPrivateKey = await importJWK({
|
|
13
|
+
kty: 'OKP',
|
|
14
|
+
crv: 'Ed25519',
|
|
15
|
+
d: encode(keyPair.secretKey.subarray(0, 32)), // Ed25519 private key is the first 32 bytes of the secretKey
|
|
16
|
+
x: encode(keyPair.publicKey),
|
|
17
|
+
});
|
|
18
|
+
return { jwkPublicKey, jwkPrivateKey };
|
|
19
|
+
};
|
|
20
|
+
const initJwt = async () => {
|
|
21
|
+
const { secrets: { jwt: jwtSecret }, } = await config();
|
|
22
|
+
const seed = crypto.createHash('sha256').update(jwtSecret).digest();
|
|
23
|
+
const keyPair = nacl.sign.keyPair.fromSeed(new Uint8Array(seed));
|
|
24
|
+
const { jwkPublicKey, jwkPrivateKey } = await toJWK(keyPair);
|
|
25
|
+
const publicKey = Buffer.from(keyPair.publicKey).toString('base64url');
|
|
26
|
+
return {
|
|
27
|
+
publicKey,
|
|
28
|
+
sign: ({ payload, expirationTime, id, }) => new SignJWT(payload)
|
|
29
|
+
.setProtectedHeader({ alg: 'EdDSA', kid: publicKey })
|
|
30
|
+
.setIssuedAt()
|
|
31
|
+
.setExpirationTime(expirationTime)
|
|
32
|
+
.setJti(id)
|
|
33
|
+
.sign(jwkPrivateKey),
|
|
34
|
+
verify: async (token) => jwtVerify(token, jwkPublicKey, { algorithms: ['EdDSA'] }).catch(() => undefined),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
let jwtPromise;
|
|
38
|
+
export const jwtUtil = () => {
|
|
39
|
+
if (!jwtPromise) {
|
|
40
|
+
jwtPromise = initJwt();
|
|
41
|
+
}
|
|
42
|
+
return jwtPromise;
|
|
43
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
2
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3
|
+
var m = o[Symbol.asyncIterator], i;
|
|
4
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
5
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
6
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
|
+
};
|
|
8
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
9
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
10
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
11
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
12
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
13
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
14
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
15
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
16
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
17
|
+
function fulfill(value) { resume("next", value); }
|
|
18
|
+
function reject(value) { resume("throw", value); }
|
|
19
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
20
|
+
};
|
|
21
|
+
function nodeStreamToIterator(stream) {
|
|
22
|
+
return __asyncGenerator(this, arguments, function* nodeStreamToIterator_1() {
|
|
23
|
+
var _a, e_1, _b, _c;
|
|
24
|
+
try {
|
|
25
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
26
|
+
_c = stream_1_1.value;
|
|
27
|
+
_d = false;
|
|
28
|
+
const chunk = _c;
|
|
29
|
+
yield yield __await(chunk);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
|
|
36
|
+
}
|
|
37
|
+
finally { if (e_1) throw e_1.error; }
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function iteratorToStream(iterator) {
|
|
42
|
+
return new ReadableStream({
|
|
43
|
+
async pull(controller) {
|
|
44
|
+
const { value, done } = await iterator.next();
|
|
45
|
+
if (done) {
|
|
46
|
+
controller.close();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
controller.enqueue(new Uint8Array(value));
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export const readStreamToReadableStream = (readStream) => {
|
|
55
|
+
return iteratorToStream(nodeStreamToIterator(readStream));
|
|
56
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { notFound } from '../errors/index.js';
|
|
2
|
+
export const throwIfUndefined = (maybeObject) => {
|
|
3
|
+
if (!maybeObject) {
|
|
4
|
+
throw notFound({ errorKey: 'error.notFound' });
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return maybeObject;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const toArrayBuffer = (data) => {
|
|
11
|
+
if (data instanceof ArrayBuffer) {
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
const copy = new ArrayBuffer(data.byteLength);
|
|
15
|
+
new Uint8Array(copy).set(new Uint8Array(data));
|
|
16
|
+
return copy;
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const ZodObjectCtor = z.object({}).constructor;
|
|
3
|
+
const ZodArrayCtor = z.array(z.string()).constructor;
|
|
4
|
+
const ZodOptionalCtor = z.string().optional().constructor;
|
|
5
|
+
const ZodNullableCtor = z.string().nullable().constructor;
|
|
6
|
+
/** Zod v4 removed `.deepPartial()`; this mirrors the v3 helper for config documents. */
|
|
7
|
+
export const zodDeepPartialSchema = (schema) => {
|
|
8
|
+
if (schema instanceof ZodObjectCtor) {
|
|
9
|
+
const shape = schema.shape;
|
|
10
|
+
const partial = {};
|
|
11
|
+
for (const key of Object.keys(shape)) {
|
|
12
|
+
partial[key] = z.optional(zodDeepPartialSchema(shape[key]));
|
|
13
|
+
}
|
|
14
|
+
return z.object(partial);
|
|
15
|
+
}
|
|
16
|
+
if (schema instanceof ZodArrayCtor) {
|
|
17
|
+
return z.array(zodDeepPartialSchema(schema.element));
|
|
18
|
+
}
|
|
19
|
+
if (schema instanceof ZodOptionalCtor) {
|
|
20
|
+
return z.optional(zodDeepPartialSchema(schema.unwrap()));
|
|
21
|
+
}
|
|
22
|
+
if (schema instanceof ZodNullableCtor) {
|
|
23
|
+
return z.nullable(zodDeepPartialSchema(schema.unwrap()));
|
|
24
|
+
}
|
|
25
|
+
return schema;
|
|
26
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { config } from '../config/index.js';
|
|
2
|
+
import { geocoder, } from '@openpeepshq/geocoder';
|
|
3
|
+
import { createCache } from 'cache-manager';
|
|
4
|
+
const cache = createCache({
|
|
5
|
+
ttl: 60 * 60 * 24 * 7 * 1000,
|
|
6
|
+
});
|
|
7
|
+
const getNominatimResults = async (query) => cache.wrap(query, async () => {
|
|
8
|
+
const coreConfig = await config();
|
|
9
|
+
const remoteGeocoder = geocoder((coreConfig.services.location.type || 'nominatim'), {
|
|
10
|
+
apiKey: coreConfig.services.location.apiKey,
|
|
11
|
+
serviceUrl: coreConfig.services.location.url,
|
|
12
|
+
});
|
|
13
|
+
return remoteGeocoder.geocode(query).catch(() => []);
|
|
14
|
+
});
|
|
15
|
+
export const getLocationSuggestions = async (query) => {
|
|
16
|
+
query = query.trim();
|
|
17
|
+
const latLngGeocoder = geocoder('latlng');
|
|
18
|
+
const latLngResults = await latLngGeocoder.geocode(query);
|
|
19
|
+
if (latLngResults.length > 0) {
|
|
20
|
+
return latLngResults;
|
|
21
|
+
}
|
|
22
|
+
const openLocationCodeGeocoder = geocoder('open-location-code');
|
|
23
|
+
const openLocationCodeResults = await openLocationCodeGeocoder.geocode(query);
|
|
24
|
+
if (openLocationCodeResults.length > 0) {
|
|
25
|
+
return openLocationCodeResults;
|
|
26
|
+
}
|
|
27
|
+
return getNominatimResults(query);
|
|
28
|
+
};
|