@openpeepshq/core 0.1.31 → 0.1.33
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/analytics/cache.js +12 -7
- package/dist/analytics/clicks.d.ts +20 -0
- package/dist/analytics/clicks.js +194 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +1 -0
- package/dist/analytics/metrics.d.ts +1 -0
- package/dist/analytics/metrics.js +5 -0
- package/dist/analytics/pdfReport.d.ts +1 -0
- package/dist/analytics/pdfReport.js +7 -5
- package/dist/analytics/privacy.d.ts +18 -0
- package/dist/analytics/privacy.js +10 -0
- package/dist/analytics/read.js +74 -16
- package/dist/analytics/report.d.ts +32 -1
- package/dist/analytics/report.js +9 -2
- package/dist/backups/index.js +13 -5
- package/dist/backups/metadata.d.ts +7 -0
- package/dist/config/defaults/community.js +0 -6
- package/dist/config/defaults/core.js +1 -0
- package/dist/config/defaults/db.d.ts +0 -2
- package/dist/config/defaults/db.js +0 -2
- package/dist/config/index.d.ts +20 -9
- package/dist/db/helpers.d.ts +6 -28
- package/dist/db/helpers.js +19 -149
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +4 -0
- package/dist/db/init.js +3 -2
- package/dist/db/migration/detect.d.ts +0 -3
- package/dist/db/migration/detect.js +0 -54
- package/dist/db/migration/importCollections.d.ts +1 -1
- package/dist/db/migration/importCollections.js +22 -6
- package/dist/db/migration/shared.d.ts +0 -4
- package/dist/db/migration/shared.js +0 -7
- package/dist/db/migration/transform.d.ts +2 -0
- package/dist/db/migration/transform.js +23 -0
- package/dist/db/pg/client.js +4 -0
- 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 +1 -0
- package/dist/db/pg/filters/posts.js +11 -1
- package/dist/db/pg/map/filters.js +5 -0
- package/dist/db/pg/map/relations.d.ts +1 -1
- package/dist/db/pg/map/relations.js +89 -41
- package/dist/db/pg/migrate.d.ts +23 -0
- package/dist/db/pg/migrate.js +87 -1
- package/dist/db/pg/queries/derived.d.ts +5 -0
- package/dist/db/pg/queries/derived.js +21 -0
- package/dist/db/pg/schema/analytics.d.ts +76 -0
- package/dist/db/pg/schema/analytics.js +11 -1
- package/dist/db/pg/schema/documents.d.ts +143 -0
- package/dist/db/pg/schema/documents.js +22 -1
- package/dist/db/pg/schema/edges.d.ts +1 -0
- package/dist/db/pg/schema/edges.js +1 -0
- package/dist/db/pg/schema/index.d.ts +218 -0
- package/dist/db/pg/sql/0005_open_power_man.sql +9 -0
- package/dist/db/pg/sql/0006_fine_trish_tilby.sql +8 -0
- 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/meta/0004_snapshot.json +1 -1
- package/dist/db/pg/sql/meta/0005_snapshot.json +4179 -0
- package/dist/db/pg/sql/meta/0006_snapshot.json +4200 -0
- package/dist/db/pg/sql/meta/0007_snapshot.json +4179 -0
- package/dist/db/pg/sql/meta/0009_snapshot.json +4299 -0
- package/dist/db/pg/sql/meta/_journal.json +35 -0
- package/dist/db/replaceOrigin.d.ts +11 -0
- package/dist/db/replaceOrigin.js +116 -0
- package/dist/db/types.d.ts +0 -4
- package/dist/events/index.d.ts +2 -1
- package/dist/events/index.js +54 -33
- package/dist/groups/finders.d.ts +2 -2
- package/dist/groups/helpers.d.ts +6 -6
- package/dist/groups/mapping.d.ts +4 -4
- package/dist/groups/mapping.js +2 -2
- package/dist/groups/mutations.js +1 -1
- 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/finders.d.ts +2 -1
- package/dist/jams/finders.js +18 -7
- package/dist/jams/helpers.d.ts +8 -4
- package/dist/jams/index.d.ts +4 -3
- package/dist/jams/index.js +23 -12
- package/dist/jams/livekit.d.ts +46 -8
- package/dist/jams/livekit.js +103 -21
- package/dist/jams/mapping.d.ts +14 -4
- package/dist/jams/mutations.d.ts +2 -0
- package/dist/jams/rtmp.d.ts +5 -0
- package/dist/jams/rtmp.js +8 -0
- package/dist/jams/token.d.ts +3 -3
- package/dist/jams/token.js +15 -12
- package/dist/jams/waitingRoom.d.ts +6 -4
- package/dist/jams/waitingRoom.js +33 -24
- package/dist/migration/index.d.ts +4 -0
- package/dist/migration/index.js +4 -0
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
- package/dist/notifications/helpers.js +6 -2
- package/dist/notifications/jobs.js +13 -2
- package/dist/notifications/push.js +11 -4
- package/dist/plugins/helpers.d.ts +6 -2
- package/dist/plugins/helpers.js +22 -10
- package/dist/plugins/index.d.ts +6 -1
- package/dist/plugins/index.js +54 -13
- package/dist/plugins/install.d.ts +20 -0
- package/dist/plugins/install.js +223 -0
- package/dist/plugins/state.d.ts +4 -0
- package/dist/plugins/state.js +29 -0
- package/dist/posts/contextClosure.d.ts +2 -1
- package/dist/posts/contextClosure.js +6 -1
- package/dist/posts/conversationQueries.d.ts +23 -0
- package/dist/posts/conversationQueries.js +135 -0
- package/dist/posts/eventAgenda.d.ts +165 -0
- package/dist/posts/eventAgenda.js +120 -0
- package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
- package/dist/posts/eventOccurrenceJobs.js +23 -0
- package/dist/posts/eventOccurrences.d.ts +4 -0
- package/dist/posts/eventOccurrences.js +40 -0
- package/dist/posts/finders.d.ts +39 -13
- package/dist/posts/finders.js +51 -66
- package/dist/posts/helpers/filters.js +1 -1
- package/dist/posts/helpers/index.d.ts +120 -34
- package/dist/posts/helpers/index.js +34 -21
- package/dist/posts/index.d.ts +4 -0
- package/dist/posts/index.js +4 -0
- package/dist/posts/mapping.d.ts +454 -0
- package/dist/posts/mapping.js +43 -9
- package/dist/posts/mutations.d.ts +4 -2
- package/dist/posts/mutations.js +49 -16
- package/dist/posts/rsvpConfirmationEmail.js +2 -1
- package/dist/posts/unseenCounts.d.ts +12 -0
- package/dist/posts/unseenCounts.js +98 -0
- package/dist/profiles/cache.d.ts +5 -1
- package/dist/profiles/cache.js +27 -1
- package/dist/profiles/helpers.d.ts +5 -5
- package/dist/profiles/index.d.ts +1 -0
- package/dist/profiles/index.js +1 -0
- package/dist/profiles/mapping.d.ts +45 -4
- package/dist/profiles/mapping.js +24 -0
- package/dist/profiles/mutations.js +12 -14
- package/dist/pushSubscriptions/helpers.d.ts +2 -2
- package/dist/pushSubscriptions/mutations.js +13 -1
- package/dist/reports/helpers.d.ts +6 -6
- package/dist/reports/helpers.js +2 -1
- package/dist/reports/mapping.js +6 -2
- package/dist/roles/defaults.js +1 -0
- package/dist/roles/mutations.d.ts +3 -3
- package/dist/roles/mutations.js +5 -3
- package/dist/server/index.d.ts +15 -7
- package/dist/server/index.js +15 -8
- package/dist/session/index.d.ts +28 -0
- package/dist/session/index.js +79 -0
- package/dist/stats/finders.d.ts +1912 -362
- package/dist/stats/mapping.d.ts +26 -5
- package/package.json +7 -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/exportArango.d.ts +0 -4
- package/dist/db/migration/exportArango.js +0 -80
- package/dist/db/replaceHostname.d.ts +0 -1
- package/dist/db/replaceHostname.js +0 -88
|
@@ -36,6 +36,41 @@
|
|
|
36
36
|
"when": 1785770303150,
|
|
37
37
|
"tag": "0004_analytics",
|
|
38
38
|
"breakpoints": true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"idx": 5,
|
|
42
|
+
"version": "7",
|
|
43
|
+
"when": 1786638408097,
|
|
44
|
+
"tag": "0005_open_power_man",
|
|
45
|
+
"breakpoints": true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"idx": 6,
|
|
49
|
+
"version": "7",
|
|
50
|
+
"when": 1787042540973,
|
|
51
|
+
"tag": "0006_fine_trish_tilby",
|
|
52
|
+
"breakpoints": true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"idx": 7,
|
|
56
|
+
"version": "7",
|
|
57
|
+
"when": 1787554098682,
|
|
58
|
+
"tag": "0007_shallow_oracle",
|
|
59
|
+
"breakpoints": true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"idx": 8,
|
|
63
|
+
"version": "7",
|
|
64
|
+
"when": 1787632300000,
|
|
65
|
+
"tag": "0008_group_owner_roles",
|
|
66
|
+
"breakpoints": true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"idx": 9,
|
|
70
|
+
"version": "7",
|
|
71
|
+
"when": 1787640000000,
|
|
72
|
+
"tag": "0009_event_occurrences",
|
|
73
|
+
"breakpoints": true
|
|
39
74
|
}
|
|
40
75
|
]
|
|
41
76
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively rewrite every absolute http(s) URL under `value` whose hostname
|
|
3
|
+
* matches `oldHostname` so it points at `newOrigin`. Pure — exported for tests.
|
|
4
|
+
*/
|
|
5
|
+
export declare const replaceOriginInValue: (value: unknown, oldHostname: string, newOrigin: string) => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* After a restore, repoint stored absolute URLs from the backup's origin to the
|
|
8
|
+
* current server. `oldHostname` comes from the backup metadata; `newOrigin` is
|
|
9
|
+
* this server's `serverRootUrl()` (scheme + host + port).
|
|
10
|
+
*/
|
|
11
|
+
export declare const replaceOrigin: (oldHostname?: string, newOrigin?: string) => Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { logger } from '../log/index.js';
|
|
3
|
+
import { pgDb } from './pg/client.js';
|
|
4
|
+
import { asTable, getTableForCollection } from './pg/map/registry.js';
|
|
5
|
+
const log = logger('db:replaceOrigin');
|
|
6
|
+
// Walk collections that embed absolute media URLs (avatar/header/image,
|
|
7
|
+
// denormalized attachments, jam backgrounds). posts covers articles + events;
|
|
8
|
+
// groups covers group avatar/header — omitting them leaves those on the backup host.
|
|
9
|
+
const hostnameCollections = [
|
|
10
|
+
'configs',
|
|
11
|
+
'entries',
|
|
12
|
+
'groups',
|
|
13
|
+
'jamEvents',
|
|
14
|
+
'mediaAttachments',
|
|
15
|
+
'posts',
|
|
16
|
+
'profileSettings',
|
|
17
|
+
'profiles',
|
|
18
|
+
];
|
|
19
|
+
const absoluteHttpUrlPattern = /https?:\/\/[^\s"'<>`]+/g;
|
|
20
|
+
/**
|
|
21
|
+
* Rewrite the origin (scheme + host + port) of a single URL when its hostname
|
|
22
|
+
* matches the backup's origin. Matching by hostname — rather than the full
|
|
23
|
+
* origin — lets a backup taken on `https://community.example` restore onto a
|
|
24
|
+
* `http://localhost:5174` dev server: the old scheme/port are dropped and the
|
|
25
|
+
* current server's origin takes their place. Path, query, hash, and any
|
|
26
|
+
* userinfo are preserved verbatim (no URL normalization).
|
|
27
|
+
*/
|
|
28
|
+
const replaceOriginInUrl = (urlValue, oldHostname, newOrigin) => {
|
|
29
|
+
try {
|
|
30
|
+
const url = new URL(urlValue);
|
|
31
|
+
if (!['http:', 'https:'].includes(url.protocol) ||
|
|
32
|
+
url.hostname !== oldHostname) {
|
|
33
|
+
return urlValue;
|
|
34
|
+
}
|
|
35
|
+
const authorityStart = urlValue.indexOf('://') + 3;
|
|
36
|
+
const afterAuthority = urlValue.slice(authorityStart).search(/[/?#]/);
|
|
37
|
+
const authorityEnd = afterAuthority === -1 ? urlValue.length : authorityStart + afterAuthority;
|
|
38
|
+
const authority = urlValue.slice(authorityStart, authorityEnd);
|
|
39
|
+
const userinfo = authority.slice(0, authority.lastIndexOf('@') + 1);
|
|
40
|
+
const rest = urlValue.slice(authorityEnd);
|
|
41
|
+
const newOriginTrimmed = newOrigin.replace(/\/+$/, '');
|
|
42
|
+
if (userinfo) {
|
|
43
|
+
const newAuthorityStart = newOriginTrimmed.indexOf('://') + 3;
|
|
44
|
+
return (newOriginTrimmed.slice(0, newAuthorityStart) +
|
|
45
|
+
userinfo +
|
|
46
|
+
newOriginTrimmed.slice(newAuthorityStart) +
|
|
47
|
+
rest);
|
|
48
|
+
}
|
|
49
|
+
return newOriginTrimmed + rest;
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
return urlValue;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const replaceOriginInString = (value, oldHostname, newOrigin) => value.replace(absoluteHttpUrlPattern, (urlValue) => replaceOriginInUrl(urlValue, oldHostname, newOrigin));
|
|
56
|
+
/**
|
|
57
|
+
* Recursively rewrite every absolute http(s) URL under `value` whose hostname
|
|
58
|
+
* matches `oldHostname` so it points at `newOrigin`. Pure — exported for tests.
|
|
59
|
+
*/
|
|
60
|
+
export const replaceOriginInValue = (value, oldHostname, newOrigin) => {
|
|
61
|
+
if (typeof value === 'string') {
|
|
62
|
+
return replaceOriginInString(value, oldHostname, newOrigin);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(value)) {
|
|
65
|
+
return value.map((item) => replaceOriginInValue(item, oldHostname, newOrigin));
|
|
66
|
+
}
|
|
67
|
+
if (value && typeof value === 'object') {
|
|
68
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
69
|
+
key,
|
|
70
|
+
replaceOriginInValue(item, oldHostname, newOrigin),
|
|
71
|
+
]));
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* After a restore, repoint stored absolute URLs from the backup's origin to the
|
|
77
|
+
* current server. `oldHostname` comes from the backup metadata; `newOrigin` is
|
|
78
|
+
* this server's `serverRootUrl()` (scheme + host + port).
|
|
79
|
+
*/
|
|
80
|
+
export const replaceOrigin = async (oldHostname, newOrigin) => {
|
|
81
|
+
if (!oldHostname || !newOrigin) {
|
|
82
|
+
log.info('No origin to replace');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
log.info(`Repointing restored URLs from ${oldHostname} to ${newOrigin}`);
|
|
86
|
+
const db = pgDb();
|
|
87
|
+
for (const collectionName of hostnameCollections) {
|
|
88
|
+
const table = getTableForCollection(collectionName);
|
|
89
|
+
const rows = await db.select().from(table);
|
|
90
|
+
let replacedCount = 0;
|
|
91
|
+
for (const row of rows) {
|
|
92
|
+
const current = row;
|
|
93
|
+
const updated = replaceOriginInValue(current, oldHostname, newOrigin);
|
|
94
|
+
if (JSON.stringify(current) === JSON.stringify(updated)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const t = asTable(table);
|
|
98
|
+
if (collectionName === 'configs') {
|
|
99
|
+
await db
|
|
100
|
+
.update(table)
|
|
101
|
+
.set(updated)
|
|
102
|
+
.where(eq(t.key, current.key));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
await db
|
|
106
|
+
.update(table)
|
|
107
|
+
.set(updated)
|
|
108
|
+
.where(eq(t.id, current.id));
|
|
109
|
+
}
|
|
110
|
+
replacedCount += 1;
|
|
111
|
+
}
|
|
112
|
+
if (replacedCount > 0) {
|
|
113
|
+
log.info(`Repointed URLs in ${replacedCount} ${collectionName} row(s)`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
package/dist/db/types.d.ts
CHANGED
|
@@ -2,10 +2,6 @@ import type { PgDb } from './pg/client';
|
|
|
2
2
|
export interface OpenpeepsDatabase {
|
|
3
3
|
db: PgDb;
|
|
4
4
|
}
|
|
5
|
-
export interface UserFunctionDefinition {
|
|
6
|
-
name: string;
|
|
7
|
-
dbFunction: Function;
|
|
8
|
-
}
|
|
9
5
|
export interface ObjectFilter<O extends object> {
|
|
10
6
|
(item: O): boolean;
|
|
11
7
|
}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -19,13 +19,14 @@ export type CoreEvents = {
|
|
|
19
19
|
};
|
|
20
20
|
export type CoreEventKey = keyof CoreEvents;
|
|
21
21
|
export declare const VALID_EVENT_KEYS: CoreEventKey[];
|
|
22
|
+
type Unsubscribe = () => void;
|
|
22
23
|
export declare const hub: {
|
|
23
24
|
/**
|
|
24
25
|
* Fan-out must not fail the caller (register/react/etc.). Redis publish and
|
|
25
26
|
* the BullMQ once-queue are best-effort side channels.
|
|
26
27
|
*/
|
|
27
28
|
emit: (eventType: string, ...eventArgs: unknown[]) => Promise<void>;
|
|
28
|
-
on: <T extends unknown[]>(eventType: string, handler: (...args: T) => unknown) =>
|
|
29
|
+
on: <T extends unknown[]>(eventType: string, handler: (...args: T) => unknown) => Unsubscribe;
|
|
29
30
|
once: (eventType: string, handler: (...args: unknown[]) => unknown) => void;
|
|
30
31
|
};
|
|
31
32
|
export { onceWorker, onceQueue } from './once';
|
package/dist/events/index.js
CHANGED
|
@@ -29,38 +29,59 @@ const publishConnection = async () => {
|
|
|
29
29
|
connectionPromise = getConnection();
|
|
30
30
|
return connectionPromise;
|
|
31
31
|
};
|
|
32
|
-
const baseHub = (prefix) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
32
|
+
const baseHub = (prefix) => {
|
|
33
|
+
const subscriptions = new Map();
|
|
34
|
+
return {
|
|
35
|
+
/**
|
|
36
|
+
* Fan-out must not fail the caller (register/react/etc.). Redis publish and
|
|
37
|
+
* the BullMQ once-queue are best-effort side channels.
|
|
38
|
+
*/
|
|
39
|
+
emit: async (eventType, ...eventArgs) => {
|
|
40
|
+
const qualifiedEventType = `${prefix}:${eventType}`;
|
|
41
|
+
try {
|
|
42
|
+
const conn = await publishConnection();
|
|
43
|
+
await conn.publish(qualifiedEventType, JSON.stringify(eventArgs));
|
|
44
|
+
log.info({ qualifiedEventType }, 'hub event published');
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
log.error({ qualifiedEventType, err }, 'hub publish failed');
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
await onceQueue().add(qualifiedEventType, eventArgs);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
log.error({ qualifiedEventType, err }, 'hub once-queue enqueue failed');
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
on: (eventType, handler) => {
|
|
57
|
+
const channel = `${prefix}:${eventType}`;
|
|
58
|
+
getConnection().then((conn) => {
|
|
59
|
+
conn.subscribe(channel, (message) => {
|
|
60
|
+
const args = JSON.parse(message);
|
|
61
|
+
handler(...args);
|
|
62
|
+
});
|
|
63
|
+
let entry = subscriptions.get(channel);
|
|
64
|
+
if (!entry) {
|
|
65
|
+
entry = { conn, channels: [] };
|
|
66
|
+
subscriptions.set(channel, entry);
|
|
67
|
+
}
|
|
68
|
+
entry.channels.push(channel);
|
|
69
|
+
});
|
|
70
|
+
return () => {
|
|
71
|
+
getConnection().then((conn) => conn.unsubscribe(channel));
|
|
72
|
+
const entry = subscriptions.get(channel);
|
|
73
|
+
if (entry) {
|
|
74
|
+
entry.channels = entry.channels.filter((c) => c !== channel);
|
|
75
|
+
if (entry.channels.length === 0) {
|
|
76
|
+
subscriptions.delete(channel);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
once: (eventType, handler) => {
|
|
82
|
+
registerOnceHandler(`${prefix}:${eventType}`, handler);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
65
86
|
export const hub = baseHub('allpeep:core');
|
|
66
87
|
export { onceWorker, onceQueue } from './once.js';
|
package/dist/groups/finders.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export declare const listAdminGroups: () => Promise<{
|
|
|
72
72
|
createdAt: string;
|
|
73
73
|
updatedAt: string;
|
|
74
74
|
postsCount: number;
|
|
75
|
-
|
|
75
|
+
owners: {
|
|
76
76
|
handle: string;
|
|
77
77
|
type: "guest" | "local" | "federated";
|
|
78
78
|
id: string;
|
|
@@ -107,7 +107,7 @@ export declare const listAdminGroups: () => Promise<{
|
|
|
107
107
|
guestData?: {
|
|
108
108
|
email?: string | undefined;
|
|
109
109
|
resource?: {
|
|
110
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "
|
|
110
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
|
|
111
111
|
id?: string | undefined;
|
|
112
112
|
} | undefined;
|
|
113
113
|
} | undefined;
|
package/dist/groups/helpers.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
25
25
|
discoverable?: boolean | undefined;
|
|
26
26
|
deletedAt?: string | null | undefined;
|
|
27
27
|
};
|
|
28
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
28
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
29
29
|
}[] | undefined;
|
|
30
30
|
deletedAt?: string | null | undefined;
|
|
31
31
|
avatar?: string | null | undefined;
|
|
@@ -71,11 +71,11 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
71
71
|
lastPostAt?: string | null | undefined;
|
|
72
72
|
deletedAt?: string | null | undefined;
|
|
73
73
|
}, data?: {
|
|
74
|
-
roles?: ("
|
|
74
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
75
75
|
} & {
|
|
76
76
|
id?: string;
|
|
77
77
|
}) => Promise<import("../db/pg/map").WithId<{
|
|
78
|
-
roles?: ("
|
|
78
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
79
79
|
} & {
|
|
80
80
|
_from: string;
|
|
81
81
|
_to: string;
|
|
@@ -105,7 +105,7 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
|
|
|
105
105
|
discoverable?: boolean | undefined;
|
|
106
106
|
deletedAt?: string | null | undefined;
|
|
107
107
|
};
|
|
108
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
108
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
109
109
|
}[] | undefined;
|
|
110
110
|
deletedAt?: string | null | undefined;
|
|
111
111
|
avatar?: string | null | undefined;
|
|
@@ -176,7 +176,7 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
176
176
|
discoverable?: boolean | undefined;
|
|
177
177
|
deletedAt?: string | null | undefined;
|
|
178
178
|
};
|
|
179
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
179
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
180
180
|
}[] | undefined;
|
|
181
181
|
deletedAt?: string | null | undefined;
|
|
182
182
|
avatar?: string | null | undefined;
|
|
@@ -222,6 +222,6 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
222
222
|
lastPostAt?: string | null | undefined;
|
|
223
223
|
deletedAt?: string | null | undefined;
|
|
224
224
|
}, data?: {
|
|
225
|
-
roles?: ("
|
|
225
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
226
226
|
} | undefined) => Promise<void>;
|
|
227
227
|
export declare const canSeeGroupFilter: (profile?: ProfileWithMeta) => PgFilter<GroupWithMeta> | undefined;
|
package/dist/groups/mapping.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
74
74
|
createdAt: string;
|
|
75
75
|
updatedAt: string;
|
|
76
76
|
postsCount: number;
|
|
77
|
-
|
|
77
|
+
owners: {
|
|
78
78
|
handle: string;
|
|
79
79
|
type: "guest" | "local" | "federated";
|
|
80
80
|
id: string;
|
|
@@ -109,7 +109,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
109
109
|
guestData?: {
|
|
110
110
|
email?: string | undefined;
|
|
111
111
|
resource?: {
|
|
112
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "
|
|
112
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
|
|
113
113
|
id?: string | undefined;
|
|
114
114
|
} | undefined;
|
|
115
115
|
} | undefined;
|
|
@@ -135,7 +135,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
135
135
|
createdAt: string;
|
|
136
136
|
updatedAt: string;
|
|
137
137
|
postsCount: number;
|
|
138
|
-
|
|
138
|
+
owners: {
|
|
139
139
|
handle: string;
|
|
140
140
|
type: "guest" | "local" | "federated";
|
|
141
141
|
id: string;
|
|
@@ -170,7 +170,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
170
170
|
guestData?: {
|
|
171
171
|
email?: string | undefined;
|
|
172
172
|
resource?: {
|
|
173
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "
|
|
173
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
|
|
174
174
|
id?: string | undefined;
|
|
175
175
|
} | undefined;
|
|
176
176
|
} | undefined;
|
package/dist/groups/mapping.js
CHANGED
|
@@ -30,12 +30,12 @@ export const adminGroupsMapping = map({
|
|
|
30
30
|
relations: [
|
|
31
31
|
...groupRelations,
|
|
32
32
|
{
|
|
33
|
-
alias: '
|
|
33
|
+
alias: 'owners',
|
|
34
34
|
edgeCollection: 'userGroups',
|
|
35
35
|
direction: 'INBOUND',
|
|
36
36
|
skipEdge: true,
|
|
37
37
|
cardinality: 'many',
|
|
38
|
-
edgeFilter: edgeFilters.
|
|
38
|
+
edgeFilter: edgeFilters.groupOwnerRole(),
|
|
39
39
|
mapping: {
|
|
40
40
|
collection: 'profiles',
|
|
41
41
|
softDelete: true,
|
package/dist/groups/mutations.js
CHANGED
|
@@ -10,7 +10,7 @@ export const createGroup = async (groupData, profile, members = []) => {
|
|
|
10
10
|
const { db } = await allpeepDb();
|
|
11
11
|
const emptyGroup = await groupsMapping.create(db, groupData);
|
|
12
12
|
await addMember(db, profile, emptyGroup, {
|
|
13
|
-
roles: ['
|
|
13
|
+
roles: ['owner'],
|
|
14
14
|
});
|
|
15
15
|
profilesCache.del(profile.id);
|
|
16
16
|
const filteredMembers = members === null || members === void 0 ? void 0 : members.filter((member) => member.id !== profile.id);
|
|
@@ -2,9 +2,9 @@ export declare const redeemInviteLinkConnector: (db: import("../db").PgDb, from:
|
|
|
2
2
|
id: string;
|
|
3
3
|
}, to: {
|
|
4
4
|
id: string;
|
|
5
|
-
}, data?: {
|
|
5
|
+
}, data?: object & {
|
|
6
6
|
id?: string;
|
|
7
|
-
}) => Promise<import("../db/pg/map").WithId<{
|
|
7
|
+
}) => Promise<import("../db/pg/map").WithId<object & {
|
|
8
8
|
_from: string;
|
|
9
9
|
_to: string;
|
|
10
10
|
}>>;
|
|
@@ -12,9 +12,9 @@ export declare const createInviteLinkConnector: (db: import("../db").PgDb, from:
|
|
|
12
12
|
id: string;
|
|
13
13
|
}, to: {
|
|
14
14
|
id: string;
|
|
15
|
-
}, data?: {
|
|
15
|
+
}, data?: object & {
|
|
16
16
|
id?: string;
|
|
17
|
-
}) => Promise<import("../db/pg/map").WithId<{
|
|
17
|
+
}) => Promise<import("../db/pg/map").WithId<object & {
|
|
18
18
|
_from: string;
|
|
19
19
|
_to: string;
|
|
20
20
|
}>>;
|
package/dist/jams/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostWithMeta } from '@openpeepshq/common/types';
|
|
2
2
|
export declare const jamStateCache: import("cache-manager").Cache;
|
|
3
|
-
export declare const getJamState: (jam: PostWithMeta) => Promise<{
|
|
3
|
+
export declare const getJamState: (jam: PostWithMeta, recurrenceId?: string) => Promise<{
|
|
4
4
|
active: boolean;
|
|
5
5
|
participants: string[];
|
|
6
6
|
}>;
|
package/dist/jams/cache.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createCache } from 'cache-manager';
|
|
2
|
+
import { jamRoomName } from '@openpeepshq/common/lib';
|
|
2
3
|
import { jamState } from './livekit.js';
|
|
3
4
|
export const jamStateCache = createCache({
|
|
4
5
|
ttl: 20 * 1000,
|
|
5
6
|
refreshThreshold: 5 * 1000,
|
|
6
7
|
});
|
|
7
|
-
export const getJamState = async (jam) => jamStateCache.wrap(jam.id, () => jamState(jam));
|
|
8
|
+
export const getJamState = async (jam, recurrenceId) => jamStateCache.wrap(jamRoomName(jam.id, recurrenceId), () => jamState(jam, undefined, recurrenceId));
|
|
8
9
|
/** Caches the LiveKit scan for live jam posts (before auth filtering). */
|
|
9
10
|
export const LIVE_JAMS_CACHE_KEY = 'live-jams';
|
|
10
11
|
export const liveJamPostsCache = createCache({
|
package/dist/jams/finders.d.ts
CHANGED
|
@@ -14,10 +14,11 @@ export declare const listAttendance: (jamId: string, { start, limit }?: {
|
|
|
14
14
|
start?: string;
|
|
15
15
|
limit?: number;
|
|
16
16
|
}) => Promise<import("../db/pg/map").WithId<JamEvent>[]>;
|
|
17
|
-
export declare const findJamState: (jam: PostWithMeta, hideParticipants?: boolean) => Promise<{
|
|
17
|
+
export declare const findJamState: (jam: PostWithMeta, hideParticipants?: boolean, recurrenceId?: string) => Promise<{
|
|
18
18
|
participants: string[];
|
|
19
19
|
active: boolean;
|
|
20
20
|
}>;
|
|
21
21
|
export declare const findJamRecording: (recordingId: string) => Promise<import("@openpeepshq/common").JamRecordingWithMeta | undefined>;
|
|
22
22
|
export declare const findActiveRecording: (jamPost: PostWithMeta) => Promise<import("@openpeepshq/common").JamRecordingWithMeta | undefined>;
|
|
23
|
+
export declare const findActiveRtmpStream: (jamPost: PostWithMeta) => Promise<import("@openpeepshq/common").JamRecordingWithMeta | undefined>;
|
|
23
24
|
export declare const listPostRecordings: (postId: string) => Promise<JamRecording[]>;
|
package/dist/jams/finders.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jamRecordingSchema, } from '@openpeepshq/common/types';
|
|
2
|
+
import { isFileJamRecording, pickActiveFileRecording, pickActiveRtmpStream, } from '@openpeepshq/common/lib';
|
|
2
3
|
import { allpeepDb } from '../db/index.js';
|
|
3
4
|
import { jamEventsMapping, jamRecordingsMapping } from './mapping.js';
|
|
4
5
|
import { addStartLimit, sortNewestFirst } from '../db/helpers.js';
|
|
@@ -7,18 +8,28 @@ import { transformJamRecordingData } from './helpers.js';
|
|
|
7
8
|
export const baseListJam = (props, { start, limit = 100 }) => addStartLimit(jamEventsMapping.filter({ matches: props }), start, limit);
|
|
8
9
|
export const listJamEvents = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId }, { start, limit }).all(db));
|
|
9
10
|
export const listAttendance = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId, type: 'join' }, { start, limit }).all(db));
|
|
10
|
-
export const findJamState = async (jam, hideParticipants) => {
|
|
11
|
-
const state = await getJamState(jam);
|
|
11
|
+
export const findJamState = async (jam, hideParticipants, recurrenceId) => {
|
|
12
|
+
const state = await getJamState(jam, recurrenceId);
|
|
12
13
|
return Object.assign(Object.assign({}, state), { participants: hideParticipants ? [] : state.participants });
|
|
13
14
|
};
|
|
14
15
|
export const findJamRecording = async (recordingId) => allpeepDb()
|
|
15
16
|
.then(({ db }) => jamRecordingsMapping.find(db, recordingId))
|
|
16
17
|
.then((recording) => recording ? transformJamRecordingData(recording) : undefined);
|
|
17
|
-
export const findActiveRecording = async (jamPost) =>
|
|
18
|
-
|
|
18
|
+
export const findActiveRecording = async (jamPost) => {
|
|
19
|
+
const recordings = await listActiveJamRecordings(jamPost);
|
|
20
|
+
const recording = pickActiveFileRecording(recordings);
|
|
21
|
+
return recording ? transformJamRecordingData(recording) : undefined;
|
|
22
|
+
};
|
|
23
|
+
export const findActiveRtmpStream = async (jamPost) => {
|
|
24
|
+
const recordings = await listActiveJamRecordings(jamPost);
|
|
25
|
+
const recording = pickActiveRtmpStream(recordings);
|
|
26
|
+
return recording ? transformJamRecordingData(recording) : undefined;
|
|
27
|
+
};
|
|
28
|
+
const listActiveJamRecordings = (jamPost) => allpeepDb().then(({ db }) => sortNewestFirst(jamRecordingsMapping.filter({
|
|
19
29
|
matches: { _to: `posts/${jamPost.id}`, status: 'active' },
|
|
20
|
-
})).
|
|
21
|
-
.then((recording) => recording ? transformJamRecordingData(recording) : undefined);
|
|
30
|
+
})).all(db));
|
|
22
31
|
export const listPostRecordings = async (postId) => allpeepDb()
|
|
23
32
|
.then(({ db }) => sortNewestFirst(jamRecordingsMapping.filter({ matches: { _to: `posts/${postId}` } })).all(db))
|
|
24
|
-
.then((recordings) => recordings
|
|
33
|
+
.then((recordings) => recordings
|
|
34
|
+
.filter(isFileJamRecording)
|
|
35
|
+
.map((recording) => jamRecordingSchema.parse(recording)));
|
package/dist/jams/helpers.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { JamRecording, JamRecordingWithMeta, PostWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
2
|
export declare const connectRecording: (db: import("../db").PgDb, from: ProfileWithMeta, to: PostWithMeta, data?: {
|
|
3
|
-
status: "
|
|
3
|
+
status: "completed" | "failed" | "active" | "requested";
|
|
4
|
+
kind?: "file" | "rtmp" | undefined;
|
|
5
|
+
destinationHost?: string | undefined;
|
|
4
6
|
egressId?: string | undefined;
|
|
5
7
|
attachment?: {
|
|
6
8
|
type: string;
|
|
@@ -22,7 +24,7 @@ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileW
|
|
|
22
24
|
updatedAt: string;
|
|
23
25
|
description?: string | undefined;
|
|
24
26
|
blurhash?: string | undefined;
|
|
25
|
-
status?: "
|
|
27
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
26
28
|
error?: string | undefined;
|
|
27
29
|
deletedAt?: string | null | undefined;
|
|
28
30
|
} | undefined;
|
|
@@ -30,7 +32,9 @@ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileW
|
|
|
30
32
|
} & {
|
|
31
33
|
id?: string;
|
|
32
34
|
}) => Promise<import("../db/pg/map").WithId<{
|
|
33
|
-
status: "
|
|
35
|
+
status: "completed" | "failed" | "active" | "requested";
|
|
36
|
+
kind?: "file" | "rtmp" | undefined;
|
|
37
|
+
destinationHost?: string | undefined;
|
|
34
38
|
egressId?: string | undefined;
|
|
35
39
|
attachment?: {
|
|
36
40
|
type: string;
|
|
@@ -52,7 +56,7 @@ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileW
|
|
|
52
56
|
updatedAt: string;
|
|
53
57
|
description?: string | undefined;
|
|
54
58
|
blurhash?: string | undefined;
|
|
55
|
-
status?: "
|
|
59
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
56
60
|
error?: string | undefined;
|
|
57
61
|
deletedAt?: string | null | undefined;
|
|
58
62
|
} | undefined;
|
package/dist/jams/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AuthorizationData, type MuteParticipantRequest, type PostWithMeta, type Profile } from '@openpeepshq/common/types';
|
|
2
2
|
export { createJamToken, createJamEgressToken } from './token';
|
|
3
|
-
export { startRecording, stopRecording, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
|
|
3
|
+
export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
|
|
4
|
+
export { rtmpStreamOutput } from './rtmp';
|
|
4
5
|
export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs';
|
|
5
6
|
export * from './waitingRoom';
|
|
6
7
|
export * from './mutations';
|
|
@@ -9,7 +10,7 @@ export * from './recording';
|
|
|
9
10
|
export { deriveJamRecordingUploadSecret, jamRecordingUploadSecret, } from './recordingUploadAuth';
|
|
10
11
|
export declare const listLiveJams: (authData: AuthorizationData) => Promise<PostWithMeta[]>;
|
|
11
12
|
export declare const findJamEvent: (id: string) => Promise<PostWithMeta | undefined>;
|
|
12
|
-
export declare const closeJam: (profile: Profile, jamEvent: PostWithMeta) => Promise<import("@openpeepshq/common").JamEvent | undefined>;
|
|
13
|
-
export declare const muteParticipant: (jamId: string, data: MuteParticipantRequest) => Promise<{
|
|
13
|
+
export declare const closeJam: (profile: Profile, jamEvent: PostWithMeta, recurrenceId?: string) => Promise<import("@openpeepshq/common").JamEvent | undefined>;
|
|
14
|
+
export declare const muteParticipant: (jamId: string, data: MuteParticipantRequest, recurrenceId?: string) => Promise<{
|
|
14
15
|
success: boolean;
|
|
15
16
|
}>;
|