@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
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ import { CommunityConfig } from './config';
3
+ import type { i18n, ResourceKey } from 'i18next';
4
+
5
+ type Literal = string | number | boolean | null | undefined;
6
+ export type Json = Literal | { [key: string]: Json } | Json[];
7
+ // NOTE: we used to model Json/ResourceKey as `z.lazy(() => z.union([...]))` for
8
+ // proper recursive validation. zod 4 + @asteasolutions/zod-to-openapi v8 blow
9
+ // the stack when walking such circular schemas during OpenAPI generation
10
+ // (isNullableSchema → safeParse(null) → ZodError → JSON.stringify on the
11
+ // lazy ref). Since runtime validation of arbitrary JSON is permissive anyway,
12
+ // model them as `z.any()` with a stable OpenAPI id and cast the public type.
13
+ export const jsonSchema = z
14
+ .any()
15
+ .openapi('JsonValue', { type: 'object' }) as unknown as z.ZodType<Json>;
16
+
17
+ export const i18nResourceKeySchema = z.any().openapi('I18nResourceKey', {
18
+ type: 'object',
19
+ }) as unknown as z.ZodType<ResourceKey>;
20
+ export const i18nResourceLanguageSchema = z.record(
21
+ z.string(),
22
+ i18nResourceKeySchema,
23
+ );
24
+ export const i18nResourceSchema = z.record(
25
+ z.string(),
26
+ i18nResourceLanguageSchema,
27
+ );
28
+
29
+ export const emailAttachmentSchema = z.object({
30
+ filename: z.string(),
31
+ /** Raw string content (e.g. an .ics body). Kept as a string so the options
32
+ * stay JSON-serializable across the email queue and HTTP render boundary. */
33
+ content: z.string(),
34
+ contentType: z.string().optional(),
35
+ /** Set to base64 when `content` is a base64-encoded binary payload (e.g. PDF). */
36
+ encoding: z.enum(['utf8', 'base64']).optional(),
37
+ });
38
+ export type EmailAttachment = z.infer<typeof emailAttachmentSchema>;
39
+
40
+ export const emailOptionsSchema = z.object({
41
+ to: z.string(),
42
+ template: z.string(),
43
+ locals: z.record(z.string(), jsonSchema).optional(),
44
+ attachments: z.array(emailAttachmentSchema).optional(),
45
+ });
46
+ export type EmailOptions = z.infer<typeof emailOptionsSchema>;
47
+
48
+ export const renderedEmailSchema = z.object({
49
+ to: z.string(),
50
+ template: z.string(),
51
+ subject: z.string(),
52
+ html: z.string(),
53
+ text: z.string(),
54
+ });
55
+ export type RenderedEmail = z.infer<typeof renderedEmailSchema>;
56
+
57
+ export interface EmailService {
58
+ send: (renderedEmail: EmailOptions) => Promise<void>;
59
+ render: (emailOptions: EmailOptions) => Promise<RenderedEmail>;
60
+ }
61
+
62
+ export interface EmailGlobals {
63
+ communityConfig: CommunityConfig;
64
+ serverData: {
65
+ rootUrl: string;
66
+ iosUrl?: string;
67
+ androidUrl?: string;
68
+ };
69
+ i18nContext: {
70
+ i18n: i18n;
71
+ t: i18n['t'];
72
+ };
73
+ /** Recipient display timezone: profile setting, else community, else UTC. */
74
+ timeZone: string;
75
+ }
76
+
77
+ export interface EmailOptionsWithGlobals extends EmailOptions {
78
+ globals: EmailGlobals;
79
+ }
80
+
81
+ export interface EmailRenderer {
82
+ (
83
+ emailOptions: EmailOptionsWithGlobals & { locals: Record<string, unknown> },
84
+ ): Promise<{ subject: string; html: string }>;
85
+ }
86
+
87
+ export type Level = 'info' | 'warn' | 'error' | 'fatal' | 'debug' | 'trace';
88
+
89
+ export interface Logger {
90
+ info: (...args: unknown[]) => void;
91
+ warn: (...args: unknown[]) => void;
92
+ error: (...args: unknown[]) => void;
93
+ fatal: (...args: unknown[]) => void;
94
+ debug: (...args: unknown[]) => void;
95
+ trace: (...args: unknown[]) => void;
96
+ }
97
+
98
+ export interface LoggerFactory {
99
+ (ns: string, meta?: Record<string, unknown>): Logger;
100
+ }
package/src/zod.ts ADDED
@@ -0,0 +1 @@
1
+ export * from 'zod';