@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.
Files changed (136) 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/pdfReport.d.ts +1 -0
  6. package/dist/analytics/pdfReport.js +5 -4
  7. package/dist/analytics/privacy.d.ts +18 -0
  8. package/dist/analytics/privacy.js +10 -0
  9. package/dist/analytics/read.js +24 -11
  10. package/dist/analytics/report.d.ts +1 -1
  11. package/dist/analytics/report.js +9 -2
  12. package/dist/backups/index.js +6 -3
  13. package/dist/backups/metadata.d.ts +7 -0
  14. package/dist/config/defaults/community.js +0 -6
  15. package/dist/config/defaults/db.d.ts +0 -2
  16. package/dist/config/defaults/db.js +0 -2
  17. package/dist/config/index.d.ts +10 -9
  18. package/dist/db/helpers.d.ts +6 -28
  19. package/dist/db/helpers.js +19 -149
  20. package/dist/db/index.d.ts +2 -0
  21. package/dist/db/index.js +4 -0
  22. package/dist/db/init.js +3 -2
  23. package/dist/db/migration/detect.d.ts +0 -3
  24. package/dist/db/migration/detect.js +0 -54
  25. package/dist/db/migration/importCollections.d.ts +1 -1
  26. package/dist/db/migration/importCollections.js +22 -6
  27. package/dist/db/migration/shared.d.ts +0 -4
  28. package/dist/db/migration/shared.js +0 -7
  29. package/dist/db/migration/transform.d.ts +2 -0
  30. package/dist/db/migration/transform.js +23 -0
  31. package/dist/db/pg/client.js +4 -0
  32. package/dist/db/pg/filters/edges.d.ts +1 -1
  33. package/dist/db/pg/filters/edges.js +1 -1
  34. package/dist/db/pg/filters/posts.d.ts +1 -0
  35. package/dist/db/pg/filters/posts.js +11 -1
  36. package/dist/db/pg/map/filters.js +5 -0
  37. package/dist/db/pg/map/relations.d.ts +1 -1
  38. package/dist/db/pg/map/relations.js +89 -41
  39. package/dist/db/pg/migrate.d.ts +23 -0
  40. package/dist/db/pg/migrate.js +87 -1
  41. package/dist/db/pg/schema/documents.d.ts +143 -0
  42. package/dist/db/pg/schema/documents.js +22 -1
  43. package/dist/db/pg/schema/edges.d.ts +1 -0
  44. package/dist/db/pg/schema/edges.js +2 -1
  45. package/dist/db/pg/schema/index.d.ts +143 -0
  46. package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
  47. package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
  48. package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
  49. package/dist/db/pg/sql/meta/0007_snapshot.json +4179 -0
  50. package/dist/db/pg/sql/meta/0009_snapshot.json +4299 -0
  51. package/dist/db/pg/sql/meta/_journal.json +21 -0
  52. package/dist/db/replaceOrigin.js +6 -0
  53. package/dist/db/types.d.ts +0 -4
  54. package/dist/events/index.d.ts +2 -1
  55. package/dist/events/index.js +54 -33
  56. package/dist/groups/finders.d.ts +2 -2
  57. package/dist/groups/helpers.d.ts +6 -6
  58. package/dist/groups/mapping.d.ts +4 -4
  59. package/dist/groups/mapping.js +2 -2
  60. package/dist/groups/mutations.js +1 -1
  61. package/dist/inviteLinks/helpers.d.ts +4 -4
  62. package/dist/jams/cache.d.ts +1 -1
  63. package/dist/jams/cache.js +2 -1
  64. package/dist/jams/finders.d.ts +2 -1
  65. package/dist/jams/finders.js +18 -7
  66. package/dist/jams/helpers.d.ts +4 -0
  67. package/dist/jams/index.d.ts +4 -3
  68. package/dist/jams/index.js +20 -13
  69. package/dist/jams/livekit.d.ts +46 -8
  70. package/dist/jams/livekit.js +103 -21
  71. package/dist/jams/mapping.d.ts +14 -4
  72. package/dist/jams/mutations.d.ts +2 -0
  73. package/dist/jams/rtmp.d.ts +5 -0
  74. package/dist/jams/rtmp.js +8 -0
  75. package/dist/jams/token.d.ts +3 -3
  76. package/dist/jams/token.js +15 -12
  77. package/dist/jams/waitingRoom.d.ts +6 -6
  78. package/dist/jams/waitingRoom.js +24 -23
  79. package/dist/migration/index.d.ts +4 -0
  80. package/dist/migration/index.js +4 -0
  81. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
  82. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
  83. package/dist/notifications/helpers.js +6 -2
  84. package/dist/notifications/push.js +11 -4
  85. package/dist/plugins/helpers.d.ts +1 -0
  86. package/dist/plugins/helpers.js +1 -8
  87. package/dist/plugins/index.d.ts +5 -0
  88. package/dist/plugins/index.js +41 -4
  89. package/dist/plugins/install.d.ts +20 -0
  90. package/dist/plugins/install.js +223 -0
  91. package/dist/plugins/state.d.ts +4 -0
  92. package/dist/plugins/state.js +29 -0
  93. package/dist/posts/eventAgenda.d.ts +165 -0
  94. package/dist/posts/eventAgenda.js +120 -0
  95. package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
  96. package/dist/posts/eventOccurrenceJobs.js +23 -0
  97. package/dist/posts/eventOccurrences.d.ts +4 -0
  98. package/dist/posts/eventOccurrences.js +40 -0
  99. package/dist/posts/finders.d.ts +32 -8
  100. package/dist/posts/finders.js +27 -45
  101. package/dist/posts/helpers/filters.js +1 -1
  102. package/dist/posts/helpers/index.d.ts +102 -16
  103. package/dist/posts/helpers/index.js +33 -20
  104. package/dist/posts/index.d.ts +3 -0
  105. package/dist/posts/index.js +3 -0
  106. package/dist/posts/mapping.d.ts +275 -0
  107. package/dist/posts/mapping.js +37 -3
  108. package/dist/posts/mutations.d.ts +1 -1
  109. package/dist/posts/mutations.js +29 -18
  110. package/dist/posts/rsvpConfirmationEmail.js +2 -1
  111. package/dist/posts/unseenCounts.d.ts +2 -0
  112. package/dist/posts/unseenCounts.js +25 -8
  113. package/dist/profiles/cache.d.ts +3 -1
  114. package/dist/profiles/cache.js +9 -1
  115. package/dist/profiles/helpers.d.ts +5 -5
  116. package/dist/profiles/index.d.ts +1 -1
  117. package/dist/profiles/index.js +1 -1
  118. package/dist/profiles/mapping.d.ts +5 -5
  119. package/dist/profiles/mutations.js +12 -14
  120. package/dist/pushSubscriptions/helpers.d.ts +2 -2
  121. package/dist/pushSubscriptions/mutations.js +13 -1
  122. package/dist/reports/helpers.d.ts +6 -6
  123. package/dist/roles/defaults.js +1 -0
  124. package/dist/server/index.d.ts +7 -7
  125. package/dist/server/index.js +15 -8
  126. package/dist/stats/finders.d.ts +1692 -142
  127. package/dist/stats/mapping.d.ts +21 -0
  128. package/package.json +4 -9
  129. package/dist/db/arango.d.ts +0 -2
  130. package/dist/db/arango.js +0 -110
  131. package/dist/db/migration/autoMigrate.d.ts +0 -2
  132. package/dist/db/migration/autoMigrate.js +0 -111
  133. package/dist/db/migration/cli.d.ts +0 -1
  134. package/dist/db/migration/cli.js +0 -56
  135. package/dist/db/migration/exportArango.d.ts +0 -4
  136. package/dist/db/migration/exportArango.js +0 -80
@@ -0,0 +1,120 @@
1
+ import { and, asc, desc, eq, gt, gte, isNotNull, isNull, lte, or, sql, } from 'drizzle-orm';
2
+ import { canReadPost } from './helpers/filters.js';
3
+ import { transformPost } from './helpers/index.js';
4
+ import { allpeepDb } from '../db/index.js';
5
+ import { capabilitiesConfig } from '../config/index.js';
6
+ import { normalizeComputedDatetime } from '../db/pg/mappers.js';
7
+ import { eventOccurrences, posts } from '../db/pg/schema/index.js';
8
+ import { postGroups } from '../db/pg/schema/edges.js';
9
+ import { postHasYesOrMaybeRsvpExpr } from '../db/pg/queries/index.js';
10
+ import { postFilters } from '../db/pg/filters/index.js';
11
+ import { fetchRowsByIds, hydrateMapData } from '../db/pg/map/relations.js';
12
+ import { postsMappingForProfile } from './mapping.js';
13
+ const occurrenceTimeFilter = (window, now) => {
14
+ const start = eventOccurrences.start;
15
+ const end = eventOccurrences.end;
16
+ if (window === 'upcoming') {
17
+ return or(gt(start, now), and(isNotNull(end), gt(end, now)));
18
+ }
19
+ if (window === 'current') {
20
+ return and(lte(start, now), or(isNull(end), gte(end, now)));
21
+ }
22
+ return sql `COALESCE(${end}, ${start}) < ${now}`;
23
+ };
24
+ const eventAgendaConditions = ({ window, now, jamOnly, mine, groupId, profileId, }) => {
25
+ const conditions = [
26
+ isNull(posts.deletedAt),
27
+ eq(posts.type, 'event'),
28
+ eq(eventOccurrences.cancelled, false),
29
+ occurrenceTimeFilter(window, now),
30
+ ];
31
+ if (jamOnly) {
32
+ conditions.push(isNotNull(sql `${posts.body}->'jam'`));
33
+ }
34
+ if (mine && profileId) {
35
+ conditions.push(or(eq(posts.creatorId, profileId), postFilters.isJamModerator(profileId).where, postHasYesOrMaybeRsvpExpr(posts, profileId)));
36
+ }
37
+ if (groupId) {
38
+ conditions.push(sql `EXISTS (SELECT 1 FROM ${postGroups} WHERE ${postGroups.fromId} = ${posts.id}::text AND ${postGroups.toId} = ${groupId})`);
39
+ }
40
+ return conditions;
41
+ };
42
+ // One row per event: a daily series would otherwise fill the first page.
43
+ export const eventAgendaOccurrenceQuery = (db, args) => {
44
+ const pickOrder = args.window === 'past'
45
+ ? desc(eventOccurrences.start)
46
+ : asc(eventOccurrences.start);
47
+ const distinctOccurrences = db
48
+ .selectDistinctOn([eventOccurrences.postId], {
49
+ postId: eventOccurrences.postId,
50
+ recurrenceId: eventOccurrences.recurrenceId,
51
+ start: eventOccurrences.start,
52
+ end: eventOccurrences.end,
53
+ })
54
+ .from(eventOccurrences)
55
+ .innerJoin(posts, eq(posts.id, eventOccurrences.postId))
56
+ .where(and(...eventAgendaConditions(args)))
57
+ .orderBy(eventOccurrences.postId, pickOrder)
58
+ .as('event_agenda');
59
+ return db
60
+ .select({
61
+ postId: distinctOccurrences.postId,
62
+ recurrenceId: distinctOccurrences.recurrenceId,
63
+ start: distinctOccurrences.start,
64
+ end: distinctOccurrences.end,
65
+ })
66
+ .from(distinctOccurrences)
67
+ .orderBy(args.window === 'past'
68
+ ? desc(distinctOccurrences.start)
69
+ : asc(distinctOccurrences.start))
70
+ .limit(args.limit)
71
+ .offset(args.offset);
72
+ };
73
+ const loadPostsByIds = async (ids, authData) => {
74
+ if (ids.length === 0)
75
+ return new Map();
76
+ const profile = authData.profile;
77
+ const { db } = await allpeepDb();
78
+ const mapData = postsMappingForProfile(profile).data();
79
+ const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
80
+ const hydrated = (await hydrateMapData(db, mapData, rows));
81
+ const config = await capabilitiesConfig();
82
+ const readable = canReadPost(config, authData);
83
+ const entries = await Promise.all(hydrated.map(async (post) => {
84
+ const transformed = await transformPost(post, profile);
85
+ return readable(transformed) ? transformed : undefined;
86
+ }));
87
+ return new Map(entries
88
+ .filter((post) => !!post)
89
+ .map((post) => [post.id, post]));
90
+ };
91
+ export const listEventAgenda = async (authData, window, { offset = 0, limit = 100, jamOnly = false, mine = false, groupId, } = {}) => {
92
+ var _a;
93
+ const { db } = await allpeepDb();
94
+ const now = new Date().toISOString();
95
+ const rows = await eventAgendaOccurrenceQuery(db, {
96
+ window,
97
+ now,
98
+ offset,
99
+ limit,
100
+ jamOnly,
101
+ mine,
102
+ groupId,
103
+ profileId: (_a = authData.profile) === null || _a === void 0 ? void 0 : _a.id,
104
+ });
105
+ const postsById = await loadPostsByIds([...new Set(rows.map((row) => row.postId))], authData);
106
+ return rows.flatMap((row) => {
107
+ const post = postsById.get(row.postId);
108
+ if (!post)
109
+ return [];
110
+ const occurrenceRecurrenceId = normalizeComputedDatetime(row.recurrenceId);
111
+ const occurrenceStart = normalizeComputedDatetime(row.start);
112
+ const occurrenceEnd = normalizeComputedDatetime(row.end);
113
+ if (!occurrenceRecurrenceId || !occurrenceStart)
114
+ return [];
115
+ return [
116
+ Object.assign(Object.assign(Object.assign({}, post), { occurrenceRecurrenceId,
117
+ occurrenceStart }), (occurrenceEnd ? { occurrenceEnd } : {})),
118
+ ];
119
+ });
120
+ };
@@ -0,0 +1,4 @@
1
+ export declare const EVENT_OCCURRENCE_CRON = "0 4 * * *";
2
+ declare const eventOccurrenceQueue: () => import("bullmq").Queue, eventOccurrenceWorker: () => import("bullmq").Worker;
3
+ export declare const ensureEventOccurrenceSchedule: () => Promise<void>;
4
+ export { eventOccurrenceQueue, eventOccurrenceWorker };
@@ -0,0 +1,23 @@
1
+ import { queueAndWorker } from '../jobs/index.js';
2
+ import { logger } from '../log/index.js';
3
+ import { rebuildRecurringEventOccurrences } from './eventOccurrences.js';
4
+ const log = logger('app:posts:eventOccurrences');
5
+ const QUEUE_NAME = 'event-occurrences';
6
+ const SCHEDULER_ID = 'event-occurrences-daily';
7
+ const JOB_NAME = 'rebuild-recurring';
8
+ export const EVENT_OCCURRENCE_CRON = '0 4 * * *';
9
+ const [eventOccurrenceQueue, eventOccurrenceWorker] = queueAndWorker(QUEUE_NAME, async () => {
10
+ const rebuilt = await rebuildRecurringEventOccurrences();
11
+ log.info(`Rebuilt occurrence index for ${rebuilt} recurring events`);
12
+ }, {
13
+ defaultJobOptions: {
14
+ removeOnComplete: { count: 10 },
15
+ removeOnFail: { age: 86400 * 14, count: 50 },
16
+ },
17
+ });
18
+ export const ensureEventOccurrenceSchedule = async () => {
19
+ const queue = eventOccurrenceQueue();
20
+ await queue.upsertJobScheduler(SCHEDULER_ID, { pattern: EVENT_OCCURRENCE_CRON }, { name: JOB_NAME, data: { type: 'rebuild' } });
21
+ log.info(`Event occurrence schedule registered: cron="${EVENT_OCCURRENCE_CRON}"`);
22
+ };
23
+ export { eventOccurrenceQueue, eventOccurrenceWorker };
@@ -0,0 +1,4 @@
1
+ import type { Event } from '@openpeepshq/common/types';
2
+ export declare const rebuildEventOccurrences: (postId: string, event: Event) => Promise<void>;
3
+ export declare const clearEventOccurrences: (postId: string) => Promise<void>;
4
+ export declare const rebuildRecurringEventOccurrences: () => Promise<number>;
@@ -0,0 +1,40 @@
1
+ import { and, eq, isNotNull, isNull, sql } from 'drizzle-orm';
2
+ import { uuidv7 } from 'uuidv7';
3
+ import { occurrencesForIndex } from '@openpeepshq/common/lib';
4
+ import { database } from '../db/index.js';
5
+ import { eventOccurrences, posts } from '../db/pg/schema/index.js';
6
+ export const rebuildEventOccurrences = async (postId, event) => {
7
+ const db = await database();
8
+ await db.delete(eventOccurrences).where(eq(eventOccurrences.postId, postId));
9
+ const rows = occurrencesForIndex(event);
10
+ if (rows.length === 0)
11
+ return;
12
+ await db.insert(eventOccurrences).values(rows.map((row) => ({
13
+ id: uuidv7(),
14
+ postId,
15
+ recurrenceId: row.recurrenceId,
16
+ start: row.start,
17
+ end: row.end,
18
+ cancelled: row.cancelled,
19
+ })));
20
+ };
21
+ export const clearEventOccurrences = async (postId) => {
22
+ const db = await database();
23
+ await db.delete(eventOccurrences).where(eq(eventOccurrences.postId, postId));
24
+ };
25
+ export const rebuildRecurringEventOccurrences = async () => {
26
+ const db = await database();
27
+ const rows = await db
28
+ .select({ id: posts.id, body: posts.body })
29
+ .from(posts)
30
+ .where(and(eq(posts.type, 'event'), isNull(posts.deletedAt), isNotNull(sql `${posts.body}->'recurrence'`)));
31
+ let rebuilt = 0;
32
+ for (const row of rows) {
33
+ const event = row.body;
34
+ if ((event === null || event === void 0 ? void 0 : event.type) !== 'event' || !event.start)
35
+ continue;
36
+ await rebuildEventOccurrences(row.id, event);
37
+ rebuilt += 1;
38
+ }
39
+ return rebuilt;
40
+ };
@@ -158,6 +158,27 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
158
158
  } | undefined;
159
159
  } | undefined;
160
160
  url?: string | undefined;
161
+ recurrence?: {
162
+ freq: "DAILY" | "WEEKLY" | "MONTHLY";
163
+ interval?: number | undefined;
164
+ byDay?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[] | undefined;
165
+ until?: string | undefined;
166
+ count?: number | undefined;
167
+ } | undefined;
168
+ exceptions?: {
169
+ recurrenceId: string;
170
+ cancelled?: boolean | undefined;
171
+ start?: string | undefined;
172
+ end?: string | undefined;
173
+ physicalLocation?: {
174
+ text: string;
175
+ coordinates?: {
176
+ lat: number;
177
+ lng: number;
178
+ alt?: number | undefined;
179
+ } | undefined;
180
+ } | undefined;
181
+ }[] | undefined;
161
182
  } | {
162
183
  type: "article";
163
184
  content?: string | undefined;
@@ -237,20 +258,23 @@ export declare const listMyFeed: (authData: AuthorizationData, { start, limit }?
237
258
  start?: string;
238
259
  limit?: number;
239
260
  }) => Promise<PostWithMeta[]>;
240
- export declare const listUpcomingEventsFeed: (authData: AuthorizationData, { offset, limit, filter, }?: {
261
+ export declare const listUpcomingEventsFeed: (authData: AuthorizationData, { offset, limit, jamOnly, mine, }?: {
241
262
  offset?: number;
242
263
  limit?: number;
243
- filter?: PgFilter<DbBasePost>;
264
+ jamOnly?: boolean;
265
+ mine?: boolean;
244
266
  }) => Promise<PostWithMeta[]>;
245
- export declare const listCurrentEventsFeed: (authData: AuthorizationData, { offset, limit, filter, }?: {
267
+ export declare const listCurrentEventsFeed: (authData: AuthorizationData, { offset, limit, jamOnly, mine, }?: {
246
268
  offset?: number;
247
269
  limit?: number;
248
- filter?: PgFilter<DbBasePost>;
270
+ jamOnly?: boolean;
271
+ mine?: boolean;
249
272
  }) => Promise<PostWithMeta[]>;
250
- export declare const listPastEventsFeed: (authData: AuthorizationData, { offset, limit, filter, }?: {
273
+ export declare const listPastEventsFeed: (authData: AuthorizationData, { offset, limit, jamOnly, mine, }?: {
251
274
  offset?: number;
252
275
  limit?: number;
253
- filter?: PgFilter<DbBasePost>;
276
+ jamOnly?: boolean;
277
+ mine?: boolean;
254
278
  }) => Promise<PostWithMeta[]>;
255
279
  export declare const listMyUpcomingEventsFeed: (authData: AuthorizationData, { offset, limit }?: {
256
280
  offset?: number;
@@ -296,5 +320,5 @@ export declare const getPostContext: (post: PostWithMeta, authData: Authorizatio
296
320
  ancestors: PostWithMeta[];
297
321
  descendants: PostWithMeta[];
298
322
  }>;
299
- export declare const mentions: (post: Post, profile: Profile) => Promise<{} | undefined>;
300
- export declare const audience: (post: Post, profile: Profile) => Promise<{} | undefined>;
323
+ export declare const mentions: (post: Post, profile: Profile) => Promise<Record<string, unknown> | undefined>;
324
+ export declare const audience: (post: Post, profile: Profile) => Promise<Record<string, unknown> | undefined>;
@@ -1,7 +1,7 @@
1
1
  import { allpeepDb, collectionInfos } from '../db/index.js';
2
2
  import { edgeFilters, postFilters } from '../db/pg/filters/index.js';
3
3
  import { contextRelation, conversationLeavesMappingForProfile, postContextMappingForProfile, postsAuthMapping, postsMappingForProfile, repostsOfPostRelationForProfile, postIdsMapping, } from './mapping.js';
4
- import { audienceConnectionFinder, currentEventsFilter, jamFilter, localFeedFilter, mentionsConnectionFinder, myEventsFilter, myFeedFilter, myFeedGroupMembershipFilter, pastEventsFilter, toFilteredPostsList, transformPost, upcomingEventsFilter, } from './helpers/index.js';
4
+ import { audienceConnectionFinder, localFeedFilter, mentionsConnectionFinder, myFeedFilter, myFeedGroupMembershipFilter, toFilteredPostsList, transformPost, } from './helpers/index.js';
5
5
  import { addQuerySort, addStart, sortOldestFirst } from '../db/helpers.js';
6
6
  import { sorts } from '../db/pg/queries/index.js';
7
7
  import { findHashtagByTag, hashtagsMapping } from '../hashtags/index.js';
@@ -13,6 +13,7 @@ import { withSpan } from '../performance/index.js';
13
13
  import { queryUnseenPostCounts } from './unseenCounts.js';
14
14
  import { getConversationThread } from './conversationQueries.js';
15
15
  import { fetchRowsByIds, hydrateMapData } from '../db/pg/map/relations.js';
16
+ import { listEventAgenda } from './eventAgenda.js';
16
17
  /**
17
18
  * Throws if the given `authData` does not include a profile.
18
19
  *
@@ -164,82 +165,63 @@ export const listPostsByGroup = async (authData, groupId, { start, limit = 100,
164
165
  .data(),
165
166
  }), { authData, limit });
166
167
  });
167
- export const listLocalFeed = async (authData, { start, limit = 100 } = { limit: 100 }) => withSpan('feed.local', () => toFilteredPostsList(baseFeed({ start, profile: authData.profile }).filter(localFeedFilter(authData.profile)), { authData, limit }));
168
+ export const listLocalFeed = async (authData, { start, limit = 100 } = { limit: 100 }) => withSpan('feed.local', () => toFilteredPostsList(baseFeed({ start, profile: authData.profile }).filter(localFeedFilter()), { authData, limit }));
168
169
  export const listMyFeed = async (authData, { start, limit = 100 } = { limit: 100 }) => {
169
170
  const profile = requireProfile(authData);
170
171
  return withSpan('feed.my', () => toFilteredPostsList(baseFeed({ start, profile }).filter(myFeedFilter(profile)), { authData, limit, filters: [myFeedGroupMembershipFilter(profile)] }));
171
172
  };
172
- export const listUpcomingEventsFeed = async (authData, { offset, limit = 100, filter, } = {
173
+ export const listUpcomingEventsFeed = async (authData, { offset, limit = 100, jamOnly, mine, } = {
173
174
  limit: 100,
174
- }) => toFilteredPostsList(baseEventsFeed(authData.profile)
175
- .filter(upcomingEventsFilter())
176
- .filter(filter), { authData, limit, offset });
177
- export const listCurrentEventsFeed = async (authData, { offset, limit = 100, filter, } = {
175
+ }) => listEventAgenda(authData, 'upcoming', { offset, limit, jamOnly, mine });
176
+ export const listCurrentEventsFeed = async (authData, { offset, limit = 100, jamOnly, mine, } = {
178
177
  limit: 100,
179
- }) => toFilteredPostsList(baseEventsFeed(authData.profile)
180
- .filter(currentEventsFilter())
181
- .filter(filter), { authData, limit, offset });
182
- export const listPastEventsFeed = async (authData, { offset, limit = 100, filter, } = {
178
+ }) => listEventAgenda(authData, 'current', { offset, limit, jamOnly, mine });
179
+ export const listPastEventsFeed = async (authData, { offset, limit = 100, jamOnly, mine, } = {
183
180
  limit: 100,
184
- }) => toFilteredPostsList(baseEventsFeed(authData.profile)
185
- .sort(sorts.eventStartDesc)
186
- .filter(pastEventsFilter())
187
- .filter(filter), { authData, limit, offset });
181
+ }) => listEventAgenda(authData, 'past', { offset, limit, jamOnly, mine });
188
182
  export const listMyUpcomingEventsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listUpcomingEventsFeed(authData, {
189
183
  offset,
190
- filter: myEventsFilter(requireProfile(authData)),
184
+ mine: true,
191
185
  limit,
192
186
  });
193
187
  export const listMyCurrentEventsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listCurrentEventsFeed(authData, {
194
188
  offset,
195
- filter: myEventsFilter(requireProfile(authData)),
189
+ mine: true,
196
190
  limit,
197
191
  });
198
192
  export const listMyPastEventsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listPastEventsFeed(authData, {
199
193
  offset,
200
- filter: myEventsFilter(requireProfile(authData)),
194
+ mine: true,
201
195
  limit,
202
196
  });
203
- export const listUpcomingJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listUpcomingEventsFeed(authData, { offset, filter: jamFilter, limit });
204
- export const listPastJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listPastEventsFeed(authData, { offset, filter: jamFilter, limit });
197
+ export const listUpcomingJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listUpcomingEventsFeed(authData, { offset, jamOnly: true, limit });
198
+ export const listPastJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listPastEventsFeed(authData, { offset, jamOnly: true, limit });
205
199
  export const listMyPastJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listPastEventsFeed(authData, {
206
200
  offset,
207
- filter: {
208
- operator: '&&',
209
- predicates: [myEventsFilter(requireProfile(authData)), jamFilter],
210
- },
201
+ jamOnly: true,
202
+ mine: true,
211
203
  limit,
212
204
  });
213
205
  export const listMyUpcomingJamsFeed = async (authData, { offset, limit = 100 } = { limit: 100 }) => listUpcomingEventsFeed(authData, {
214
206
  offset,
215
- filter: {
216
- operator: '&&',
217
- predicates: [myEventsFilter(requireProfile(authData)), jamFilter],
218
- },
207
+ jamOnly: true,
208
+ mine: true,
219
209
  limit,
220
210
  });
221
- const baseGroupEventsFeed = async (authData, groupId, { filter, sort } = {}) => {
211
+ export const listUpcomingGroupEventsFeed = async (authData, groupId, { offset, limit = 100 } = { limit: 100 }) => {
222
212
  const group = await findGroup(groupId);
223
213
  if (!group) {
224
214
  throw new Error(`Group ${groupId} not found`);
225
215
  }
226
- const profile = authData.profile;
227
- return groupsMapping.relationsFrom(group, {
228
- alias: 'posts',
229
- edgeCollection: collectionInfos.postGroupsCollection.name,
230
- direction: 'INBOUND',
231
- skipEdge: true,
232
- cardinality: 'many',
233
- mapping: baseEventsFeed(profile).filter(filter).sort(sort).data(),
234
- });
216
+ return listEventAgenda(authData, 'upcoming', { offset, limit, groupId });
217
+ };
218
+ export const listPastGroupEventsFeed = async (authData, groupId, { offset, limit = 100 } = { limit: 100 }) => {
219
+ const group = await findGroup(groupId);
220
+ if (!group) {
221
+ throw new Error(`Group ${groupId} not found`);
222
+ }
223
+ return listEventAgenda(authData, 'past', { offset, limit, groupId });
235
224
  };
236
- export const listUpcomingGroupEventsFeed = async (authData, groupId, { offset, limit = 100 } = { limit: 100 }) => toFilteredPostsList(await baseGroupEventsFeed(authData, groupId, {
237
- filter: upcomingEventsFilter(),
238
- }), { authData, limit, offset });
239
- export const listPastGroupEventsFeed = async (authData, groupId, { offset, limit = 100 } = { limit: 100 }) => toFilteredPostsList(await baseGroupEventsFeed(authData, groupId, {
240
- filter: pastEventsFilter(),
241
- sort: sorts.eventStartDesc,
242
- }), { authData, limit, offset });
243
225
  export const reposts = async (post, authData) => toFilteredPostsList(postsMappingForProfile(authData.profile).relationsFrom(post, repostsOfPostRelationForProfile(authData.profile)), { authData });
244
226
  export const getConversationByEnd = async (post, authData) => ancestors(authData, post, 9999, sortOldestFirst(postsMappingForProfile(authData.profile))).then((conversation) => [...conversation, post]);
245
227
  export const getConversationByStart = async (post, authData) => getConversationThread(post, authData);
@@ -1,6 +1,6 @@
1
1
  import { postWithMetaSchema, } from '@openpeepshq/common/types';
2
2
  import { combine, eventTimeFilters, postFilters } from '../../db/pg/filters/index.js';
3
- import { checkCapabilities, getPostCapabilities } from '@openpeepshq/common/lib';
3
+ import { checkCapabilities, getPostCapabilities, } from '@openpeepshq/common/lib';
4
4
  export const ownPostsFilter = (profile) => ({
5
5
  matches: {
6
6
  creatorId: profile.id,
@@ -149,6 +149,27 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
149
149
  } | undefined;
150
150
  } | undefined;
151
151
  url?: string | undefined;
152
+ recurrence?: {
153
+ freq: "DAILY" | "WEEKLY" | "MONTHLY";
154
+ interval?: number | undefined;
155
+ byDay?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[] | undefined;
156
+ until?: string | undefined;
157
+ count?: number | undefined;
158
+ } | undefined;
159
+ exceptions?: {
160
+ recurrenceId: string;
161
+ cancelled?: boolean | undefined;
162
+ start?: string | undefined;
163
+ end?: string | undefined;
164
+ physicalLocation?: {
165
+ text: string;
166
+ coordinates?: {
167
+ lat: number;
168
+ lng: number;
169
+ alt?: number | undefined;
170
+ } | undefined;
171
+ } | undefined;
172
+ }[] | undefined;
152
173
  } | {
153
174
  type: "article";
154
175
  content?: string | undefined;
@@ -323,6 +344,27 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
323
344
  } | undefined;
324
345
  } | undefined;
325
346
  url?: string | undefined;
347
+ recurrence?: {
348
+ freq: "DAILY" | "WEEKLY" | "MONTHLY";
349
+ interval?: number | undefined;
350
+ byDay?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[] | undefined;
351
+ until?: string | undefined;
352
+ count?: number | undefined;
353
+ } | undefined;
354
+ exceptions?: {
355
+ recurrenceId: string;
356
+ cancelled?: boolean | undefined;
357
+ start?: string | undefined;
358
+ end?: string | undefined;
359
+ physicalLocation?: {
360
+ text: string;
361
+ coordinates?: {
362
+ lat: number;
363
+ lng: number;
364
+ alt?: number | undefined;
365
+ } | undefined;
366
+ } | undefined;
367
+ }[] | undefined;
326
368
  } | {
327
369
  type: "article";
328
370
  content?: string | undefined;
@@ -371,6 +413,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
371
413
  type: "rsvp";
372
414
  data: {
373
415
  response: "removed" | "no" | "yes" | "tentative";
416
+ recurrenceId?: string | undefined;
374
417
  };
375
418
  }) & {
376
419
  id?: string;
@@ -512,6 +555,27 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
512
555
  } | undefined;
513
556
  } | undefined;
514
557
  url?: string | undefined;
558
+ recurrence?: {
559
+ freq: "DAILY" | "WEEKLY" | "MONTHLY";
560
+ interval?: number | undefined;
561
+ byDay?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[] | undefined;
562
+ until?: string | undefined;
563
+ count?: number | undefined;
564
+ } | undefined;
565
+ exceptions?: {
566
+ recurrenceId: string;
567
+ cancelled?: boolean | undefined;
568
+ start?: string | undefined;
569
+ end?: string | undefined;
570
+ physicalLocation?: {
571
+ text: string;
572
+ coordinates?: {
573
+ lat: number;
574
+ lng: number;
575
+ alt?: number | undefined;
576
+ } | undefined;
577
+ } | undefined;
578
+ }[] | undefined;
515
579
  } | {
516
580
  type: "article";
517
581
  content?: string | undefined;
@@ -686,6 +750,27 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
686
750
  } | undefined;
687
751
  } | undefined;
688
752
  url?: string | undefined;
753
+ recurrence?: {
754
+ freq: "DAILY" | "WEEKLY" | "MONTHLY";
755
+ interval?: number | undefined;
756
+ byDay?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[] | undefined;
757
+ until?: string | undefined;
758
+ count?: number | undefined;
759
+ } | undefined;
760
+ exceptions?: {
761
+ recurrenceId: string;
762
+ cancelled?: boolean | undefined;
763
+ start?: string | undefined;
764
+ end?: string | undefined;
765
+ physicalLocation?: {
766
+ text: string;
767
+ coordinates?: {
768
+ lat: number;
769
+ lng: number;
770
+ alt?: number | undefined;
771
+ } | undefined;
772
+ } | undefined;
773
+ }[] | undefined;
689
774
  } | {
690
775
  type: "article";
691
776
  content?: string | undefined;
@@ -734,15 +819,16 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
734
819
  type: "rsvp";
735
820
  data: {
736
821
  response: "removed" | "no" | "yes" | "tentative";
822
+ recurrenceId?: string | undefined;
737
823
  };
738
824
  }) & {
739
825
  _from: string;
740
826
  _to: string;
741
827
  }>>;
742
828
  export declare const entryDisconnector: (db: import("../../db").PgDb, from: Profile, to: Post) => Promise<void>;
743
- export declare const replyConnector: (db: import("../../db").PgDb, from: Post, to: Post, data?: {
829
+ export declare const replyConnector: (db: import("../../db").PgDb, from: Post, to: Post, data?: object & {
744
830
  id?: string;
745
- }) => Promise<import("../../db/pg/map").WithId<{
831
+ }) => Promise<import("../../db/pg/map").WithId<object & {
746
832
  _from: string;
747
833
  _to: string;
748
834
  }>>;
@@ -765,22 +851,22 @@ export declare const groupConnector: (db: import("../../db").PgDb, from: Post, t
765
851
  discoverable?: boolean | undefined;
766
852
  lastPostAt?: string | null | undefined;
767
853
  deletedAt?: string | null | undefined;
768
- }, data?: {
854
+ }, data?: object & {
769
855
  id?: string;
770
- }) => Promise<import("../../db/pg/map").WithId<{
856
+ }) => Promise<import("../../db/pg/map").WithId<object & {
771
857
  _from: string;
772
858
  _to: string;
773
859
  }>>;
774
- export declare const audienceConnector: (db: import("../../db").PgDb, from: Post, to: Profile, data?: {
860
+ export declare const audienceConnector: (db: import("../../db").PgDb, from: Post, to: Profile, data?: object & {
775
861
  id?: string;
776
- }) => Promise<import("../../db/pg/map").WithId<{
862
+ }) => Promise<import("../../db/pg/map").WithId<object & {
777
863
  _from: string;
778
864
  _to: string;
779
865
  }>>;
780
- export declare const audienceConnectionFinder: (db: import("../../db").PgDb, from: Post, to: Profile) => Promise<{} | undefined>;
781
- export declare const hashtagConnector: (db: import("../../db").PgDb, from: Post, to: Hashtag, data?: {
866
+ export declare const audienceConnectionFinder: (db: import("../../db").PgDb, from: Post, to: Profile) => Promise<Record<string, unknown> | undefined>;
867
+ export declare const hashtagConnector: (db: import("../../db").PgDb, from: Post, to: Hashtag, data?: object & {
782
868
  id?: string;
783
- }) => Promise<import("../../db/pg/map").WithId<{
869
+ }) => Promise<import("../../db/pg/map").WithId<object & {
784
870
  _from: string;
785
871
  _to: string;
786
872
  }>>;
@@ -795,10 +881,10 @@ export declare const mentionConnector: (db: import("../../db").PgDb, from: Post,
795
881
  _from: string;
796
882
  _to: string;
797
883
  }>>;
798
- export declare const mentionsConnectionFinder: (db: import("../../db").PgDb, from: Post, to: Profile) => Promise<{} | undefined>;
799
- export declare const repostConnector: (db: import("../../db").PgDb, from: Post, to: Post, data?: {
884
+ export declare const mentionsConnectionFinder: (db: import("../../db").PgDb, from: Post, to: Profile) => Promise<Record<string, unknown> | undefined>;
885
+ export declare const repostConnector: (db: import("../../db").PgDb, from: Post, to: Post, data?: object & {
800
886
  id?: string;
801
- }) => Promise<import("../../db/pg/map").WithId<{
887
+ }) => Promise<import("../../db/pg/map").WithId<object & {
802
888
  _from: string;
803
889
  _to: string;
804
890
  }>>;
@@ -813,16 +899,16 @@ export declare const reactionConnector: (db: import("../../db").PgDb, from: Prof
813
899
  _to: string;
814
900
  }>>;
815
901
  export declare const reactionDisconnector: (db: import("../../db").PgDb, from: Profile, to: Post) => Promise<void>;
816
- export declare const bookmarkConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: {
902
+ export declare const bookmarkConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: object & {
817
903
  id?: string;
818
- }) => Promise<import("../../db/pg/map").WithId<{
904
+ }) => Promise<import("../../db/pg/map").WithId<object & {
819
905
  _from: string;
820
906
  _to: string;
821
907
  }>>;
822
908
  export declare const bookmarkDisconnector: (db: import("../../db").PgDb, from: Profile, to: Post) => Promise<void>;
823
- export declare const postSeenConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: {
909
+ export declare const postSeenConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: object & {
824
910
  id?: string;
825
- }) => Promise<import("../../db/pg/map").WithId<{
911
+ }) => Promise<import("../../db/pg/map").WithId<object & {
826
912
  _from: string;
827
913
  _to: string;
828
914
  }>>;