@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.
Files changed (167) hide show
  1. package/dist/accessTokens/helpers.d.ts +2 -2
  2. package/dist/accessTokens/tokens.js +14 -7
  3. package/dist/accounts/mutations.d.ts +2 -2
  4. package/dist/analytics/cache.js +12 -7
  5. package/dist/analytics/clicks.d.ts +20 -0
  6. package/dist/analytics/clicks.js +194 -0
  7. package/dist/analytics/index.d.ts +1 -0
  8. package/dist/analytics/index.js +1 -0
  9. package/dist/analytics/metrics.d.ts +1 -0
  10. package/dist/analytics/metrics.js +5 -0
  11. package/dist/analytics/pdfReport.d.ts +1 -0
  12. package/dist/analytics/pdfReport.js +7 -5
  13. package/dist/analytics/privacy.d.ts +18 -0
  14. package/dist/analytics/privacy.js +10 -0
  15. package/dist/analytics/read.js +74 -16
  16. package/dist/analytics/report.d.ts +32 -1
  17. package/dist/analytics/report.js +9 -2
  18. package/dist/backups/index.js +13 -5
  19. package/dist/backups/metadata.d.ts +7 -0
  20. package/dist/config/defaults/community.js +0 -6
  21. package/dist/config/defaults/core.js +1 -0
  22. package/dist/config/defaults/db.d.ts +0 -2
  23. package/dist/config/defaults/db.js +0 -2
  24. package/dist/config/index.d.ts +20 -9
  25. package/dist/db/helpers.d.ts +6 -28
  26. package/dist/db/helpers.js +19 -149
  27. package/dist/db/index.d.ts +2 -0
  28. package/dist/db/index.js +4 -0
  29. package/dist/db/init.js +3 -2
  30. package/dist/db/migration/detect.d.ts +0 -3
  31. package/dist/db/migration/detect.js +0 -54
  32. package/dist/db/migration/importCollections.d.ts +1 -1
  33. package/dist/db/migration/importCollections.js +22 -6
  34. package/dist/db/migration/shared.d.ts +0 -4
  35. package/dist/db/migration/shared.js +0 -7
  36. package/dist/db/migration/transform.d.ts +2 -0
  37. package/dist/db/migration/transform.js +23 -0
  38. package/dist/db/pg/client.js +4 -0
  39. package/dist/db/pg/filters/edges.d.ts +1 -1
  40. package/dist/db/pg/filters/edges.js +1 -1
  41. package/dist/db/pg/filters/posts.d.ts +1 -0
  42. package/dist/db/pg/filters/posts.js +11 -1
  43. package/dist/db/pg/map/filters.js +5 -0
  44. package/dist/db/pg/map/relations.d.ts +1 -1
  45. package/dist/db/pg/map/relations.js +89 -41
  46. package/dist/db/pg/migrate.d.ts +23 -0
  47. package/dist/db/pg/migrate.js +87 -1
  48. package/dist/db/pg/queries/derived.d.ts +5 -0
  49. package/dist/db/pg/queries/derived.js +21 -0
  50. package/dist/db/pg/schema/analytics.d.ts +76 -0
  51. package/dist/db/pg/schema/analytics.js +11 -1
  52. package/dist/db/pg/schema/documents.d.ts +143 -0
  53. package/dist/db/pg/schema/documents.js +22 -1
  54. package/dist/db/pg/schema/edges.d.ts +1 -0
  55. package/dist/db/pg/schema/edges.js +1 -0
  56. package/dist/db/pg/schema/index.d.ts +218 -0
  57. package/dist/db/pg/sql/0005_open_power_man.sql +9 -0
  58. package/dist/db/pg/sql/0006_fine_trish_tilby.sql +8 -0
  59. package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
  60. package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
  61. package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
  62. package/dist/db/pg/sql/meta/0004_snapshot.json +1 -1
  63. package/dist/db/pg/sql/meta/0005_snapshot.json +4179 -0
  64. package/dist/db/pg/sql/meta/0006_snapshot.json +4200 -0
  65. package/dist/db/pg/sql/meta/0007_snapshot.json +4179 -0
  66. package/dist/db/pg/sql/meta/0009_snapshot.json +4299 -0
  67. package/dist/db/pg/sql/meta/_journal.json +35 -0
  68. package/dist/db/replaceOrigin.d.ts +11 -0
  69. package/dist/db/replaceOrigin.js +116 -0
  70. package/dist/db/types.d.ts +0 -4
  71. package/dist/events/index.d.ts +2 -1
  72. package/dist/events/index.js +54 -33
  73. package/dist/groups/finders.d.ts +2 -2
  74. package/dist/groups/helpers.d.ts +6 -6
  75. package/dist/groups/mapping.d.ts +4 -4
  76. package/dist/groups/mapping.js +2 -2
  77. package/dist/groups/mutations.js +1 -1
  78. package/dist/inviteLinks/helpers.d.ts +4 -4
  79. package/dist/jams/cache.d.ts +1 -1
  80. package/dist/jams/cache.js +2 -1
  81. package/dist/jams/finders.d.ts +2 -1
  82. package/dist/jams/finders.js +18 -7
  83. package/dist/jams/helpers.d.ts +8 -4
  84. package/dist/jams/index.d.ts +4 -3
  85. package/dist/jams/index.js +23 -12
  86. package/dist/jams/livekit.d.ts +46 -8
  87. package/dist/jams/livekit.js +103 -21
  88. package/dist/jams/mapping.d.ts +14 -4
  89. package/dist/jams/mutations.d.ts +2 -0
  90. package/dist/jams/rtmp.d.ts +5 -0
  91. package/dist/jams/rtmp.js +8 -0
  92. package/dist/jams/token.d.ts +3 -3
  93. package/dist/jams/token.js +15 -12
  94. package/dist/jams/waitingRoom.d.ts +6 -4
  95. package/dist/jams/waitingRoom.js +33 -24
  96. package/dist/migration/index.d.ts +4 -0
  97. package/dist/migration/index.js +4 -0
  98. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
  99. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
  100. package/dist/notifications/helpers.js +6 -2
  101. package/dist/notifications/jobs.js +13 -2
  102. package/dist/notifications/push.js +11 -4
  103. package/dist/plugins/helpers.d.ts +6 -2
  104. package/dist/plugins/helpers.js +22 -10
  105. package/dist/plugins/index.d.ts +6 -1
  106. package/dist/plugins/index.js +54 -13
  107. package/dist/plugins/install.d.ts +20 -0
  108. package/dist/plugins/install.js +223 -0
  109. package/dist/plugins/state.d.ts +4 -0
  110. package/dist/plugins/state.js +29 -0
  111. package/dist/posts/contextClosure.d.ts +2 -1
  112. package/dist/posts/contextClosure.js +6 -1
  113. package/dist/posts/conversationQueries.d.ts +23 -0
  114. package/dist/posts/conversationQueries.js +135 -0
  115. package/dist/posts/eventAgenda.d.ts +165 -0
  116. package/dist/posts/eventAgenda.js +120 -0
  117. package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
  118. package/dist/posts/eventOccurrenceJobs.js +23 -0
  119. package/dist/posts/eventOccurrences.d.ts +4 -0
  120. package/dist/posts/eventOccurrences.js +40 -0
  121. package/dist/posts/finders.d.ts +39 -13
  122. package/dist/posts/finders.js +51 -66
  123. package/dist/posts/helpers/filters.js +1 -1
  124. package/dist/posts/helpers/index.d.ts +120 -34
  125. package/dist/posts/helpers/index.js +34 -21
  126. package/dist/posts/index.d.ts +4 -0
  127. package/dist/posts/index.js +4 -0
  128. package/dist/posts/mapping.d.ts +454 -0
  129. package/dist/posts/mapping.js +43 -9
  130. package/dist/posts/mutations.d.ts +4 -2
  131. package/dist/posts/mutations.js +49 -16
  132. package/dist/posts/rsvpConfirmationEmail.js +2 -1
  133. package/dist/posts/unseenCounts.d.ts +12 -0
  134. package/dist/posts/unseenCounts.js +98 -0
  135. package/dist/profiles/cache.d.ts +5 -1
  136. package/dist/profiles/cache.js +27 -1
  137. package/dist/profiles/helpers.d.ts +5 -5
  138. package/dist/profiles/index.d.ts +1 -0
  139. package/dist/profiles/index.js +1 -0
  140. package/dist/profiles/mapping.d.ts +45 -4
  141. package/dist/profiles/mapping.js +24 -0
  142. package/dist/profiles/mutations.js +12 -14
  143. package/dist/pushSubscriptions/helpers.d.ts +2 -2
  144. package/dist/pushSubscriptions/mutations.js +13 -1
  145. package/dist/reports/helpers.d.ts +6 -6
  146. package/dist/reports/helpers.js +2 -1
  147. package/dist/reports/mapping.js +6 -2
  148. package/dist/roles/defaults.js +1 -0
  149. package/dist/roles/mutations.d.ts +3 -3
  150. package/dist/roles/mutations.js +5 -3
  151. package/dist/server/index.d.ts +15 -7
  152. package/dist/server/index.js +15 -8
  153. package/dist/session/index.d.ts +28 -0
  154. package/dist/session/index.js +79 -0
  155. package/dist/stats/finders.d.ts +1912 -362
  156. package/dist/stats/mapping.d.ts +26 -5
  157. package/package.json +7 -12
  158. package/dist/db/arango.d.ts +0 -2
  159. package/dist/db/arango.js +0 -110
  160. package/dist/db/migration/autoMigrate.d.ts +0 -2
  161. package/dist/db/migration/autoMigrate.js +0 -111
  162. package/dist/db/migration/cli.d.ts +0 -1
  163. package/dist/db/migration/cli.js +0 -56
  164. package/dist/db/migration/exportArango.d.ts +0 -4
  165. package/dist/db/migration/exportArango.js +0 -80
  166. package/dist/db/replaceHostname.d.ts +0 -1
  167. 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
+ };
@@ -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
  }
@@ -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) => void;
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';
@@ -29,38 +29,59 @@ const publishConnection = async () => {
29
29
  connectionPromise = getConnection();
30
30
  return connectionPromise;
31
31
  };
32
- const baseHub = (prefix) => ({
33
- /**
34
- * Fan-out must not fail the caller (register/react/etc.). Redis publish and
35
- * the BullMQ once-queue are best-effort side channels.
36
- */
37
- emit: async (eventType, ...eventArgs) => {
38
- const qualifiedEventType = `${prefix}:${eventType}`;
39
- try {
40
- const conn = await publishConnection();
41
- await conn.publish(qualifiedEventType, JSON.stringify(eventArgs));
42
- log.info({ qualifiedEventType }, 'hub event published');
43
- }
44
- catch (err) {
45
- log.error({ qualifiedEventType, err }, 'hub publish failed');
46
- }
47
- try {
48
- await onceQueue().add(qualifiedEventType, eventArgs);
49
- }
50
- catch (err) {
51
- log.error({ qualifiedEventType, err }, 'hub once-queue enqueue failed');
52
- }
53
- },
54
- on: (eventType, handler) => {
55
- // Subscriber mode requires a dedicated connection (not the publisher).
56
- getConnection().then((conn) => conn.subscribe(`${prefix}:${eventType}`, (message) => {
57
- const args = JSON.parse(message);
58
- handler(...args);
59
- }));
60
- },
61
- once: (eventType, handler) => {
62
- registerOnceHandler(`${prefix}:${eventType}`, handler);
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';
@@ -72,7 +72,7 @@ export declare const listAdminGroups: () => Promise<{
72
72
  createdAt: string;
73
73
  updatedAt: string;
74
74
  postsCount: number;
75
- admins: {
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" | "*" | "jam" | "webhooks" | "analytics" | "render";
110
+ type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
111
111
  id?: string | undefined;
112
112
  } | undefined;
113
113
  } | undefined;
@@ -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" | "moderator" | "invited")[] | null | undefined;
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?: ("member" | "moderator" | "admin" | "local" | "none" | "invited")[] | null | undefined;
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?: ("member" | "moderator" | "admin" | "local" | "none" | "invited")[] | null | undefined;
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" | "moderator" | "invited")[] | null | undefined;
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" | "moderator" | "invited")[] | null | undefined;
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?: ("member" | "moderator" | "admin" | "local" | "none" | "invited")[] | null | undefined;
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;
@@ -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
- admins: {
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" | "*" | "jam" | "webhooks" | "analytics" | "render";
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
- admins: {
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" | "*" | "jam" | "webhooks" | "analytics" | "render";
173
+ type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
174
174
  id?: string | undefined;
175
175
  } | undefined;
176
176
  } | undefined;
@@ -30,12 +30,12 @@ export const adminGroupsMapping = map({
30
30
  relations: [
31
31
  ...groupRelations,
32
32
  {
33
- alias: 'admins',
33
+ alias: 'owners',
34
34
  edgeCollection: 'userGroups',
35
35
  direction: 'INBOUND',
36
36
  skipEdge: true,
37
37
  cardinality: 'many',
38
- edgeFilter: edgeFilters.groupAdminRole(),
38
+ edgeFilter: edgeFilters.groupOwnerRole(),
39
39
  mapping: {
40
40
  collection: 'profiles',
41
41
  softDelete: true,
@@ -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: ['admin'],
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
  }>>;
@@ -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
  }>;
@@ -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({
@@ -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[]>;
@@ -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) => allpeepDb()
18
- .then(({ db }) => sortNewestFirst(jamRecordingsMapping.filter({
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
- })).first(db))
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.map((recording) => jamRecordingSchema.parse(recording)));
33
+ .then((recordings) => recordings
34
+ .filter(isFileJamRecording)
35
+ .map((recording) => jamRecordingSchema.parse(recording)));
@@ -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: "active" | "completed" | "failed" | "requested";
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?: "ready" | "failed" | "processing" | undefined;
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: "active" | "completed" | "failed" | "requested";
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?: "ready" | "failed" | "processing" | undefined;
59
+ status?: "failed" | "processing" | "ready" | undefined;
56
60
  error?: string | undefined;
57
61
  deletedAt?: string | null | undefined;
58
62
  } | undefined;
@@ -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
  }>;