@openpeepshq/common 0.1.43
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/LICENSE.md +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/adminSections.d.ts +53 -0
- package/dist/lib/adminSections.js +62 -0
- package/dist/lib/attachmentHelpers.d.ts +1 -0
- package/dist/lib/attachmentHelpers.js +13 -0
- package/dist/lib/capabilitiesHelpers.d.ts +118 -0
- package/dist/lib/capabilitiesHelpers.js +238 -0
- package/dist/lib/colors.d.ts +5 -0
- package/dist/lib/colors.js +17 -0
- package/dist/lib/csvHelpers.d.ts +6 -0
- package/dist/lib/csvHelpers.js +17 -0
- package/dist/lib/eventIcs.d.ts +4 -0
- package/dist/lib/eventIcs.js +83 -0
- package/dist/lib/groupHelpers.d.ts +134 -0
- package/dist/lib/groupHelpers.js +216 -0
- package/dist/lib/index.d.ts +17 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/jamHelpers.d.ts +5 -0
- package/dist/lib/jamHelpers.js +37 -0
- package/dist/lib/markdownHelpers.d.ts +1 -0
- package/dist/lib/markdownHelpers.js +24 -0
- package/dist/lib/mediaDimensions.d.ts +19 -0
- package/dist/lib/mediaDimensions.js +19 -0
- package/dist/lib/postHelpers.d.ts +146 -0
- package/dist/lib/postHelpers.js +144 -0
- package/dist/lib/profileHelpers.d.ts +30 -0
- package/dist/lib/profileHelpers.js +75 -0
- package/dist/lib/pushHelpers.d.ts +4 -0
- package/dist/lib/pushHelpers.js +6 -0
- package/dist/lib/scopeHelpers.d.ts +25 -0
- package/dist/lib/scopeHelpers.js +85 -0
- package/dist/lib/text.d.ts +3 -0
- package/dist/lib/text.js +18 -0
- package/dist/lib/tokenHelpers.d.ts +21 -0
- package/dist/lib/tokenHelpers.js +81 -0
- package/dist/lib/utils.d.ts +43 -0
- package/dist/lib/utils.js +200 -0
- package/dist/types/admin-db.d.ts +62 -0
- package/dist/types/admin-db.js +41 -0
- package/dist/types/admin-email.d.ts +39 -0
- package/dist/types/admin-email.js +41 -0
- package/dist/types/admin-jobs.d.ts +15 -0
- package/dist/types/admin-jobs.js +14 -0
- package/dist/types/admin-performance.d.ts +23 -0
- package/dist/types/admin-performance.js +14 -0
- package/dist/types/analytics.d.ts +583 -0
- package/dist/types/analytics.js +213 -0
- package/dist/types/api.d.ts +20076 -0
- package/dist/types/api.js +492 -0
- package/dist/types/apple-app-site-association.d.ts +50 -0
- package/dist/types/apple-app-site-association.js +38 -0
- package/dist/types/auth.d.ts +367 -0
- package/dist/types/auth.js +17 -0
- package/dist/types/capabilities.d.ts +24 -0
- package/dist/types/capabilities.js +144 -0
- package/dist/types/config.d.ts +858 -0
- package/dist/types/config.js +352 -0
- package/dist/types/db.d.ts +8780 -0
- package/dist/types/db.js +65 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +18 -0
- package/dist/types/internal.d.ts +44337 -0
- package/dist/types/internal.js +154 -0
- package/dist/types/models.d.ts +2619 -0
- package/dist/types/models.js +599 -0
- package/dist/types/notifications.d.ts +148 -0
- package/dist/types/notifications.js +40 -0
- package/dist/types/plugins.d.ts +66 -0
- package/dist/types/plugins.js +29 -0
- package/dist/types/stats.d.ts +10216 -0
- package/dist/types/stats.js +109 -0
- package/dist/types/stripe.d.ts +42 -0
- package/dist/types/stripe.js +35 -0
- package/dist/types/utils.d.ts +84 -0
- package/dist/types/utils.js +39 -0
- package/package.json +54 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { accessTokenCapabilities, accessTokenRelationships, profileCapabilities, profileRelationships, reportCapabilities, reportRelationships, } from './capabilities.js';
|
|
3
|
+
import { postCapabilities } from './capabilities.js';
|
|
4
|
+
import { postRelationships } from './capabilities.js';
|
|
5
|
+
export const passwordPlaceHolder = '*********';
|
|
6
|
+
export const password = (sanitize) => sanitize
|
|
7
|
+
? z
|
|
8
|
+
.string()
|
|
9
|
+
.transform(() => passwordPlaceHolder)
|
|
10
|
+
.describe('password')
|
|
11
|
+
: z.string();
|
|
12
|
+
export const fixed = (type, sanitize) => (sanitize ? type.describe('fixed') : type);
|
|
13
|
+
export const hidden = (type) => type.describe('hidden');
|
|
14
|
+
export const longText = (type) => type.describe('longText');
|
|
15
|
+
export const mediaStorageParamsSchema = z.object({
|
|
16
|
+
path: z.string(),
|
|
17
|
+
prefix: z.string(),
|
|
18
|
+
host: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
export const stripePaymentConfigSchema = (sanitize) => z.object({
|
|
21
|
+
paidMembership: z
|
|
22
|
+
.object({
|
|
23
|
+
enabled: z.boolean(),
|
|
24
|
+
productId: z.string().optional(),
|
|
25
|
+
trialPeriodDays: z.number().optional(),
|
|
26
|
+
})
|
|
27
|
+
.optional(),
|
|
28
|
+
publishableKey: password(sanitize).optional(),
|
|
29
|
+
secretKey: password(sanitize).optional(),
|
|
30
|
+
webhookSecret: password(sanitize).optional(),
|
|
31
|
+
});
|
|
32
|
+
export const emailConfigSchemaFactory = (sanitize) => z.object({
|
|
33
|
+
service: z.string(),
|
|
34
|
+
defaultTemplatePath: z.string(),
|
|
35
|
+
defaultFrom: z.string().optional(),
|
|
36
|
+
transportConfig: z.object({
|
|
37
|
+
host: z.string(),
|
|
38
|
+
port: z.number(),
|
|
39
|
+
secure: z.boolean().default(true),
|
|
40
|
+
// Optional so unauthenticated SMTP (e.g. Mailpit) can omit credentials.
|
|
41
|
+
auth: z
|
|
42
|
+
.object({
|
|
43
|
+
user: z.string().optional(),
|
|
44
|
+
pass: password(sanitize).optional(),
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
export const emailConfigSchema = emailConfigSchemaFactory(false);
|
|
50
|
+
export const emailConfigSanitizedSchema = emailConfigSchemaFactory(true);
|
|
51
|
+
export const coreConfigSchemaFactory = (sanitize) => z.object({
|
|
52
|
+
version: fixed(z.string(), sanitize),
|
|
53
|
+
environment: fixed(z.string(), sanitize),
|
|
54
|
+
server: z.object({
|
|
55
|
+
host: z.string(),
|
|
56
|
+
signUpsOpen: z.boolean(),
|
|
57
|
+
publicContent: z.boolean(),
|
|
58
|
+
/** Cap on non-deleted profiles; 0 / unset = unlimited. Env-only (not admin-editable). */
|
|
59
|
+
maxProfiles: fixed(z.number().int().nonnegative().optional(), sanitize),
|
|
60
|
+
}),
|
|
61
|
+
db: fixed(z.object({
|
|
62
|
+
url: z.string().url(),
|
|
63
|
+
databaseName: z.string().optional(),
|
|
64
|
+
databaseUrl: z.string(),
|
|
65
|
+
}), sanitize),
|
|
66
|
+
redis: fixed(z.object({
|
|
67
|
+
host: z.string(),
|
|
68
|
+
}), sanitize),
|
|
69
|
+
email: emailConfigSchemaFactory(sanitize).describe('hidden'),
|
|
70
|
+
logs: fixed(z.object({
|
|
71
|
+
local: fixed(z.object({
|
|
72
|
+
path: z.string(),
|
|
73
|
+
}), sanitize),
|
|
74
|
+
}), sanitize),
|
|
75
|
+
media: z.object({
|
|
76
|
+
storage: z.object({
|
|
77
|
+
driver: z.enum(['openpeeps']),
|
|
78
|
+
params: mediaStorageParamsSchema,
|
|
79
|
+
}),
|
|
80
|
+
}),
|
|
81
|
+
network: z.object({
|
|
82
|
+
port: z.number(),
|
|
83
|
+
}),
|
|
84
|
+
plugins: z.object({
|
|
85
|
+
path: z.string(),
|
|
86
|
+
}),
|
|
87
|
+
secrets: z.object({
|
|
88
|
+
jwt: password(sanitize),
|
|
89
|
+
}),
|
|
90
|
+
jams: z.object({
|
|
91
|
+
livekit: z.object({
|
|
92
|
+
url: z.string(),
|
|
93
|
+
apiKey: z.string().optional(),
|
|
94
|
+
apiSecret: password(sanitize).optional(),
|
|
95
|
+
recordingEnabled: z.boolean().optional(),
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
vapid: z.object({
|
|
99
|
+
privateKey: password(sanitize).optional(),
|
|
100
|
+
publicKey: z.string().optional(),
|
|
101
|
+
}),
|
|
102
|
+
federation: z.object({
|
|
103
|
+
active: z.boolean(),
|
|
104
|
+
}),
|
|
105
|
+
activityPub: z.object({
|
|
106
|
+
defaultDomain: z.string(),
|
|
107
|
+
itemsPerPage: z.number(),
|
|
108
|
+
threadDepth: z.number(),
|
|
109
|
+
federation: z.object({
|
|
110
|
+
requestTimeout: z.number(),
|
|
111
|
+
}),
|
|
112
|
+
}),
|
|
113
|
+
sso: z.object({
|
|
114
|
+
generic: z
|
|
115
|
+
.object({
|
|
116
|
+
userProfileRequest: z.object({
|
|
117
|
+
url: z.string(),
|
|
118
|
+
authHeader: z.string().optional(),
|
|
119
|
+
}),
|
|
120
|
+
userProfilePaths: z.object({
|
|
121
|
+
email: z.string(),
|
|
122
|
+
handle: z.string().optional(),
|
|
123
|
+
avatar: z.string().optional(),
|
|
124
|
+
displayName: z.string().optional(),
|
|
125
|
+
}),
|
|
126
|
+
createAccounts: z.boolean().optional(),
|
|
127
|
+
createProfiles: z.boolean().optional(),
|
|
128
|
+
})
|
|
129
|
+
.default({
|
|
130
|
+
userProfileRequest: {
|
|
131
|
+
url: 'https://example.com/profile',
|
|
132
|
+
authHeader: 'Bearer ${token}',
|
|
133
|
+
},
|
|
134
|
+
userProfilePaths: {
|
|
135
|
+
email: '$.data.account.email',
|
|
136
|
+
},
|
|
137
|
+
createAccounts: true,
|
|
138
|
+
createProfiles: true,
|
|
139
|
+
})
|
|
140
|
+
.array(),
|
|
141
|
+
oidc: z
|
|
142
|
+
.object({
|
|
143
|
+
id: z.string(),
|
|
144
|
+
name: z.string(),
|
|
145
|
+
authorizationUrl: z.string(),
|
|
146
|
+
tokenUrl: z.string(),
|
|
147
|
+
userinfoUrl: z.string(),
|
|
148
|
+
jwksUri: z.string().optional(),
|
|
149
|
+
clientId: z.string(),
|
|
150
|
+
clientSecret: password(sanitize).optional(),
|
|
151
|
+
scope: z.string().optional(),
|
|
152
|
+
claimMapping: z
|
|
153
|
+
.object({
|
|
154
|
+
email: z.string().optional(),
|
|
155
|
+
handle: z.string().optional(),
|
|
156
|
+
displayName: z.string().optional(),
|
|
157
|
+
avatar: z.string().optional(),
|
|
158
|
+
})
|
|
159
|
+
.optional(),
|
|
160
|
+
approvalRequired: z.boolean().optional(),
|
|
161
|
+
})
|
|
162
|
+
.default({
|
|
163
|
+
id: 'example-oidc',
|
|
164
|
+
name: 'OIDC Provider',
|
|
165
|
+
authorizationUrl: 'https://example.com/authorize',
|
|
166
|
+
tokenUrl: 'https://example.com/token',
|
|
167
|
+
userinfoUrl: 'https://example.com/userinfo',
|
|
168
|
+
clientId: '',
|
|
169
|
+
scope: 'openid email profile',
|
|
170
|
+
claimMapping: {
|
|
171
|
+
email: 'email',
|
|
172
|
+
handle: 'preferred_username',
|
|
173
|
+
displayName: 'name',
|
|
174
|
+
avatar: 'picture',
|
|
175
|
+
},
|
|
176
|
+
approvalRequired: false,
|
|
177
|
+
})
|
|
178
|
+
.array(),
|
|
179
|
+
}),
|
|
180
|
+
services: z.object({
|
|
181
|
+
sentry: z.object({
|
|
182
|
+
enabled: z.boolean(),
|
|
183
|
+
dsn: z.string().optional(),
|
|
184
|
+
replayEnabled: z.boolean().optional(),
|
|
185
|
+
}),
|
|
186
|
+
location: z.object({
|
|
187
|
+
type: z.string(),
|
|
188
|
+
url: z.string(),
|
|
189
|
+
apiKey: password(sanitize).optional(),
|
|
190
|
+
}),
|
|
191
|
+
}),
|
|
192
|
+
apps: z.object({
|
|
193
|
+
ios: z.object({
|
|
194
|
+
url: z.string().optional(),
|
|
195
|
+
bundleIdentifier: z.string().optional(),
|
|
196
|
+
teamId: z.string().optional(),
|
|
197
|
+
appId: z.string().optional(),
|
|
198
|
+
apnKeyId: z.string().optional(),
|
|
199
|
+
apnSigningKey: longText(z.string()).optional(),
|
|
200
|
+
}),
|
|
201
|
+
android: z.object({
|
|
202
|
+
url: z.string().optional(),
|
|
203
|
+
packageName: z.string().optional(),
|
|
204
|
+
appId: z.string().optional(),
|
|
205
|
+
fcmCredentials: longText(z.string()).optional(),
|
|
206
|
+
}),
|
|
207
|
+
}),
|
|
208
|
+
payments: z.object({
|
|
209
|
+
stripe: stripePaymentConfigSchema(sanitize),
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
export const coreConfigSchema = coreConfigSchemaFactory(false);
|
|
213
|
+
export const coreConfigSanitizedSchema = coreConfigSchemaFactory(true);
|
|
214
|
+
export const communityConfigSchemaFactory = (_sanitize) => z.object({
|
|
215
|
+
theme: z.object({
|
|
216
|
+
base: z.string(),
|
|
217
|
+
icon: z.string().optional(),
|
|
218
|
+
mobileIcon: z.string().optional(),
|
|
219
|
+
primaryHex: z.string(),
|
|
220
|
+
logoFull: z.string().optional(),
|
|
221
|
+
logoSmall: z.string().optional(),
|
|
222
|
+
defaultProfileAvatar: z.string().optional(),
|
|
223
|
+
defaultGroupAvatar: z.string().optional(),
|
|
224
|
+
backgroundAuth: z.string().optional(),
|
|
225
|
+
background: z.string().optional(),
|
|
226
|
+
light: z.object({
|
|
227
|
+
primaryHex: z.string(),
|
|
228
|
+
logoSmall: z.string().optional(),
|
|
229
|
+
defaultProfileAvatar: z.string().optional(),
|
|
230
|
+
defaultGroupAvatar: z.string().optional(),
|
|
231
|
+
backgroundAuth: z.string().optional(),
|
|
232
|
+
background: z.string().optional(),
|
|
233
|
+
}),
|
|
234
|
+
dark: z.object({
|
|
235
|
+
primaryHex: z.string(),
|
|
236
|
+
logoSmall: z.string().optional(),
|
|
237
|
+
defaultProfileAvatar: z.string().optional(),
|
|
238
|
+
defaultGroupAvatar: z.string().optional(),
|
|
239
|
+
backgroundAuth: z.string().optional(),
|
|
240
|
+
background: z.string().optional(),
|
|
241
|
+
}),
|
|
242
|
+
}),
|
|
243
|
+
profiles: z
|
|
244
|
+
.object({
|
|
245
|
+
additionalFields: z
|
|
246
|
+
.object({
|
|
247
|
+
key: z.string(),
|
|
248
|
+
label: z.string(),
|
|
249
|
+
icon: z.string().optional(),
|
|
250
|
+
linkPattern: z.string().optional(),
|
|
251
|
+
})
|
|
252
|
+
.array()
|
|
253
|
+
.optional(),
|
|
254
|
+
})
|
|
255
|
+
.optional(),
|
|
256
|
+
info: z.object({
|
|
257
|
+
name: z.string(),
|
|
258
|
+
tagLine: z.string(),
|
|
259
|
+
contactEmail: z.string().email().optional(),
|
|
260
|
+
privacyPolicy: z.string().optional(),
|
|
261
|
+
termsAndConditions: z.string().optional(),
|
|
262
|
+
}),
|
|
263
|
+
content: z.object({
|
|
264
|
+
aboutPage: z.string().optional(),
|
|
265
|
+
welcomePage: z.string().optional(),
|
|
266
|
+
codeOfConduct: z.string().optional(),
|
|
267
|
+
welcomeEmail: z.string().optional(),
|
|
268
|
+
pinnedPost: z.string().optional(),
|
|
269
|
+
}),
|
|
270
|
+
settings: z.object({
|
|
271
|
+
openRegistrations: z.boolean(),
|
|
272
|
+
defaultLanguage: z.string().optional(),
|
|
273
|
+
}),
|
|
274
|
+
roles: z.object({
|
|
275
|
+
onRegistration: z.object({
|
|
276
|
+
add: z.string().array(),
|
|
277
|
+
remove: z.string().array(),
|
|
278
|
+
}),
|
|
279
|
+
onEmailValidation: z.object({
|
|
280
|
+
add: z.string().array(),
|
|
281
|
+
remove: z.string().array(),
|
|
282
|
+
}),
|
|
283
|
+
}),
|
|
284
|
+
});
|
|
285
|
+
export const communityConfigSchema = communityConfigSchemaFactory(false);
|
|
286
|
+
export const communityConfigSanitizedSchema = communityConfigSchemaFactory(true);
|
|
287
|
+
const addWildCardOptions = (capabilities) => {
|
|
288
|
+
const wildCard = '*';
|
|
289
|
+
const firstLevelCategories = new Set(capabilities.map((capability) => capability.split('-')[0]));
|
|
290
|
+
const secondLevelCategories = [...firstLevelCategories].map((flc) => new Set(capabilities
|
|
291
|
+
.map((c) => c.split('-'))
|
|
292
|
+
.filter((clist) => clist[0] === flc)
|
|
293
|
+
.map((clist) => `${flc}-${clist[1]}`)));
|
|
294
|
+
return [
|
|
295
|
+
wildCard,
|
|
296
|
+
...capabilities,
|
|
297
|
+
[...firstLevelCategories].map((flc) => `${flc}-${wildCard}`),
|
|
298
|
+
[...secondLevelCategories].flatMap((slc) => [
|
|
299
|
+
...slc,
|
|
300
|
+
`${slc.keys().next().value}-${wildCard}`,
|
|
301
|
+
]),
|
|
302
|
+
].flat();
|
|
303
|
+
};
|
|
304
|
+
export const capabilitiesSchema = z
|
|
305
|
+
.object({
|
|
306
|
+
add: z.string().array().optional(),
|
|
307
|
+
remove: z.string().array().optional(),
|
|
308
|
+
})
|
|
309
|
+
.optional();
|
|
310
|
+
const capabilitiesGroupSchema = (capabilities) => z
|
|
311
|
+
.object({
|
|
312
|
+
add: z
|
|
313
|
+
.array(z.enum(addWildCardOptions(capabilities)))
|
|
314
|
+
.optional()
|
|
315
|
+
.default([]),
|
|
316
|
+
remove: z
|
|
317
|
+
.array(z.enum(addWildCardOptions(capabilities)))
|
|
318
|
+
.optional()
|
|
319
|
+
.default([]),
|
|
320
|
+
})
|
|
321
|
+
.optional()
|
|
322
|
+
.default({ add: [], remove: [] });
|
|
323
|
+
const relationshipsGroupSchema = (relationships, capabilities) => z.object(Object.fromEntries(relationships.map((relationship) => [
|
|
324
|
+
relationship,
|
|
325
|
+
capabilitiesGroupSchema(capabilities),
|
|
326
|
+
])));
|
|
327
|
+
export const capabilitiesConfigSchema = z.object({
|
|
328
|
+
post: relationshipsGroupSchema(postRelationships, [...postCapabilities]),
|
|
329
|
+
profile: relationshipsGroupSchema(profileRelationships, [
|
|
330
|
+
...profileCapabilities,
|
|
331
|
+
...postCapabilities,
|
|
332
|
+
]),
|
|
333
|
+
report: relationshipsGroupSchema(reportRelationships, [
|
|
334
|
+
...reportCapabilities,
|
|
335
|
+
]),
|
|
336
|
+
accessToken: relationshipsGroupSchema(accessTokenRelationships, [
|
|
337
|
+
...accessTokenCapabilities,
|
|
338
|
+
]),
|
|
339
|
+
});
|
|
340
|
+
export const capabilitiesConfigSchemaFactory = (_sanitize) => z.object({
|
|
341
|
+
post: relationshipsGroupSchema(postRelationships, [...postCapabilities]),
|
|
342
|
+
profile: relationshipsGroupSchema(profileRelationships, [
|
|
343
|
+
...profileCapabilities,
|
|
344
|
+
...postCapabilities,
|
|
345
|
+
]),
|
|
346
|
+
report: relationshipsGroupSchema(reportRelationships, [
|
|
347
|
+
...reportCapabilities,
|
|
348
|
+
]),
|
|
349
|
+
accessToken: relationshipsGroupSchema(accessTokenRelationships, [
|
|
350
|
+
...accessTokenCapabilities,
|
|
351
|
+
]),
|
|
352
|
+
});
|