@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,399 @@
|
|
|
1
|
+
import { and, eq, getTableColumns, inArray, sql, } from 'drizzle-orm';
|
|
2
|
+
import { applyDateRangeToEdgeSql, applyLimit, applyPostFilters, applySqlLimit, applySort, partitionFilters, sortToSqlOrderBy, getEdgeTable, } from './filters.js';
|
|
3
|
+
import { isSqlFilter } from '../filters/index.js';
|
|
4
|
+
import { asTable, edgeRegistry, getTableForCollection, rowToDocument, } from './registry.js';
|
|
5
|
+
import { normalizeComputedDatetime } from '../mappers.js';
|
|
6
|
+
const buildComputedSelect = (mapData, tableRef) => {
|
|
7
|
+
var _a;
|
|
8
|
+
return Object.fromEntries(((_a = mapData.computedFields) !== null && _a !== void 0 ? _a : []).map((field) => [
|
|
9
|
+
field.alias,
|
|
10
|
+
field.expr({
|
|
11
|
+
table: tableRef,
|
|
12
|
+
collection: mapData.collection,
|
|
13
|
+
activityWindow: mapData.activityWindow,
|
|
14
|
+
}),
|
|
15
|
+
]));
|
|
16
|
+
};
|
|
17
|
+
const mapRowToDoc = (mapData, row) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const doc = rowToDocument(mapData.collection, row);
|
|
20
|
+
for (const field of (_a = mapData.computedFields) !== null && _a !== void 0 ? _a : []) {
|
|
21
|
+
if (field.alias in row) {
|
|
22
|
+
const value = row[field.alias];
|
|
23
|
+
doc[field.alias] =
|
|
24
|
+
field.alias === 'lastPostAt' ? normalizeComputedDatetime(value) : value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return doc;
|
|
28
|
+
};
|
|
29
|
+
const vertexCollectionFor = (relation) => {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
const edgeName = typeof relation.edgeCollection === 'string'
|
|
32
|
+
? relation.edgeCollection
|
|
33
|
+
: relation.edgeCollection.name;
|
|
34
|
+
return ((_b = (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.collection) !== null && _b !== void 0 ? _b : (_c = edgeRegistry[edgeName]) === null || _c === void 0 ? void 0 : _c[relation.direction === 'INBOUND' ? 'fromCollection' : 'toCollection']);
|
|
35
|
+
};
|
|
36
|
+
const edgeCollectionName = (edge) => typeof edge === 'string' ? edge : edge.name;
|
|
37
|
+
const parentEdgeColumn = (relation) => relation.direction === 'INBOUND' ? 'toId' : 'fromId';
|
|
38
|
+
const vertexEdgeColumn = (relation) => relation.direction === 'INBOUND' ? 'fromId' : 'toId';
|
|
39
|
+
export const fetchRowsByIds = async (db, collection, ids, softDelete) => {
|
|
40
|
+
if (!ids.length)
|
|
41
|
+
return [];
|
|
42
|
+
const table = asTable(getTableForCollection(collection));
|
|
43
|
+
const conditions = [inArray(table.id, ids)];
|
|
44
|
+
if (softDelete !== false && table.deletedAt) {
|
|
45
|
+
conditions.push(sql `${table.deletedAt} IS NULL`);
|
|
46
|
+
}
|
|
47
|
+
const rows = await db
|
|
48
|
+
.select()
|
|
49
|
+
.from(getTableForCollection(collection))
|
|
50
|
+
.where(and(...conditions));
|
|
51
|
+
return rows.map((row) => rowToDocument(collection, row));
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Like {@link fetchRowsByIds}, but applies mapping SQL filters (and SQL sort).
|
|
55
|
+
* Returns `{ docs, postFilters }` so callers can hydrate with the remaining
|
|
56
|
+
* OM filters — same split as {@link executeAll}.
|
|
57
|
+
*/
|
|
58
|
+
export const fetchFilteredRowsByIds = async (db, mapData, ids) => {
|
|
59
|
+
if (!ids.length)
|
|
60
|
+
return { docs: [], postFilters: [] };
|
|
61
|
+
const tableRef = getTableForCollection(mapData.collection);
|
|
62
|
+
const table = asTable(tableRef);
|
|
63
|
+
const { sqlWhere, postFilters } = partitionFilters(mapData.collection, table, mapData.filters, mapData.defaultFilter, mapData.softDelete);
|
|
64
|
+
const conditions = [inArray(table.id, ids)];
|
|
65
|
+
if (sqlWhere) {
|
|
66
|
+
conditions.push(sqlWhere);
|
|
67
|
+
}
|
|
68
|
+
const orderBy = sortToSqlOrderBy(mapData.collection, tableRef, mapData.sort, mapData.activityWindow);
|
|
69
|
+
const columns = getTableColumns(tableRef);
|
|
70
|
+
const computedSelect = buildComputedSelect(mapData, tableRef);
|
|
71
|
+
let query = db
|
|
72
|
+
.select(Object.assign(Object.assign({}, columns), computedSelect))
|
|
73
|
+
.from(tableRef)
|
|
74
|
+
.where(and(...conditions))
|
|
75
|
+
.$dynamic();
|
|
76
|
+
if (orderBy) {
|
|
77
|
+
query = query.orderBy(...orderBy);
|
|
78
|
+
}
|
|
79
|
+
const rows = await query;
|
|
80
|
+
let docs = rows.map((row) => mapRowToDoc(mapData, row));
|
|
81
|
+
if (!orderBy) {
|
|
82
|
+
docs = applySort(docs, mapData.sort);
|
|
83
|
+
}
|
|
84
|
+
return { docs, postFilters };
|
|
85
|
+
};
|
|
86
|
+
const hydrateDocuments = async (db, collection, mapData, rows, postFilters) => {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
|
+
let docs = rows;
|
|
89
|
+
for (const relation of (_a = mapData.relations) !== null && _a !== void 0 ? _a : []) {
|
|
90
|
+
docs = await attachRelation(db, collection, docs, relation);
|
|
91
|
+
}
|
|
92
|
+
for (const fkr of (_b = mapData.foreignKeyRelations) !== null && _b !== void 0 ? _b : []) {
|
|
93
|
+
docs = await attachForeignKeyRelation(db, docs, fkr);
|
|
94
|
+
}
|
|
95
|
+
docs = await attachDerivedProperties(db, docs, mapData.derivedProperties);
|
|
96
|
+
docs = applyPostFilters(docs, postFilters !== null && postFilters !== void 0 ? postFilters : mapData.filters, postFilters ? undefined : mapData.defaultFilter);
|
|
97
|
+
docs = applySort(docs, mapData.sort);
|
|
98
|
+
for (const relation of (_c = mapData.postFilterRelations) !== null && _c !== void 0 ? _c : []) {
|
|
99
|
+
docs = await attachRelation(db, collection, docs, relation);
|
|
100
|
+
}
|
|
101
|
+
for (const fkr of (_d = mapData.postFilterForeignKeyRelations) !== null && _d !== void 0 ? _d : []) {
|
|
102
|
+
docs = await attachForeignKeyRelation(db, docs, fkr);
|
|
103
|
+
}
|
|
104
|
+
docs = await attachDerivedProperties(db, docs, mapData.postFilterDerivedProperties);
|
|
105
|
+
return docs;
|
|
106
|
+
};
|
|
107
|
+
const attachDerivedProperties = async (db, docs, derivedProperties) => {
|
|
108
|
+
if (!(derivedProperties === null || derivedProperties === void 0 ? void 0 : derivedProperties.length))
|
|
109
|
+
return docs;
|
|
110
|
+
let result = docs;
|
|
111
|
+
for (const dp of derivedProperties) {
|
|
112
|
+
if (dp.batchResolve) {
|
|
113
|
+
const values = await dp.batchResolve(db, result);
|
|
114
|
+
result = result.map((doc) => (Object.assign(Object.assign({}, doc), { [String(dp.alias)]: values.get(doc.id) })));
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
result = await Promise.all(result.map(async (doc) => (Object.assign(Object.assign({}, doc), { [String(dp.alias)]: await evaluateDerived(db, doc, dp) }))));
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
};
|
|
121
|
+
export const hydrateMapData = async (db, mapData, rows, postFilters) => hydrateDocuments(db, mapData.collection, mapData, rows, postFilters);
|
|
122
|
+
const attachForeignKeyRelation = async (db, docs, fkr) => Promise.all(docs.map(async (doc) => {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const raw = doc[fkr.foreignKeyProperty];
|
|
125
|
+
const ids = fkr.cardinality === 'many'
|
|
126
|
+
? ((_a = raw) !== null && _a !== void 0 ? _a : [])
|
|
127
|
+
: raw
|
|
128
|
+
? [raw]
|
|
129
|
+
: [];
|
|
130
|
+
const loaded = (await Promise.all(ids.map((id) => executeFind(db, fkr.mapping.collection, fkr.mapping, id)))).filter(Boolean);
|
|
131
|
+
return Object.assign(Object.assign({}, doc), { [fkr.alias]: fkr.cardinality === 'many' ? loaded : ((_b = loaded[0]) !== null && _b !== void 0 ? _b : undefined) });
|
|
132
|
+
}));
|
|
133
|
+
const attachRelation = async (db, parentCollection, docs, relation) => {
|
|
134
|
+
var _a;
|
|
135
|
+
if (relation.maxDepth && relation.maxDepth > 1) {
|
|
136
|
+
return Promise.all(docs.map(async (doc) => (Object.assign(Object.assign({}, doc), { [relation.alias]: await traverseRelation(db, doc.id, relation) }))));
|
|
137
|
+
}
|
|
138
|
+
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
139
|
+
const edgeTable = asTable(edgeTableRef);
|
|
140
|
+
const parentIds = docs.map((d) => d.id);
|
|
141
|
+
if (!parentIds.length)
|
|
142
|
+
return docs;
|
|
143
|
+
const parentCol = edgeTable[parentEdgeColumn(relation)];
|
|
144
|
+
const edgeConditions = [inArray(parentCol, parentIds)];
|
|
145
|
+
const edgeExtraFilter = typeof relation.edgeFilter === 'string'
|
|
146
|
+
? applyDateRangeToEdgeSql(edgeTableRef, relation.edgeFilter)
|
|
147
|
+
: isSqlFilter(relation.edgeFilter)
|
|
148
|
+
? relation.edgeFilter.where
|
|
149
|
+
: undefined;
|
|
150
|
+
if (edgeExtraFilter)
|
|
151
|
+
edgeConditions.push(edgeExtraFilter);
|
|
152
|
+
const edgeRows = await db
|
|
153
|
+
.select()
|
|
154
|
+
.from(edgeTableRef)
|
|
155
|
+
.where(and(...edgeConditions));
|
|
156
|
+
const grouped = new Map();
|
|
157
|
+
for (const edge of edgeRows) {
|
|
158
|
+
const parentId = edge[parentEdgeColumn(relation)];
|
|
159
|
+
const list = (_a = grouped.get(parentId)) !== null && _a !== void 0 ? _a : [];
|
|
160
|
+
list.push(edge);
|
|
161
|
+
grouped.set(parentId, list);
|
|
162
|
+
}
|
|
163
|
+
return Promise.all(docs.map(async (doc) => {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
const edgesForDoc = (_a = grouped.get(doc.id)) !== null && _a !== void 0 ? _a : [];
|
|
166
|
+
if (relation.count) {
|
|
167
|
+
let count = edgesForDoc.length;
|
|
168
|
+
if ((_b = relation.mapping) === null || _b === void 0 ? void 0 : _b.collection) {
|
|
169
|
+
const vertexCol = vertexEdgeColumn(relation);
|
|
170
|
+
const vertexIds = edgesForDoc.map((e) => e[vertexCol]);
|
|
171
|
+
const vertices = await fetchRowsByIds(db, relation.mapping.collection, vertexIds, relation.mapping.softDelete);
|
|
172
|
+
const filtered = applyPostFilters(vertices, relation.mapping.filters, relation.mapping.defaultFilter);
|
|
173
|
+
count = filtered.length;
|
|
174
|
+
}
|
|
175
|
+
return Object.assign(Object.assign({}, doc), { [relation.alias]: count });
|
|
176
|
+
}
|
|
177
|
+
const value = await resolveRelationValue(db, edgesForDoc, relation, parentCollection);
|
|
178
|
+
return Object.assign(Object.assign({}, doc), { [relation.alias]: value });
|
|
179
|
+
}));
|
|
180
|
+
};
|
|
181
|
+
const resolveRelationValue = async (db, edgeRows, relation, _parentCollection) => {
|
|
182
|
+
var _a;
|
|
183
|
+
const vertexCollection = vertexCollectionFor(relation);
|
|
184
|
+
const vertexCol = vertexEdgeColumn(relation);
|
|
185
|
+
const vertexIds = edgeRows.map((e) => e[vertexCol]);
|
|
186
|
+
if (!vertexCollection) {
|
|
187
|
+
const items = edgeRows.map((edge) => {
|
|
188
|
+
var _a;
|
|
189
|
+
return rowToDocument(edgeCollectionName(relation.edgeCollection), edge, (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.keepMetadata);
|
|
190
|
+
});
|
|
191
|
+
return relation.cardinality === 'one' ? items[0] : items;
|
|
192
|
+
}
|
|
193
|
+
let vertices = await fetchRowsByIds(db, vertexCollection, vertexIds, (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.softDelete);
|
|
194
|
+
if (relation.mapping) {
|
|
195
|
+
vertices = await hydrateMapData(db, relation.mapping, vertices);
|
|
196
|
+
}
|
|
197
|
+
if (relation.skipEdge) {
|
|
198
|
+
return relation.cardinality === 'one' ? vertices[0] : vertices;
|
|
199
|
+
}
|
|
200
|
+
const items = edgeRows
|
|
201
|
+
.map((edge) => {
|
|
202
|
+
var _a;
|
|
203
|
+
const vertexId = edge[vertexCol];
|
|
204
|
+
const vertex = vertices.find((v) => v.id === vertexId);
|
|
205
|
+
if (!vertex)
|
|
206
|
+
return undefined;
|
|
207
|
+
const edgeDoc = rowToDocument(edgeCollectionName(relation.edgeCollection), edge, (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.keepMetadata);
|
|
208
|
+
if (relation.vertexAlias) {
|
|
209
|
+
return Object.assign(Object.assign({}, edgeDoc), { [relation.vertexAlias]: vertex });
|
|
210
|
+
}
|
|
211
|
+
return Object.assign(Object.assign({}, edgeDoc), vertex);
|
|
212
|
+
})
|
|
213
|
+
.filter(Boolean);
|
|
214
|
+
return relation.cardinality === 'one' ? items[0] : items;
|
|
215
|
+
};
|
|
216
|
+
const nodeCapFromLimit = (limit) => {
|
|
217
|
+
if (limit == null)
|
|
218
|
+
return undefined;
|
|
219
|
+
return typeof limit === 'number' ? limit : limit[1];
|
|
220
|
+
};
|
|
221
|
+
const traverseRelation = async (db, startId, relation) => {
|
|
222
|
+
var _a, _b, _c, _d, _e;
|
|
223
|
+
const maxDepth = (_a = relation.maxDepth) !== null && _a !== void 0 ? _a : 1;
|
|
224
|
+
const nodeCap = nodeCapFromLimit((_b = relation.mapping) === null || _b === void 0 ? void 0 : _b.limit);
|
|
225
|
+
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
226
|
+
const edgeTable = asTable(edgeTableRef);
|
|
227
|
+
const collected = [];
|
|
228
|
+
const visited = new Set([startId]);
|
|
229
|
+
let frontier = [startId];
|
|
230
|
+
for (let depth = 0; depth < maxDepth && frontier.length; depth++) {
|
|
231
|
+
if (nodeCap !== undefined && collected.length >= nodeCap)
|
|
232
|
+
break;
|
|
233
|
+
const parentCol = edgeTable[parentEdgeColumn(relation)];
|
|
234
|
+
const vertexCol = vertexEdgeColumn(relation);
|
|
235
|
+
const edgeRows = await db
|
|
236
|
+
.select()
|
|
237
|
+
.from(edgeTableRef)
|
|
238
|
+
.where(inArray(parentCol, frontier));
|
|
239
|
+
if (!edgeRows.length)
|
|
240
|
+
break;
|
|
241
|
+
let vertexIds = [
|
|
242
|
+
...new Set(edgeRows
|
|
243
|
+
.map((e) => e[vertexCol])
|
|
244
|
+
.filter((id) => !visited.has(id))),
|
|
245
|
+
];
|
|
246
|
+
if (!vertexIds.length)
|
|
247
|
+
break;
|
|
248
|
+
if (nodeCap !== undefined) {
|
|
249
|
+
const remaining = nodeCap - collected.length;
|
|
250
|
+
vertexIds = vertexIds.slice(0, remaining);
|
|
251
|
+
}
|
|
252
|
+
for (const id of vertexIds) {
|
|
253
|
+
visited.add(id);
|
|
254
|
+
}
|
|
255
|
+
const vertexCollection = vertexCollectionFor(relation);
|
|
256
|
+
if (!vertexCollection)
|
|
257
|
+
break;
|
|
258
|
+
let vertices = await fetchRowsByIds(db, vertexCollection, vertexIds, (_c = relation.mapping) === null || _c === void 0 ? void 0 : _c.softDelete);
|
|
259
|
+
if (relation.mapping) {
|
|
260
|
+
vertices = await hydrateMapData(db, relation.mapping, vertices);
|
|
261
|
+
}
|
|
262
|
+
collected.push(...vertices);
|
|
263
|
+
frontier = vertexIds;
|
|
264
|
+
}
|
|
265
|
+
// BFS is nearest-first; conversation roots need mapping sort (e.g. id ASC).
|
|
266
|
+
return applyLimit(applySort(collected, (_d = relation.mapping) === null || _d === void 0 ? void 0 : _d.sort), (_e = relation.mapping) === null || _e === void 0 ? void 0 : _e.limit);
|
|
267
|
+
};
|
|
268
|
+
export const executeFind = async (db, collection, mapData, id, ignoreSoftDelete = false) => {
|
|
269
|
+
if (!id)
|
|
270
|
+
return undefined;
|
|
271
|
+
const tableRef = getTableForCollection(collection);
|
|
272
|
+
const table = asTable(tableRef);
|
|
273
|
+
const columns = getTableColumns(tableRef);
|
|
274
|
+
const computedSelect = buildComputedSelect(mapData, tableRef);
|
|
275
|
+
const conditions = [eq(table.id, id)];
|
|
276
|
+
if (!ignoreSoftDelete && mapData.softDelete !== false && table.deletedAt) {
|
|
277
|
+
conditions.push(sql `${table.deletedAt} IS NULL`);
|
|
278
|
+
}
|
|
279
|
+
const rows = await db
|
|
280
|
+
.select(Object.assign(Object.assign({}, columns), computedSelect))
|
|
281
|
+
.from(tableRef)
|
|
282
|
+
.where(and(...conditions))
|
|
283
|
+
.limit(1);
|
|
284
|
+
const row = rows[0];
|
|
285
|
+
if (!row)
|
|
286
|
+
return undefined;
|
|
287
|
+
const hydrated = await hydrateMapData(db, mapData, [
|
|
288
|
+
mapRowToDoc(mapData, row),
|
|
289
|
+
]);
|
|
290
|
+
return hydrated[0];
|
|
291
|
+
};
|
|
292
|
+
export const executeAll = async (db, mapData) => {
|
|
293
|
+
var _a;
|
|
294
|
+
const tableRef = getTableForCollection(mapData.collection);
|
|
295
|
+
const table = asTable(tableRef);
|
|
296
|
+
const { sqlWhere, postFilters } = partitionFilters(mapData.collection, table, mapData.filters, mapData.defaultFilter, mapData.softDelete);
|
|
297
|
+
const orderBy = sortToSqlOrderBy(mapData.collection, tableRef, mapData.sort, mapData.activityWindow);
|
|
298
|
+
const canSqlPaginate = postFilters.length === 0 && (!((_a = mapData.sort) === null || _a === void 0 ? void 0 : _a.length) || !!orderBy);
|
|
299
|
+
const columns = getTableColumns(tableRef);
|
|
300
|
+
const computedSelect = buildComputedSelect(mapData, tableRef);
|
|
301
|
+
let query = db
|
|
302
|
+
.select(Object.assign(Object.assign({}, columns), computedSelect))
|
|
303
|
+
.from(tableRef)
|
|
304
|
+
.$dynamic();
|
|
305
|
+
if (sqlWhere)
|
|
306
|
+
query = query.where(sqlWhere);
|
|
307
|
+
if (canSqlPaginate && orderBy)
|
|
308
|
+
query = query.orderBy(...orderBy);
|
|
309
|
+
if (canSqlPaginate && mapData.limit) {
|
|
310
|
+
query = applySqlLimit(query, mapData.limit);
|
|
311
|
+
}
|
|
312
|
+
const rows = await query;
|
|
313
|
+
let docs = rows.map((row) => mapRowToDoc(mapData, row));
|
|
314
|
+
docs = await hydrateMapData(db, mapData, docs, postFilters);
|
|
315
|
+
if (!orderBy) {
|
|
316
|
+
docs = applySort(docs, mapData.sort);
|
|
317
|
+
}
|
|
318
|
+
if (!canSqlPaginate) {
|
|
319
|
+
docs = applyLimit(docs, mapData.limit);
|
|
320
|
+
}
|
|
321
|
+
return docs;
|
|
322
|
+
};
|
|
323
|
+
export const executeCount = async (db, mapData) => {
|
|
324
|
+
var _a, _b;
|
|
325
|
+
const table = getTableForCollection(mapData.collection);
|
|
326
|
+
const { sqlWhere, postFilters } = partitionFilters(mapData.collection, table, mapData.filters, mapData.defaultFilter, mapData.softDelete);
|
|
327
|
+
if (!postFilters.length) {
|
|
328
|
+
const rows = (await db
|
|
329
|
+
.select({ value: sql `count(*)::int` })
|
|
330
|
+
.from(table)
|
|
331
|
+
.where(sqlWhere));
|
|
332
|
+
return Number((_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0);
|
|
333
|
+
}
|
|
334
|
+
const docs = await executeAll(db, Object.assign(Object.assign({}, mapData), { limit: undefined }));
|
|
335
|
+
return docs.length;
|
|
336
|
+
};
|
|
337
|
+
export const executeFirst = async (db, mapData) => {
|
|
338
|
+
const limited = applyLimit(await executeAll(db, mapData), [0, 1]);
|
|
339
|
+
return limited[0];
|
|
340
|
+
};
|
|
341
|
+
export const relationsFrom = async (db, start, parentCollection, relation) => {
|
|
342
|
+
var _a;
|
|
343
|
+
// Match attachRelation: honor maxDepth via BFS traversal. Without this,
|
|
344
|
+
// callers like getConversationByStart only see direct (depth-1) replies.
|
|
345
|
+
if (relation.maxDepth && relation.maxDepth > 1) {
|
|
346
|
+
return traverseRelation(db, start.id, relation);
|
|
347
|
+
}
|
|
348
|
+
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
349
|
+
const edgeTable = asTable(edgeTableRef);
|
|
350
|
+
const parentCol = edgeTable[parentEdgeColumn(relation)];
|
|
351
|
+
const edgeRows = await db
|
|
352
|
+
.select()
|
|
353
|
+
.from(edgeTableRef)
|
|
354
|
+
.where(eq(parentCol, start.id));
|
|
355
|
+
if (relation.count) {
|
|
356
|
+
return [{ count: edgeRows.length }];
|
|
357
|
+
}
|
|
358
|
+
if (relation.skipEdge && relation.mapping.collection) {
|
|
359
|
+
const vertexCol = vertexEdgeColumn(relation);
|
|
360
|
+
const vertexIds = edgeRows.map((e) => e[vertexCol]);
|
|
361
|
+
// Apply mapping SQL filters (e.g. documentKeyBefore for `start` cursors)
|
|
362
|
+
// here — fetchRowsByIds alone ignores them, and applyPostFilters skips
|
|
363
|
+
// SqlFilters, which previously broke chronological pagination for group /
|
|
364
|
+
// profile / bookmark / hashtag feeds built via relationsFrom.
|
|
365
|
+
const { docs, postFilters } = await fetchFilteredRowsByIds(db, relation.mapping, vertexIds);
|
|
366
|
+
return hydrateMapData(db, relation.mapping, docs, postFilters);
|
|
367
|
+
}
|
|
368
|
+
// Keep edge fields (e.g. roles) and attach the related vertex under
|
|
369
|
+
// vertexAlias — same shape as hydrateDocuments/attachRelation.
|
|
370
|
+
const value = await resolveRelationValue(db, edgeRows, relation, parentCollection);
|
|
371
|
+
if (relation.cardinality === 'one') {
|
|
372
|
+
return value ? [value] : [];
|
|
373
|
+
}
|
|
374
|
+
return (_a = value) !== null && _a !== void 0 ? _a : [];
|
|
375
|
+
};
|
|
376
|
+
export const evaluateDerived = async (db, doc, derived) => derived.resolve(db, doc);
|
|
377
|
+
export const deleteRelationsFor = async (db, startId, relation) => {
|
|
378
|
+
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
379
|
+
const edgeTable = asTable(edgeTableRef);
|
|
380
|
+
const parentCol = edgeTable[parentEdgeColumn(relation)];
|
|
381
|
+
const vertexCol = vertexEdgeColumn(relation);
|
|
382
|
+
const edgeRows = await db
|
|
383
|
+
.select()
|
|
384
|
+
.from(edgeTableRef)
|
|
385
|
+
.where(eq(parentCol, startId));
|
|
386
|
+
for (const edge of edgeRows) {
|
|
387
|
+
const vertexId = edge[vertexCol];
|
|
388
|
+
if (relation.mapping.collection) {
|
|
389
|
+
const vertexTableRef = getTableForCollection(relation.mapping.collection);
|
|
390
|
+
const vertexTable = asTable(vertexTableRef);
|
|
391
|
+
await db
|
|
392
|
+
.delete(vertexTableRef)
|
|
393
|
+
.where(eq(vertexTable.id, vertexId));
|
|
394
|
+
}
|
|
395
|
+
await db
|
|
396
|
+
.delete(edgeTableRef)
|
|
397
|
+
.where(eq(edgeTable.id, edge.id));
|
|
398
|
+
}
|
|
399
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MapData, SearchDefinition } from './queryTypes';
|
|
2
|
+
import type { PgQueryResult } from './types';
|
|
3
|
+
export declare const buildSearchResult: <O extends object>(mapData: MapData<O>, searchDefinition: SearchDefinition) => PgQueryResult<{
|
|
4
|
+
data: O;
|
|
5
|
+
score: number;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
7
|
+
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]); } }
|
|
8
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
9
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
10
|
+
function fulfill(value) { resume("next", value); }
|
|
11
|
+
function reject(value) { resume("throw", value); }
|
|
12
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
13
|
+
};
|
|
14
|
+
import { and, sql } from 'drizzle-orm';
|
|
15
|
+
import { applyLimit, applyPostFilters, applySort, applySqlLimit, partitionFilters, } from './filters.js';
|
|
16
|
+
import { hydrateMapData } from './relations.js';
|
|
17
|
+
import { asTable, getTableForCollection, rowToDocument, searchViewCollections, } from './registry.js';
|
|
18
|
+
const escapeJsonKey = (key) => key.replace(/'/g, "''");
|
|
19
|
+
const normalizeSearchPath = (collection, field) => {
|
|
20
|
+
let path = field;
|
|
21
|
+
if (collection === 'posts' && path.startsWith('data.')) {
|
|
22
|
+
path = path.slice(5);
|
|
23
|
+
}
|
|
24
|
+
return path;
|
|
25
|
+
};
|
|
26
|
+
const jsonBodyTextExpr = (path) => {
|
|
27
|
+
const parts = path.split('.');
|
|
28
|
+
if (parts.length === 1) {
|
|
29
|
+
return sql.raw(`body->>'${escapeJsonKey(parts[0])}'`);
|
|
30
|
+
}
|
|
31
|
+
const parents = parts
|
|
32
|
+
.slice(0, -1)
|
|
33
|
+
.map((part) => `'${escapeJsonKey(part)}'`)
|
|
34
|
+
.join('->');
|
|
35
|
+
const last = escapeJsonKey(parts[parts.length - 1]);
|
|
36
|
+
return sql.raw(`body->${parents}->>'${last}'`);
|
|
37
|
+
};
|
|
38
|
+
const fieldToSql = (collection, field) => {
|
|
39
|
+
const scalarFields = {
|
|
40
|
+
profiles: { handle: 'handle' },
|
|
41
|
+
groups: { handle: 'handle' },
|
|
42
|
+
posts: { type: 'type', visibility: 'visibility' },
|
|
43
|
+
};
|
|
44
|
+
const scalars = scalarFields[collection];
|
|
45
|
+
const path = normalizeSearchPath(collection, field);
|
|
46
|
+
const top = path.split('.')[0];
|
|
47
|
+
if (scalars === null || scalars === void 0 ? void 0 : scalars[top]) {
|
|
48
|
+
return sql.raw(`"${scalars[top]}"`);
|
|
49
|
+
}
|
|
50
|
+
return jsonBodyTextExpr(path);
|
|
51
|
+
};
|
|
52
|
+
const fieldMatchesQuery = (collection, field, query, mode = 'substring') => {
|
|
53
|
+
var _a;
|
|
54
|
+
const like = mode === 'prefix' ? `${query}%` : `%${query}%`;
|
|
55
|
+
const scalarFields = {
|
|
56
|
+
profiles: { handle: 'handle' },
|
|
57
|
+
groups: { handle: 'handle' },
|
|
58
|
+
posts: { type: 'type', visibility: 'visibility' },
|
|
59
|
+
};
|
|
60
|
+
const path = normalizeSearchPath(collection, field);
|
|
61
|
+
const top = path.split('.')[0];
|
|
62
|
+
if ((_a = scalarFields[collection]) === null || _a === void 0 ? void 0 : _a[top]) {
|
|
63
|
+
return sql `${fieldToSql(collection, field)} ILIKE ${like}`;
|
|
64
|
+
}
|
|
65
|
+
const parts = path.split('.');
|
|
66
|
+
if (parts[0] === 'attachments' && parts.length === 2) {
|
|
67
|
+
return sql `EXISTS (SELECT 1 FROM jsonb_array_elements(COALESCE(body->'attachments', '[]'::jsonb)) AS elem WHERE elem->>${parts[1]} ILIKE ${like})`;
|
|
68
|
+
}
|
|
69
|
+
if (parts[0] === 'options' && parts.length === 2) {
|
|
70
|
+
return sql `EXISTS (SELECT 1 FROM jsonb_array_elements(COALESCE(body->'options', '[]'::jsonb)) AS elem WHERE elem->>${parts[1]} ILIKE ${like})`;
|
|
71
|
+
}
|
|
72
|
+
return sql `${jsonBodyTextExpr(path)} ILIKE ${like}`;
|
|
73
|
+
};
|
|
74
|
+
const searchableCollections = new Set(['profiles', 'groups', 'posts']);
|
|
75
|
+
const searchVectorExpr = (table) => {
|
|
76
|
+
if (table.searchVector) {
|
|
77
|
+
return sql `${table.searchVector}`;
|
|
78
|
+
}
|
|
79
|
+
return sql `to_tsvector('english', coalesce(${table.body}::text, ''))`;
|
|
80
|
+
};
|
|
81
|
+
const shortQueryPrefixFields = (collection, fields) => {
|
|
82
|
+
const allowed = new Set(collection === 'profiles' || collection === 'groups'
|
|
83
|
+
? ['handle', 'displayName']
|
|
84
|
+
: ['handle', 'displayName', 'data.name']);
|
|
85
|
+
return fields.filter((field) => {
|
|
86
|
+
const path = normalizeSearchPath(collection, field);
|
|
87
|
+
return allowed.has(path) || allowed.has(field);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const buildSearchWhere = (collection, fields, query, table) => {
|
|
91
|
+
const tsQuery = sql `plainto_tsquery('english', ${query})`;
|
|
92
|
+
const tsvectorExpr = searchVectorExpr(table);
|
|
93
|
+
const trimmed = query.trim();
|
|
94
|
+
const shortQuery = trimmed.length > 0 && trimmed.length < 2;
|
|
95
|
+
const ilikeFields = shortQuery
|
|
96
|
+
? shortQueryPrefixFields(collection, fields)
|
|
97
|
+
: fields;
|
|
98
|
+
const ilikeParts = ilikeFields.map((field) => fieldMatchesQuery(collection, field, trimmed, shortQuery ? 'prefix' : 'substring'));
|
|
99
|
+
if (!ilikeParts.length) {
|
|
100
|
+
return sql `(${tsvectorExpr} @@ ${tsQuery})`;
|
|
101
|
+
}
|
|
102
|
+
return sql `(${tsvectorExpr} @@ ${tsQuery} OR ${sql.join(ilikeParts, sql ` OR `)})`;
|
|
103
|
+
};
|
|
104
|
+
export const buildSearchResult = (mapData, searchDefinition) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const collection = (_a = searchViewCollections[searchDefinition.view]) !== null && _a !== void 0 ? _a : mapData.collection;
|
|
107
|
+
const runSearch = async (db) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const tableRef = getTableForCollection(collection);
|
|
110
|
+
const table = asTable(tableRef);
|
|
111
|
+
const { sqlWhere, postFilters } = collection === mapData.collection
|
|
112
|
+
? partitionFilters(mapData.collection, tableRef, mapData.filters, mapData.defaultFilter, mapData.softDelete)
|
|
113
|
+
: { sqlWhere: undefined, postFilters: [] };
|
|
114
|
+
const searchWhere = buildSearchWhere(collection, searchDefinition.fields, searchDefinition.query, table);
|
|
115
|
+
const where = sqlWhere ? and(searchWhere, sqlWhere) : searchWhere;
|
|
116
|
+
const tsQuery = sql `plainto_tsquery('english', ${searchDefinition.query})`;
|
|
117
|
+
const rank = searchableCollections.has(collection)
|
|
118
|
+
? sql `ts_rank(${searchVectorExpr(table)}, ${tsQuery})`
|
|
119
|
+
: sql `ts_rank(to_tsvector('english', coalesce(${table.body}::text, '')), ${tsQuery})`;
|
|
120
|
+
const pageLimit = (_a = searchDefinition.limit) !== null && _a !== void 0 ? _a : mapData.limit;
|
|
121
|
+
// When post-filters must run in JS, fetch the full match set; otherwise
|
|
122
|
+
// page in SQL so we only hydrate the requested window.
|
|
123
|
+
let selectQuery = db
|
|
124
|
+
.select({
|
|
125
|
+
row: tableRef,
|
|
126
|
+
score: rank,
|
|
127
|
+
})
|
|
128
|
+
.from(tableRef)
|
|
129
|
+
.where(where)
|
|
130
|
+
.orderBy(sql `${rank} DESC`)
|
|
131
|
+
.$dynamic();
|
|
132
|
+
if (!postFilters.length) {
|
|
133
|
+
selectQuery = applySqlLimit(selectQuery, pageLimit);
|
|
134
|
+
}
|
|
135
|
+
const rows = await selectQuery;
|
|
136
|
+
let docs = rows.map(({ row, score }) => ({
|
|
137
|
+
data: rowToDocument(collection, row),
|
|
138
|
+
score: score !== null && score !== void 0 ? score : 0,
|
|
139
|
+
}));
|
|
140
|
+
if (collection === mapData.collection && docs.length) {
|
|
141
|
+
const hydrated = await hydrateMapData(db, mapData, docs.map((d) => d.data), postFilters);
|
|
142
|
+
docs = hydrated.map((data, i) => {
|
|
143
|
+
var _a, _b;
|
|
144
|
+
return ({
|
|
145
|
+
data: data,
|
|
146
|
+
score: (_b = (_a = docs[i]) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : 0,
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
if (postFilters.length) {
|
|
150
|
+
const kept = new Set(applyPostFilters(docs.map((d) => d.data), postFilters));
|
|
151
|
+
docs = docs.filter((d) => kept.has(d.data));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
docs = applySort(docs, mapData.sort);
|
|
155
|
+
return applyLimit(docs, pageLimit);
|
|
156
|
+
};
|
|
157
|
+
const runCount = async (db) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const tableRef = getTableForCollection(collection);
|
|
160
|
+
const { sqlWhere, postFilters } = collection === mapData.collection
|
|
161
|
+
? partitionFilters(mapData.collection, tableRef, mapData.filters, mapData.defaultFilter, mapData.softDelete)
|
|
162
|
+
: { sqlWhere: undefined, postFilters: [] };
|
|
163
|
+
if (!postFilters.length) {
|
|
164
|
+
const searchWhere = buildSearchWhere(collection, searchDefinition.fields, searchDefinition.query, asTable(tableRef));
|
|
165
|
+
const where = sqlWhere ? and(searchWhere, sqlWhere) : searchWhere;
|
|
166
|
+
const rows = (await db
|
|
167
|
+
.select({ value: sql `count(*)::int` })
|
|
168
|
+
.from(tableRef)
|
|
169
|
+
.where(where));
|
|
170
|
+
return Number((_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0);
|
|
171
|
+
}
|
|
172
|
+
return runSearch(db).then((rows) => rows.length);
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
all: (db) => runSearch(db),
|
|
176
|
+
count: (db) => runCount(db),
|
|
177
|
+
first: (db) => runSearch(db).then((rows) => rows[0]),
|
|
178
|
+
limit: (limit) => buildSearchResult(Object.assign(Object.assign({}, mapData), { limit: limit }), searchDefinition),
|
|
179
|
+
query: () => {
|
|
180
|
+
throw new Error('query() is not supported for Postgres fulltextSearch');
|
|
181
|
+
},
|
|
182
|
+
cursor: function (db) {
|
|
183
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
184
|
+
for (const row of yield __await(runSearch(db))) {
|
|
185
|
+
yield yield __await(row);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Limit } from './queryTypes';
|
|
2
|
+
import type { PgDb } from '../client';
|
|
3
|
+
export type { Limit } from './queryTypes';
|
|
4
|
+
export type PgQueryResult<T extends object> = {
|
|
5
|
+
all: (db: PgDb) => Promise<T[]>;
|
|
6
|
+
count: (db: PgDb) => Promise<number>;
|
|
7
|
+
first: (db: PgDb) => Promise<T | undefined>;
|
|
8
|
+
limit: (limit: Limit) => PgQueryResult<T>;
|
|
9
|
+
query: () => never;
|
|
10
|
+
cursor: (db: PgDb) => AsyncGenerator<T>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Model } from '@openpeepshq/common/types';
|
|
2
|
+
export type RowTimestamps = {
|
|
3
|
+
createdAt: string;
|
|
4
|
+
updatedAt: string;
|
|
5
|
+
deletedAt?: string | null;
|
|
6
|
+
};
|
|
7
|
+
/** Postgres returns timestamptz strings with offsets; Zod expects UTC `Z`. */
|
|
8
|
+
export declare const normalizeIsoDatetime: (value: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Computed SQL fields (e.g. max(created_at) as lastPostAt) skip rowToModel.
|
|
11
|
+
* Normalize them the same way so API output schemas accept the values.
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeComputedDatetime: (value: unknown) => string | null;
|
|
14
|
+
export declare const rowToModel: <T extends object>(id: string, data: T, timestamps: RowTimestamps) => Model<T>;
|
|
15
|
+
export declare const modelTimestampsFromRow: (row: RowTimestamps) => {
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
deletedAt: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare const notDeleted: <T extends {
|
|
21
|
+
deletedAt?: string | null;
|
|
22
|
+
}>(row: T) => boolean;
|
|
23
|
+
export declare const nowIso: () => string;
|
|
24
|
+
export type DocumentRow = RowTimestamps & {
|
|
25
|
+
id: string;
|
|
26
|
+
body?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
export declare const mergeDocumentBody: <T extends object>(row: DocumentRow, scalars?: Partial<T>) => T;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Postgres returns timestamptz strings with offsets; Zod expects UTC `Z`. */
|
|
2
|
+
export const normalizeIsoDatetime = (value) => new Date(value).toISOString();
|
|
3
|
+
/**
|
|
4
|
+
* Computed SQL fields (e.g. max(created_at) as lastPostAt) skip rowToModel.
|
|
5
|
+
* Normalize them the same way so API output schemas accept the values.
|
|
6
|
+
*/
|
|
7
|
+
export const normalizeComputedDatetime = (value) => {
|
|
8
|
+
if (value == null || value === '')
|
|
9
|
+
return null;
|
|
10
|
+
if (value instanceof Date)
|
|
11
|
+
return value.toISOString();
|
|
12
|
+
if (typeof value === 'string')
|
|
13
|
+
return normalizeIsoDatetime(value);
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
export const rowToModel = (id, data, timestamps) => (Object.assign(Object.assign(Object.assign({ id }, data), { createdAt: normalizeIsoDatetime(timestamps.createdAt), updatedAt: normalizeIsoDatetime(timestamps.updatedAt) }), (timestamps.deletedAt
|
|
17
|
+
? { deletedAt: normalizeIsoDatetime(timestamps.deletedAt) }
|
|
18
|
+
: {})));
|
|
19
|
+
export const modelTimestampsFromRow = (row) => ({
|
|
20
|
+
createdAt: normalizeIsoDatetime(row.createdAt),
|
|
21
|
+
updatedAt: normalizeIsoDatetime(row.updatedAt),
|
|
22
|
+
deletedAt: row.deletedAt ? normalizeIsoDatetime(row.deletedAt) : undefined,
|
|
23
|
+
});
|
|
24
|
+
export const notDeleted = (row) => !row.deletedAt;
|
|
25
|
+
export const nowIso = () => new Date().toISOString();
|
|
26
|
+
export const mergeDocumentBody = (row, scalars = {}) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (Object.assign(Object.assign({}, ((_a = row.body) !== null && _a !== void 0 ? _a : {})), scalars));
|
|
29
|
+
};
|