@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,14 @@
|
|
|
1
|
+
/** Fail if app tables are missing (used when RUN_DB_MIGRATE_ON_BOOT=false). */
|
|
2
|
+
export declare const assertSchemaReady: () => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Apply Drizzle migrations. Heals half-wiped DBs where the journal and
|
|
5
|
+
* `public` schema disagree (orphan types, missing tables, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Concurrent starters often hit duplicate_table / pg_type conflicts; if app
|
|
8
|
+
* tables already exist we must NOT reset — that would DROP SCHEMA under the
|
|
9
|
+
* other process mid-import. Also refuses reset when application data exists.
|
|
10
|
+
*
|
|
11
|
+
* Callers that may race (initPostgres, auto-migrate) must hold
|
|
12
|
+
* SCHEMA_MIGRATE_LOCK around this function.
|
|
13
|
+
*/
|
|
14
|
+
export declare const runMigrations: () => Promise<void>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { getTableName, sql } from 'drizzle-orm';
|
|
5
|
+
import { migrate } from 'drizzle-orm/node-postgres/migrator';
|
|
6
|
+
import { logger } from '../../log/index.js';
|
|
7
|
+
import { pgDb, resetPostgresSchemas } from './client.js';
|
|
8
|
+
import { getTableForCollection } from './map/registry.js';
|
|
9
|
+
import { DOCUMENT_IMPORT_ORDER, EDGE_IMPORT_ORDER } from '../migration/shared.js';
|
|
10
|
+
const log = logger('openpeeps:pg:migrate');
|
|
11
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const resolveMigrationsFolder = () => {
|
|
13
|
+
const besideModule = join(moduleDir, 'sql');
|
|
14
|
+
if (existsSync(besideModule)) {
|
|
15
|
+
return besideModule;
|
|
16
|
+
}
|
|
17
|
+
return join(moduleDir, '..', '..', '..', 'src', 'db', 'pg', 'sql');
|
|
18
|
+
};
|
|
19
|
+
const migrationsFolder = resolveMigrationsFolder();
|
|
20
|
+
const APP_TABLE_NAMES = [
|
|
21
|
+
...DOCUMENT_IMPORT_ORDER.map((collection) => getTableName(getTableForCollection(collection))),
|
|
22
|
+
...EDGE_IMPORT_ORDER.map((collection) => getTableName(getTableForCollection(collection))),
|
|
23
|
+
];
|
|
24
|
+
const tableExists = async (tableName) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const db = pgDb();
|
|
27
|
+
const result = await db.execute(sql.raw(`SELECT to_regclass('public.${tableName}')::text AS regclass`));
|
|
28
|
+
return ((_a = result.rows[0]) === null || _a === void 0 ? void 0 : _a.regclass) != null;
|
|
29
|
+
};
|
|
30
|
+
const missingAppTables = async () => {
|
|
31
|
+
const missing = [];
|
|
32
|
+
for (const tableName of APP_TABLE_NAMES) {
|
|
33
|
+
if (!(await tableExists(tableName))) {
|
|
34
|
+
missing.push(tableName);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return missing;
|
|
38
|
+
};
|
|
39
|
+
const ensurePublicSchema = async () => {
|
|
40
|
+
const db = pgDb();
|
|
41
|
+
await db.execute(sql.raw('CREATE SCHEMA IF NOT EXISTS public'));
|
|
42
|
+
await db.execute(sql.raw('GRANT ALL ON SCHEMA public TO CURRENT_USER'));
|
|
43
|
+
await db.execute(sql.raw('GRANT ALL ON SCHEMA public TO public'));
|
|
44
|
+
await db.execute(sql.raw('SET search_path TO public'));
|
|
45
|
+
};
|
|
46
|
+
/** pg_type / relation conflicts from a half-wiped or concurrent migrate. */
|
|
47
|
+
const isSchemaConflictError = (err) => {
|
|
48
|
+
const candidates = [
|
|
49
|
+
err,
|
|
50
|
+
err && typeof err === 'object' && 'cause' in err
|
|
51
|
+
? err.cause
|
|
52
|
+
: undefined,
|
|
53
|
+
];
|
|
54
|
+
return candidates.some((candidate) => {
|
|
55
|
+
if (!candidate || typeof candidate !== 'object') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const code = candidate.code;
|
|
59
|
+
// 23505 unique_violation (e.g. orphan composite type in pg_type)
|
|
60
|
+
// 42P07 duplicate_table
|
|
61
|
+
// 3F000 invalid_schema_name (stale search_path after DROP public)
|
|
62
|
+
return code === '23505' || code === '42P07' || code === '3F000';
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const applyMigrations = async () => {
|
|
66
|
+
await ensurePublicSchema();
|
|
67
|
+
await migrate(pgDb(), { migrationsFolder });
|
|
68
|
+
};
|
|
69
|
+
const postgresHasAppData = async () => {
|
|
70
|
+
const db = pgDb();
|
|
71
|
+
for (const tableName of APP_TABLE_NAMES) {
|
|
72
|
+
if (!(await tableExists(tableName))) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const result = await db.execute(sql.raw(`SELECT 1 FROM "${tableName}" LIMIT 1`));
|
|
76
|
+
if (result.rows.length > 0) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
};
|
|
82
|
+
const resetAndMigrate = async (reason) => {
|
|
83
|
+
if (await postgresHasAppData()) {
|
|
84
|
+
throw new Error(`${reason}; refusing to DROP SCHEMA because Postgres already has application data`);
|
|
85
|
+
}
|
|
86
|
+
log.warn('%s; resetting public + drizzle schemas and remigrating', reason);
|
|
87
|
+
await resetPostgresSchemas();
|
|
88
|
+
await applyMigrations();
|
|
89
|
+
};
|
|
90
|
+
/** Fail if app tables are missing (used when RUN_DB_MIGRATE_ON_BOOT=false). */
|
|
91
|
+
export const assertSchemaReady = async () => {
|
|
92
|
+
const missing = await missingAppTables();
|
|
93
|
+
if (missing.length > 0) {
|
|
94
|
+
throw new Error(`Postgres schema incomplete (missing: ${missing.join(', ')}); run migrate job first`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Apply Drizzle migrations. Heals half-wiped DBs where the journal and
|
|
99
|
+
* `public` schema disagree (orphan types, missing tables, etc.).
|
|
100
|
+
*
|
|
101
|
+
* Concurrent starters often hit duplicate_table / pg_type conflicts; if app
|
|
102
|
+
* tables already exist we must NOT reset — that would DROP SCHEMA under the
|
|
103
|
+
* other process mid-import. Also refuses reset when application data exists.
|
|
104
|
+
*
|
|
105
|
+
* Callers that may race (initPostgres, auto-migrate) must hold
|
|
106
|
+
* SCHEMA_MIGRATE_LOCK around this function.
|
|
107
|
+
*/
|
|
108
|
+
export const runMigrations = async () => {
|
|
109
|
+
log.info('Running Postgres migrations from %s', migrationsFolder);
|
|
110
|
+
try {
|
|
111
|
+
await applyMigrations();
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (!isSchemaConflictError(err)) {
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
const missing = await missingAppTables();
|
|
118
|
+
if (missing.length === 0) {
|
|
119
|
+
log.warn('Postgres migrate hit a schema conflict but app tables exist (likely a concurrent migrator); continuing');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
await resetAndMigrate(`Postgres migrate hit a schema conflict and tables are missing (${missing.join(', ')})`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const missing = await missingAppTables();
|
|
126
|
+
if (missing.length > 0) {
|
|
127
|
+
await resetAndMigrate(`App tables missing after migrate (${missing.join(', ')})`);
|
|
128
|
+
}
|
|
129
|
+
const stillMissing = await missingAppTables();
|
|
130
|
+
if (stillMissing.length > 0) {
|
|
131
|
+
throw new Error(`Postgres migrations completed but tables still missing: ${stillMissing.join(', ')}`);
|
|
132
|
+
}
|
|
133
|
+
log.info('Postgres migrations complete');
|
|
134
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SQL } from 'drizzle-orm';
|
|
2
|
+
import type { ActivityWindow } from '../map/queryTypes';
|
|
3
|
+
import { type PgTable } from '../map/registry';
|
|
4
|
+
export declare const profileActivityScoreExpr: (outerTable: PgTable, window?: ActivityWindow) => SQL;
|
|
5
|
+
export declare const postActivityScoreExpr: (outerTable: PgTable) => SQL;
|
|
6
|
+
export declare const postReplyCountExpr: (outerTable: PgTable) => SQL<number>;
|
|
7
|
+
export declare const postReplyToCountExpr: (outerTable: PgTable) => SQL<number>;
|
|
8
|
+
export declare const postHasYesOrMaybeRsvpExpr: (outerTable: PgTable, profileId: string) => SQL;
|
|
9
|
+
export declare const groupLastPostAtExpr: (outerTable: PgTable) => SQL;
|
|
10
|
+
export declare const groupPostsCountExpr: (outerTable: PgTable) => SQL;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { and, count, eq, exists, gte, isNull, lt, sql, } from 'drizzle-orm';
|
|
2
|
+
import { alias, QueryBuilder } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { posts } from '../schema/documents.js';
|
|
4
|
+
import { entries, follows, postGroups, reactions, repost, replyTo, } from '../schema/edges.js';
|
|
5
|
+
import { asTable } from '../map/registry.js';
|
|
6
|
+
const queryBuilder = new QueryBuilder();
|
|
7
|
+
const outerIdText = (table) => sql `${asTable(table).id}::text`;
|
|
8
|
+
const edgeOutboundCount = (edgeTable, outerTable, window) => {
|
|
9
|
+
const conditions = [
|
|
10
|
+
sql `${edgeTable.fromId} = ${outerIdText(outerTable)}`,
|
|
11
|
+
];
|
|
12
|
+
if (window === null || window === void 0 ? void 0 : window.start) {
|
|
13
|
+
conditions.push(gte(edgeTable.createdAt, window.start.toISOString()));
|
|
14
|
+
}
|
|
15
|
+
if (window === null || window === void 0 ? void 0 : window.end) {
|
|
16
|
+
conditions.push(lt(edgeTable.createdAt, window.end.toISOString()));
|
|
17
|
+
}
|
|
18
|
+
return sql `(SELECT count(*)::int FROM ${edgeTable} WHERE ${and(...conditions)})`;
|
|
19
|
+
};
|
|
20
|
+
export const profileActivityScoreExpr = (outerTable, window) => sql `COALESCE(${edgeOutboundCount(entries, outerTable, window)}, 0) + COALESCE(${edgeOutboundCount(reactions, outerTable, window)}, 0) + COALESCE(${edgeOutboundCount(follows, outerTable, window)}, 0)`;
|
|
21
|
+
export const postActivityScoreExpr = (outerTable) => {
|
|
22
|
+
const postId = outerIdText(outerTable);
|
|
23
|
+
return sql `(SELECT count(*)::int FROM ${reactions} WHERE ${reactions.toId} = ${postId}) + (SELECT count(*)::int FROM ${entries} WHERE ${entries.toId} = ${postId}) + (SELECT count(*)::int FROM ${replyTo} rt INNER JOIN ${posts} p ON p.id::text = rt.from_id WHERE rt.to_id = ${postId} AND p.deleted_at IS NULL) + (SELECT count(*)::int FROM ${repost} WHERE ${repost.toId} = ${postId})`;
|
|
24
|
+
};
|
|
25
|
+
export const postReplyCountExpr = (outerTable) => {
|
|
26
|
+
const replyPosts = alias(posts, 'reply_posts');
|
|
27
|
+
const postId = outerIdText(outerTable);
|
|
28
|
+
const query = queryBuilder
|
|
29
|
+
.select({ count: count() })
|
|
30
|
+
.from(replyTo)
|
|
31
|
+
.innerJoin(replyPosts, eq(sql `${replyPosts.id}::text`, replyTo.fromId))
|
|
32
|
+
.where(and(eq(replyTo.toId, postId), isNull(replyPosts.deletedAt)));
|
|
33
|
+
return sql `(${query})`.mapWith(Number);
|
|
34
|
+
};
|
|
35
|
+
export const postReplyToCountExpr = (outerTable) => {
|
|
36
|
+
const query = queryBuilder
|
|
37
|
+
.select({ count: count() })
|
|
38
|
+
.from(replyTo)
|
|
39
|
+
.where(eq(replyTo.fromId, outerIdText(outerTable)));
|
|
40
|
+
return sql `(${query})`.mapWith(Number);
|
|
41
|
+
};
|
|
42
|
+
export const postHasYesOrMaybeRsvpExpr = (outerTable, profileId) => exists(queryBuilder
|
|
43
|
+
.select({ id: entries.id })
|
|
44
|
+
.from(entries)
|
|
45
|
+
.where(and(eq(entries.toId, outerIdText(outerTable)), eq(entries.fromId, profileId), sql `${entries.body}->>'type' = 'rsvp'`, sql `${entries.body}->'data'->>'response' IN ('yes', 'tentative')`)));
|
|
46
|
+
export const groupLastPostAtExpr = (outerTable) => sql `(SELECT max(${postGroups.createdAt}) FROM ${postGroups} WHERE ${postGroups.toId} = ${outerIdText(outerTable)})`;
|
|
47
|
+
export const groupPostsCountExpr = (outerTable) => sql `(SELECT count(*)::int FROM ${postGroups} pg INNER JOIN ${posts} p ON p.id::text = pg.from_id WHERE pg.to_id = ${outerIdText(outerTable)} AND p.deleted_at IS NULL)`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ActivityWindow, ComputedField } from '../map/queryTypes';
|
|
2
|
+
export declare const computedFields: {
|
|
3
|
+
profileActivityScore: (window?: ActivityWindow) => ComputedField;
|
|
4
|
+
postActivityScore: () => ComputedField;
|
|
5
|
+
groupLastPostAt: () => ComputedField;
|
|
6
|
+
groupPostsCount: () => ComputedField;
|
|
7
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { groupLastPostAtExpr, groupPostsCountExpr, postActivityScoreExpr, profileActivityScoreExpr, } from './activity.js';
|
|
2
|
+
export const computedFields = {
|
|
3
|
+
profileActivityScore: (window) => ({
|
|
4
|
+
alias: 'activityScore',
|
|
5
|
+
expr: ({ table }) => profileActivityScoreExpr(table, window),
|
|
6
|
+
}),
|
|
7
|
+
postActivityScore: () => ({
|
|
8
|
+
alias: 'activityScore',
|
|
9
|
+
expr: ({ table }) => postActivityScoreExpr(table),
|
|
10
|
+
}),
|
|
11
|
+
groupLastPostAt: () => ({
|
|
12
|
+
alias: 'lastPostAt',
|
|
13
|
+
expr: ({ table }) => groupLastPostAtExpr(table),
|
|
14
|
+
}),
|
|
15
|
+
groupPostsCount: () => ({
|
|
16
|
+
alias: 'postsCount',
|
|
17
|
+
expr: ({ table }) => groupPostsCountExpr(table),
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PgDb } from '../client';
|
|
2
|
+
import type { DerivedProperty } from '../map/queryTypes';
|
|
3
|
+
type Doc = Record<string, unknown>;
|
|
4
|
+
export declare const profileDerived: {
|
|
5
|
+
postsCount: (db: PgDb, doc: Doc) => Promise<number>;
|
|
6
|
+
lastSeen: (db: PgDb, doc: Doc) => Promise<string | null>;
|
|
7
|
+
profileStats: (_db: PgDb, doc: Doc) => {
|
|
8
|
+
followersCount: number;
|
|
9
|
+
followingCount: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const postDerived: {
|
|
13
|
+
seen: (profileId?: string) => (db: PgDb, doc: Doc) => Promise<boolean>;
|
|
14
|
+
/** One post_seen query for the whole hydrate batch. */
|
|
15
|
+
seenBatch: (profileId?: string) => DerivedProperty;
|
|
16
|
+
inReplyToId: (_db: PgDb, doc: Doc) => string | undefined;
|
|
17
|
+
groupId: (_db: PgDb, doc: Doc) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const groupDerived: {
|
|
20
|
+
lastPostAt: (db: PgDb, doc: Doc) => Promise<string | null>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { and, eq, inArray, sql } from 'drizzle-orm';
|
|
2
|
+
import { posts } from '../schema/documents.js';
|
|
3
|
+
import { entries, postSeen } from '../schema/edges.js';
|
|
4
|
+
import { normalizeIsoDatetime } from '../mappers.js';
|
|
5
|
+
import { asTable } from '../map/registry.js';
|
|
6
|
+
import { getEdgeTable } from '../map/filters.js';
|
|
7
|
+
const maxIso = (values) => {
|
|
8
|
+
const dates = values.filter((v) => !!v);
|
|
9
|
+
if (!dates.length)
|
|
10
|
+
return null;
|
|
11
|
+
return normalizeIsoDatetime(dates.reduce((a, b) => (a > b ? a : b)));
|
|
12
|
+
};
|
|
13
|
+
export const profileDerived = {
|
|
14
|
+
postsCount: async (db, doc) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const postsTable = asTable(posts);
|
|
17
|
+
const rows = await db
|
|
18
|
+
.select({ count: sql `count(*)::int` })
|
|
19
|
+
.from(posts)
|
|
20
|
+
.where(and(eq(postsTable.creatorId, doc.id), sql `${postsTable.deletedAt} IS NULL`));
|
|
21
|
+
return (_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0;
|
|
22
|
+
},
|
|
23
|
+
lastSeen: async (db, doc) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const profileId = doc.id;
|
|
26
|
+
const entriesTable = asTable(entries);
|
|
27
|
+
const postSeenTable = asTable(postSeen);
|
|
28
|
+
const [entryRows, seenRows] = await Promise.all([
|
|
29
|
+
db
|
|
30
|
+
.select({ max: sql `max(${entriesTable.createdAt})` })
|
|
31
|
+
.from(entries)
|
|
32
|
+
.where(eq(entriesTable.fromId, profileId)),
|
|
33
|
+
db
|
|
34
|
+
.select({ max: sql `max(${postSeenTable.createdAt})` })
|
|
35
|
+
.from(postSeen)
|
|
36
|
+
.where(eq(postSeenTable.fromId, profileId)),
|
|
37
|
+
]);
|
|
38
|
+
return maxIso([
|
|
39
|
+
(_a = entryRows[0]) === null || _a === void 0 ? void 0 : _a.max,
|
|
40
|
+
(_b = seenRows[0]) === null || _b === void 0 ? void 0 : _b.max,
|
|
41
|
+
]);
|
|
42
|
+
},
|
|
43
|
+
profileStats: (_db, doc) => ({
|
|
44
|
+
followersCount: Array.isArray(doc.followers) ? doc.followers.length : 0,
|
|
45
|
+
followingCount: Array.isArray(doc.following) ? doc.following.length : 0,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
export const postDerived = {
|
|
49
|
+
seen: (profileId) => async (db, doc) => {
|
|
50
|
+
if (!profileId)
|
|
51
|
+
return false;
|
|
52
|
+
const edgeTableRef = getEdgeTable('postSeen');
|
|
53
|
+
const edgeTable = asTable(edgeTableRef);
|
|
54
|
+
const rows = await db
|
|
55
|
+
.select({ one: sql `1` })
|
|
56
|
+
.from(edgeTableRef)
|
|
57
|
+
.where(and(eq(edgeTable.fromId, profileId), eq(edgeTable.toId, doc.id)))
|
|
58
|
+
.limit(1);
|
|
59
|
+
return rows.length > 0;
|
|
60
|
+
},
|
|
61
|
+
/** One post_seen query for the whole hydrate batch. */
|
|
62
|
+
seenBatch: (profileId) => ({
|
|
63
|
+
alias: 'seen',
|
|
64
|
+
resolve: postDerived.seen(profileId),
|
|
65
|
+
batchResolve: async (db, docs) => {
|
|
66
|
+
const values = new Map();
|
|
67
|
+
if (!profileId || !docs.length) {
|
|
68
|
+
for (const doc of docs)
|
|
69
|
+
values.set(doc.id, false);
|
|
70
|
+
return values;
|
|
71
|
+
}
|
|
72
|
+
const ids = docs.map((doc) => doc.id);
|
|
73
|
+
const edgeTableRef = getEdgeTable('postSeen');
|
|
74
|
+
const edgeTable = asTable(edgeTableRef);
|
|
75
|
+
const rows = (await db
|
|
76
|
+
.select({ toId: edgeTable.toId })
|
|
77
|
+
.from(edgeTableRef)
|
|
78
|
+
.where(and(eq(edgeTable.fromId, profileId), inArray(edgeTable.toId, ids))));
|
|
79
|
+
const seenIds = new Set(rows.map((row) => row.toId));
|
|
80
|
+
for (const id of ids)
|
|
81
|
+
values.set(id, seenIds.has(id));
|
|
82
|
+
return values;
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
inReplyToId: (_db, doc) => { var _a; return (_a = doc.replyTo) === null || _a === void 0 ? void 0 : _a.id; },
|
|
86
|
+
groupId: (_db, doc) => { var _a; return (_a = doc.group) === null || _a === void 0 ? void 0 : _a.id; },
|
|
87
|
+
};
|
|
88
|
+
export const groupDerived = {
|
|
89
|
+
lastPostAt: async (db, doc) => {
|
|
90
|
+
var _a;
|
|
91
|
+
const edgeTableRef = getEdgeTable('postGroups');
|
|
92
|
+
const edgeTable = asTable(edgeTableRef);
|
|
93
|
+
const rows = await db
|
|
94
|
+
.select({ max: sql `max(${edgeTable.createdAt})` })
|
|
95
|
+
.from(edgeTableRef)
|
|
96
|
+
.where(eq(edgeTable.toId, doc.id));
|
|
97
|
+
const value = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.max;
|
|
98
|
+
return value ? normalizeIsoDatetime(value) : null;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { groupLastPostAtExpr, groupPostsCountExpr, postActivityScoreExpr, postHasYesOrMaybeRsvpExpr, postReplyCountExpr, postReplyToCountExpr, profileActivityScoreExpr, } from './activity';
|
|
2
|
+
export { computedFields } from './computed';
|
|
3
|
+
export { groupDerived, postDerived, profileDerived } from './derived';
|
|
4
|
+
export { sorts } from './sorts';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { groupLastPostAtExpr, groupPostsCountExpr, postActivityScoreExpr, postHasYesOrMaybeRsvpExpr, postReplyCountExpr, postReplyToCountExpr, profileActivityScoreExpr, } from './activity.js';
|
|
2
|
+
export { computedFields } from './computed.js';
|
|
3
|
+
export { groupDerived, postDerived, profileDerived } from './derived.js';
|
|
4
|
+
export { sorts } from './sorts.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ObjectSort } from '../map/queryTypes';
|
|
2
|
+
export declare const sorts: {
|
|
3
|
+
idDesc: ObjectSort;
|
|
4
|
+
idAsc: ObjectSort;
|
|
5
|
+
createdAtDesc: ObjectSort;
|
|
6
|
+
eventStartAsc: ObjectSort;
|
|
7
|
+
eventStartDesc: ObjectSort;
|
|
8
|
+
activityScoreDesc: ObjectSort;
|
|
9
|
+
lastPostAtDesc: ObjectSort;
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const sorts = {
|
|
2
|
+
idDesc: [['id', 'DESC']],
|
|
3
|
+
idAsc: [['id', 'ASC']],
|
|
4
|
+
createdAtDesc: [['createdAt', 'DESC']],
|
|
5
|
+
eventStartAsc: [['data.start', 'ASC']],
|
|
6
|
+
eventStartDesc: [['data.start', 'DESC']],
|
|
7
|
+
activityScoreDesc: [['activityScore', 'DESC']],
|
|
8
|
+
lastPostAtDesc: [['lastPostAt', 'DESC']],
|
|
9
|
+
};
|