@openpeepshq/core 0.1.34 → 0.2.0

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 (192) hide show
  1. package/dist/accessTokens/finders.js +5 -6
  2. package/dist/accessTokens/mutations.js +1 -1
  3. package/dist/accessTokens/tokens.js +8 -11
  4. package/dist/accounts/helpers.js +6 -2
  5. package/dist/accounts/mutations.js +13 -8
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +1 -2
  9. package/dist/analytics/dateRange.js +3 -5
  10. package/dist/analytics/jobs.js +3 -4
  11. package/dist/analytics/pdfReport.js +45 -61
  12. package/dist/analytics/privacy.js +1 -1
  13. package/dist/analytics/read.js +116 -135
  14. package/dist/analytics/report.d.ts +2 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +13 -16
  18. package/dist/backups/metadata.js +1 -1
  19. package/dist/config/db.js +2 -4
  20. package/dist/config/defaults/community.js +1 -0
  21. package/dist/config/defaults/core.js +13 -8
  22. package/dist/config/defaults/logs.d.ts +4 -0
  23. package/dist/config/defaults/logs.js +5 -0
  24. package/dist/config/index.d.ts +9 -0
  25. package/dist/config/index.js +9 -11
  26. package/dist/db/explorer/query.js +9 -8
  27. package/dist/db/explorer/sql.js +8 -8
  28. package/dist/db/helpers.js +15 -5
  29. package/dist/db/migration/importCollections.js +15 -18
  30. package/dist/db/migration/shared.js +15 -35
  31. package/dist/db/pg/client.js +4 -7
  32. package/dist/db/pg/filters/index.js +1 -1
  33. package/dist/db/pg/filters/posts.d.ts +2 -0
  34. package/dist/db/pg/filters/posts.js +3 -1
  35. package/dist/db/pg/helpers.js +2 -14
  36. package/dist/db/pg/map/filters.js +8 -8
  37. package/dist/db/pg/map/helpers.js +5 -1
  38. package/dist/db/pg/map/index.js +46 -51
  39. package/dist/db/pg/map/mutations.js +56 -21
  40. package/dist/db/pg/map/registry.js +87 -50
  41. package/dist/db/pg/map/relations.js +67 -63
  42. package/dist/db/pg/map/search.js +15 -37
  43. package/dist/db/pg/mappers.js +13 -7
  44. package/dist/db/pg/migrate.js +2 -3
  45. package/dist/db/pg/queries/activity.js +2 -2
  46. package/dist/db/pg/queries/derived.js +8 -12
  47. package/dist/db/pg/schema/documents.js +119 -18
  48. package/dist/db/pg/schema/edges.js +7 -1
  49. package/dist/db/pg/schema/index.js +5 -1
  50. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  51. package/dist/db/pg/sql/meta/_journal.json +8 -1
  52. package/dist/db/replaceOrigin.js +1 -1
  53. package/dist/email/queueStats.js +8 -11
  54. package/dist/email/render.js +7 -4
  55. package/dist/email/send.js +19 -17
  56. package/dist/email/smtpTest.js +10 -6
  57. package/dist/errors/index.js +1 -1
  58. package/dist/events/once.js +2 -4
  59. package/dist/federation/activities.js +1 -2
  60. package/dist/groups/finders.d.ts +2 -2
  61. package/dist/groups/helpers.d.ts +6 -6
  62. package/dist/groups/helpers.js +1 -2
  63. package/dist/groups/mapping.d.ts +4 -4
  64. package/dist/groups/mutations.js +1 -1
  65. package/dist/hashtags/finders.js +2 -2
  66. package/dist/inviteLinks/mutations.js +2 -3
  67. package/dist/jams/export.js +5 -7
  68. package/dist/jams/finders.js +4 -1
  69. package/dist/jams/health.d.ts +6 -4
  70. package/dist/jams/health.js +15 -11
  71. package/dist/jams/helpers.d.ts +2 -2
  72. package/dist/jams/helpers.js +6 -2
  73. package/dist/jams/index.js +2 -2
  74. package/dist/jams/jobs.js +1 -2
  75. package/dist/jams/livekit.d.ts +2 -2
  76. package/dist/jams/livekit.js +8 -8
  77. package/dist/jams/mapping.d.ts +10 -10
  78. package/dist/jams/mutations.d.ts +2 -2
  79. package/dist/jams/recording.js +1 -1
  80. package/dist/jams/token.js +13 -17
  81. package/dist/jobs/index.js +7 -6
  82. package/dist/jobs/jobDetail.js +5 -6
  83. package/dist/jobs/jobLog.js +2 -3
  84. package/dist/lib/streams.js +4 -39
  85. package/dist/lib/zodDeepPartial.d.ts +1 -1
  86. package/dist/lib/zodDeepPartial.js +1 -1
  87. package/dist/log/index.d.ts +1 -0
  88. package/dist/log/index.js +14 -29
  89. package/dist/log/retention.d.ts +9 -0
  90. package/dist/log/retention.js +83 -0
  91. package/dist/log/retentionJobs.d.ts +17 -0
  92. package/dist/log/retentionJobs.js +50 -0
  93. package/dist/media/index.js +127 -4
  94. package/dist/media/jobs.js +1 -2
  95. package/dist/media/openpeeps/index.js +11 -46
  96. package/dist/media/processing.js +7 -4
  97. package/dist/media/streaming.js +5 -5
  98. package/dist/media/streamingCleanupJobs.js +1 -2
  99. package/dist/media/streamingJobs.js +3 -4
  100. package/dist/media/streamingPrewarm.js +7 -11
  101. package/dist/mediaAttachments/index.js +6 -2
  102. package/dist/mediaAttachments/mapping.d.ts +1 -1
  103. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  104. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  105. package/dist/notifications/defaultNotifications/follow/index.js +14 -17
  106. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  107. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  108. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  109. package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
  110. package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
  111. package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
  112. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  113. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  114. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  115. package/dist/notifications/defaultNotifications/newGroupPost/index.js +9 -10
  116. package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
  117. package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
  118. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  119. package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
  120. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
  121. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  122. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  123. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  124. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  125. package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
  126. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
  127. package/dist/notifications/eventIcsAttachment.d.ts +6 -0
  128. package/dist/notifications/eventIcsAttachment.js +32 -0
  129. package/dist/notifications/fcmCredential.js +1 -1
  130. package/dist/notifications/finders.js +1 -1
  131. package/dist/notifications/helpers.d.ts +11 -1
  132. package/dist/notifications/helpers.js +38 -9
  133. package/dist/notifications/jobs.js +16 -7
  134. package/dist/notifications/mutations.js +13 -2
  135. package/dist/notifications/push.js +11 -16
  136. package/dist/performance/index.js +3 -3
  137. package/dist/plugins/helpers.js +3 -6
  138. package/dist/plugins/index.js +2 -3
  139. package/dist/plugins/install.js +31 -17
  140. package/dist/plugins/pluginAuth.js +3 -4
  141. package/dist/plugins/state.js +2 -3
  142. package/dist/posts/activity.d.ts +1 -1
  143. package/dist/posts/activity.js +2 -3
  144. package/dist/posts/contextClosure.js +1 -2
  145. package/dist/posts/conversationQueries.js +2 -4
  146. package/dist/posts/eventAgenda.js +12 -7
  147. package/dist/posts/eventOccurrences.js +2 -2
  148. package/dist/posts/finders.d.ts +46 -6
  149. package/dist/posts/finders.js +21 -9
  150. package/dist/posts/helpers/filters.js +2 -3
  151. package/dist/posts/helpers/index.d.ts +170 -18
  152. package/dist/posts/helpers/index.js +43 -27
  153. package/dist/posts/mapping.d.ts +616 -84
  154. package/dist/posts/mapping.js +60 -18
  155. package/dist/posts/mutations.d.ts +85 -9
  156. package/dist/posts/mutations.js +47 -34
  157. package/dist/posts/pollEnd.js +3 -6
  158. package/dist/posts/rsvpConfirmationEmail.js +18 -8
  159. package/dist/posts/threadPreview.js +1 -1
  160. package/dist/processingStats/queries.js +6 -7
  161. package/dist/profileSettings/cache.js +1 -2
  162. package/dist/profileSettings/mapping.d.ts +1 -0
  163. package/dist/profiles/activitySummary.js +23 -28
  164. package/dist/profiles/cache.js +15 -8
  165. package/dist/profiles/export.js +30 -39
  166. package/dist/profiles/finders.js +7 -5
  167. package/dist/profiles/mapping.d.ts +10 -10
  168. package/dist/profiles/mutations.js +3 -5
  169. package/dist/redis/connection.js +1 -1
  170. package/dist/reports/helpers.js +7 -3
  171. package/dist/reports/mapping.d.ts +1 -1
  172. package/dist/roles/mutations.js +20 -21
  173. package/dist/search/finders.js +15 -3
  174. package/dist/search/helpers.js +1 -1
  175. package/dist/sentry/index.js +9 -11
  176. package/dist/seo/index.d.ts +50 -0
  177. package/dist/seo/index.js +145 -0
  178. package/dist/seo/route.d.ts +18 -0
  179. package/dist/seo/route.js +19 -0
  180. package/dist/server/index.d.ts +1 -0
  181. package/dist/server/index.js +16 -11
  182. package/dist/server/status.js +6 -7
  183. package/dist/session/index.js +2 -2
  184. package/dist/stats/finders.js +13 -4
  185. package/dist/stats/helpers.js +4 -1
  186. package/dist/stats/mapping.d.ts +43 -5
  187. package/dist/stats/mapping.js +9 -2
  188. package/dist/stripe/cache.js +5 -6
  189. package/dist/stripe/connection.js +3 -4
  190. package/dist/stripe/helpers.js +15 -20
  191. package/package.json +5 -6
  192. package/LICENSE +0 -674
@@ -4,22 +4,19 @@ import { getUserStripeSubscription, refreshStripeSubscription, stripeCache, } fr
4
4
  import { findProfileSettings, updateProfileSettings } from '../profileSettings/index.js';
5
5
  import { getStripe, initStripeWithCredentials } from './connection.js';
6
6
  export const getStripeDetails = async () => {
7
- var _a;
8
7
  const cfg = await config();
9
- const data = (_a = cfg.payments) === null || _a === void 0 ? void 0 : _a.stripe;
8
+ const data = cfg.payments?.stripe;
10
9
  const protocol = process.env.NODE_ENV === 'production' ? 'https' : 'http';
11
10
  const success_url = `${protocol}://${cfg.server.host}/payment/success`;
12
11
  const cancel_url = `${protocol}://${cfg.server.host}/auth/login`;
13
12
  const portal_return_url = `${protocol}://${cfg.server.host}/settings/billing`;
14
- return Object.assign(Object.assign({}, data), { success_url, cancel_url, portal_return_url });
13
+ return { ...data, success_url, cancel_url, portal_return_url };
15
14
  };
16
15
  export const stripeMembershipActive = async () => {
17
- var _a;
18
16
  const data = await getStripeDetails();
19
- return !!((_a = data === null || data === void 0 ? void 0 : data.paidMembership) === null || _a === void 0 ? void 0 : _a.enabled);
17
+ return !!data?.paidMembership?.enabled;
20
18
  };
21
19
  const getPrices = async (stripeInstance, productId = '', limit = 1) => {
22
- var _a, _b;
23
20
  if (!productId) {
24
21
  throw new Error('[STRIPE_PRICE][ERROR] No productId found');
25
22
  }
@@ -31,13 +28,13 @@ const getPrices = async (stripeInstance, productId = '', limit = 1) => {
31
28
  }
32
29
  const defaultPriceId = typeof product.default_price === 'string'
33
30
  ? product.default_price
34
- : ((_b = (_a = product.default_price) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null);
31
+ : (product.default_price?.id ?? null);
35
32
  if (defaultPriceId && limit === 1) {
36
33
  try {
37
34
  const price = await stripeInstance.prices.retrieve(defaultPriceId);
38
35
  return { data: [price] };
39
36
  }
40
- catch (_c) {
37
+ catch {
41
38
  return { data: [] };
42
39
  }
43
40
  }
@@ -51,7 +48,7 @@ const getPrices = async (stripeInstance, productId = '', limit = 1) => {
51
48
  };
52
49
  export const testStripeCredentials = async (data) => {
53
50
  try {
54
- const credentials = Object.assign(Object.assign({}, (await getStripeDetails())), data);
51
+ const credentials = { ...(await getStripeDetails()), ...data };
55
52
  const stripe = initStripeWithCredentials(credentials);
56
53
  if (!stripe) {
57
54
  return {
@@ -60,14 +57,14 @@ export const testStripeCredentials = async (data) => {
60
57
  };
61
58
  }
62
59
  const { paidMembership } = credentials;
63
- const productId = paidMembership === null || paidMembership === void 0 ? void 0 : paidMembership.productId;
60
+ const productId = paidMembership?.productId;
64
61
  if (!productId) {
65
62
  return {
66
63
  success: false,
67
64
  key: 'configuration.server.stripe.errors.noProductId',
68
65
  };
69
66
  }
70
- const prices = await getPrices(stripe, paidMembership === null || paidMembership === void 0 ? void 0 : paidMembership.productId, 1);
67
+ const prices = await getPrices(stripe, paidMembership?.productId, 1);
71
68
  if (prices.data.length === 0) {
72
69
  return {
73
70
  success: false,
@@ -92,7 +89,7 @@ export const createStripeCustomerPortal = async (stripeId) => {
92
89
  }));
93
90
  return session.url;
94
91
  }
95
- catch (_a) { }
92
+ catch { }
96
93
  };
97
94
  export const createStripeCustomer = async (profile, account) => {
98
95
  const profileSettings = await findProfileSettings(profile.id);
@@ -134,10 +131,9 @@ const allowedEvents = [
134
131
  'payment_intent.canceled',
135
132
  ];
136
133
  export const processEvent = async (event) => {
137
- var _a;
138
134
  if (!allowedEvents.includes(event.type))
139
135
  return;
140
- const { customer: customerId } = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.object;
136
+ const { customer: customerId } = event?.data?.object;
141
137
  if (typeof customerId !== 'string') {
142
138
  throw new Error(`[STRIPE HOOK][CANCER] ID isn't string.\nEvent type: ${event.type}`);
143
139
  }
@@ -167,14 +163,13 @@ export const checkSubscription = async (profile, account, refresh = false) => {
167
163
  return true;
168
164
  };
169
165
  export const createStripeCheckoutUrl = async (profile, account) => {
170
- var _a;
171
166
  const stripeCustomerId = await getOrCreateStripeCustomerId(profile, account);
172
167
  if (!stripeCustomerId) {
173
168
  throw new Error('[STRIPE_CHECKOUT][ERROR] No stripe customer id found');
174
169
  }
175
170
  const { paidMembership, success_url, cancel_url } = (await getStripeDetails());
176
- const productId = paidMembership === null || paidMembership === void 0 ? void 0 : paidMembership.productId;
177
- const trialPeriodDays = (_a = paidMembership === null || paidMembership === void 0 ? void 0 : paidMembership.trialPeriodDays) !== null && _a !== void 0 ? _a : 0;
171
+ const productId = paidMembership?.productId;
172
+ const trialPeriodDays = paidMembership?.trialPeriodDays ?? 0;
178
173
  const prices = await getPrices(await getStripe(), productId, 1);
179
174
  const line_items = prices.data.map((price) => ({
180
175
  price: price.id,
@@ -186,7 +181,7 @@ export const createStripeCheckoutUrl = async (profile, account) => {
186
181
  try {
187
182
  const res = await getUserStripeSubscription(stripeCustomerId);
188
183
  let successUrl = success_url;
189
- if (res !== null && (res === null || res === void 0 ? void 0 : res.status) !== 'none') {
184
+ if (res !== null && res?.status !== 'none') {
190
185
  successUrl = `${success_url}?user=true`;
191
186
  }
192
187
  const subscription_data = trialPeriodDays > 0
@@ -205,7 +200,7 @@ export const createStripeCheckoutUrl = async (profile, account) => {
205
200
  subscription_data,
206
201
  allow_promotion_codes: true,
207
202
  }))
208
- .then((session) => { var _a; return (_a = session.url) !== null && _a !== void 0 ? _a : undefined; });
203
+ .then((session) => session.url ?? undefined);
209
204
  }
210
- catch (_b) { }
205
+ catch { }
211
206
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/core",
3
- "version": "0.1.34",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
@@ -37,11 +37,10 @@
37
37
  "type-fest": "^4.31.0",
38
38
  "uuidv7": "^1.0.2",
39
39
  "web-push": "^3.6.7",
40
- "zod": "^4.4.3",
41
- "@openpeepshq/common": "0.1.46",
42
- "@openpeepshq/i18n": "^0.1.10",
43
- "@openpeepshq/geocoder": "^0.1.2",
44
- "@openpeepshq/fetch-client": "^0.1.7"
40
+ "@openpeepshq/common": "0.4.0",
41
+ "@openpeepshq/fetch-client": "^0.2.1",
42
+ "@openpeepshq/i18n": "^0.2.0",
43
+ "@openpeepshq/geocoder": "^0.1.2"
45
44
  },
46
45
  "main": "dist/index.js",
47
46
  "types": "dist/index.d.ts",