@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,48 @@
|
|
|
1
|
+
import type { CollectionInfo } from './map/queryTypes';
|
|
2
|
+
/** Named collection/edge refs aligned with `documentRegistry` and `edgeRegistry`. */
|
|
3
|
+
export declare const collectionInfos: {
|
|
4
|
+
readonly dataMigrationsCollection: CollectionInfo;
|
|
5
|
+
readonly i18nCollection: CollectionInfo;
|
|
6
|
+
readonly configCollection: CollectionInfo;
|
|
7
|
+
readonly accountsCollection: CollectionInfo;
|
|
8
|
+
readonly profilesCollection: CollectionInfo;
|
|
9
|
+
readonly followsCollection: CollectionInfo;
|
|
10
|
+
readonly requestsFollowCollection: CollectionInfo;
|
|
11
|
+
readonly controlsCollection: CollectionInfo;
|
|
12
|
+
readonly postsCollection: CollectionInfo;
|
|
13
|
+
readonly mentionsCollection: CollectionInfo;
|
|
14
|
+
readonly audienceCollection: CollectionInfo;
|
|
15
|
+
readonly hashtagsCollection: CollectionInfo;
|
|
16
|
+
readonly postHashtagsCollection: CollectionInfo;
|
|
17
|
+
readonly reportsCollection: CollectionInfo;
|
|
18
|
+
readonly createdReportCollection: CollectionInfo;
|
|
19
|
+
readonly isReportedProfileCollection: CollectionInfo;
|
|
20
|
+
readonly isReportedObjectCollection: CollectionInfo;
|
|
21
|
+
readonly entriesCollection: CollectionInfo;
|
|
22
|
+
readonly reactionsCollection: CollectionInfo;
|
|
23
|
+
readonly repliesCollection: CollectionInfo;
|
|
24
|
+
readonly repostCollection: CollectionInfo;
|
|
25
|
+
readonly mediaAttachmentsCollection: CollectionInfo;
|
|
26
|
+
readonly processingStatsCollection: CollectionInfo;
|
|
27
|
+
readonly rolesCollection: CollectionInfo;
|
|
28
|
+
readonly accessTokensCollection: CollectionInfo;
|
|
29
|
+
readonly profileAccessTokensCollection: CollectionInfo;
|
|
30
|
+
readonly hasRoleCollection: CollectionInfo;
|
|
31
|
+
readonly notificationsCollection: CollectionInfo;
|
|
32
|
+
readonly pushSubscriptionsCollection: CollectionInfo;
|
|
33
|
+
readonly accountToPushSubscriptionCollection: CollectionInfo;
|
|
34
|
+
readonly jamEventsCollection: CollectionInfo;
|
|
35
|
+
readonly inviteLinksCollection: CollectionInfo;
|
|
36
|
+
readonly inviteLinkCreatorsCollection: CollectionInfo;
|
|
37
|
+
readonly inviteLinkRedeemersCollection: CollectionInfo;
|
|
38
|
+
readonly groupsCollection: CollectionInfo;
|
|
39
|
+
readonly postGroupsCollection: CollectionInfo;
|
|
40
|
+
readonly userGroupsCollection: CollectionInfo;
|
|
41
|
+
readonly hasSeenCollection: CollectionInfo;
|
|
42
|
+
readonly hasReadCollection: CollectionInfo;
|
|
43
|
+
readonly bookmarksCollection: CollectionInfo;
|
|
44
|
+
readonly postSeenCollection: CollectionInfo;
|
|
45
|
+
readonly profileSettingsCollection: CollectionInfo;
|
|
46
|
+
readonly jamRecordingsCollection: CollectionInfo;
|
|
47
|
+
};
|
|
48
|
+
export type CollectionInfoKey = keyof typeof collectionInfos;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const document = (name) => ({
|
|
2
|
+
name,
|
|
3
|
+
});
|
|
4
|
+
const edge = (name) => ({
|
|
5
|
+
name,
|
|
6
|
+
edge: true,
|
|
7
|
+
});
|
|
8
|
+
/** Named collection/edge refs aligned with `documentRegistry` and `edgeRegistry`. */
|
|
9
|
+
export const collectionInfos = {
|
|
10
|
+
dataMigrationsCollection: document('dataMigrations'),
|
|
11
|
+
i18nCollection: document('i18n'),
|
|
12
|
+
configCollection: document('configs'),
|
|
13
|
+
accountsCollection: document('accounts'),
|
|
14
|
+
profilesCollection: document('profiles'),
|
|
15
|
+
followsCollection: edge('follows'),
|
|
16
|
+
requestsFollowCollection: edge('requestsFollow'),
|
|
17
|
+
controlsCollection: edge('controls'),
|
|
18
|
+
postsCollection: document('posts'),
|
|
19
|
+
mentionsCollection: edge('mentions'),
|
|
20
|
+
audienceCollection: edge('audience'),
|
|
21
|
+
hashtagsCollection: document('hashtags'),
|
|
22
|
+
postHashtagsCollection: edge('postHashtags'),
|
|
23
|
+
reportsCollection: document('reports'),
|
|
24
|
+
createdReportCollection: edge('createdReport'),
|
|
25
|
+
isReportedProfileCollection: edge('isReportedProfile'),
|
|
26
|
+
isReportedObjectCollection: edge('isReportedObject'),
|
|
27
|
+
entriesCollection: edge('entries'),
|
|
28
|
+
reactionsCollection: edge('reactions'),
|
|
29
|
+
repliesCollection: edge('replyTo'),
|
|
30
|
+
repostCollection: edge('repost'),
|
|
31
|
+
mediaAttachmentsCollection: document('mediaAttachments'),
|
|
32
|
+
processingStatsCollection: document('processingStats'),
|
|
33
|
+
rolesCollection: document('roles'),
|
|
34
|
+
accessTokensCollection: document('accessTokens'),
|
|
35
|
+
profileAccessTokensCollection: edge('profileAccessTokens'),
|
|
36
|
+
hasRoleCollection: edge('hasRole'),
|
|
37
|
+
notificationsCollection: document('notifications'),
|
|
38
|
+
pushSubscriptionsCollection: document('pushSubscriptions'),
|
|
39
|
+
accountToPushSubscriptionCollection: edge('accountToPushSubscription'),
|
|
40
|
+
jamEventsCollection: document('jamEvents'),
|
|
41
|
+
inviteLinksCollection: document('inviteLinks'),
|
|
42
|
+
inviteLinkCreatorsCollection: edge('inviteLinkCreators'),
|
|
43
|
+
inviteLinkRedeemersCollection: edge('inviteLinkRedeemers'),
|
|
44
|
+
groupsCollection: document('groups'),
|
|
45
|
+
postGroupsCollection: edge('postGroups'),
|
|
46
|
+
userGroupsCollection: edge('userGroups'),
|
|
47
|
+
hasSeenCollection: edge('hasSeen'),
|
|
48
|
+
hasReadCollection: edge('hasRead'),
|
|
49
|
+
bookmarksCollection: edge('bookmarks'),
|
|
50
|
+
postSeenCollection: edge('postSeen'),
|
|
51
|
+
profileSettingsCollection: document('profileSettings'),
|
|
52
|
+
jamRecordingsCollection: edge('jamRecordings'),
|
|
53
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SQL } from 'drizzle-orm';
|
|
2
|
+
import { type SqlFilter } from './types';
|
|
3
|
+
type TimestampColumn = {
|
|
4
|
+
createdAt: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const createdAtBetween: (column: TimestampColumn, start?: Date, end?: Date) => SqlFilter | undefined;
|
|
7
|
+
export declare const beforeId: (column: {
|
|
8
|
+
id: unknown;
|
|
9
|
+
}, id: string) => SqlFilter;
|
|
10
|
+
export declare const afterId: (column: {
|
|
11
|
+
id: unknown;
|
|
12
|
+
}, id: string) => SqlFilter;
|
|
13
|
+
export declare const notDeleted: (column: {
|
|
14
|
+
deletedAt: unknown;
|
|
15
|
+
}) => SqlFilter;
|
|
16
|
+
export declare const compareCount: (countExpr: SQL, op: "==" | "!=" | ">" | ">=" | "<" | "<=", value: number) => SQL;
|
|
17
|
+
export declare const jsonBodyPath: (body: SQL, path: string[]) => SQL;
|
|
18
|
+
export declare const jsonBodyExists: (body: SQL, path: string[]) => SQL;
|
|
19
|
+
export declare const documentKeyBefore: (collection: string, id: string) => SqlFilter;
|
|
20
|
+
export declare const documentKeyAfter: (collection: string, id: string) => SqlFilter;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { and, eq, gt, gte, isNull, lt, lte, ne, sql, } from 'drizzle-orm';
|
|
2
|
+
import { asTable, getTableForCollection } from '../map/registry.js';
|
|
3
|
+
import { pgSql } from './types.js';
|
|
4
|
+
export const createdAtBetween = (column, start, end) => {
|
|
5
|
+
const parts = [];
|
|
6
|
+
if (start) {
|
|
7
|
+
parts.push(gte(column.createdAt, start.toISOString()));
|
|
8
|
+
}
|
|
9
|
+
if (end) {
|
|
10
|
+
parts.push(lt(column.createdAt, end.toISOString()));
|
|
11
|
+
}
|
|
12
|
+
return parts.length ? pgSql(and(...parts)) : undefined;
|
|
13
|
+
};
|
|
14
|
+
export const beforeId = (column, id) => pgSql(lt(column.id, id));
|
|
15
|
+
export const afterId = (column, id) => pgSql(gt(column.id, id));
|
|
16
|
+
export const notDeleted = (column) => pgSql(isNull(column.deletedAt));
|
|
17
|
+
export const compareCount = (countExpr, op, value) => {
|
|
18
|
+
switch (op) {
|
|
19
|
+
case '==':
|
|
20
|
+
return eq(countExpr, value);
|
|
21
|
+
case '!=':
|
|
22
|
+
return ne(countExpr, value);
|
|
23
|
+
case '>':
|
|
24
|
+
return gt(countExpr, value);
|
|
25
|
+
case '>=':
|
|
26
|
+
return gte(countExpr, value);
|
|
27
|
+
case '<':
|
|
28
|
+
return lt(countExpr, value);
|
|
29
|
+
case '<=':
|
|
30
|
+
return lte(countExpr, value);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const jsonBodyPath = (body, path) => {
|
|
34
|
+
if (!path.length)
|
|
35
|
+
return body;
|
|
36
|
+
if (path.length === 1) {
|
|
37
|
+
return sql `${body}->>${path[0]}`;
|
|
38
|
+
}
|
|
39
|
+
const parents = path
|
|
40
|
+
.slice(0, -1)
|
|
41
|
+
.map((part) => `'${part.replace(/'/g, "''")}'`)
|
|
42
|
+
.join('->');
|
|
43
|
+
const last = path[path.length - 1].replace(/'/g, "''");
|
|
44
|
+
return sql `${body}->${sql.raw(parents)}->>${last}`;
|
|
45
|
+
};
|
|
46
|
+
export const jsonBodyExists = (body, path) => sql `${body}->${sql.raw(path.map((part) => `'${part.replace(/'/g, "''")}'`).join('->'))} IS NOT NULL`;
|
|
47
|
+
export const documentKeyBefore = (collection, id) => beforeId(asTable(getTableForCollection(collection)), id);
|
|
48
|
+
export const documentKeyAfter = (collection, id) => afterId(asTable(getTableForCollection(collection)), id);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SqlFilter } from './types';
|
|
2
|
+
export declare const edgeFilters: {
|
|
3
|
+
entryType: (type: string) => SqlFilter;
|
|
4
|
+
entryCreated: (start?: Date, end?: Date) => SqlFilter | undefined;
|
|
5
|
+
bodyFieldEq: (table: {
|
|
6
|
+
body: unknown;
|
|
7
|
+
}, field: string, value: string) => SqlFilter;
|
|
8
|
+
groupAdminRole: () => SqlFilter;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { eq, sql } from 'drizzle-orm';
|
|
2
|
+
import { entries, userGroups } from '../schema/edges.js';
|
|
3
|
+
import { createdAtBetween } from './common.js';
|
|
4
|
+
import { pgSql } from './types.js';
|
|
5
|
+
export const edgeFilters = {
|
|
6
|
+
entryType: (type) => pgSql(eq(sql `${entries.body}->>'type'`, type)),
|
|
7
|
+
entryCreated: (start, end) => createdAtBetween(entries, start, end),
|
|
8
|
+
bodyFieldEq: (table, field, value) => pgSql(eq(sql `${table.body}->>${field}`, value)),
|
|
9
|
+
groupAdminRole: () => pgSql(sql `${userGroups.body}->'roles' ? 'admin'`),
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SqlFilter } from './types';
|
|
2
|
+
export declare const groupFilters: {
|
|
3
|
+
memberOf: (groupIds: string[]) => SqlFilter | undefined;
|
|
4
|
+
publiclyReadable: () => SqlFilter;
|
|
5
|
+
locallyReadable: () => SqlFilter;
|
|
6
|
+
readableByLocalProfile: (groupIds: string[]) => SqlFilter;
|
|
7
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { inArray, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { groups } from '../schema/documents.js';
|
|
3
|
+
import { pgSql } from './types.js';
|
|
4
|
+
export const groupFilters = {
|
|
5
|
+
memberOf: (groupIds) => groupIds.length ? pgSql(inArray(groups.id, groupIds)) : undefined,
|
|
6
|
+
publiclyReadable: () => pgSql(sql `${groups.body}->'capabilities'->'none'->'add' ? 'core-groups-read'`),
|
|
7
|
+
locallyReadable: () => pgSql(sql `${groups.body}->'capabilities'->'local'->'add' ? 'core-groups-read'`),
|
|
8
|
+
readableByLocalProfile: (groupIds) => {
|
|
9
|
+
const membershipFilter = groupFilters.memberOf(groupIds);
|
|
10
|
+
const readable = or(groupFilters.publiclyReadable().where, groupFilters.locallyReadable().where);
|
|
11
|
+
return membershipFilter
|
|
12
|
+
? pgSql(or(readable, membershipFilter.where))
|
|
13
|
+
: pgSql(readable);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type SQL } from 'drizzle-orm';
|
|
2
|
+
import type { OMFilter, PgFilter } from '../map/queryTypes';
|
|
3
|
+
import { isSqlFilter, pgSql, type SqlFilter } from './types';
|
|
4
|
+
export { createdAtBetween, afterId, beforeId, documentKeyAfter, documentKeyBefore, notDeleted, } from './common';
|
|
5
|
+
export { edgeFilters } from './edges';
|
|
6
|
+
export { eventTimeFilters, postFilters } from './posts';
|
|
7
|
+
export { groupFilters } from './groups';
|
|
8
|
+
export { notificationFilters } from './notifications';
|
|
9
|
+
export { profileFilters } from './profiles';
|
|
10
|
+
export { isSqlFilter, pgSql };
|
|
11
|
+
export type { SqlFilter };
|
|
12
|
+
export type { PgFilter } from '../map/queryTypes';
|
|
13
|
+
export declare const combine: {
|
|
14
|
+
and: <O extends object>(...filters: PgFilter<O>[]) => PgFilter<O>;
|
|
15
|
+
or: <O extends object>(...filters: PgFilter<O>[]) => PgFilter<O>;
|
|
16
|
+
};
|
|
17
|
+
export declare const sqlConditions: (...filters: SqlFilter[]) => SQL | undefined;
|
|
18
|
+
export declare const partitionPgFilters: <O extends object>(filters: PgFilter<O>[] | undefined) => {
|
|
19
|
+
sqlFilters: SqlFilter[];
|
|
20
|
+
omFilters: OMFilter<O>[];
|
|
21
|
+
};
|
|
22
|
+
export declare const wrapSql: (where: SQL) => SqlFilter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { and } from 'drizzle-orm';
|
|
2
|
+
import { isSqlFilter, pgSql } from './types.js';
|
|
3
|
+
export { createdAtBetween, afterId, beforeId, documentKeyAfter, documentKeyBefore, notDeleted, } from './common.js';
|
|
4
|
+
export { edgeFilters } from './edges.js';
|
|
5
|
+
export { eventTimeFilters, postFilters } from './posts.js';
|
|
6
|
+
export { groupFilters } from './groups.js';
|
|
7
|
+
export { notificationFilters } from './notifications.js';
|
|
8
|
+
export { profileFilters } from './profiles.js';
|
|
9
|
+
export { isSqlFilter, pgSql };
|
|
10
|
+
export const combine = {
|
|
11
|
+
and: (...filters) => ({
|
|
12
|
+
operator: '&&',
|
|
13
|
+
predicates: filters,
|
|
14
|
+
}),
|
|
15
|
+
or: (...filters) => ({
|
|
16
|
+
operator: '||',
|
|
17
|
+
predicates: filters,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
export const sqlConditions = (...filters) => {
|
|
21
|
+
const parts = filters.map((filter) => filter.where);
|
|
22
|
+
return parts.length ? and(...parts) : undefined;
|
|
23
|
+
};
|
|
24
|
+
export const partitionPgFilters = (filters) => {
|
|
25
|
+
const sqlFilters = [];
|
|
26
|
+
const omFilters = [];
|
|
27
|
+
for (const filter of filters !== null && filters !== void 0 ? filters : []) {
|
|
28
|
+
if (isSqlFilter(filter))
|
|
29
|
+
sqlFilters.push(filter);
|
|
30
|
+
else
|
|
31
|
+
omFilters.push(filter);
|
|
32
|
+
}
|
|
33
|
+
return { sqlFilters, omFilters };
|
|
34
|
+
};
|
|
35
|
+
export const wrapSql = pgSql;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { eq, sql } from 'drizzle-orm';
|
|
2
|
+
import { notifications } from '../schema/documents.js';
|
|
3
|
+
import { pgSql } from './types.js';
|
|
4
|
+
const seenExpr = sql `COALESCE((${notifications.body}->>'seen')::boolean, false)`;
|
|
5
|
+
const readExpr = sql `COALESCE((${notifications.body}->>'read')::boolean, false)`;
|
|
6
|
+
export const notificationFilters = {
|
|
7
|
+
forProfile: (profileId) => pgSql(eq(notifications.profileId, profileId)),
|
|
8
|
+
unseen: () => pgSql(eq(seenExpr, false)),
|
|
9
|
+
unread: () => pgSql(eq(readExpr, false)),
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SqlFilter } from './types';
|
|
2
|
+
export declare const postFilters: {
|
|
3
|
+
notDirect: () => SqlFilter;
|
|
4
|
+
isDirect: () => SqlFilter;
|
|
5
|
+
hasJam: () => SqlFilter;
|
|
6
|
+
creatorId: (id: string) => SqlFilter;
|
|
7
|
+
type: (type: string) => SqlFilter;
|
|
8
|
+
replyCount: (op: "==" | "!=" | ">" | ">=" | "<" | "<=", count: number) => SqlFilter;
|
|
9
|
+
replyCountZero: () => SqlFilter;
|
|
10
|
+
replyCountPositive: () => SqlFilter;
|
|
11
|
+
isJamModerator: (profileId: string) => SqlFilter;
|
|
12
|
+
hasYesOrMaybeRsvp: (profileId: string) => SqlFilter;
|
|
13
|
+
};
|
|
14
|
+
export declare const eventTimeFilters: {
|
|
15
|
+
upcoming: (now?: string) => SqlFilter;
|
|
16
|
+
current: (now?: string) => SqlFilter;
|
|
17
|
+
past: (now?: string) => SqlFilter;
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { and, eq, isNotNull, ne, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { posts } from '../schema/documents.js';
|
|
3
|
+
import { postHasYesOrMaybeRsvpExpr, postReplyCountExpr, } from '../queries/activity.js';
|
|
4
|
+
import { compareCount } from './common.js';
|
|
5
|
+
import { pgSql } from './types.js';
|
|
6
|
+
const eventStart = sql `${posts.body}->>'start'`;
|
|
7
|
+
const eventEnd = sql `${posts.body}->>'end'`;
|
|
8
|
+
const postsReplyCountExpr = postReplyCountExpr(posts);
|
|
9
|
+
export const postFilters = {
|
|
10
|
+
notDirect: () => pgSql(ne(posts.visibility, 'direct')),
|
|
11
|
+
isDirect: () => pgSql(eq(posts.visibility, 'direct')),
|
|
12
|
+
hasJam: () => pgSql(isNotNull(sql `${posts.body}->'jam'`)),
|
|
13
|
+
creatorId: (id) => pgSql(eq(posts.creatorId, id)),
|
|
14
|
+
type: (type) => pgSql(eq(posts.type, type)),
|
|
15
|
+
replyCount: (op, count) => pgSql(compareCount(postsReplyCountExpr, op, count)),
|
|
16
|
+
replyCountZero: () => postFilters.replyCount('==', 0),
|
|
17
|
+
replyCountPositive: () => postFilters.replyCount('>', 0),
|
|
18
|
+
isJamModerator: (profileId) => pgSql(sql `${posts.body}->'jam'->'moderators' ? ${profileId}`),
|
|
19
|
+
hasYesOrMaybeRsvp: (profileId) => pgSql(postHasYesOrMaybeRsvpExpr(posts, profileId)),
|
|
20
|
+
};
|
|
21
|
+
export const eventTimeFilters = {
|
|
22
|
+
upcoming: (now = new Date().toISOString()) => pgSql(or(sql `${eventStart} > ${now}`, and(sql `${posts.body}->'end' IS NOT NULL`, sql `${eventEnd} > ${now}`))),
|
|
23
|
+
current: (now = new Date().toISOString()) => pgSql(and(sql `${eventStart} <= ${now}`, or(sql `${posts.body}->'end' IS NULL`, sql `${eventEnd} >= ${now}`))),
|
|
24
|
+
past: (now = new Date().toISOString()) => pgSql(sql `COALESCE(${eventEnd}, ${eventStart}) < ${now}`),
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { eq, gt, ne } from 'drizzle-orm';
|
|
2
|
+
import { profiles } from '../schema/documents.js';
|
|
3
|
+
import { profileActivityScoreExpr } from '../queries/activity.js';
|
|
4
|
+
import { pgSql } from './types.js';
|
|
5
|
+
export const profileFilters = {
|
|
6
|
+
notGuest: () => pgSql(ne(profiles.type, 'guest')),
|
|
7
|
+
type: (type) => pgSql(eq(profiles.type, type)),
|
|
8
|
+
activityScorePositive: (start, end) => pgSql(gt(profileActivityScoreExpr(profiles, { start, end }), 0)),
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type SQL } from 'drizzle-orm';
|
|
2
|
+
import type { PgDb } from './client';
|
|
3
|
+
export type SoftDeleteTable = {
|
|
4
|
+
id: unknown;
|
|
5
|
+
deletedAt: unknown;
|
|
6
|
+
updatedAt: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare const activeRow: <T extends SoftDeleteTable>(table: T) => SQL | undefined;
|
|
9
|
+
export declare const findById: <TRow>(db: PgDb, table: SoftDeleteTable & Record<string, unknown>, id: string, includeDeleted?: boolean) => Promise<TRow | undefined>;
|
|
10
|
+
export declare const softDeleteById: (db: PgDb, table: SoftDeleteTable & Record<string, unknown>, id: string) => Promise<void>;
|
|
11
|
+
export declare const insertEdge: (db: PgDb, table: Record<string, unknown> & {
|
|
12
|
+
fromId: unknown;
|
|
13
|
+
toId: unknown;
|
|
14
|
+
}, fromId: string, toId: string, body?: Record<string, unknown>) => Promise<string>;
|
|
15
|
+
export declare const deleteEdge: (db: PgDb, table: Record<string, unknown> & {
|
|
16
|
+
fromId: unknown;
|
|
17
|
+
toId: unknown;
|
|
18
|
+
}, fromId: string, toId: string) => Promise<void>;
|
|
19
|
+
export declare const countRows: (db: PgDb, table: Record<string, unknown>, where?: SQL) => Promise<number>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { and, eq, isNull, sql } from 'drizzle-orm';
|
|
13
|
+
import { nowIso } from './mappers.js';
|
|
14
|
+
import { uuidv7 } from 'uuidv7';
|
|
15
|
+
export const activeRow = (table) => isNull(table.deletedAt);
|
|
16
|
+
export const findById = async (db, table, id, includeDeleted = false) => {
|
|
17
|
+
const conditions = [eq(table.id, id)];
|
|
18
|
+
if (!includeDeleted && table.deletedAt) {
|
|
19
|
+
conditions.push(isNull(table.deletedAt));
|
|
20
|
+
}
|
|
21
|
+
const rows = await db
|
|
22
|
+
.select()
|
|
23
|
+
.from(table)
|
|
24
|
+
.where(and(...conditions))
|
|
25
|
+
.limit(1);
|
|
26
|
+
return rows[0];
|
|
27
|
+
};
|
|
28
|
+
export const softDeleteById = async (db, table, id) => {
|
|
29
|
+
await db
|
|
30
|
+
.update(table)
|
|
31
|
+
.set({
|
|
32
|
+
deletedAt: nowIso(),
|
|
33
|
+
updatedAt: nowIso(),
|
|
34
|
+
})
|
|
35
|
+
.where(eq(table.id, id));
|
|
36
|
+
};
|
|
37
|
+
export const insertEdge = async (db, table, fromId, toId, body = {}) => {
|
|
38
|
+
// Callers (e.g. jam recordings) pass a pre-generated id on the body; use it
|
|
39
|
+
// as the row primary key and keep it out of jsonb so finds/updates match.
|
|
40
|
+
const { id: providedId } = body, edgeBody = __rest(body, ["id"]);
|
|
41
|
+
const id = typeof providedId === 'string' && providedId.length > 0
|
|
42
|
+
? providedId
|
|
43
|
+
: uuidv7();
|
|
44
|
+
const ts = nowIso();
|
|
45
|
+
await db.insert(table).values({
|
|
46
|
+
id,
|
|
47
|
+
fromId,
|
|
48
|
+
toId,
|
|
49
|
+
body: edgeBody,
|
|
50
|
+
createdAt: ts,
|
|
51
|
+
updatedAt: ts,
|
|
52
|
+
});
|
|
53
|
+
return id;
|
|
54
|
+
};
|
|
55
|
+
export const deleteEdge = async (db, table, fromId, toId) => {
|
|
56
|
+
await db
|
|
57
|
+
.delete(table)
|
|
58
|
+
.where(and(eq(table.fromId, fromId), eq(table.toId, toId)));
|
|
59
|
+
};
|
|
60
|
+
export const countRows = async (db, table, where) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const query = db
|
|
63
|
+
.select({ count: sql `count(*)::int` })
|
|
64
|
+
.from(table);
|
|
65
|
+
const result = (where ? await query.where(where) : await query);
|
|
66
|
+
return (_b = (_a = result[0]) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0;
|
|
67
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type SQL } from 'drizzle-orm';
|
|
2
|
+
import type { ActivityWindow, Limit, ObjectSort, PgFilter } from './queryTypes';
|
|
3
|
+
import { type PgTable } from './registry';
|
|
4
|
+
export declare const evaluateStringFilter: (doc: Record<string, unknown>, expression: string) => boolean;
|
|
5
|
+
export declare const evaluateFilter: (doc: Record<string, unknown>, filter?: PgFilter<Record<string, unknown>>) => boolean;
|
|
6
|
+
export declare const stringFilterToSql: (collection: string, table: PgTable, expression: string) => SQL | undefined;
|
|
7
|
+
export declare const filterToSql: (collection: string, table: PgTable, filter: PgFilter<Record<string, unknown>>) => SQL | undefined;
|
|
8
|
+
export declare const partitionFilters: (collection: string, table: PgTable, filters: PgFilter<Record<string, unknown>>[] | undefined, defaultFilter?: PgFilter<Record<string, unknown>>, softDelete?: boolean) => {
|
|
9
|
+
sqlWhere: SQL | undefined;
|
|
10
|
+
postFilters: PgFilter<Record<string, unknown>>[];
|
|
11
|
+
};
|
|
12
|
+
export declare const filtersToSql: (collection: string, table: PgTable, filters: PgFilter<Record<string, unknown>>[] | undefined, softDelete: boolean | undefined) => SQL | undefined;
|
|
13
|
+
export declare const applyDateRangeToEdgeSql: (table: PgTable, filter?: PgFilter<Record<string, unknown>>) => SQL | undefined;
|
|
14
|
+
export declare const sortToSqlOrderBy: (collection: string, table: PgTable, sort?: ObjectSort, activityWindow?: ActivityWindow) => SQL[] | undefined;
|
|
15
|
+
export declare const applyPostFilters: <O extends object>(docs: O[], filters: PgFilter<O>[] | undefined, defaultFilter?: PgFilter<O>) => O[];
|
|
16
|
+
export declare const applySort: <O extends object>(docs: O[], sort?: [string, "ASC" | "DESC" | undefined][]) => O[];
|
|
17
|
+
export declare const applyLimit: <O>(docs: O[], limit?: Limit) => O[];
|
|
18
|
+
export declare const applySqlLimit: <T extends {
|
|
19
|
+
limit: (n: number) => T;
|
|
20
|
+
offset: (n: number) => T;
|
|
21
|
+
}>(query: T, limit?: Limit) => T;
|
|
22
|
+
export declare const getEdgeTable: (edgeCollection: string) => PgTable;
|