@openpeepshq/core 0.1.32 → 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/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 +24 -11
- package/dist/analytics/report.d.ts +1 -1
- package/dist/analytics/report.js +9 -2
- package/dist/backups/index.js +6 -3
- package/dist/backups/metadata.d.ts +7 -0
- package/dist/config/defaults/community.js +0 -6
- package/dist/config/defaults/db.d.ts +0 -2
- package/dist/config/defaults/db.js +0 -2
- package/dist/config/index.d.ts +10 -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/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 +2 -1
- package/dist/db/pg/schema/index.d.ts +143 -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/0007_snapshot.json +4179 -0
- package/dist/db/pg/sql/meta/0009_snapshot.json +4299 -0
- package/dist/db/pg/sql/meta/_journal.json +21 -0
- package/dist/db/replaceOrigin.js +6 -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 +4 -0
- package/dist/jams/index.d.ts +4 -3
- package/dist/jams/index.js +20 -13
- 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 -6
- package/dist/jams/waitingRoom.js +24 -23
- 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/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 +41 -4
- 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/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 +32 -8
- package/dist/posts/finders.js +27 -45
- package/dist/posts/helpers/filters.js +1 -1
- package/dist/posts/helpers/index.d.ts +102 -16
- package/dist/posts/helpers/index.js +33 -20
- package/dist/posts/index.d.ts +3 -0
- package/dist/posts/index.js +3 -0
- package/dist/posts/mapping.d.ts +275 -0
- package/dist/posts/mapping.js +37 -3
- package/dist/posts/mutations.d.ts +1 -1
- package/dist/posts/mutations.js +29 -18
- package/dist/posts/rsvpConfirmationEmail.js +2 -1
- package/dist/posts/unseenCounts.d.ts +2 -0
- package/dist/posts/unseenCounts.js +25 -8
- package/dist/profiles/cache.d.ts +3 -1
- package/dist/profiles/cache.js +9 -1
- package/dist/profiles/helpers.d.ts +5 -5
- package/dist/profiles/index.d.ts +1 -1
- package/dist/profiles/index.js +1 -1
- package/dist/profiles/mapping.d.ts +5 -5
- 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/roles/defaults.js +1 -0
- package/dist/server/index.d.ts +7 -7
- package/dist/server/index.js +15 -8
- package/dist/stats/finders.d.ts +1692 -142
- package/dist/stats/mapping.d.ts +21 -0
- package/package.json +4 -9
- 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
|
@@ -50,6 +50,27 @@
|
|
|
50
50
|
"when": 1787042540973,
|
|
51
51
|
"tag": "0006_fine_trish_tilby",
|
|
52
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
|
|
53
74
|
}
|
|
54
75
|
]
|
|
55
76
|
}
|
package/dist/db/replaceOrigin.js
CHANGED
|
@@ -3,11 +3,17 @@ import { logger } from '../log/index.js';
|
|
|
3
3
|
import { pgDb } from './pg/client.js';
|
|
4
4
|
import { asTable, getTableForCollection } from './pg/map/registry.js';
|
|
5
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.
|
|
6
9
|
const hostnameCollections = [
|
|
7
10
|
'configs',
|
|
8
11
|
'entries',
|
|
12
|
+
'groups',
|
|
9
13
|
'jamEvents',
|
|
10
14
|
'mediaAttachments',
|
|
15
|
+
'posts',
|
|
16
|
+
'profileSettings',
|
|
11
17
|
'profiles',
|
|
12
18
|
];
|
|
13
19
|
const absoluteHttpUrlPattern = /https?:\/\/[^\s"'<>`]+/g;
|
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
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;
|
|
@@ -31,6 +33,8 @@ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileW
|
|
|
31
33
|
id?: string;
|
|
32
34
|
}) => Promise<import("../db/pg/map").WithId<{
|
|
33
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;
|
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
|
}>;
|
package/dist/jams/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jamRoomName, postIdFromJamRoomName, uniquePostsById, } from '@openpeepshq/common/lib';
|
|
2
|
+
import { listParticipantIds, reclaimOrphanJamRoom, roomService, stopRecording, stopRtmpStream, } from './livekit.js';
|
|
2
3
|
import { jamStateCache, LIVE_JAMS_CACHE_KEY, liveJamPostsCache } from './cache.js';
|
|
3
4
|
import { localInstanceDomain, parseRoomInstanceDomain } from './helpers.js';
|
|
4
5
|
import { findPost } from '../posts/index.js';
|
|
@@ -8,7 +9,8 @@ import { uuidv7 } from 'uuidv7';
|
|
|
8
9
|
import { canReadPost } from '../posts/helpers/index.js';
|
|
9
10
|
import { capabilitiesConfig } from '../config/index.js';
|
|
10
11
|
export { createJamToken, createJamEgressToken } from './token.js';
|
|
11
|
-
export { startRecording, stopRecording, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit.js';
|
|
12
|
+
export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit.js';
|
|
13
|
+
export { rtmpStreamOutput } from './rtmp.js';
|
|
12
14
|
export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs.js';
|
|
13
15
|
export * from './waitingRoom.js';
|
|
14
16
|
export * from './mutations.js';
|
|
@@ -44,9 +46,10 @@ const fetchLiveJamPosts = async () => {
|
|
|
44
46
|
if (localDomain && roomDomain && roomDomain !== localDomain) {
|
|
45
47
|
return undefined;
|
|
46
48
|
}
|
|
49
|
+
const postId = postIdFromJamRoomName(room.name);
|
|
47
50
|
// Fast path: Room.numParticipants includes hidden egress — 0 means truly empty.
|
|
48
51
|
if (!room.numParticipants) {
|
|
49
|
-
const post = await findPost(
|
|
52
|
+
const post = await findPost(postId);
|
|
50
53
|
if (post) {
|
|
51
54
|
reclaimLocalOrphan(post);
|
|
52
55
|
}
|
|
@@ -59,7 +62,7 @@ const fetchLiveJamPosts = async () => {
|
|
|
59
62
|
// egress-only ghosts from real live jams.
|
|
60
63
|
const humans = await listParticipantIds(room.name);
|
|
61
64
|
if (humans.length === 0) {
|
|
62
|
-
const post = await findPost(
|
|
65
|
+
const post = await findPost(postId);
|
|
63
66
|
if (post) {
|
|
64
67
|
reclaimLocalOrphan(post);
|
|
65
68
|
}
|
|
@@ -68,9 +71,9 @@ const fetchLiveJamPosts = async () => {
|
|
|
68
71
|
}
|
|
69
72
|
return undefined;
|
|
70
73
|
}
|
|
71
|
-
return findPost(
|
|
74
|
+
return findPost(postId);
|
|
72
75
|
}));
|
|
73
|
-
return posts
|
|
76
|
+
return uniquePostsById(posts);
|
|
74
77
|
};
|
|
75
78
|
export const listLiveJams = async (authData) => {
|
|
76
79
|
const [posts, config] = await Promise.all([
|
|
@@ -80,31 +83,35 @@ export const listLiveJams = async (authData) => {
|
|
|
80
83
|
return posts.filter(canReadPost(config, authData));
|
|
81
84
|
};
|
|
82
85
|
export const findJamEvent = async (id) => findPost(id).then((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) === null || _b === void 0 ? void 0 : _b.jam) ? post : undefined; });
|
|
83
|
-
export const closeJam = async (profile, jamEvent) => {
|
|
86
|
+
export const closeJam = async (profile, jamEvent, recurrenceId) => {
|
|
84
87
|
const rs = await roomService();
|
|
85
88
|
if (rs === undefined) {
|
|
86
89
|
return undefined;
|
|
87
90
|
}
|
|
88
|
-
await stopRecording(jamEvent);
|
|
89
|
-
|
|
91
|
+
await stopRecording(jamEvent, recurrenceId);
|
|
92
|
+
await stopRtmpStream(jamEvent);
|
|
93
|
+
return rs
|
|
94
|
+
.deleteRoom(jamRoomName(jamEvent.id, recurrenceId))
|
|
95
|
+
.then(async () => {
|
|
90
96
|
await Promise.all([
|
|
91
|
-
invalidateJamCaches(jamEvent.id),
|
|
92
|
-
clearJamAdmittance(jamEvent).catch(() => undefined),
|
|
97
|
+
invalidateJamCaches(jamRoomName(jamEvent.id, recurrenceId)),
|
|
98
|
+
clearJamAdmittance(jamEvent, recurrenceId).catch(() => undefined),
|
|
93
99
|
]);
|
|
94
100
|
return createJamEvent({
|
|
95
101
|
id: uuidv7(),
|
|
96
102
|
jamId: jamEvent.id,
|
|
97
103
|
type: 'close',
|
|
98
104
|
profileId: profile.id,
|
|
105
|
+
recurrenceId,
|
|
99
106
|
});
|
|
100
107
|
});
|
|
101
108
|
};
|
|
102
|
-
export const muteParticipant = async (jamId, data) => {
|
|
109
|
+
export const muteParticipant = async (jamId, data, recurrenceId) => {
|
|
103
110
|
const rs = await roomService();
|
|
104
111
|
if (rs === undefined) {
|
|
105
112
|
return { success: false };
|
|
106
113
|
}
|
|
107
|
-
const result = await rs.mutePublishedTrack(jamId, data.identity, data.trackSid, true);
|
|
114
|
+
const result = await rs.mutePublishedTrack(jamRoomName(jamId, recurrenceId), data.identity, data.trackSid, true);
|
|
108
115
|
if (!result) {
|
|
109
116
|
return { success: false };
|
|
110
117
|
}
|
package/dist/jams/livekit.d.ts
CHANGED
|
@@ -7,18 +7,56 @@ export declare const JAM_ROOM_DEPARTURE_TIMEOUT_SEC = 60;
|
|
|
7
7
|
export declare const roomService: () => Promise<RoomServiceClient | undefined>;
|
|
8
8
|
export declare const listParticipantIds: (jamId: string) => Promise<string[]>;
|
|
9
9
|
/**
|
|
10
|
-
* Relative path for the observer view (full jam UI). Used
|
|
11
|
-
* moderator observer links
|
|
10
|
+
* Relative path for the observer view (full jam UI). Used for human
|
|
11
|
+
* moderator observer links, jam recording web egress, and RTMP web egress.
|
|
12
12
|
*/
|
|
13
|
-
export declare const getJamObserverPath: (jamId: string) => Promise<string>;
|
|
14
|
-
export declare const getJamRecordingUrl: (jamId: string) => Promise<string>;
|
|
15
|
-
export declare const startRecording: (profile: ProfileWithMeta, jamPost: PostWithMeta) => Promise<JamRecording>;
|
|
13
|
+
export declare const getJamObserverPath: (jamId: string, recurrenceId?: string) => Promise<string>;
|
|
14
|
+
export declare const getJamRecordingUrl: (jamId: string, recurrenceId?: string) => Promise<string>;
|
|
15
|
+
export declare const startRecording: (profile: ProfileWithMeta, jamPost: PostWithMeta, recurrenceId?: string) => Promise<JamRecording>;
|
|
16
|
+
export declare const startRtmpStream: (profile: ProfileWithMeta, jamPost: PostWithMeta, rtmpUrl: string, destinationHost?: string) => Promise<JamRecording>;
|
|
17
|
+
export declare const stopRtmpStream: (jamPost: PostWithMeta) => Promise<{
|
|
18
|
+
status: "completed";
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
deletedAt?: string | null | undefined;
|
|
22
|
+
kind?: "file" | "rtmp" | undefined;
|
|
23
|
+
destinationHost?: string | undefined;
|
|
24
|
+
egressId?: string | undefined;
|
|
25
|
+
attachment?: {
|
|
26
|
+
type: string;
|
|
27
|
+
url: string;
|
|
28
|
+
previewUrl: string | null;
|
|
29
|
+
textUrl: null;
|
|
30
|
+
filename: string;
|
|
31
|
+
meta: {
|
|
32
|
+
usage?: string | undefined;
|
|
33
|
+
focus?: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
} | undefined;
|
|
37
|
+
mimetype?: string | undefined;
|
|
38
|
+
size?: number | undefined;
|
|
39
|
+
};
|
|
40
|
+
id: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
blurhash?: string | undefined;
|
|
45
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
46
|
+
error?: string | undefined;
|
|
47
|
+
deletedAt?: string | null | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
replyPostId?: string | undefined;
|
|
50
|
+
id: string;
|
|
51
|
+
profile: ProfileWithMeta;
|
|
52
|
+
post: PostWithMeta;
|
|
53
|
+
} | undefined>;
|
|
16
54
|
export declare const stopEgress: (egressId: string) => Promise<void>;
|
|
17
|
-
export declare const stopRecording: (jamPost: PostWithMeta) => Promise<JamRecordingWithMeta | undefined>;
|
|
55
|
+
export declare const stopRecording: (jamPost: PostWithMeta, recurrenceId?: string) => Promise<JamRecordingWithMeta | undefined>;
|
|
18
56
|
/**
|
|
19
57
|
* Stops leftover egress and deletes a LiveKit room that has no human
|
|
20
58
|
* participants (egress-only / orphan rooms). Safe to call repeatedly.
|
|
21
59
|
*/
|
|
22
|
-
export declare const reclaimOrphanJamRoom: (jam: PostWithMeta) => Promise<void>;
|
|
60
|
+
export declare const reclaimOrphanJamRoom: (jam: PostWithMeta, roomName?: string) => Promise<void>;
|
|
23
61
|
export declare const finishRecording: (jamRecording: JamRecordingWithMeta) => Promise<void>;
|
|
24
|
-
export declare const jamState: (jam: PostWithMeta, hideParticipants?: boolean) => Promise<JamState>;
|
|
62
|
+
export declare const jamState: (jam: PostWithMeta, hideParticipants?: boolean, recurrenceId?: string) => Promise<JamState>;
|