@openpeepshq/common 0.1.45 → 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 (126) hide show
  1. package/dist/lib/adminSections.js +1 -1
  2. package/dist/lib/capabilitiesHelpers.d.ts +9 -7
  3. package/dist/lib/capabilitiesHelpers.js +43 -38
  4. package/dist/lib/csvHelpers.js +1 -1
  5. package/dist/lib/eventIcs.d.ts +17 -0
  6. package/dist/lib/eventIcs.js +91 -15
  7. package/dist/lib/eventRecurrence.d.ts +19 -0
  8. package/dist/lib/eventRecurrence.js +82 -20
  9. package/dist/lib/eventTime.d.ts +7 -0
  10. package/dist/lib/eventTime.js +23 -9
  11. package/dist/lib/federationHosts.d.ts +3 -0
  12. package/dist/lib/federationHosts.js +17 -0
  13. package/dist/lib/feedCursor.d.ts +14 -0
  14. package/dist/lib/feedCursor.js +22 -0
  15. package/dist/lib/feedFormat.d.ts +12 -0
  16. package/dist/lib/feedFormat.js +14 -0
  17. package/dist/lib/groupHelpers.js +13 -34
  18. package/dist/lib/groupTemplateHelpers.js +6 -10
  19. package/dist/lib/index.d.ts +7 -0
  20. package/dist/lib/index.js +7 -0
  21. package/dist/lib/jamHelpers.d.ts +11 -2
  22. package/dist/lib/jamHelpers.js +43 -9
  23. package/dist/lib/legacyThemeRoot.d.ts +3 -0
  24. package/dist/lib/legacyThemeRoot.js +10 -0
  25. package/dist/lib/markdownHelpers.d.ts +8 -0
  26. package/dist/lib/markdownHelpers.js +34 -6
  27. package/dist/lib/postHelpers.d.ts +142 -3
  28. package/dist/lib/postHelpers.js +323 -47
  29. package/dist/lib/profileHelpers.d.ts +11 -0
  30. package/dist/lib/profileHelpers.js +34 -10
  31. package/dist/lib/pushHelpers.js +3 -4
  32. package/dist/lib/reactions.d.ts +17 -0
  33. package/dist/lib/reactions.js +37 -0
  34. package/dist/lib/scopeHelpers.d.ts +31 -2
  35. package/dist/lib/scopeHelpers.js +39 -8
  36. package/dist/lib/ssoLoginUrl.js +4 -6
  37. package/dist/lib/ssoProviders.d.ts +72 -0
  38. package/dist/lib/ssoProviders.js +366 -0
  39. package/dist/lib/timeZone.d.ts +9 -0
  40. package/dist/lib/timeZone.js +44 -0
  41. package/dist/lib/tokenHelpers.js +5 -5
  42. package/dist/lib/utils.js +6 -7
  43. package/dist/types/admin-db.js +1 -1
  44. package/dist/types/analytics.d.ts +20 -0
  45. package/dist/types/analytics.js +4 -0
  46. package/dist/types/api.d.ts +41800 -11853
  47. package/dist/types/api.js +53 -5
  48. package/dist/types/auth.d.ts +20 -6
  49. package/dist/types/capabilities.d.ts +15 -1
  50. package/dist/types/capabilities.js +51 -0
  51. package/dist/types/config.d.ts +99 -0
  52. package/dist/types/config.js +56 -4
  53. package/dist/types/db.d.ts +1155 -164
  54. package/dist/types/db.js +14 -0
  55. package/dist/types/export.d.ts +120 -0
  56. package/dist/types/export.js +7 -0
  57. package/dist/types/index.d.ts +2 -0
  58. package/dist/types/index.js +2 -0
  59. package/dist/types/internal.d.ts +2577 -524
  60. package/dist/types/internal.js +6 -0
  61. package/dist/types/models.d.ts +63 -7
  62. package/dist/types/models.js +40 -3
  63. package/dist/types/plugins.d.ts +22 -0
  64. package/dist/types/plugins.js +66 -0
  65. package/dist/types/roleDefaults.d.ts +31 -0
  66. package/dist/types/roleDefaults.js +110 -0
  67. package/dist/types/stats.d.ts +54606 -6065
  68. package/dist/types/stats.js +30 -0
  69. package/dist/types/utils.d.ts +2 -0
  70. package/dist/types/utils.js +1 -3
  71. package/dist/zod.d.ts +1 -0
  72. package/dist/zod.js +1 -0
  73. package/package.json +36 -6
  74. package/src/index.ts +4 -0
  75. package/src/lib/adminSections.ts +84 -0
  76. package/src/lib/attachmentHelpers.ts +14 -0
  77. package/src/lib/capabilitiesHelpers.ts +532 -0
  78. package/src/lib/colors.ts +20 -0
  79. package/src/lib/csvHelpers.ts +31 -0
  80. package/src/lib/eventIcs.ts +265 -0
  81. package/src/lib/eventRecurrence.ts +495 -0
  82. package/src/lib/eventTime.ts +206 -0
  83. package/src/lib/federationHosts.ts +22 -0
  84. package/src/lib/feedCursor.ts +27 -0
  85. package/src/lib/feedFormat.ts +24 -0
  86. package/src/lib/groupHelpers.ts +421 -0
  87. package/src/lib/groupTemplateHelpers.ts +83 -0
  88. package/src/lib/index.ts +29 -0
  89. package/src/lib/jamHelpers.ts +164 -0
  90. package/src/lib/legacyThemeRoot.ts +14 -0
  91. package/src/lib/markdownHelpers.ts +122 -0
  92. package/src/lib/mediaDimensions.ts +21 -0
  93. package/src/lib/postHelpers.ts +783 -0
  94. package/src/lib/profileHelpers.ts +220 -0
  95. package/src/lib/pushHelpers.ts +34 -0
  96. package/src/lib/reactions.ts +52 -0
  97. package/src/lib/reportHelpers.ts +7 -0
  98. package/src/lib/scopeHelpers.ts +176 -0
  99. package/src/lib/ssoLoginUrl.ts +93 -0
  100. package/src/lib/ssoProviders.ts +472 -0
  101. package/src/lib/text.ts +26 -0
  102. package/src/lib/timeZone.ts +52 -0
  103. package/src/lib/tokenHelpers.ts +119 -0
  104. package/src/lib/utils.ts +322 -0
  105. package/src/types/admin-db.ts +74 -0
  106. package/src/types/admin-email.ts +55 -0
  107. package/src/types/admin-jobs.ts +17 -0
  108. package/src/types/admin-performance.ts +20 -0
  109. package/src/types/analytics.ts +318 -0
  110. package/src/types/api.ts +871 -0
  111. package/src/types/apple-app-site-association.ts +54 -0
  112. package/src/types/auth.ts +22 -0
  113. package/src/types/capabilities.ts +280 -0
  114. package/src/types/config.ts +546 -0
  115. package/src/types/db.ts +138 -0
  116. package/src/types/export.ts +10 -0
  117. package/src/types/index.ts +20 -0
  118. package/src/types/internal.ts +338 -0
  119. package/src/types/models.ts +939 -0
  120. package/src/types/notifications.ts +92 -0
  121. package/src/types/plugins.ts +150 -0
  122. package/src/types/roleDefaults.ts +132 -0
  123. package/src/types/stats.ts +195 -0
  124. package/src/types/stripe.ts +45 -0
  125. package/src/types/utils.ts +100 -0
  126. package/src/zod.ts +1 -0
@@ -17,6 +17,14 @@ export const mediaStorageParamsSchema = z.object({
17
17
  prefix: z.string(),
18
18
  host: z.string().optional(),
19
19
  });
20
+ /** MiB. 1024 is 1 GiB — the default shown in the admin media section. */
21
+ export const DEFAULT_MAX_MEDIA_UPLOAD_MB = 1024;
22
+ export const mediaUploadLimitBytes = (maxUploadMb) => {
23
+ const mb = Number.isInteger(maxUploadMb) && maxUploadMb >= 1
24
+ ? maxUploadMb
25
+ : DEFAULT_MAX_MEDIA_UPLOAD_MB;
26
+ return mb * 1024 * 1024;
27
+ };
20
28
  export const stripePaymentConfigSchema = (sanitize) => z.object({
21
29
  paidMembership: z
22
30
  .object({
@@ -59,7 +67,7 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
59
67
  maxProfiles: fixed(z.number().int().nonnegative().optional(), sanitize),
60
68
  }),
61
69
  db: fixed(z.object({
62
- // Optional leftovers so Arango-era stored configs still parse.
70
+ // Optional legacy fields so older stored configs still parse.
63
71
  url: z.string().url().optional(),
64
72
  databaseName: z.string().optional(),
65
73
  databaseUrl: z.string(),
@@ -74,6 +82,12 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
74
82
  }), sanitize),
75
83
  }), sanitize),
76
84
  media: z.object({
85
+ maxUploadMb: z
86
+ .number()
87
+ .int()
88
+ .min(1)
89
+ .default(DEFAULT_MAX_MEDIA_UPLOAD_MB)
90
+ .catch(DEFAULT_MAX_MEDIA_UPLOAD_MB),
77
91
  storage: z.object({
78
92
  driver: z.enum(['openpeeps']),
79
93
  params: mediaStorageParamsSchema,
@@ -103,6 +117,8 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
103
117
  }),
104
118
  federation: z.object({
105
119
  active: z.boolean(),
120
+ /** Host patterns (`mastodon.social`, `*.example.com`). Empty = fail closed. */
121
+ allowedHosts: z.array(z.string()).default([]),
106
122
  }),
107
123
  activityPub: z.object({
108
124
  defaultDomain: z.string(),
@@ -112,7 +128,8 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
112
128
  requestTimeout: z.number(),
113
129
  }),
114
130
  }),
115
- sso: z.object({
131
+ sso: z
132
+ .object({
116
133
  onlySSO: z.boolean().optional(),
117
134
  generic: z
118
135
  .object({
@@ -152,9 +169,28 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
152
169
  .object({
153
170
  id: z.string(),
154
171
  name: z.string(),
172
+ kind: z
173
+ .enum([
174
+ 'oidc',
175
+ 'github',
176
+ 'gitlab',
177
+ 'gitlab-selfhosted',
178
+ 'google',
179
+ 'entra',
180
+ 'auth0',
181
+ 'keycloak',
182
+ 'authentik',
183
+ 'okta',
184
+ 'discord',
185
+ 'pocketid',
186
+ ])
187
+ .optional(),
188
+ instanceUrl: z.string().optional(),
189
+ tenant: z.string().optional(),
155
190
  authorizationUrl: z.string(),
156
191
  tokenUrl: z.string(),
157
192
  userinfoUrl: z.string(),
193
+ emailsUrl: z.string().optional(),
158
194
  jwksUri: z.string().optional(),
159
195
  clientId: z.string(),
160
196
  clientSecret: password(sanitize).optional(),
@@ -172,6 +208,7 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
172
208
  .default({
173
209
  id: 'example-oidc',
174
210
  name: 'OIDC Provider',
211
+ kind: 'oidc',
175
212
  authorizationUrl: 'https://example.com/authorize',
176
213
  tokenUrl: 'https://example.com/token',
177
214
  userinfoUrl: 'https://example.com/userinfo',
@@ -186,7 +223,8 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
186
223
  approvalRequired: false,
187
224
  })
188
225
  .array(),
189
- }),
226
+ })
227
+ .describe('hidden'),
190
228
  services: z.object({
191
229
  sentry: z.object({
192
230
  enabled: z.boolean(),
@@ -234,6 +272,15 @@ export const communityConfigSchemaFactory = (_sanitize) => z.object({
234
272
  base: z.string(),
235
273
  icon: z.string().optional(),
236
274
  mobileIcon: z.string().optional(),
275
+ // Kept so /server/info still satisfies common 0.1.44 (required
276
+ // theme.primaryHex) and RN 0.3.1 root-theme reads.
277
+ primaryHex: z.string().optional(),
278
+ logoFull: z.string().optional(),
279
+ logoSmall: z.string().optional(),
280
+ defaultProfileAvatar: z.string().optional(),
281
+ defaultGroupAvatar: z.string().optional(),
282
+ backgroundAuth: z.string().optional(),
283
+ background: z.string().optional(),
237
284
  light: z.object({
238
285
  primaryHex: z.string(),
239
286
  secondaryHex: z.string().optional(),
@@ -283,6 +330,11 @@ export const communityConfigSchemaFactory = (_sanitize) => z.object({
283
330
  settings: z.object({
284
331
  openRegistrations: z.boolean(),
285
332
  defaultLanguage: z.string().optional(),
333
+ defaultTimeZone: z.string().optional(),
334
+ defaultFeedFormat: z.enum(['threaded', 'linear']).optional(),
335
+ /** Adds member profile pages to the sitemap. Off by default: a crawled
336
+ * profile is cached by search engines long after the member leaves. */
337
+ indexProfiles: z.boolean().optional(),
286
338
  }),
287
339
  roles: z.object({
288
340
  onRegistration: z.object({
@@ -310,7 +362,7 @@ const addWildCardOptions = (capabilities) => {
310
362
  [...firstLevelCategories].map((flc) => `${flc}-${wildCard}`),
311
363
  [...secondLevelCategories].flatMap((slc) => [
312
364
  ...slc,
313
- `${slc.keys().next().value}-${wildCard}`,
365
+ ...[...slc].map((key) => `${key}-${wildCard}`),
314
366
  ]),
315
367
  ].flat();
316
368
  };