@openpeepshq/common 0.4.0 → 0.5.11

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 (69) hide show
  1. package/dist/lib/adminSections.d.ts +4 -0
  2. package/dist/lib/adminSections.js +5 -0
  3. package/dist/lib/attachmentHelpers.js +5 -1
  4. package/dist/lib/capabilitiesHelpers.d.ts +9 -0
  5. package/dist/lib/capabilitiesHelpers.js +9 -0
  6. package/dist/lib/csvHelpers.d.ts +2 -0
  7. package/dist/lib/csvHelpers.js +13 -0
  8. package/dist/lib/eventRecurrence.d.ts +9 -0
  9. package/dist/lib/eventRecurrence.js +17 -9
  10. package/dist/lib/eventWaitlist.d.ts +58 -0
  11. package/dist/lib/eventWaitlist.js +217 -0
  12. package/dist/lib/index.d.ts +1 -0
  13. package/dist/lib/index.js +1 -0
  14. package/dist/lib/markdownHelpers.d.ts +12 -3
  15. package/dist/lib/markdownHelpers.js +115 -6
  16. package/dist/lib/postHelpers.d.ts +35 -5
  17. package/dist/lib/postHelpers.js +85 -10
  18. package/dist/lib/profileHelpers.d.ts +12 -2
  19. package/dist/lib/profileHelpers.js +24 -3
  20. package/dist/lib/resources.d.ts +29 -1
  21. package/dist/lib/resources.js +74 -2
  22. package/dist/lib/utils.js +11 -11
  23. package/dist/types/admin-livekit.d.ts +23 -0
  24. package/dist/types/admin-livekit.js +18 -0
  25. package/dist/types/admin-media.d.ts +41 -0
  26. package/dist/types/admin-media.js +20 -0
  27. package/dist/types/api.d.ts +19945 -3526
  28. package/dist/types/api.js +15 -9
  29. package/dist/types/capabilities.d.ts +2 -2
  30. package/dist/types/capabilities.js +3 -0
  31. package/dist/types/config.d.ts +3 -0
  32. package/dist/types/config.js +6 -0
  33. package/dist/types/db.d.ts +65 -22
  34. package/dist/types/forbiddenHandles.d.ts +28 -0
  35. package/dist/types/forbiddenHandles.js +75 -0
  36. package/dist/types/index.d.ts +2 -0
  37. package/dist/types/index.js +2 -0
  38. package/dist/types/internal.d.ts +163 -44
  39. package/dist/types/models.d.ts +28 -14
  40. package/dist/types/models.js +27 -28
  41. package/dist/types/notifications.d.ts +2 -0
  42. package/dist/types/notifications.js +4 -2
  43. package/dist/types/roleDefaults.js +109 -95
  44. package/dist/types/stats.d.ts +348 -108
  45. package/package.json +7 -6
  46. package/src/lib/adminSections.ts +5 -0
  47. package/src/lib/attachmentHelpers.ts +18 -12
  48. package/src/lib/capabilitiesHelpers.ts +15 -0
  49. package/src/lib/csvHelpers.ts +19 -3
  50. package/src/lib/eventRecurrence.ts +19 -10
  51. package/src/lib/eventWaitlist.ts +325 -0
  52. package/src/lib/index.ts +1 -0
  53. package/src/lib/markdownHelpers.ts +121 -7
  54. package/src/lib/postHelpers.ts +129 -11
  55. package/src/lib/profileHelpers.ts +38 -3
  56. package/src/lib/resources.ts +105 -2
  57. package/src/lib/utils.ts +40 -31
  58. package/src/types/admin-livekit.ts +24 -0
  59. package/src/types/admin-media.ts +29 -0
  60. package/src/types/api.ts +19 -9
  61. package/src/types/auth.ts +2 -2
  62. package/src/types/capabilities.ts +3 -0
  63. package/src/types/config.ts +6 -0
  64. package/src/types/forbiddenHandles.ts +103 -0
  65. package/src/types/index.ts +2 -0
  66. package/src/types/models.ts +53 -33
  67. package/src/types/notifications.ts +7 -7
  68. package/src/types/roleDefaults.ts +115 -96
  69. package/src/types/stripe.ts +3 -1
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ export const handleRegexBase = '[a-zA-Z0-9_-]{1,16}';
3
+ export const handleRegex = new RegExp(`^${handleRegexBase}$`);
4
+ export const HANDLE_RESERVED_MESSAGE = 'Handle is reserved';
5
+ /**
6
+ * Platform routes and system names. Always reserved. Community config can add
7
+ * names, but these stay in code so an admin cannot delete them.
8
+ */
9
+ export const forbiddenHandles = [
10
+ 'admin',
11
+ 'allpeep',
12
+ 'api',
13
+ 'app',
14
+ 'auth',
15
+ 'config',
16
+ 'core',
17
+ 'db',
18
+ 'email',
19
+ 'federation',
20
+ 'jam',
21
+ 'media',
22
+ 'network',
23
+ 'plugins',
24
+ 'undefined',
25
+ 'jamStarted',
26
+ 'jamSpeaker',
27
+ 'jamModerator',
28
+ 'new',
29
+ ];
30
+ const defaultForbiddenHandles = new Set(forbiddenHandles.map((handle) => handle.toLowerCase()));
31
+ export const normalizeForbiddenHandle = (value) => value.trim().toLowerCase();
32
+ export const isDefaultForbiddenHandle = (value) => defaultForbiddenHandles.has(normalizeForbiddenHandle(value));
33
+ /** Exact username match, case-insensitive. `additional` is the community list. */
34
+ export const isForbiddenHandle = (value, additional) => {
35
+ const normalized = normalizeForbiddenHandle(value);
36
+ if (!normalized)
37
+ return false;
38
+ if (defaultForbiddenHandles.has(normalized))
39
+ return true;
40
+ return (additional ?? []).some((entry) => normalizeForbiddenHandle(entry) === normalized);
41
+ };
42
+ export const classifyAdditionalForbiddenHandle = (raw, existing = []) => {
43
+ const value = normalizeForbiddenHandle(raw);
44
+ if (!value)
45
+ return 'empty';
46
+ if (!handleRegex.test(value))
47
+ return 'invalid';
48
+ if (isDefaultForbiddenHandle(value))
49
+ return 'builtIn';
50
+ if (existing.some((entry) => normalizeForbiddenHandle(entry) === value)) {
51
+ return 'duplicate';
52
+ }
53
+ return null;
54
+ };
55
+ /**
56
+ * Community-added names only. Built-in names, blanks, duplicates, and values
57
+ * that can never match a handle are dropped so they cannot be stored or deleted.
58
+ */
59
+ export const collectAdditionalForbiddenHandles = (values) => {
60
+ const issues = [];
61
+ const handles = [];
62
+ values.forEach((raw, index) => {
63
+ const issue = classifyAdditionalForbiddenHandle(raw, handles);
64
+ if (issue === 'empty' || issue === 'invalid') {
65
+ issues.push({ index, issue });
66
+ return;
67
+ }
68
+ if (issue)
69
+ return;
70
+ handles.push(normalizeForbiddenHandle(raw));
71
+ });
72
+ return { handles, issues };
73
+ };
74
+ /** Stored as given. PATCH normalizes before save; reads stay a plain string list. */
75
+ export const additionalForbiddenHandlesSchema = z.array(z.string());
@@ -15,6 +15,8 @@ export * from './notifications';
15
15
  export * from './stripe';
16
16
  export * from './db';
17
17
  export * from './admin-email';
18
+ export * from './admin-media';
18
19
  export * from './admin-jobs';
19
20
  export * from './admin-db';
20
21
  export * from './admin-performance';
22
+ export * from './admin-livekit';
@@ -15,6 +15,8 @@ export * from './notifications.js';
15
15
  export * from './stripe.js';
16
16
  export * from './db.js';
17
17
  export * from './admin-email.js';
18
+ export * from './admin-media.js';
18
19
  export * from './admin-jobs.js';
19
20
  export * from './admin-db.js';
20
21
  export * from './admin-performance.js';
22
+ export * from './admin-livekit.js';