@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.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/defaults/logs.d.ts +4 -0
- package/dist/config/defaults/logs.js +5 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +3 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/finders.d.ts +2 -2
- package/dist/groups/helpers.d.ts +6 -6
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -4
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.d.ts +2 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/mapping.d.ts +10 -10
- package/dist/jams/mutations.d.ts +2 -2
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +14 -29
- package/dist/log/retention.d.ts +9 -0
- package/dist/log/retention.js +83 -0
- package/dist/log/retentionJobs.d.ts +17 -0
- package/dist/log/retentionJobs.js +50 -0
- package/dist/media/index.js +127 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/mediaAttachments/mapping.d.ts +1 -1
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
- package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
- package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +9 -10
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/eventIcsAttachment.d.ts +6 -0
- package/dist/notifications/eventIcsAttachment.js +32 -0
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.d.ts +11 -1
- package/dist/notifications/helpers.js +38 -9
- package/dist/notifications/jobs.js +16 -7
- package/dist/notifications/mutations.js +13 -2
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +1 -1
- package/dist/posts/activity.js +2 -3
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +12 -7
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +46 -6
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +170 -18
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +616 -84
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +85 -9
- package/dist/posts/mutations.js +47 -34
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profileSettings/mapping.d.ts +1 -0
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mapping.d.ts +10 -10
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +43 -5
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
- package/LICENSE +0 -674
package/dist/stripe/helpers.js
CHANGED
|
@@ -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 =
|
|
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
|
|
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 !!
|
|
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
|
-
: (
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 } =
|
|
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
|
|
177
|
-
const trialPeriodDays =
|
|
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 &&
|
|
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) =>
|
|
203
|
+
.then((session) => session.url ?? undefined);
|
|
209
204
|
}
|
|
210
|
-
catch
|
|
205
|
+
catch { }
|
|
211
206
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/core",
|
|
3
|
-
"version": "0.
|
|
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
|
-
"
|
|
41
|
-
"@openpeepshq/
|
|
42
|
-
"@openpeepshq/i18n": "^0.
|
|
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",
|