@openpeepshq/core 0.1.33 → 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/accounts/mutations.js +33 -35
- package/dist/analytics/compile.js +16 -10
- package/dist/analytics/read.js +52 -9
- package/dist/analytics/report.d.ts +20 -0
- package/dist/backups/index.js +75 -15
- package/dist/backups/metadata.d.ts +2 -3
- package/dist/backups/metadata.js +6 -2
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +7 -3
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +3 -0
- package/dist/config/index.d.ts +21 -0
- package/dist/config/index.js +7 -1
- package/dist/db/helpers.d.ts +1 -0
- package/dist/db/helpers.js +11 -3
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -0
- package/dist/db/init.js +2 -3
- package/dist/db/migration/importCollections.d.ts +14 -9
- package/dist/db/migration/importCollections.js +114 -164
- package/dist/db/migration/shared.d.ts +2 -33
- package/dist/db/migration/shared.js +2 -52
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/posts.d.ts +10 -0
- package/dist/db/pg/filters/posts.js +28 -4
- 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 +32 -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.js +9 -5
- package/dist/db/pg/migrate.d.ts +1 -2
- package/dist/db/pg/migrate.js +6 -6
- 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 +279 -41
- package/dist/db/pg/schema/documents.js +21 -8
- package/dist/db/pg/schema/edges.d.ts +116 -7
- package/dist/db/pg/schema/edges.js +2 -1
- package/dist/db/pg/schema/index.d.ts +362 -15
- 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/{0009_snapshot.json → 0015_snapshot.json} +291 -36
- package/dist/db/pg/sql/meta/_journal.json +43 -1
- package/dist/email/render.js +11 -3
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +1 -0
- 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 +2 -1
- package/dist/groups/helpers.d.ts +18 -0
- package/dist/groups/mapping.d.ts +4 -2
- 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/jams/export.d.ts +19 -0
- package/dist/jams/export.js +60 -0
- package/dist/jams/health.d.ts +8 -0
- package/dist/jams/health.js +46 -0
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/index.d.ts +2 -0
- package/dist/jams/index.js +23 -16
- package/dist/jams/jobs.js +1 -1
- package/dist/jams/livekit.d.ts +49 -4
- package/dist/jams/livekit.js +56 -39
- package/dist/jams/mapping.d.ts +3 -3
- package/dist/jams/mutations.d.ts +1 -1
- package/dist/jams/recording.d.ts +10 -0
- package/dist/jams/recording.js +32 -0
- package/dist/jams/token.d.ts +13 -1
- package/dist/jams/token.js +18 -7
- package/dist/jams/waitingRoom.js +1 -1
- 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/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/jobs.js +3 -1
- package/dist/notifications/mutations.js +4 -0
- package/dist/plugins/index.js +37 -1
- package/dist/plugins/install.d.ts +28 -9
- package/dist/plugins/install.js +281 -49
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +10 -6
- 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 +1 -0
- package/dist/posts/eventAgenda.js +10 -4
- package/dist/posts/eventOccurrenceJobs.js +7 -2
- package/dist/posts/eventOccurrences.d.ts +6 -0
- package/dist/posts/eventOccurrences.js +21 -0
- package/dist/posts/finders.d.ts +15 -8
- package/dist/posts/finders.js +67 -18
- package/dist/posts/helpers/filters.js +13 -8
- package/dist/posts/helpers/index.d.ts +27 -14
- package/dist/posts/helpers/index.js +34 -14
- package/dist/posts/index.d.ts +5 -2
- package/dist/posts/index.js +5 -2
- package/dist/posts/mapping.d.ts +216 -13
- package/dist/posts/mapping.js +14 -13
- package/dist/posts/mutations.d.ts +440 -3
- package/dist/posts/mutations.js +155 -32
- 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 -16
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.js +4 -1
- 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 +1 -0
- package/dist/profiles/cache.js +19 -6
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +8 -3
- package/dist/profiles/helpers.d.ts +2 -0
- package/dist/profiles/index.d.ts +2 -0
- package/dist/profiles/index.js +2 -0
- 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 +31 -2
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -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 +18 -0
- package/dist/server/index.js +24 -12
- 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 -17681
- package/dist/stats/finders.js +9 -5
- package/dist/stats/mapping.d.ts +0 -1
- package/dist/stats/mapping.js +0 -3
- package/package.json +4 -5
- package/dist/db/migration/detect.d.ts +0 -3
- package/dist/db/migration/detect.js +0 -33
- 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 -20
- package/dist/db/migration/transform.js +0 -232
- 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/db/pg/sql/meta/0006_snapshot.json +0 -4200
- package/dist/db/pg/sql/meta/0007_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/migration/index.d.ts +0 -4
- package/dist/migration/index.js +0 -4
- package/dist/roles/defaults.d.ts +0 -2
- package/dist/roles/defaults.js +0 -95
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { collectVotes } from '@openpeepshq/common/lib';
|
|
2
|
+
const addProfile = (byId, profile) => {
|
|
3
|
+
if (profile === null || profile === void 0 ? void 0 : profile.id) {
|
|
4
|
+
byId.set(profile.id, profile);
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
/** Poll author, voters, and parent post author when the poll is a reply. */
|
|
8
|
+
export const pollEndedRecipientProfiles = (post) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const byId = new Map();
|
|
11
|
+
addProfile(byId, post.profile);
|
|
12
|
+
addProfile(byId, (_a = post.replyTo) === null || _a === void 0 ? void 0 : _a.profile);
|
|
13
|
+
const { votes } = collectVotes(post);
|
|
14
|
+
for (const vote of votes) {
|
|
15
|
+
addProfile(byId, vote.profile);
|
|
16
|
+
}
|
|
17
|
+
return [...byId.values()];
|
|
18
|
+
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExpandedNotification } from '@openpeepshq/common/types';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
type: string;
|
|
4
4
|
event: string;
|
|
5
|
+
defaultSettings: {
|
|
6
|
+
readonly create: true;
|
|
7
|
+
readonly push: true;
|
|
8
|
+
readonly email: true;
|
|
9
|
+
};
|
|
5
10
|
eventHandler: (senderProfile: unknown, post: unknown, data: unknown) => Promise<void>;
|
|
6
11
|
pushRenderer: (notification: ExpandedNotification) => Promise<{
|
|
7
12
|
title: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notificationAll, } from '@openpeepshq/common/types';
|
|
1
2
|
import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
2
3
|
import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
|
|
3
4
|
import { communityConfig } from '../../../config/index.js';
|
|
@@ -9,6 +10,11 @@ const eventHandler = async (senderProfile, post, data) => {
|
|
|
9
10
|
if (entryData.type !== 'rsvp') {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
13
|
+
// Cancellations use rsvpCanceled. A plain "no" or organizer removal is not an RSVP.
|
|
14
|
+
const response = entryData.data.response;
|
|
15
|
+
if (response !== 'yes' && response !== 'tentative') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
12
18
|
await maybeCreateNotification(mergedPost.profile, {
|
|
13
19
|
type: 'rsvp',
|
|
14
20
|
postId: mergedPost.id,
|
|
@@ -35,6 +41,7 @@ const pushRenderer = async (notification) => {
|
|
|
35
41
|
export default {
|
|
36
42
|
type: 'rsvp',
|
|
37
43
|
event: 'rsvpCreated',
|
|
44
|
+
defaultSettings: notificationAll,
|
|
38
45
|
eventHandler,
|
|
39
46
|
pushRenderer,
|
|
40
47
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ExpandedNotification } from '@openpeepshq/common/types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
type: string;
|
|
4
|
+
event: string;
|
|
5
|
+
defaultSettings: {
|
|
6
|
+
readonly create: true;
|
|
7
|
+
readonly push: true;
|
|
8
|
+
readonly email: true;
|
|
9
|
+
};
|
|
10
|
+
eventHandler: (senderProfile: unknown, post: unknown, data: unknown) => Promise<void>;
|
|
11
|
+
pushRenderer: (notification: ExpandedNotification) => Promise<{
|
|
12
|
+
title: string;
|
|
13
|
+
options: {
|
|
14
|
+
body: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
actions: {
|
|
17
|
+
action: string;
|
|
18
|
+
title: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
invalidateQueries: string[][];
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { notificationAll, } from '@openpeepshq/common/types';
|
|
2
|
+
import { getProfileAvatar, isRsvpCancelNotice, profileName, rsvpCancelWhenLabels, } from '@openpeepshq/common/lib';
|
|
3
|
+
import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
4
|
+
import { findProfile, listGroupMembers } from '@openpeepshq/core/profiles';
|
|
5
|
+
import { communityConfig } from '../../../config/index.js';
|
|
6
|
+
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
|
+
import { rsvpCancelRecipients } from './recipients.js';
|
|
8
|
+
const eventName = (post) => { var _a, _b; return ((_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? (_b = post.data.name) === null || _b === void 0 ? void 0 : _b.trim() : undefined; };
|
|
9
|
+
const whenText = (post, notice) => {
|
|
10
|
+
if (!post)
|
|
11
|
+
return '';
|
|
12
|
+
const when = rsvpCancelWhenLabels(post, notice);
|
|
13
|
+
if (when.series)
|
|
14
|
+
return 'All dates in the series';
|
|
15
|
+
return when.labels.join(', ');
|
|
16
|
+
};
|
|
17
|
+
const eventHandler = async (senderProfile, post, data) => {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
const mergedPost = post;
|
|
20
|
+
const fromProfile = senderProfile;
|
|
21
|
+
const cancel = data === null || data === void 0 ? void 0 : data.cancel;
|
|
22
|
+
if (!isRsvpCancelNotice(cancel))
|
|
23
|
+
return;
|
|
24
|
+
if (mergedPost.type !== 'event' || ((_a = mergedPost.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const event = mergedPost.data;
|
|
28
|
+
const moderatorIds = [
|
|
29
|
+
...((_b = event.moderators) !== null && _b !== void 0 ? _b : []),
|
|
30
|
+
...((_d = (_c = event.jam) === null || _c === void 0 ? void 0 : _c.moderators) !== null && _d !== void 0 ? _d : []),
|
|
31
|
+
];
|
|
32
|
+
const moderators = (await Promise.all(moderatorIds.map((id) => findProfile(id)))).filter((profile) => !!profile);
|
|
33
|
+
const groupAdmins = mergedPost.group
|
|
34
|
+
? (await listGroupMembers(mergedPost.group))
|
|
35
|
+
.filter((member) => { var _a, _b; return ((_a = member.roles) === null || _a === void 0 ? void 0 : _a.includes('owner')) || ((_b = member.roles) === null || _b === void 0 ? void 0 : _b.includes('admin')); })
|
|
36
|
+
.map((member) => member.profile)
|
|
37
|
+
: [];
|
|
38
|
+
const recipients = rsvpCancelRecipients([mergedPost.profile, ...moderators, ...groupAdmins], fromProfile.id);
|
|
39
|
+
for (const recipient of recipients) {
|
|
40
|
+
await maybeCreateNotification(recipient, Object.assign(Object.assign({ type: 'rsvpCanceled', postId: mergedPost.id, fromProfileId: fromProfile.id }, (mergedPost.groupId ? { groupId: mergedPost.groupId } : {})), { data: cancel }));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const pushRenderer = async (notification) => {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
const notice = isRsvpCancelNotice(notification.data)
|
|
46
|
+
? notification.data
|
|
47
|
+
: { occurrenceIds: [], series: false };
|
|
48
|
+
const name = eventName((_a = notification.post) !== null && _a !== void 0 ? _a : undefined);
|
|
49
|
+
const when = whenText((_b = notification.post) !== null && _b !== void 0 ? _b : undefined, notice);
|
|
50
|
+
return {
|
|
51
|
+
title: `${profileName(notification.senderProfile)} canceled their RSVP`,
|
|
52
|
+
options: {
|
|
53
|
+
body: [name, when].filter(Boolean).join(' · '),
|
|
54
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
55
|
+
actions: [
|
|
56
|
+
{
|
|
57
|
+
action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
|
|
58
|
+
title: 'View event',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
invalidateQueries: [
|
|
63
|
+
PUSH_INVALIDATE.posts,
|
|
64
|
+
PUSH_INVALIDATE.notifications,
|
|
65
|
+
PUSH_INVALIDATE.notificationStats,
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export default {
|
|
70
|
+
type: 'rsvpCanceled',
|
|
71
|
+
event: 'rsvpCreated',
|
|
72
|
+
defaultSettings: notificationAll,
|
|
73
|
+
eventHandler,
|
|
74
|
+
pushRenderer,
|
|
75
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** One notification per person. The member who canceled is not notified. */
|
|
2
|
+
export const rsvpCancelRecipients = (profiles, actorId) => {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
return profiles.filter((profile) => {
|
|
5
|
+
if (!profile.id || profile.id === actorId || seen.has(profile.id)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
seen.add(profile.id);
|
|
9
|
+
return true;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
@@ -42,7 +42,9 @@ const [notificationQueue, notificationWorker] = queueAndWorker('process-notifica
|
|
|
42
42
|
await mailer.send({
|
|
43
43
|
template: `notification-${notification.type}`,
|
|
44
44
|
to: account.email,
|
|
45
|
-
locals: notification,
|
|
45
|
+
locals: Object.assign(Object.assign({}, notification), (profileSettings.timeZone
|
|
46
|
+
? { timeZone: profileSettings.timeZone }
|
|
47
|
+
: {})),
|
|
46
48
|
});
|
|
47
49
|
await logStep(jobLog, log, `Queued email notification to ${account.email}`);
|
|
48
50
|
}
|
|
@@ -4,6 +4,7 @@ import { notificationFilters } from '../db/pg/filters/index.js';
|
|
|
4
4
|
import { baseListNotifications, expandNotification, notificationSettings, } from './helpers.js';
|
|
5
5
|
import { hub } from '../events/index.js';
|
|
6
6
|
import { findProfile } from '../profiles/index.js';
|
|
7
|
+
import { isBlockedPair } from '@openpeepshq/common/lib';
|
|
7
8
|
import { logger } from '../log/index.js';
|
|
8
9
|
import { findProfileSettings } from '../profileSettings/index.js';
|
|
9
10
|
const log = logger('openpeeps:notifications');
|
|
@@ -25,6 +26,9 @@ export const maybeCreateNotification = async (profile, data) => {
|
|
|
25
26
|
log.error(`Profile ${profile.id} not found`);
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
29
|
+
if (data.fromProfileId && isBlockedPair(fullProfile, data.fromProfileId)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
const profileSettings = await findProfileSettings(profile.id);
|
|
29
33
|
if (!profileSettings) {
|
|
30
34
|
log.error(`profileSettings ${profile.id} not found`);
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { hub, VALID_EVENT_KEYS } from '../events/index.js';
|
|
2
2
|
import { defaultConfig, registerConfigSchema } from '../config/index.js';
|
|
3
|
-
import { pluginManifestSchema } from '@openpeepshq/common';
|
|
3
|
+
import { i18nResourceSchema, pluginManifestSchema } from '@openpeepshq/common';
|
|
4
|
+
import path from 'node:path';
|
|
4
5
|
import { enumeratePluginInfos, enumerateReferencedPluginInfos, isPluginEnabled, sortByDependencies, } from './helpers.js';
|
|
5
6
|
import { getPluginStateOverrides } from './state.js';
|
|
7
|
+
import { selfHealInstalledPlugins } from './install.js';
|
|
6
8
|
import { logger } from '../log/index.js';
|
|
9
|
+
import { clearPluginLocales, registerPluginLocales } from '../i18n/index.js';
|
|
7
10
|
export * from './pluginAuth.js';
|
|
8
11
|
export * from './state.js';
|
|
9
12
|
export * from './install.js';
|
|
@@ -26,6 +29,7 @@ const clearPluginState = () => {
|
|
|
26
29
|
loadedModules.clear();
|
|
27
30
|
pluginManifests.clear();
|
|
28
31
|
pluginUnsubscribers.clear();
|
|
32
|
+
clearPluginLocales();
|
|
29
33
|
initialized = false;
|
|
30
34
|
};
|
|
31
35
|
export const initializePlugins = async () => {
|
|
@@ -34,6 +38,17 @@ export const initializePlugins = async () => {
|
|
|
34
38
|
}
|
|
35
39
|
const { plugins: { path: pluginsPath, rootPackageJsonPath }, } = await defaultConfig;
|
|
36
40
|
const stateOverrides = await getPluginStateOverrides();
|
|
41
|
+
// Re-fetch admin-installed plugins whose files are missing (e.g. the
|
|
42
|
+
// plugins path is not a persistent volume and the container was recreated).
|
|
43
|
+
// Never let a failed heal take the boot down — the plugin is surfaced as a
|
|
44
|
+
// failed entry below so an admin can see why and re-install it.
|
|
45
|
+
let healFailures = {};
|
|
46
|
+
try {
|
|
47
|
+
healFailures = await selfHealInstalledPlugins();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
log.error(e, 'Plugin self-heal failed; continuing without it.');
|
|
51
|
+
}
|
|
37
52
|
const loadPlugin = async (key, info, pluginPath) => {
|
|
38
53
|
var _a, _b;
|
|
39
54
|
const [namespace, name] = key.split('/');
|
|
@@ -89,6 +104,15 @@ export const initializePlugins = async () => {
|
|
|
89
104
|
if ('manifest' in pluginModule) {
|
|
90
105
|
pluginManifests.set(key, pluginManifestSchema.parse(pluginModule.manifest));
|
|
91
106
|
}
|
|
107
|
+
if ('locales' in pluginModule) {
|
|
108
|
+
const parsed = i18nResourceSchema.safeParse(pluginModule.locales);
|
|
109
|
+
if (parsed.success) {
|
|
110
|
+
registerPluginLocales(key, parsed.data);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
log.warn(`${plugin.key} locales export is invalid. Skipping translations.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
92
116
|
plugin.status = 'loaded';
|
|
93
117
|
}
|
|
94
118
|
catch (e) {
|
|
@@ -106,6 +130,18 @@ export const initializePlugins = async () => {
|
|
|
106
130
|
for (const [key, info, pluginPath] of sortedInfos) {
|
|
107
131
|
await loadPlugin(key, info, pluginPath);
|
|
108
132
|
}
|
|
133
|
+
for (const [key, reason] of Object.entries(healFailures)) {
|
|
134
|
+
const [namespace, name] = key.split('/');
|
|
135
|
+
loadedPlugins.set(key, {
|
|
136
|
+
key,
|
|
137
|
+
namespace,
|
|
138
|
+
name,
|
|
139
|
+
info: { name: key },
|
|
140
|
+
path: path.join(pluginsPath, key),
|
|
141
|
+
status: 'failed',
|
|
142
|
+
error: reason,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
109
145
|
initialized = true;
|
|
110
146
|
return Object.fromEntries(loadedPlugins.entries());
|
|
111
147
|
};
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { PluginInstallSource } from '@openpeepshq/common/types';
|
|
2
|
+
type InstalledPluginRecord = {
|
|
3
|
+
/** Redacted source label (npm:pkg@ver or git:url#ref); never the credentials. */
|
|
4
|
+
source: string;
|
|
5
|
+
/** True when the install required credentials that are not stored. */
|
|
6
|
+
requiresAuth: boolean;
|
|
7
|
+
installedAt: string;
|
|
8
|
+
installedBy?: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type InstalledPluginsBody = Record<string, InstalledPluginRecord>;
|
|
11
|
+
export declare const getInstalledPlugins: () => Promise<InstalledPluginsBody>;
|
|
12
|
+
export declare const linkHostPeerDependencies: (installDir: string, names: string[]) => Promise<{
|
|
13
|
+
success: true;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const installPlugin: (source: PluginInstallSource, installedBy?: string, options?: {
|
|
19
|
+
selfHeal?: boolean;
|
|
20
|
+
}) => Promise<{
|
|
11
21
|
success: boolean;
|
|
12
22
|
pluginKey?: string;
|
|
13
23
|
error?: string;
|
|
@@ -16,5 +26,14 @@ export declare const uninstallPlugin: (pluginKey: string, uninstalledBy?: string
|
|
|
16
26
|
success: boolean;
|
|
17
27
|
error?: string;
|
|
18
28
|
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Re-downloads admin-installed plugins whose files are missing from the
|
|
31
|
+
* plugins directory (e.g. after a container recreate whose plugins path was
|
|
32
|
+
* not a persistent volume). Credentials are not stored, so plugins installed
|
|
33
|
+
* from private sources cannot be re-fetched — they are reported for manual
|
|
34
|
+
* re-install instead. Returns pluginKey -> reason for every plugin that is
|
|
35
|
+
* still unavailable after the attempt.
|
|
36
|
+
*/
|
|
37
|
+
export declare const selfHealInstalledPlugins: () => Promise<Record<string, string>>;
|
|
19
38
|
export declare const getInstalledPluginKeys: () => Promise<string[]>;
|
|
20
39
|
export {};
|