@openpeepshq/core 0.1.32 → 0.1.34
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/dist/accessTokens/helpers.d.ts +2 -2
- package/dist/accessTokens/tokens.js +14 -7
- package/dist/accounts/mutations.d.ts +2 -2
- package/dist/accounts/mutations.js +33 -35
- package/dist/analytics/cache.js +12 -7
- package/dist/analytics/compile.js +16 -10
- package/dist/analytics/pdfReport.d.ts +1 -0
- package/dist/analytics/pdfReport.js +5 -4
- package/dist/analytics/privacy.d.ts +18 -0
- package/dist/analytics/privacy.js +10 -0
- package/dist/analytics/read.js +75 -19
- package/dist/analytics/report.d.ts +21 -1
- package/dist/analytics/report.js +9 -2
- package/dist/backups/index.js +78 -15
- package/dist/backups/metadata.d.ts +8 -2
- package/dist/backups/metadata.js +6 -2
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +7 -9
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +3 -0
- package/dist/config/defaults/db.d.ts +0 -2
- package/dist/config/defaults/db.js +0 -2
- package/dist/config/index.d.ts +25 -3
- package/dist/config/index.js +7 -1
- package/dist/db/helpers.d.ts +7 -28
- package/dist/db/helpers.js +30 -152
- package/dist/db/index.d.ts +3 -1
- package/dist/db/index.js +5 -0
- package/dist/db/init.js +2 -2
- package/dist/db/migration/importCollections.d.ts +15 -10
- package/dist/db/migration/importCollections.js +121 -155
- package/dist/db/migration/shared.d.ts +2 -37
- package/dist/db/migration/shared.js +2 -59
- package/dist/db/pg/client.js +4 -0
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/edges.d.ts +1 -1
- package/dist/db/pg/filters/edges.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +11 -0
- package/dist/db/pg/filters/posts.js +37 -3
- package/dist/db/pg/filters/profiles.d.ts +1 -0
- package/dist/db/pg/filters/profiles.js +2 -1
- package/dist/db/pg/map/filters.js +37 -2
- package/dist/db/pg/map/mutations.js +13 -8
- package/dist/db/pg/map/registry.d.ts +5 -0
- package/dist/db/pg/map/registry.js +64 -24
- package/dist/db/pg/map/relations.d.ts +1 -1
- package/dist/db/pg/map/relations.js +98 -46
- package/dist/db/pg/migrate.d.ts +22 -0
- package/dist/db/pg/migrate.js +88 -2
- package/dist/db/pg/queries/activity.js +3 -3
- package/dist/db/pg/queries/sorts.d.ts +1 -0
- package/dist/db/pg/queries/sorts.js +4 -0
- package/dist/db/pg/schema/documents.d.ts +422 -41
- package/dist/db/pg/schema/documents.js +43 -9
- package/dist/db/pg/schema/edges.d.ts +117 -7
- package/dist/db/pg/schema/edges.js +4 -2
- package/dist/db/pg/schema/index.d.ts +505 -15
- package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
- package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
- package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
- package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
- package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
- package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
- package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
- package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
- package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
- package/dist/db/pg/sql/meta/{0006_snapshot.json → 0015_snapshot.json} +393 -39
- package/dist/db/pg/sql/meta/_journal.json +64 -1
- package/dist/db/replaceOrigin.js +6 -0
- package/dist/db/types.d.ts +0 -4
- package/dist/email/render.js +11 -3
- package/dist/events/index.d.ts +6 -1
- package/dist/events/index.js +55 -33
- package/dist/federation/activities.d.ts +17 -0
- package/dist/federation/activities.js +26 -0
- package/dist/federation/identity.d.ts +16 -0
- package/dist/federation/identity.js +52 -0
- package/dist/federation/index.d.ts +4 -0
- package/dist/federation/index.js +3 -0
- package/dist/federation/profiles.d.ts +3 -0
- package/dist/federation/profiles.js +14 -0
- package/dist/groups/finders.d.ts +3 -2
- package/dist/groups/helpers.d.ts +24 -6
- package/dist/groups/mapping.d.ts +6 -4
- package/dist/groups/mapping.js +2 -2
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.d.ts +6 -3
- package/dist/hashtags/finders.js +2 -0
- package/dist/hashtags/helpers.d.ts +8 -0
- package/dist/hashtags/helpers.js +4 -0
- package/dist/hashtags/index.d.ts +2 -0
- package/dist/hashtags/index.js +2 -0
- package/dist/hashtags/mutations.d.ts +3 -0
- package/dist/hashtags/mutations.js +13 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +3 -1
- package/dist/i18n/pluginLocales.d.ts +6 -0
- package/dist/i18n/pluginLocales.js +15 -0
- package/dist/inviteLinks/helpers.d.ts +4 -4
- package/dist/jams/cache.d.ts +1 -1
- package/dist/jams/cache.js +2 -1
- package/dist/jams/export.d.ts +19 -0
- package/dist/jams/export.js +60 -0
- package/dist/jams/finders.d.ts +2 -1
- package/dist/jams/finders.js +18 -7
- package/dist/jams/health.d.ts +8 -0
- package/dist/jams/health.js +46 -0
- package/dist/jams/helpers.d.ts +6 -2
- package/dist/jams/index.d.ts +6 -3
- package/dist/jams/index.js +41 -27
- package/dist/jams/jobs.js +1 -1
- package/dist/jams/livekit.d.ts +93 -10
- package/dist/jams/livekit.js +151 -52
- package/dist/jams/mapping.d.ts +17 -7
- package/dist/jams/mutations.d.ts +3 -1
- package/dist/jams/recording.d.ts +10 -0
- package/dist/jams/recording.js +32 -0
- package/dist/jams/rtmp.d.ts +5 -0
- package/dist/jams/rtmp.js +8 -0
- package/dist/jams/token.d.ts +15 -3
- package/dist/jams/token.js +30 -16
- package/dist/jams/waitingRoom.d.ts +6 -6
- package/dist/jams/waitingRoom.js +24 -23
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +6 -1
- package/dist/jobs/jobDetail.js +1 -6
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +23 -8
- package/dist/media/processing.js +18 -7
- package/dist/notifications/defaultNotifications/follow/index.js +2 -2
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
- package/dist/notifications/defaultNotifications/index.js +4 -0
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
- package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
- package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +18 -0
- package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
- package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
- package/dist/notifications/helpers.js +6 -2
- package/dist/notifications/jobs.js +3 -1
- package/dist/notifications/mutations.js +4 -0
- package/dist/notifications/push.js +11 -4
- package/dist/plugins/helpers.d.ts +1 -0
- package/dist/plugins/helpers.js +1 -8
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +78 -5
- package/dist/plugins/install.d.ts +39 -0
- package/dist/plugins/install.js +455 -0
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +10 -6
- package/dist/plugins/state.d.ts +4 -0
- package/dist/plugins/state.js +29 -0
- package/dist/posts/activity.d.ts +9 -0
- package/dist/posts/activity.js +35 -0
- package/dist/posts/contextClosure.d.ts +1 -9
- package/dist/posts/contextClosure.js +15 -44
- package/dist/posts/conversationQueries.d.ts +7 -0
- package/dist/posts/conversationQueries.js +76 -2
- package/dist/posts/eventAgenda.d.ts +166 -0
- package/dist/posts/eventAgenda.js +126 -0
- package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
- package/dist/posts/eventOccurrenceJobs.js +28 -0
- package/dist/posts/eventOccurrences.d.ts +10 -0
- package/dist/posts/eventOccurrences.js +61 -0
- package/dist/posts/finders.d.ts +47 -16
- package/dist/posts/finders.js +93 -62
- package/dist/posts/helpers/filters.js +14 -9
- package/dist/posts/helpers/index.d.ts +129 -30
- package/dist/posts/helpers/index.js +66 -33
- package/dist/posts/index.d.ts +7 -1
- package/dist/posts/index.js +7 -1
- package/dist/posts/mapping.d.ts +491 -13
- package/dist/posts/mapping.js +45 -10
- package/dist/posts/mutations.d.ts +441 -4
- package/dist/posts/mutations.js +177 -43
- package/dist/posts/pollEnd.d.ts +3 -0
- package/dist/posts/pollEnd.js +7 -0
- package/dist/posts/pollEndJobs.d.ts +8 -0
- package/dist/posts/pollEndJobs.js +49 -0
- package/dist/posts/replyClosure.d.ts +10 -0
- package/dist/posts/replyClosure.js +43 -0
- package/dist/posts/rsvpConfirmationEmail.js +14 -15
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.d.ts +2 -0
- package/dist/posts/unseenCounts.js +28 -8
- package/dist/profileSettings/cache.js +22 -5
- package/dist/profileSettings/mapping.d.ts +2 -0
- package/dist/profiles/activityQueries.d.ts +5 -0
- package/dist/profiles/activityQueries.js +85 -0
- package/dist/profiles/activitySummary.d.ts +3 -0
- package/dist/profiles/activitySummary.js +87 -0
- package/dist/profiles/blocks.d.ts +12 -0
- package/dist/profiles/blocks.js +73 -0
- package/dist/profiles/cache.d.ts +4 -1
- package/dist/profiles/cache.js +28 -7
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +8 -3
- package/dist/profiles/helpers.d.ts +7 -5
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +3 -1
- package/dist/profiles/mapping.d.ts +10 -5
- package/dist/profiles/mapping.js +13 -1
- package/dist/profiles/mutations.d.ts +8 -4
- package/dist/profiles/mutations.js +42 -15
- package/dist/pushSubscriptions/helpers.d.ts +2 -2
- package/dist/pushSubscriptions/mutations.js +13 -1
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -6
- package/dist/reports/helpers.d.ts +6 -6
- package/dist/roles/index.d.ts +1 -1
- package/dist/roles/index.js +1 -1
- package/dist/roles/mapping.d.ts +1 -0
- package/dist/roles/mutations.js +86 -3
- package/dist/search/mapping.d.ts +1 -1
- package/dist/search/mapping.js +6 -2
- package/dist/server/index.d.ts +19 -1
- package/dist/server/index.js +37 -18
- package/dist/server/stablePublicServerInfo.d.ts +17 -0
- package/dist/server/stablePublicServerInfo.js +37 -0
- package/dist/server/status.d.ts +25 -0
- package/dist/server/status.js +98 -0
- package/dist/stats/finders.d.ts +1 -16131
- package/dist/stats/finders.js +9 -5
- package/dist/stats/mapping.d.ts +21 -1
- package/dist/stats/mapping.js +0 -3
- package/package.json +6 -12
- package/dist/db/arango.d.ts +0 -2
- package/dist/db/arango.js +0 -110
- package/dist/db/migration/autoMigrate.d.ts +0 -2
- package/dist/db/migration/autoMigrate.js +0 -111
- package/dist/db/migration/cli.d.ts +0 -1
- package/dist/db/migration/cli.js +0 -56
- package/dist/db/migration/detect.d.ts +0 -6
- package/dist/db/migration/detect.js +0 -87
- package/dist/db/migration/exportArango.d.ts +0 -4
- package/dist/db/migration/exportArango.js +0 -80
- package/dist/db/migration/importPostgres.d.ts +0 -3
- package/dist/db/migration/importPostgres.js +0 -18
- package/dist/db/migration/transform.d.ts +0 -18
- package/dist/db/migration/transform.js +0 -209
- package/dist/db/migration/validate.d.ts +0 -18
- package/dist/db/migration/validate.js +0 -69
- package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
- package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
- package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
- package/dist/mastodon/index.d.ts +0 -4
- package/dist/mastodon/index.js +0 -51
- package/dist/mastodon/types.d.ts +0 -7579
- package/dist/mastodon/types.js +0 -523
- package/dist/mastodon/typescript.d.ts +0 -1578
- package/dist/mastodon/typescript.js +0 -1
- package/dist/roles/defaults.d.ts +0 -2
- package/dist/roles/defaults.js +0 -94
|
@@ -11,14 +11,31 @@ export const profileSettingsCache = createCache({
|
|
|
11
11
|
hub.on('profileSettingsUpdated', (profileId) => {
|
|
12
12
|
void profileSettingsCache.del(profileId);
|
|
13
13
|
});
|
|
14
|
+
const uniqueViolation = (error) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const current = error;
|
|
17
|
+
return current.code === '23505' || ((_a = current.cause) === null || _a === void 0 ? void 0 : _a.code) === '23505';
|
|
18
|
+
};
|
|
19
|
+
const readProfileSettings = async (db, id) =>
|
|
20
|
+
// Include soft-deleted rows: the profile_id unique index still covers them,
|
|
21
|
+
// so a miss here would insert and fail with 23505.
|
|
22
|
+
profileSettingsMapping.find(db, id, { ignoreSoftDelete: true });
|
|
14
23
|
export const getProfileSettings = async (id) => profileSettingsCache.wrap(id, async () => {
|
|
15
24
|
const { db } = await allpeepDb();
|
|
16
|
-
const foundSettings = await
|
|
25
|
+
const foundSettings = await readProfileSettings(db, id);
|
|
17
26
|
if (foundSettings) {
|
|
18
27
|
return foundSettings;
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
id
|
|
22
|
-
}
|
|
23
|
-
|
|
29
|
+
try {
|
|
30
|
+
return await profileSettingsMapping.create(db, { id });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// Another request created the row between the read and this insert.
|
|
34
|
+
if (!uniqueViolation(error))
|
|
35
|
+
throw error;
|
|
36
|
+
const raced = await readProfileSettings(db, id);
|
|
37
|
+
if (raced)
|
|
38
|
+
return raced;
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
24
41
|
});
|
|
@@ -2,6 +2,7 @@ import { ProfileSettings } from '@openpeepshq/common/types';
|
|
|
2
2
|
export declare const profileSettingsMapping: import("../db/pg/map").Mapping<{
|
|
3
3
|
id: string;
|
|
4
4
|
language?: string | undefined;
|
|
5
|
+
timeZone?: string | undefined;
|
|
5
6
|
theme?: "light" | "dark" | "community" | "system" | undefined;
|
|
6
7
|
defaults?: {
|
|
7
8
|
privacy?: "public" | "unlisted" | "private" | undefined;
|
|
@@ -31,6 +32,7 @@ export declare const profileSettingsMapping: import("../db/pg/map").Mapping<{
|
|
|
31
32
|
customerId?: string | undefined;
|
|
32
33
|
} | undefined;
|
|
33
34
|
feedSettings?: {
|
|
35
|
+
format?: "threaded" | "linear" | undefined;
|
|
34
36
|
communityFeed?: {
|
|
35
37
|
showGroupPosts?: boolean | undefined;
|
|
36
38
|
} | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOP_POSTS_LIMIT = 5;
|
|
2
|
+
export declare const TOP_POST_CANDIDATE_LIMIT = 25;
|
|
3
|
+
export declare const profileActivityCountsSql: (profileId: string) => import("drizzle-orm").SQL<unknown>;
|
|
4
|
+
export declare const profileTopPostScoresSql: (profileId: string) => import("drizzle-orm").SQL<unknown>;
|
|
5
|
+
export declare const takeTopReadablePosts: <T>(ordered: T[], isReadable: (item: T) => boolean) => T[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { postActivityScoreExpr } from '../db/pg/queries/index.js';
|
|
3
|
+
import { posts } from '../db/pg/schema/documents.js';
|
|
4
|
+
import { bookmarks, entries, replyTo, repost, userGroups, } from '../db/pg/schema/edges.js';
|
|
5
|
+
export const TOP_POSTS_LIMIT = 5;
|
|
6
|
+
export const TOP_POST_CANDIDATE_LIMIT = 25;
|
|
7
|
+
const isReplySql = sql `EXISTS (
|
|
8
|
+
SELECT 1 FROM ${replyTo} WHERE ${replyTo.fromId} = ${posts.id}::text
|
|
9
|
+
)`;
|
|
10
|
+
export const profileActivityCountsSql = (profileId) => sql `
|
|
11
|
+
SELECT
|
|
12
|
+
COUNT(*) FILTER (WHERE NOT ${isReplySql})::int AS posts_count,
|
|
13
|
+
COUNT(*) FILTER (WHERE ${isReplySql})::int AS replies_count,
|
|
14
|
+
COUNT(*) FILTER (
|
|
15
|
+
WHERE ${posts.type} = 'event' AND NOT ${isReplySql}
|
|
16
|
+
)::int AS events_count,
|
|
17
|
+
(
|
|
18
|
+
SELECT COUNT(*)::int FROM ${entries}
|
|
19
|
+
WHERE ${entries.fromId} = ${profileId}
|
|
20
|
+
AND ${entries.body}->>'type' = 'reaction'
|
|
21
|
+
) AS reactions_given,
|
|
22
|
+
(
|
|
23
|
+
SELECT COUNT(*)::int
|
|
24
|
+
FROM ${entries}
|
|
25
|
+
INNER JOIN ${posts} received_posts
|
|
26
|
+
ON received_posts.id::text = ${entries.toId}
|
|
27
|
+
WHERE received_posts.creator_id = ${profileId}
|
|
28
|
+
AND received_posts.deleted_at IS NULL
|
|
29
|
+
AND received_posts.visibility <> 'direct'
|
|
30
|
+
AND ${entries.body}->>'type' = 'reaction'
|
|
31
|
+
) AS reactions_received,
|
|
32
|
+
(
|
|
33
|
+
SELECT COUNT(*)::int FROM ${repost}
|
|
34
|
+
WHERE ${repost.fromId} = ${profileId}
|
|
35
|
+
) AS reposts_count,
|
|
36
|
+
(
|
|
37
|
+
SELECT COUNT(*)::int
|
|
38
|
+
FROM ${repost}
|
|
39
|
+
INNER JOIN ${posts} reposted_posts
|
|
40
|
+
ON reposted_posts.id::text = ${repost.toId}
|
|
41
|
+
WHERE reposted_posts.creator_id = ${profileId}
|
|
42
|
+
AND reposted_posts.deleted_at IS NULL
|
|
43
|
+
AND reposted_posts.visibility <> 'direct'
|
|
44
|
+
) AS reposts_received,
|
|
45
|
+
(
|
|
46
|
+
SELECT COUNT(*)::int
|
|
47
|
+
FROM ${replyTo}
|
|
48
|
+
INNER JOIN ${posts} reply_child_posts
|
|
49
|
+
ON reply_child_posts.id::text = ${replyTo.fromId}
|
|
50
|
+
INNER JOIN ${posts} parent_posts
|
|
51
|
+
ON parent_posts.id::text = ${replyTo.toId}
|
|
52
|
+
WHERE parent_posts.creator_id = ${profileId}
|
|
53
|
+
AND parent_posts.deleted_at IS NULL
|
|
54
|
+
AND parent_posts.visibility <> 'direct'
|
|
55
|
+
AND reply_child_posts.deleted_at IS NULL
|
|
56
|
+
) AS replies_received,
|
|
57
|
+
(
|
|
58
|
+
SELECT COUNT(*)::int FROM ${entries}
|
|
59
|
+
WHERE ${entries.fromId} = ${profileId}
|
|
60
|
+
AND ${entries.body}->>'type' = 'rsvp'
|
|
61
|
+
) AS rsvps_count,
|
|
62
|
+
(
|
|
63
|
+
SELECT COUNT(*)::int FROM ${bookmarks}
|
|
64
|
+
WHERE ${bookmarks.fromId} = ${profileId}
|
|
65
|
+
) AS bookmarks_count,
|
|
66
|
+
(
|
|
67
|
+
SELECT COUNT(*)::int FROM ${userGroups}
|
|
68
|
+
WHERE ${userGroups.fromId} = ${profileId}
|
|
69
|
+
) AS groups_count
|
|
70
|
+
FROM ${posts}
|
|
71
|
+
WHERE ${posts.creatorId} = ${profileId}
|
|
72
|
+
AND ${posts.deletedAt} IS NULL
|
|
73
|
+
AND ${posts.visibility} <> 'direct'
|
|
74
|
+
`;
|
|
75
|
+
export const profileTopPostScoresSql = (profileId) => sql `
|
|
76
|
+
SELECT ${posts.id}::text AS id, (${postActivityScoreExpr(posts)})::int AS activity_score
|
|
77
|
+
FROM ${posts}
|
|
78
|
+
WHERE ${posts.creatorId} = ${profileId}
|
|
79
|
+
AND ${posts.deletedAt} IS NULL
|
|
80
|
+
AND ${posts.visibility} <> 'direct'
|
|
81
|
+
AND NOT ${isReplySql}
|
|
82
|
+
ORDER BY activity_score DESC, ${posts.id} DESC
|
|
83
|
+
LIMIT ${TOP_POST_CANDIDATE_LIMIT}
|
|
84
|
+
`;
|
|
85
|
+
export const takeTopReadablePosts = (ordered, isReadable) => ordered.filter(isReadable).slice(0, TOP_POSTS_LIMIT);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AuthorizationData, ProfileActivitySummary, type AdminProfileSummary } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const getProfileActivitySummary: (authData: AuthorizationData, profileId: string) => Promise<ProfileActivitySummary>;
|
|
3
|
+
export declare const getAdminProfileSummary: (authData: AuthorizationData, profileId: string) => Promise<AdminProfileSummary>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { adminProfileSummarySchema, profileActivitySummarySchema, publicPostWithActivityScoreSchema, publicProfileSchema, } from '@openpeepshq/common/types';
|
|
2
|
+
import { allpeepDb } from '../db/index.js';
|
|
3
|
+
import { fetchRowsByIds, hydrateMapData } from '../db/pg/map/relations.js';
|
|
4
|
+
import { capabilitiesConfig } from '../config/index.js';
|
|
5
|
+
import { canReadPost, transformPost } from '../posts/helpers/index.js';
|
|
6
|
+
import { postsMappingForProfile } from '../posts/mapping.js';
|
|
7
|
+
import { listBlockedByIds } from './blocks.js';
|
|
8
|
+
import { findProfile } from './finders.js';
|
|
9
|
+
import { listReportsByReportedProfile } from '../reports/finders.js';
|
|
10
|
+
import { profileActivityCountsSql, profileTopPostScoresSql, takeTopReadablePosts, } from './activityQueries.js';
|
|
11
|
+
const sqlRows = (result) => { var _a; return (_a = result.rows) !== null && _a !== void 0 ? _a : []; };
|
|
12
|
+
const loadPostsByIds = async (db, ids, authData) => {
|
|
13
|
+
if (ids.length === 0)
|
|
14
|
+
return [];
|
|
15
|
+
const mapData = postsMappingForProfile(authData.profile).data();
|
|
16
|
+
const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
|
|
17
|
+
const hydrated = (await hydrateMapData(db, mapData, rows));
|
|
18
|
+
const byId = new Map(await Promise.all(hydrated.map(async (post) => {
|
|
19
|
+
const transformed = await transformPost(post, authData.profile);
|
|
20
|
+
return [transformed.id, transformed];
|
|
21
|
+
})));
|
|
22
|
+
return ids
|
|
23
|
+
.map((id) => byId.get(id))
|
|
24
|
+
.filter((post) => !!post);
|
|
25
|
+
};
|
|
26
|
+
export const getProfileActivitySummary = async (authData, profileId) => {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
28
|
+
const { db } = await allpeepDb();
|
|
29
|
+
const [countRow] = sqlRows(await db.execute(profileActivityCountsSql(profileId)));
|
|
30
|
+
const scored = sqlRows(await db.execute(profileTopPostScoresSql(profileId)))
|
|
31
|
+
.map((row) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return ({
|
|
34
|
+
id: String((_a = row.id) !== null && _a !== void 0 ? _a : ''),
|
|
35
|
+
activityScore: Number((_b = row.activity_score) !== null && _b !== void 0 ? _b : 0),
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.filter((row) => row.id);
|
|
39
|
+
const scoreById = new Map(scored.map((row) => [row.id, row.activityScore]));
|
|
40
|
+
const loaded = await loadPostsByIds(db, scored.map((row) => row.id), authData);
|
|
41
|
+
const config = await capabilitiesConfig();
|
|
42
|
+
const readable = canReadPost(config, authData);
|
|
43
|
+
const topPosts = takeTopReadablePosts(loaded, readable)
|
|
44
|
+
.map((post) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return publicPostWithActivityScoreSchema.safeParse(Object.assign(Object.assign({}, post), { activityScore: (_a = scoreById.get(post.id)) !== null && _a !== void 0 ? _a : 0 }));
|
|
47
|
+
})
|
|
48
|
+
.filter((result) => result.success)
|
|
49
|
+
.map((result) => result.data);
|
|
50
|
+
return profileActivitySummarySchema.parse({
|
|
51
|
+
postsCount: Number((_a = countRow === null || countRow === void 0 ? void 0 : countRow.posts_count) !== null && _a !== void 0 ? _a : 0),
|
|
52
|
+
repliesCount: Number((_b = countRow === null || countRow === void 0 ? void 0 : countRow.replies_count) !== null && _b !== void 0 ? _b : 0),
|
|
53
|
+
eventsCount: Number((_c = countRow === null || countRow === void 0 ? void 0 : countRow.events_count) !== null && _c !== void 0 ? _c : 0),
|
|
54
|
+
reactionsGiven: Number((_d = countRow === null || countRow === void 0 ? void 0 : countRow.reactions_given) !== null && _d !== void 0 ? _d : 0),
|
|
55
|
+
reactionsReceived: Number((_e = countRow === null || countRow === void 0 ? void 0 : countRow.reactions_received) !== null && _e !== void 0 ? _e : 0),
|
|
56
|
+
repostsCount: Number((_f = countRow === null || countRow === void 0 ? void 0 : countRow.reposts_count) !== null && _f !== void 0 ? _f : 0),
|
|
57
|
+
repostsReceived: Number((_g = countRow === null || countRow === void 0 ? void 0 : countRow.reposts_received) !== null && _g !== void 0 ? _g : 0),
|
|
58
|
+
repliesReceived: Number((_h = countRow === null || countRow === void 0 ? void 0 : countRow.replies_received) !== null && _h !== void 0 ? _h : 0),
|
|
59
|
+
rsvpsCount: Number((_j = countRow === null || countRow === void 0 ? void 0 : countRow.rsvps_count) !== null && _j !== void 0 ? _j : 0),
|
|
60
|
+
bookmarksCount: Number((_k = countRow === null || countRow === void 0 ? void 0 : countRow.bookmarks_count) !== null && _k !== void 0 ? _k : 0),
|
|
61
|
+
groupsCount: Number((_l = countRow === null || countRow === void 0 ? void 0 : countRow.groups_count) !== null && _l !== void 0 ? _l : 0),
|
|
62
|
+
topPosts,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export const getAdminProfileSummary = async (authData, profileId) => {
|
|
66
|
+
var _a, _b, _c, _d, _e, _f;
|
|
67
|
+
const profile = await findProfile(profileId);
|
|
68
|
+
if (!profile) {
|
|
69
|
+
throw new Error(`Profile with id ${profileId} not found`);
|
|
70
|
+
}
|
|
71
|
+
const activity = await getProfileActivitySummary(authData, profileId);
|
|
72
|
+
const { db } = await allpeepDb();
|
|
73
|
+
const [blockedByIds, reports] = await Promise.all([
|
|
74
|
+
listBlockedByIds(db, profileId),
|
|
75
|
+
listReportsByReportedProfile(profile),
|
|
76
|
+
]);
|
|
77
|
+
return adminProfileSummarySchema.parse({
|
|
78
|
+
profile: publicProfileSchema.parse(profile),
|
|
79
|
+
activity,
|
|
80
|
+
createdAt: profile.createdAt,
|
|
81
|
+
email: (_b = (_a = profile.controllers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.email,
|
|
82
|
+
followersCount: (_d = (_c = profile.profileStats) === null || _c === void 0 ? void 0 : _c.followersCount) !== null && _d !== void 0 ? _d : 0,
|
|
83
|
+
followingCount: (_f = (_e = profile.profileStats) === null || _e === void 0 ? void 0 : _e.followingCount) !== null && _f !== void 0 ? _f : 0,
|
|
84
|
+
reportsCount: reports.length,
|
|
85
|
+
blockedByCount: blockedByIds.length,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PgDb } from '../db/pg/client';
|
|
2
|
+
export declare const listBlockingIds: (db: PgDb, profileId: string) => Promise<string[]>;
|
|
3
|
+
export declare const listBlockedByIds: (db: PgDb, profileId: string) => Promise<string[]>;
|
|
4
|
+
export declare const loadBlockIds: (db: PgDb, profileId: string) => Promise<{
|
|
5
|
+
blockingIds: string[];
|
|
6
|
+
blockedByIds: string[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare const insertBlock: (db: PgDb, fromId: string, toId: string) => Promise<void>;
|
|
9
|
+
export declare const deleteBlock: (db: PgDb, fromId: string, toId: string) => Promise<void>;
|
|
10
|
+
export declare const dropFollowsBetween: (db: PgDb, a: string, b: string) => Promise<void>;
|
|
11
|
+
export declare const areBlocked: (db: PgDb, a: string, b: string) => Promise<boolean>;
|
|
12
|
+
export declare const hasBlockAmong: (db: PgDb, ids: string[]) => Promise<boolean>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { and, eq, inArray, or } from 'drizzle-orm';
|
|
2
|
+
import { uuidv7 } from 'uuidv7';
|
|
3
|
+
import { nowIso } from '../db/pg/mappers.js';
|
|
4
|
+
import { blocks, follows, requestsFollow } from '../db/pg/schema/edges.js';
|
|
5
|
+
export const listBlockingIds = async (db, profileId) => {
|
|
6
|
+
const rows = await db
|
|
7
|
+
.select({ toId: blocks.toId })
|
|
8
|
+
.from(blocks)
|
|
9
|
+
.where(eq(blocks.fromId, profileId));
|
|
10
|
+
return rows.map((row) => row.toId);
|
|
11
|
+
};
|
|
12
|
+
export const listBlockedByIds = async (db, profileId) => {
|
|
13
|
+
const rows = await db
|
|
14
|
+
.select({ fromId: blocks.fromId })
|
|
15
|
+
.from(blocks)
|
|
16
|
+
.where(eq(blocks.toId, profileId));
|
|
17
|
+
return rows.map((row) => row.fromId);
|
|
18
|
+
};
|
|
19
|
+
export const loadBlockIds = async (db, profileId) => {
|
|
20
|
+
const [blockingIds, blockedByIds] = await Promise.all([
|
|
21
|
+
listBlockingIds(db, profileId),
|
|
22
|
+
listBlockedByIds(db, profileId),
|
|
23
|
+
]);
|
|
24
|
+
return { blockingIds, blockedByIds };
|
|
25
|
+
};
|
|
26
|
+
export const insertBlock = async (db, fromId, toId) => {
|
|
27
|
+
const ts = nowIso();
|
|
28
|
+
await db
|
|
29
|
+
.insert(blocks)
|
|
30
|
+
.values({
|
|
31
|
+
id: uuidv7(),
|
|
32
|
+
fromId,
|
|
33
|
+
toId,
|
|
34
|
+
body: {},
|
|
35
|
+
createdAt: ts,
|
|
36
|
+
updatedAt: ts,
|
|
37
|
+
})
|
|
38
|
+
.onConflictDoNothing();
|
|
39
|
+
};
|
|
40
|
+
export const deleteBlock = async (db, fromId, toId) => {
|
|
41
|
+
await db
|
|
42
|
+
.delete(blocks)
|
|
43
|
+
.where(and(eq(blocks.fromId, fromId), eq(blocks.toId, toId)));
|
|
44
|
+
};
|
|
45
|
+
const eitherDirection = (a, b) => or(and(eq(follows.fromId, a), eq(follows.toId, b)), and(eq(follows.fromId, b), eq(follows.toId, a)));
|
|
46
|
+
const eitherFollowRequest = (a, b) => or(and(eq(requestsFollow.fromId, a), eq(requestsFollow.toId, b)), and(eq(requestsFollow.fromId, b), eq(requestsFollow.toId, a)));
|
|
47
|
+
export const dropFollowsBetween = async (db, a, b) => {
|
|
48
|
+
await Promise.all([
|
|
49
|
+
db.delete(follows).where(eitherDirection(a, b)),
|
|
50
|
+
db.delete(requestsFollow).where(eitherFollowRequest(a, b)),
|
|
51
|
+
]);
|
|
52
|
+
};
|
|
53
|
+
export const areBlocked = async (db, a, b) => {
|
|
54
|
+
if (!a || !b || a === b)
|
|
55
|
+
return false;
|
|
56
|
+
const rows = await db
|
|
57
|
+
.select({ id: blocks.id })
|
|
58
|
+
.from(blocks)
|
|
59
|
+
.where(or(and(eq(blocks.fromId, a), eq(blocks.toId, b)), and(eq(blocks.fromId, b), eq(blocks.toId, a))))
|
|
60
|
+
.limit(1);
|
|
61
|
+
return rows.length > 0;
|
|
62
|
+
};
|
|
63
|
+
export const hasBlockAmong = async (db, ids) => {
|
|
64
|
+
const unique = [...new Set(ids.filter(Boolean))];
|
|
65
|
+
if (unique.length < 2)
|
|
66
|
+
return false;
|
|
67
|
+
const rows = await db
|
|
68
|
+
.select({ id: blocks.id })
|
|
69
|
+
.from(blocks)
|
|
70
|
+
.where(and(inArray(blocks.fromId, unique), inArray(blocks.toId, unique)))
|
|
71
|
+
.limit(1);
|
|
72
|
+
return rows.length > 0;
|
|
73
|
+
};
|
package/dist/profiles/cache.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { ProfileWithMeta } from '@openpeepshq/common/types';
|
|
1
|
+
import { Profile, ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
2
|
export declare const profilesCache: import("cache-manager").Cache;
|
|
3
|
+
export declare const publicProfilesCache: import("cache-manager").Cache;
|
|
4
|
+
export declare const clearProfileCache: (profile: Pick<Profile, "id" | "handle">) => Promise<void>;
|
|
3
5
|
export declare const getProfile: (id: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
|
|
4
6
|
/** Lean profile for post/feed hydrate — no followers/following trees. */
|
|
5
7
|
export declare const getPublicProfile: (id: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
|
|
8
|
+
/** Local handle lookup only — federated paths must use uri or (handle, domain). */
|
|
6
9
|
export declare const getProfileByHandle: (handle: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
|
|
7
10
|
export declare const getProfiles: (ids: string[]) => Promise<ProfileWithMeta[]>;
|
package/dist/profiles/cache.js
CHANGED
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
import { createCache } from 'cache-manager';
|
|
2
2
|
import { allpeepDb } from '../db/index.js';
|
|
3
3
|
import { profilesMapping, publicProfilesMapping } from './mapping.js';
|
|
4
|
+
import { loadBlockIds } from './blocks.js';
|
|
4
5
|
export const profilesCache = createCache({
|
|
5
6
|
ttl: 60 * 60 * 1000,
|
|
6
7
|
refreshThreshold: 60 * 1000,
|
|
7
8
|
});
|
|
8
|
-
const publicProfilesCache = createCache({
|
|
9
|
+
export const publicProfilesCache = createCache({
|
|
9
10
|
ttl: 60 * 60 * 1000,
|
|
10
11
|
refreshThreshold: 60 * 1000,
|
|
11
12
|
});
|
|
13
|
+
export const clearProfileCache = async (profile) => {
|
|
14
|
+
await Promise.all([
|
|
15
|
+
profilesCache.del(profile.id),
|
|
16
|
+
profilesCache.del(profile.handle),
|
|
17
|
+
publicProfilesCache.del(profile.id),
|
|
18
|
+
publicProfilesCache.del(`all:${profile.id}`),
|
|
19
|
+
]);
|
|
20
|
+
};
|
|
12
21
|
const withEmptyFollowGraphs = (profile) => {
|
|
13
|
-
var _a, _b, _c, _d;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
23
|
return (Object.assign(Object.assign({}, profile), { roles: (_a = profile.roles) !== null && _a !== void 0 ? _a : [], followers: [], following: [], controllers: (_b = profile.controllers) !== null && _b !== void 0 ? _b : [], memberships: (_c = profile.memberships) !== null && _c !== void 0 ? _c : [], profileStats: (_d = profile.profileStats) !== null && _d !== void 0 ? _d : {
|
|
15
24
|
followersCount: 0,
|
|
16
25
|
followingCount: 0,
|
|
17
|
-
} }));
|
|
26
|
+
}, blockingIds: (_e = profile.blockingIds) !== null && _e !== void 0 ? _e : [], blockedByIds: (_f = profile.blockedByIds) !== null && _f !== void 0 ? _f : [] }));
|
|
27
|
+
};
|
|
28
|
+
const withBlockIds = async (profile) => {
|
|
29
|
+
if (!profile)
|
|
30
|
+
return undefined;
|
|
31
|
+
const { db } = await allpeepDb();
|
|
32
|
+
const { blockingIds, blockedByIds } = await loadBlockIds(db, profile.id);
|
|
33
|
+
return Object.assign(Object.assign({}, profile), { blockingIds, blockedByIds });
|
|
18
34
|
};
|
|
19
|
-
export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb()
|
|
35
|
+
export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb()
|
|
36
|
+
.then(({ db }) => ignoreSoftDelete
|
|
20
37
|
? profilesMapping.ignoreSoftDelete().find(db, id)
|
|
21
|
-
: profilesMapping.find(db, id))
|
|
38
|
+
: profilesMapping.find(db, id))
|
|
39
|
+
.then(withBlockIds));
|
|
22
40
|
/** Lean profile for post/feed hydrate — no followers/following trees. */
|
|
23
41
|
export const getPublicProfile = async (id, ignoreSoftDelete = false) => {
|
|
24
42
|
const profile = await publicProfilesCache.wrap(`${ignoreSoftDelete ? 'all:' : ''}${id}`, () => allpeepDb().then(({ db }) => ignoreSoftDelete
|
|
@@ -26,11 +44,14 @@ export const getPublicProfile = async (id, ignoreSoftDelete = false) => {
|
|
|
26
44
|
: publicProfilesMapping.find(db, id)));
|
|
27
45
|
return profile ? withEmptyFollowGraphs(profile) : undefined;
|
|
28
46
|
};
|
|
29
|
-
|
|
47
|
+
/** Local handle lookup only — federated paths must use uri or (handle, domain). */
|
|
48
|
+
export const getProfileByHandle = async (handle, ignoreSoftDelete = false) => profilesCache.wrap(handle, () => allpeepDb()
|
|
49
|
+
.then(({ db }) => ignoreSoftDelete
|
|
30
50
|
? profilesMapping
|
|
31
51
|
.ignoreSoftDelete()
|
|
32
52
|
.findOneBy(db, { matches: { handle } })
|
|
33
|
-
: profilesMapping.findOneBy(db, { matches: { handle } }))
|
|
53
|
+
: profilesMapping.findOneBy(db, { matches: { handle } }))
|
|
54
|
+
.then(withBlockIds));
|
|
34
55
|
export const getProfiles = async (ids) => profilesCache
|
|
35
56
|
.mget(ids)
|
|
36
57
|
.then((profiles) => Promise.all(profiles.map(async (p, index) => p || (await getProfile(ids[index])))))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Account, GroupMember, GroupWithMeta, Profile, ProfileWithMeta, Role } from '@openpeepshq/common/types';
|
|
2
2
|
export declare const findProfile: (profileId: string) => Promise<ProfileWithMeta | undefined>;
|
|
3
3
|
export declare const findProfileByHandle: (handle: string) => Promise<ProfileWithMeta | undefined>;
|
|
4
|
+
export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles';
|
|
4
5
|
export declare const existsProfileByHandle: (handle: string) => Promise<boolean>;
|
|
5
|
-
export declare const listProfiles: () => Promise<ProfileWithMeta[]>;
|
|
6
|
+
export declare const listProfiles: (viewer?: ProfileWithMeta) => Promise<ProfileWithMeta[]>;
|
|
6
7
|
export declare const listProfilesByRole: (role: Role) => Promise<ProfileWithMeta[]>;
|
|
7
8
|
export declare const listProfilesByAccount: (account: Account) => Promise<ProfileWithMeta[]>;
|
|
8
9
|
export declare const listProfilesWithCapabilities: (capabilities: string[]) => Promise<ProfileWithMeta[]>;
|
package/dist/profiles/finders.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { accountProfileRelation, baseProfilesMapping, membersRelation, profileRoleRelation, } from './mapping.js';
|
|
2
2
|
import { allpeepDb } from '../db/index.js';
|
|
3
3
|
import { profileFilters } from '../db/pg/filters/index.js';
|
|
4
|
+
import { blockedPairIds, getUniqueBy } from '@openpeepshq/common/lib';
|
|
4
5
|
import { rolesMapping } from '../roles/mapping.js';
|
|
5
6
|
import { findRolesByCapabilities } from '../roles/finders.js';
|
|
6
7
|
import { expandProfiles, followFinder } from './helpers.js';
|
|
@@ -10,9 +11,13 @@ import { listGroups } from '../groups/index.js';
|
|
|
10
11
|
import { getProfile, getProfileByHandle } from './cache.js';
|
|
11
12
|
export const findProfile = (profileId) => getProfile(profileId);
|
|
12
13
|
export const findProfileByHandle = (handle) => getProfileByHandle(handle);
|
|
14
|
+
export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles.js';
|
|
13
15
|
export const existsProfileByHandle = (handle) => getProfileByHandle(handle, true).then(Boolean);
|
|
14
|
-
export const listProfiles = () => allpeepDb()
|
|
15
|
-
.then(({ db }) => baseProfilesMapping
|
|
16
|
+
export const listProfiles = (viewer) => allpeepDb()
|
|
17
|
+
.then(({ db }) => baseProfilesMapping
|
|
18
|
+
.filter(profileFilters.notGuest())
|
|
19
|
+
.filter(profileFilters.notIdIn(blockedPairIds(viewer)))
|
|
20
|
+
.all(db))
|
|
16
21
|
.then(expandProfiles);
|
|
17
22
|
export const listProfilesByRole = (role) => allpeepDb()
|
|
18
23
|
.then(({ db }) => rolesMapping.relationsFrom(role, profileRoleRelation).all(db))
|
|
@@ -22,7 +27,7 @@ export const listProfilesByAccount = (account) => allpeepDb()
|
|
|
22
27
|
.then(expandProfiles);
|
|
23
28
|
export const listProfilesWithCapabilities = async (capabilities) => findRolesByCapabilities(capabilities)
|
|
24
29
|
.then((roles) => Promise.all(roles.map((role) => listProfilesByRole(role))))
|
|
25
|
-
.then((pp) => pp.flat());
|
|
30
|
+
.then((pp) => getUniqueBy(pp.flat(), (p) => p.id));
|
|
26
31
|
export const follows = (follower, followed) => allpeepDb().then(({ db }) => followFinder(db, follower, followed).then(Boolean));
|
|
27
32
|
export const listGroupMembers = (group) => allpeepDb()
|
|
28
33
|
.then(({ db }) => groupsMapping.relationsFrom(group, membersRelation).all(db))
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Profile, ProfileWithMeta, Role } from '@openpeepshq/common/types';
|
|
2
2
|
export declare const followConnector: (db: import("../db").PgDb, from: Profile, to: Profile, data?: {
|
|
3
|
+
uri?: string | undefined;
|
|
3
4
|
reblogs?: boolean | undefined;
|
|
4
5
|
notify?: boolean | undefined;
|
|
5
6
|
languages?: string[] | undefined;
|
|
6
7
|
} & {
|
|
7
8
|
id?: string;
|
|
8
9
|
}) => Promise<import("../db/pg/map").WithId<{
|
|
10
|
+
uri?: string | undefined;
|
|
9
11
|
reblogs?: boolean | undefined;
|
|
10
12
|
notify?: boolean | undefined;
|
|
11
13
|
languages?: string[] | undefined;
|
|
@@ -14,11 +16,11 @@ export declare const followConnector: (db: import("../db").PgDb, from: Profile,
|
|
|
14
16
|
_to: string;
|
|
15
17
|
}>>;
|
|
16
18
|
export declare const followDisconnector: (db: import("../db").PgDb, from: Profile, to: Profile) => Promise<void>;
|
|
17
|
-
export declare const followFinder: (db: import("../db").PgDb, from: Profile, to: Profile) => Promise<
|
|
19
|
+
export declare const followFinder: (db: import("../db").PgDb, from: Profile, to: Profile) => Promise<Record<string, unknown> | undefined>;
|
|
18
20
|
export declare const expandProfiles: (profiles: Profile[]) => Promise<ProfileWithMeta[]>;
|
|
19
|
-
export declare const roleAssigner: (db: import("../db").PgDb, from: Profile, to: Role, data?: {
|
|
21
|
+
export declare const roleAssigner: (db: import("../db").PgDb, from: Profile, to: Role, data?: object & {
|
|
20
22
|
id?: string;
|
|
21
|
-
}) => Promise<import("../db/pg/map").WithId<{
|
|
23
|
+
}) => Promise<import("../db/pg/map").WithId<object & {
|
|
22
24
|
_from: string;
|
|
23
25
|
_to: string;
|
|
24
26
|
}>>;
|
|
@@ -27,9 +29,9 @@ export declare const giveControl: (db: import("../db").PgDb, from: {
|
|
|
27
29
|
id: string;
|
|
28
30
|
}, to: {
|
|
29
31
|
id: string;
|
|
30
|
-
}, data?: {
|
|
32
|
+
}, data?: object & {
|
|
31
33
|
id?: string;
|
|
32
|
-
}) => Promise<import("../db/pg/map").WithId<{
|
|
34
|
+
}) => Promise<import("../db/pg/map").WithId<object & {
|
|
33
35
|
_from: string;
|
|
34
36
|
_to: string;
|
|
35
37
|
}>>;
|
package/dist/profiles/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ export * from './mapping';
|
|
|
2
2
|
export * from './mutations';
|
|
3
3
|
export * from './finders';
|
|
4
4
|
export * from './export';
|
|
5
|
-
export {
|
|
5
|
+
export { getProfileActivitySummary, getAdminProfileSummary, } from './activitySummary';
|
|
6
|
+
export { getProfile, getPublicProfile, getProfiles, clearProfileCache, } from './cache';
|
|
7
|
+
export { areBlocked, hasBlockAmong, loadBlockIds, listBlockingIds, } from './blocks';
|
|
6
8
|
export declare const findNewFreeHandle: (seed: string) => Promise<string>;
|
package/dist/profiles/index.js
CHANGED
|
@@ -3,7 +3,9 @@ export * from './mapping.js';
|
|
|
3
3
|
export * from './mutations.js';
|
|
4
4
|
export * from './finders.js';
|
|
5
5
|
export * from './export.js';
|
|
6
|
-
export {
|
|
6
|
+
export { getProfileActivitySummary, getAdminProfileSummary, } from './activitySummary.js';
|
|
7
|
+
export { getProfile, getPublicProfile, getProfiles, clearProfileCache, } from './cache.js';
|
|
8
|
+
export { areBlocked, hasBlockAmong, loadBlockIds, listBlockingIds, } from './blocks.js';
|
|
7
9
|
const sanitizeHandle = (name) => name.replace(/[^a-zA-Z0-9]/g, '-');
|
|
8
10
|
export const findNewFreeHandle = async (seed) => {
|
|
9
11
|
let counter = 2;
|
|
@@ -35,10 +35,11 @@ export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
35
35
|
guestData?: {
|
|
36
36
|
email?: string | undefined;
|
|
37
37
|
resource?: {
|
|
38
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
38
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
39
39
|
id?: string | undefined;
|
|
40
40
|
} | undefined;
|
|
41
41
|
} | undefined;
|
|
42
|
+
pinnedPostId?: string | undefined;
|
|
42
43
|
}, Profile, Profile>;
|
|
43
44
|
/** Lean mapping for public search results (memberships only). */
|
|
44
45
|
export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping<{
|
|
@@ -73,10 +74,11 @@ export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping
|
|
|
73
74
|
guestData?: {
|
|
74
75
|
email?: string | undefined;
|
|
75
76
|
resource?: {
|
|
76
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
77
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
77
78
|
id?: string | undefined;
|
|
78
79
|
} | undefined;
|
|
79
80
|
} | undefined;
|
|
81
|
+
pinnedPostId?: string | undefined;
|
|
80
82
|
}, ProfileWithMeta, ProfileWithMeta>;
|
|
81
83
|
/**
|
|
82
84
|
* Lean public profile for feed/API hydrate — memberships + SQL follower
|
|
@@ -114,10 +116,11 @@ export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
114
116
|
guestData?: {
|
|
115
117
|
email?: string | undefined;
|
|
116
118
|
resource?: {
|
|
117
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
119
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
118
120
|
id?: string | undefined;
|
|
119
121
|
} | undefined;
|
|
120
122
|
} | undefined;
|
|
123
|
+
pinnedPostId?: string | undefined;
|
|
121
124
|
}, ProfileWithMeta, ProfileWithMeta>;
|
|
122
125
|
export declare const profilesMapping: import("../db/pg/map").Mapping<{
|
|
123
126
|
handle: string;
|
|
@@ -151,10 +154,11 @@ export declare const profilesMapping: import("../db/pg/map").Mapping<{
|
|
|
151
154
|
guestData?: {
|
|
152
155
|
email?: string | undefined;
|
|
153
156
|
resource?: {
|
|
154
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
157
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
155
158
|
id?: string | undefined;
|
|
156
159
|
} | undefined;
|
|
157
160
|
} | undefined;
|
|
161
|
+
pinnedPostId?: string | undefined;
|
|
158
162
|
}, ProfileWithMeta, ProfileWithMeta>;
|
|
159
163
|
export declare const membersExportMapping: import("../db/pg/map").Mapping<{
|
|
160
164
|
handle: string;
|
|
@@ -188,10 +192,11 @@ export declare const membersExportMapping: import("../db/pg/map").Mapping<{
|
|
|
188
192
|
guestData?: {
|
|
189
193
|
email?: string | undefined;
|
|
190
194
|
resource?: {
|
|
191
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
195
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
192
196
|
id?: string | undefined;
|
|
193
197
|
} | undefined;
|
|
194
198
|
} | undefined;
|
|
199
|
+
pinnedPostId?: string | undefined;
|
|
195
200
|
}, Profile, Profile>;
|
|
196
201
|
export declare const membersRelation: RelationWithMapping<ProfileWithMeta, GroupMember>;
|
|
197
202
|
export declare const profileRoleRelation: RelationWithMapping<Profile>;
|
package/dist/profiles/mapping.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { map } from '../db/pg/map/index.js';
|
|
2
2
|
import { groupsMapping } from '../groups/mapping.js';
|
|
3
3
|
import { profileDerived } from '../db/pg/queries/index.js';
|
|
4
|
+
import { edgeFilters } from '../db/pg/filters/index.js';
|
|
4
5
|
const membersExportStatsRelations = [
|
|
5
6
|
{
|
|
6
7
|
alias: 'reactionsCount',
|
|
7
|
-
edgeCollection: '
|
|
8
|
+
edgeCollection: 'entries',
|
|
8
9
|
direction: 'OUTBOUND',
|
|
9
10
|
count: true,
|
|
10
11
|
cardinality: 'one',
|
|
12
|
+
edgeFilter: edgeFilters.entryType('reaction'),
|
|
11
13
|
},
|
|
12
14
|
];
|
|
13
15
|
export const profileAccountRelation = {
|
|
@@ -65,6 +67,16 @@ export const profileRelations = [
|
|
|
65
67
|
relations: baseProfileRelations,
|
|
66
68
|
},
|
|
67
69
|
},
|
|
70
|
+
{
|
|
71
|
+
alias: 'followedHashtags',
|
|
72
|
+
edgeCollection: 'profileHashtags',
|
|
73
|
+
direction: 'OUTBOUND',
|
|
74
|
+
skipEdge: true,
|
|
75
|
+
cardinality: 'many',
|
|
76
|
+
mapping: {
|
|
77
|
+
collection: 'hashtags',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
68
80
|
];
|
|
69
81
|
export const baseProfilesMapping = map({
|
|
70
82
|
collection: 'profiles',
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { Account, FollowData, GuestPassRequest, Profile, ProfileData, Role } from '@openpeepshq/common/types';
|
|
2
|
-
export declare const createProfile: (data: ProfileData, controllingAccount?: Account) => Promise<
|
|
3
|
-
export declare const createGuestProfile: (guestPassRequest: GuestPassRequest) => Promise<
|
|
4
|
-
export declare const updateProfile: (profileId: string, data: Partial<ProfileData>) => Promise<
|
|
1
|
+
import { Account, FollowData, GuestPassRequest, Profile, ProfileData, ProfileWithMeta, Role } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const createProfile: (data: ProfileData, controllingAccount?: Account) => Promise<ProfileWithMeta>;
|
|
3
|
+
export declare const createGuestProfile: (guestPassRequest: GuestPassRequest) => Promise<ProfileWithMeta>;
|
|
4
|
+
export declare const updateProfile: (profileId: string, data: Partial<ProfileData>) => Promise<ProfileWithMeta>;
|
|
5
|
+
export declare const pinPostOnProfile: (profile: Pick<Profile, "id" | "handle">, pinnedPostId: string) => Promise<ProfileWithMeta>;
|
|
5
6
|
export declare const deleteProfile: (profileId: string) => Promise<void>;
|
|
6
7
|
export declare const follow: (follower: Profile, followed: Profile, followData: FollowData) => Promise<void>;
|
|
7
8
|
export declare const unfollow: (follower: Profile, followed: Profile) => Promise<void>;
|
|
9
|
+
export declare const blockProfile: (blocker: Profile, blocked: Profile) => Promise<void>;
|
|
10
|
+
export declare const unblockProfile: (blocker: Profile, blocked: Profile) => Promise<void>;
|
|
11
|
+
export declare const listBlockedProfiles: (profile: Profile) => Promise<ProfileWithMeta[]>;
|
|
8
12
|
export declare const assignRole: (profile: Profile, role: Role) => Promise<boolean>;
|
|
9
13
|
export declare const unassignRole: (profile: Profile, role: Role) => Promise<boolean>;
|