@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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readdir, stat, statfs } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export const processStartedAt = new Date(Date.now() - process.uptime() * 1000).toISOString();
|
|
5
|
+
const FOLDER_SIZE_CACHE_MS = 30000;
|
|
6
|
+
let folderSizeCache = null;
|
|
7
|
+
/** Sum of regular files under dir. Skips unreadable entries. */
|
|
8
|
+
export const folderSize = async (dir) => {
|
|
9
|
+
let total = 0;
|
|
10
|
+
let entries;
|
|
11
|
+
try {
|
|
12
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const full = path.join(dir, entry.name);
|
|
19
|
+
try {
|
|
20
|
+
if (entry.isSymbolicLink())
|
|
21
|
+
continue;
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
total += await folderSize(full);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (entry.isFile()) {
|
|
27
|
+
total += (await stat(full)).size;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (_b) {
|
|
31
|
+
// Skip entries we cannot stat (permissions, races).
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return total;
|
|
35
|
+
};
|
|
36
|
+
const cachedFolderSize = async (mediaPath) => {
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
if (folderSizeCache &&
|
|
39
|
+
folderSizeCache.mediaPath === mediaPath &&
|
|
40
|
+
now - folderSizeCache.at < FOLDER_SIZE_CACHE_MS) {
|
|
41
|
+
return folderSizeCache.bytes;
|
|
42
|
+
}
|
|
43
|
+
const bytes = await folderSize(mediaPath);
|
|
44
|
+
folderSizeCache = { mediaPath, at: now, bytes };
|
|
45
|
+
return bytes;
|
|
46
|
+
};
|
|
47
|
+
/** Media-folder byte size plus free space on that volume. Null if unreadable. */
|
|
48
|
+
export const diskUsage = async (mediaPath) => {
|
|
49
|
+
try {
|
|
50
|
+
const stats = await statfs(mediaPath);
|
|
51
|
+
const blockSize = Number(stats.bsize);
|
|
52
|
+
const totalBytes = Number(stats.blocks) * blockSize;
|
|
53
|
+
const freeBytes = Number(stats.bavail) * blockSize;
|
|
54
|
+
if (!Number.isFinite(totalBytes) || totalBytes <= 0)
|
|
55
|
+
return null;
|
|
56
|
+
const folderBytes = await cachedFolderSize(mediaPath);
|
|
57
|
+
return { folderBytes, totalBytes, freeBytes };
|
|
58
|
+
}
|
|
59
|
+
catch (_a) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export const cpuTimes = (cpus = os.cpus()) => {
|
|
64
|
+
let idle = 0;
|
|
65
|
+
let total = 0;
|
|
66
|
+
for (const cpu of cpus) {
|
|
67
|
+
const times = cpu.times;
|
|
68
|
+
idle += times.idle;
|
|
69
|
+
total += times.user + times.nice + times.sys + times.idle + times.irq;
|
|
70
|
+
}
|
|
71
|
+
return { idle, total };
|
|
72
|
+
};
|
|
73
|
+
export const cpuUsedPercent = (previous, next) => {
|
|
74
|
+
const idleDelta = next.idle - previous.idle;
|
|
75
|
+
const totalDelta = next.total - previous.total;
|
|
76
|
+
if (totalDelta <= 0)
|
|
77
|
+
return 0;
|
|
78
|
+
return Math.min(100, Math.max(0, (1 - idleDelta / totalDelta) * 100));
|
|
79
|
+
};
|
|
80
|
+
export const memoryUsage = (totalBytes = os.totalmem(), freeBytes = os.freemem()) => {
|
|
81
|
+
if (!Number.isFinite(totalBytes) || totalBytes <= 0)
|
|
82
|
+
return null;
|
|
83
|
+
const usedBytes = Math.max(0, Math.min(totalBytes, totalBytes - Math.max(0, freeBytes)));
|
|
84
|
+
return { usedBytes, totalBytes };
|
|
85
|
+
};
|
|
86
|
+
const CPU_SAMPLE_MS = 50;
|
|
87
|
+
export const hostResources = async (wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const memory = memoryUsage();
|
|
90
|
+
const previous = cpuTimes();
|
|
91
|
+
await wait(CPU_SAMPLE_MS);
|
|
92
|
+
const cpuPercent = Math.round(cpuUsedPercent(previous, cpuTimes()) * 10) / 10;
|
|
93
|
+
return {
|
|
94
|
+
memoryUsedBytes: (_a = memory === null || memory === void 0 ? void 0 : memory.usedBytes) !== null && _a !== void 0 ? _a : 0,
|
|
95
|
+
memoryTotalBytes: (_b = memory === null || memory === void 0 ? void 0 : memory.totalBytes) !== null && _b !== void 0 ? _b : 0,
|
|
96
|
+
cpuUsedPercent: cpuPercent,
|
|
97
|
+
};
|
|
98
|
+
};
|