@openpeepshq/common 0.3.2 → 0.5.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/lib/adminSections.d.ts +4 -0
- package/dist/lib/adminSections.js +5 -0
- package/dist/lib/attachmentHelpers.js +5 -1
- package/dist/lib/capabilitiesHelpers.d.ts +9 -0
- package/dist/lib/capabilitiesHelpers.js +9 -0
- package/dist/lib/csvHelpers.d.ts +2 -0
- package/dist/lib/csvHelpers.js +13 -0
- package/dist/lib/eventRecurrence.d.ts +11 -1
- package/dist/lib/eventRecurrence.js +23 -13
- package/dist/lib/eventWaitlist.d.ts +58 -0
- package/dist/lib/eventWaitlist.js +217 -0
- package/dist/lib/groupHelpers.d.ts +5 -0
- package/dist/lib/groupHelpers.js +16 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/markdownHelpers.d.ts +12 -3
- package/dist/lib/markdownHelpers.js +115 -6
- package/dist/lib/postHelpers.d.ts +27 -5
- package/dist/lib/postHelpers.js +73 -11
- package/dist/lib/profileHelpers.d.ts +12 -2
- package/dist/lib/profileHelpers.js +19 -2
- package/dist/lib/resources.d.ts +29 -1
- package/dist/lib/resources.js +74 -2
- package/dist/lib/utils.js +11 -11
- package/dist/types/admin-livekit.d.ts +23 -0
- package/dist/types/admin-livekit.js +18 -0
- package/dist/types/admin-media.d.ts +41 -0
- package/dist/types/admin-media.js +20 -0
- package/dist/types/api.d.ts +19945 -3526
- package/dist/types/api.js +16 -10
- package/dist/types/capabilities.d.ts +2 -2
- package/dist/types/capabilities.js +3 -0
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.js +14 -2
- package/dist/types/db.d.ts +65 -22
- package/dist/types/forbiddenHandles.d.ts +28 -0
- package/dist/types/forbiddenHandles.js +75 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/internal.d.ts +163 -44
- package/dist/types/models.d.ts +46 -14
- package/dist/types/models.js +38 -28
- package/dist/types/notifications.d.ts +2 -0
- package/dist/types/notifications.js +4 -2
- package/dist/types/roleDefaults.js +109 -95
- package/dist/types/stats.d.ts +348 -108
- package/package.json +7 -6
- package/src/lib/adminSections.ts +5 -0
- package/src/lib/attachmentHelpers.ts +18 -12
- package/src/lib/capabilitiesHelpers.ts +15 -0
- package/src/lib/csvHelpers.ts +19 -3
- package/src/lib/eventRecurrence.ts +33 -19
- package/src/lib/eventWaitlist.ts +325 -0
- package/src/lib/groupHelpers.ts +25 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/markdownHelpers.ts +121 -7
- package/src/lib/postHelpers.ts +102 -13
- package/src/lib/profileHelpers.ts +31 -2
- package/src/lib/resources.ts +105 -2
- package/src/lib/utils.ts +40 -31
- package/src/types/admin-livekit.ts +24 -0
- package/src/types/admin-media.ts +29 -0
- package/src/types/api.ts +20 -10
- package/src/types/auth.ts +2 -2
- package/src/types/capabilities.ts +3 -0
- package/src/types/config.ts +19 -10
- package/src/types/forbiddenHandles.ts +103 -0
- package/src/types/index.ts +2 -0
- package/src/types/models.ts +70 -33
- package/src/types/notifications.ts +7 -7
- package/src/types/roleDefaults.ts +115 -96
- package/src/types/stripe.ts +3 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const livekitDiagnosisCheckIdSchema = z.enum([
|
|
4
|
+
'url',
|
|
5
|
+
'apiKey',
|
|
6
|
+
'apiSecret',
|
|
7
|
+
'reachable',
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
export const livekitDiagnosisSchema = z.object({
|
|
11
|
+
connected: z.boolean(),
|
|
12
|
+
recordingEnabled: z.boolean(),
|
|
13
|
+
url: z.string().optional(),
|
|
14
|
+
/** Last probe failure. Credentials are redacted before this is returned. */
|
|
15
|
+
error: z.string().optional(),
|
|
16
|
+
checks: z.array(
|
|
17
|
+
z.object({
|
|
18
|
+
id: livekitDiagnosisCheckIdSchema,
|
|
19
|
+
ok: z.boolean(),
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type LivekitDiagnosis = z.infer<typeof livekitDiagnosisSchema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const storedMediaStatusSchema = z.enum([
|
|
4
|
+
'referenced',
|
|
5
|
+
'pending',
|
|
6
|
+
'due',
|
|
7
|
+
'unseen',
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
export type StoredMediaStatus = z.infer<typeof storedMediaStatusSchema>;
|
|
11
|
+
|
|
12
|
+
export const storedMediaFileSchema = z.object({
|
|
13
|
+
storageId: z.string(),
|
|
14
|
+
size: z.number(),
|
|
15
|
+
modifiedAt: z.string(),
|
|
16
|
+
status: storedMediaStatusSchema,
|
|
17
|
+
unreferencedSince: z.string().nullable(),
|
|
18
|
+
deletesAt: z.string().nullable(),
|
|
19
|
+
url: z.string(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type StoredMediaFile = z.infer<typeof storedMediaFileSchema>;
|
|
23
|
+
|
|
24
|
+
export const storedMediaListSchema = z.object({
|
|
25
|
+
files: z.array(storedMediaFileSchema),
|
|
26
|
+
graceMs: z.number(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type StoredMediaList = z.infer<typeof storedMediaListSchema>;
|
package/src/types/api.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
accessTokenSchema,
|
|
10
10
|
accountInteractionsSchema,
|
|
11
11
|
accountNameSchema,
|
|
12
|
+
federatedHandleSchema,
|
|
12
13
|
accountSchema,
|
|
13
14
|
answerSchema,
|
|
14
15
|
applicationDataSchema,
|
|
@@ -76,7 +77,7 @@ export const publicProfileSchema = z.object({
|
|
|
76
77
|
createdAt: z.string().datetime(),
|
|
77
78
|
updatedAt: z.string().datetime(),
|
|
78
79
|
deletedAt: z.string().datetime().nullable().optional(),
|
|
79
|
-
handle:
|
|
80
|
+
handle: federatedHandleSchema,
|
|
80
81
|
avatar: z.string().url().nullable().optional(),
|
|
81
82
|
header: z.string().url().nullable().optional(),
|
|
82
83
|
displayName: z.string().max(30).optional(),
|
|
@@ -231,7 +232,7 @@ const basePublicPostSchema = publicReplyPostSchema.extend({
|
|
|
231
232
|
/** Newest conversation descendants for a nested timeline preview. */
|
|
232
233
|
latestReplies: publicReplyPostSchema.array().optional(),
|
|
233
234
|
latestRepliesHasMore: z.boolean().optional(),
|
|
234
|
-
/** Last reply
|
|
235
|
+
/** Last reply on the conversation root; feeds sort by this. */
|
|
235
236
|
lastActivityAt: z.string().datetime().optional(),
|
|
236
237
|
application: publicApplicationSchema.optional(),
|
|
237
238
|
mentions: z.array(mentionWithPublicProfileSchema),
|
|
@@ -661,14 +662,15 @@ export const updateProfileRequestSchema = profileDataSchema
|
|
|
661
662
|
})
|
|
662
663
|
.superRefine((value, ctx) => {
|
|
663
664
|
if (value.handle === undefined || value.type === 'federated') return;
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
665
|
+
const result = accountNameSchema.safeParse(value.handle);
|
|
666
|
+
if (result.success) return;
|
|
667
|
+
ctx.addIssue({
|
|
668
|
+
code: 'custom',
|
|
669
|
+
path: ['handle'],
|
|
670
|
+
message:
|
|
671
|
+
result.error.issues[0]?.message ??
|
|
672
|
+
'Handle must be 1–16 characters: letters, numbers, underscores, or hyphens (no spaces or punctuation)',
|
|
673
|
+
});
|
|
672
674
|
});
|
|
673
675
|
export type UpdateProfileRequest = z.infer<typeof updateProfileRequestSchema>;
|
|
674
676
|
|
|
@@ -782,6 +784,14 @@ export const searchResultCountsSchema = z.object({
|
|
|
782
784
|
});
|
|
783
785
|
export type SearchResultCounts = z.infer<typeof searchResultCountsSchema>;
|
|
784
786
|
|
|
787
|
+
export const directMessageSearchHitSchema = z.object({
|
|
788
|
+
conversationId: z.uuid(),
|
|
789
|
+
message: publicPostSchema,
|
|
790
|
+
});
|
|
791
|
+
export type DirectMessageSearchHit = z.infer<
|
|
792
|
+
typeof directMessageSearchHitSchema
|
|
793
|
+
>;
|
|
794
|
+
|
|
785
795
|
// Plain object schema — used as API contract & in OpenAPI generation. Cross-
|
|
786
796
|
// field validation lives on `postCreationDataFormSchema` below to keep this
|
|
787
797
|
// schema introspectable by zod-to-openapi (which can't walk zod-4 `.refine()`
|
package/src/types/auth.ts
CHANGED
|
@@ -17,6 +17,6 @@ export const authorizationDataSchema = z.object({
|
|
|
17
17
|
account: accountWithMetaSchema.optional(),
|
|
18
18
|
service: z.string().optional(),
|
|
19
19
|
scopes: z.array(scopeSchema),
|
|
20
|
-
})
|
|
20
|
+
});
|
|
21
21
|
|
|
22
|
-
export type AuthorizationData = z.infer<typeof authorizationDataSchema>;
|
|
22
|
+
export type AuthorizationData = z.infer<typeof authorizationDataSchema>;
|
|
@@ -216,6 +216,8 @@ export const roleCapabilities = [
|
|
|
216
216
|
'core-roles-read',
|
|
217
217
|
'core-roles-update',
|
|
218
218
|
'core-maintenance-restart',
|
|
219
|
+
'core-media-read',
|
|
220
|
+
'core-media-delete',
|
|
219
221
|
'core-inviteLinks-create',
|
|
220
222
|
'core-inviteLinks-read',
|
|
221
223
|
'core-inviteLinks-update',
|
|
@@ -249,6 +251,7 @@ export const roleCapabilityEditorKeys = [
|
|
|
249
251
|
'core-inviteLinks-*',
|
|
250
252
|
'core-logs-*',
|
|
251
253
|
'core-maintenance-*',
|
|
254
|
+
'core-media-*',
|
|
252
255
|
'core-plugins-*',
|
|
253
256
|
'core-profiles-*',
|
|
254
257
|
'core-posts-create-*',
|
package/src/types/config.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from './capabilities';
|
|
11
11
|
import { postCapabilities } from './capabilities';
|
|
12
12
|
import { postRelationships } from './capabilities';
|
|
13
|
+
import { additionalForbiddenHandlesSchema } from './forbiddenHandles';
|
|
13
14
|
|
|
14
15
|
export const passwordPlaceHolder = '*********';
|
|
15
16
|
|
|
@@ -134,17 +135,20 @@ export const coreConfigSchemaFactory = (sanitize?: boolean) =>
|
|
|
134
135
|
sanitize,
|
|
135
136
|
),
|
|
136
137
|
email: emailConfigSchemaFactory(sanitize).describe('hidden'),
|
|
137
|
-
logs:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
z.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
logs: z.object({
|
|
139
|
+
local: fixed(
|
|
140
|
+
z.object({
|
|
141
|
+
path: z.string(),
|
|
142
|
+
}),
|
|
143
|
+
sanitize,
|
|
144
|
+
),
|
|
145
|
+
retention: z.object({
|
|
146
|
+
/** Age in days at which a daily log file is zipped. */
|
|
147
|
+
zipAfterDays: z.number().int().min(1).default(7).catch(7),
|
|
148
|
+
/** Age in days at which log files (and their zips) are deleted. */
|
|
149
|
+
deleteAfterDays: z.number().int().min(1).default(30).catch(30),
|
|
145
150
|
}),
|
|
146
|
-
|
|
147
|
-
),
|
|
151
|
+
}),
|
|
148
152
|
media: z.object({
|
|
149
153
|
maxUploadMb: z
|
|
150
154
|
.number()
|
|
@@ -407,6 +411,11 @@ export const communityConfigSchemaFactory = (_sanitize?: boolean) =>
|
|
|
407
411
|
/** Adds member profile pages to the sitemap. Off by default: a crawled
|
|
408
412
|
* profile is cached by search engines long after the member leaves. */
|
|
409
413
|
indexProfiles: z.boolean().optional(),
|
|
414
|
+
/**
|
|
415
|
+
* Usernames this community blocks in addition to the built-in list.
|
|
416
|
+
* Built-in names are not stored here and cannot be removed.
|
|
417
|
+
*/
|
|
418
|
+
additionalForbiddenHandles: additionalForbiddenHandlesSchema.optional(),
|
|
410
419
|
}),
|
|
411
420
|
roles: z.object({
|
|
412
421
|
onRegistration: z.object({
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const handleRegexBase = '[a-zA-Z0-9_-]{1,16}';
|
|
4
|
+
|
|
5
|
+
export const handleRegex = new RegExp(`^${handleRegexBase}$`);
|
|
6
|
+
|
|
7
|
+
export const HANDLE_RESERVED_MESSAGE = 'Handle is reserved';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Platform routes and system names. Always reserved. Community config can add
|
|
11
|
+
* names, but these stay in code so an admin cannot delete them.
|
|
12
|
+
*/
|
|
13
|
+
export const forbiddenHandles = [
|
|
14
|
+
'admin',
|
|
15
|
+
'allpeep',
|
|
16
|
+
'api',
|
|
17
|
+
'app',
|
|
18
|
+
'auth',
|
|
19
|
+
'config',
|
|
20
|
+
'core',
|
|
21
|
+
'db',
|
|
22
|
+
'email',
|
|
23
|
+
'federation',
|
|
24
|
+
'jam',
|
|
25
|
+
'media',
|
|
26
|
+
'network',
|
|
27
|
+
'plugins',
|
|
28
|
+
'undefined',
|
|
29
|
+
'jamStarted',
|
|
30
|
+
'jamSpeaker',
|
|
31
|
+
'jamModerator',
|
|
32
|
+
'new',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const defaultForbiddenHandles = new Set(
|
|
36
|
+
forbiddenHandles.map((handle) => handle.toLowerCase()),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const normalizeForbiddenHandle = (value: string) =>
|
|
40
|
+
value.trim().toLowerCase();
|
|
41
|
+
|
|
42
|
+
export const isDefaultForbiddenHandle = (value: string) =>
|
|
43
|
+
defaultForbiddenHandles.has(normalizeForbiddenHandle(value));
|
|
44
|
+
|
|
45
|
+
/** Exact username match, case-insensitive. `additional` is the community list. */
|
|
46
|
+
export const isForbiddenHandle = (
|
|
47
|
+
value: string,
|
|
48
|
+
additional?: readonly string[],
|
|
49
|
+
) => {
|
|
50
|
+
const normalized = normalizeForbiddenHandle(value);
|
|
51
|
+
if (!normalized) return false;
|
|
52
|
+
if (defaultForbiddenHandles.has(normalized)) return true;
|
|
53
|
+
return (additional ?? []).some(
|
|
54
|
+
(entry) => normalizeForbiddenHandle(entry) === normalized,
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type AdditionalForbiddenHandleIssue =
|
|
59
|
+
| 'empty'
|
|
60
|
+
| 'invalid'
|
|
61
|
+
| 'builtIn'
|
|
62
|
+
| 'duplicate';
|
|
63
|
+
|
|
64
|
+
export const classifyAdditionalForbiddenHandle = (
|
|
65
|
+
raw: string,
|
|
66
|
+
existing: readonly string[] = [],
|
|
67
|
+
): AdditionalForbiddenHandleIssue | null => {
|
|
68
|
+
const value = normalizeForbiddenHandle(raw);
|
|
69
|
+
if (!value) return 'empty';
|
|
70
|
+
if (!handleRegex.test(value)) return 'invalid';
|
|
71
|
+
if (isDefaultForbiddenHandle(value)) return 'builtIn';
|
|
72
|
+
if (existing.some((entry) => normalizeForbiddenHandle(entry) === value)) {
|
|
73
|
+
return 'duplicate';
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Community-added names only. Built-in names, blanks, duplicates, and values
|
|
80
|
+
* that can never match a handle are dropped so they cannot be stored or deleted.
|
|
81
|
+
*/
|
|
82
|
+
export const collectAdditionalForbiddenHandles = (
|
|
83
|
+
values: readonly string[],
|
|
84
|
+
) => {
|
|
85
|
+
const issues: {
|
|
86
|
+
index: number;
|
|
87
|
+
issue: Extract<AdditionalForbiddenHandleIssue, 'empty' | 'invalid'>;
|
|
88
|
+
}[] = [];
|
|
89
|
+
const handles: string[] = [];
|
|
90
|
+
values.forEach((raw, index) => {
|
|
91
|
+
const issue = classifyAdditionalForbiddenHandle(raw, handles);
|
|
92
|
+
if (issue === 'empty' || issue === 'invalid') {
|
|
93
|
+
issues.push({ index, issue });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (issue) return;
|
|
97
|
+
handles.push(normalizeForbiddenHandle(raw));
|
|
98
|
+
});
|
|
99
|
+
return { handles, issues };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** Stored as given. PATCH normalizes before save; reads stay a plain string list. */
|
|
103
|
+
export const additionalForbiddenHandlesSchema = z.array(z.string());
|
package/src/types/index.ts
CHANGED
|
@@ -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';
|
package/src/types/models.ts
CHANGED
|
@@ -4,38 +4,37 @@ import ISO6391 from 'iso-639-1';
|
|
|
4
4
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
5
5
|
import { groupRelationships } from './capabilities';
|
|
6
6
|
import { capabilitiesSchema } from './config';
|
|
7
|
+
import {
|
|
8
|
+
HANDLE_RESERVED_MESSAGE,
|
|
9
|
+
additionalForbiddenHandlesSchema,
|
|
10
|
+
classifyAdditionalForbiddenHandle,
|
|
11
|
+
collectAdditionalForbiddenHandles,
|
|
12
|
+
forbiddenHandles,
|
|
13
|
+
handleRegex,
|
|
14
|
+
handleRegexBase,
|
|
15
|
+
isDefaultForbiddenHandle,
|
|
16
|
+
isForbiddenHandle,
|
|
17
|
+
normalizeForbiddenHandle,
|
|
18
|
+
} from './forbiddenHandles';
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
HANDLE_RESERVED_MESSAGE,
|
|
22
|
+
additionalForbiddenHandlesSchema,
|
|
23
|
+
classifyAdditionalForbiddenHandle,
|
|
24
|
+
collectAdditionalForbiddenHandles,
|
|
25
|
+
forbiddenHandles,
|
|
26
|
+
handleRegex,
|
|
27
|
+
handleRegexBase,
|
|
28
|
+
isDefaultForbiddenHandle,
|
|
29
|
+
isForbiddenHandle,
|
|
30
|
+
normalizeForbiddenHandle,
|
|
31
|
+
};
|
|
7
32
|
|
|
8
33
|
extendZodWithOpenApi(z);
|
|
9
34
|
|
|
10
|
-
export const handleRegexBase = '[a-zA-Z0-9_-]{1,16}';
|
|
11
|
-
|
|
12
|
-
export const handleRegex = new RegExp(`^${handleRegexBase}$`);
|
|
13
|
-
|
|
14
35
|
/** `@handle` using the allowed handle charset. No `\\b` — hyphens are not word chars. */
|
|
15
36
|
export const mentionHandleRegexBase = `(^|[\\s(>])@(${handleRegexBase})(?=\\s|$|[.,!?;:])`;
|
|
16
37
|
|
|
17
|
-
export const forbiddenHandles = [
|
|
18
|
-
'admin',
|
|
19
|
-
'allpeep',
|
|
20
|
-
'api',
|
|
21
|
-
'app',
|
|
22
|
-
'auth',
|
|
23
|
-
'config',
|
|
24
|
-
'core',
|
|
25
|
-
'db',
|
|
26
|
-
'email',
|
|
27
|
-
'federation',
|
|
28
|
-
'jam',
|
|
29
|
-
'media',
|
|
30
|
-
'network',
|
|
31
|
-
'plugins',
|
|
32
|
-
'undefined',
|
|
33
|
-
'jamStarted',
|
|
34
|
-
'jamSpeaker',
|
|
35
|
-
'jamModerator',
|
|
36
|
-
'new',
|
|
37
|
-
];
|
|
38
|
-
|
|
39
38
|
export const baseSchemaShape = {
|
|
40
39
|
createdAt: z.iso.datetime(),
|
|
41
40
|
updatedAt: z.iso.datetime(),
|
|
@@ -137,6 +136,19 @@ export const profileNotificationSettings = z.object({
|
|
|
137
136
|
export type ProfileNotificationSettings = z.infer<
|
|
138
137
|
typeof profileNotificationSettings
|
|
139
138
|
>;
|
|
139
|
+
|
|
140
|
+
/** Per-group activity level. Unset means `all`, matching account settings. */
|
|
141
|
+
export const groupNotificationLevelOptions = [
|
|
142
|
+
'all',
|
|
143
|
+
'mostRelevant',
|
|
144
|
+
'off',
|
|
145
|
+
] as const;
|
|
146
|
+
export const groupNotificationLevelSchema = z.enum(
|
|
147
|
+
groupNotificationLevelOptions,
|
|
148
|
+
);
|
|
149
|
+
export type GroupNotificationLevel = z.infer<
|
|
150
|
+
typeof groupNotificationLevelSchema
|
|
151
|
+
>;
|
|
140
152
|
export const jamSettingsSchema = z.object({
|
|
141
153
|
backgroundObfuscation: z
|
|
142
154
|
.discriminatedUnion('type', [
|
|
@@ -170,6 +182,10 @@ export const profileSettingsDataSchema = z.object({
|
|
|
170
182
|
theme: ThemeOptionsSchema.optional(),
|
|
171
183
|
defaults: profileSettingsDefaultsSchema.optional(),
|
|
172
184
|
notifications: z.record(z.string(), profileNotificationSettings).optional(),
|
|
185
|
+
/** Per-group level. A missing group id means all activity for that group. */
|
|
186
|
+
groupNotificationLevels: z
|
|
187
|
+
.record(z.string(), groupNotificationLevelSchema)
|
|
188
|
+
.optional(),
|
|
173
189
|
jamSettings: jamSettingsSchema.optional(),
|
|
174
190
|
stripeSettings: z
|
|
175
191
|
.object({
|
|
@@ -195,8 +211,8 @@ export type ProfileSettings = Model<ProfileSettingsData>;
|
|
|
195
211
|
|
|
196
212
|
export const accountNameSchema = z
|
|
197
213
|
.string()
|
|
198
|
-
.refine((value: string) => !
|
|
199
|
-
message:
|
|
214
|
+
.refine((value: string) => !isForbiddenHandle(value), {
|
|
215
|
+
message: HANDLE_RESERVED_MESSAGE,
|
|
200
216
|
})
|
|
201
217
|
.refine((value: string) => handleRegex.test(value ?? ''), {
|
|
202
218
|
message:
|
|
@@ -523,10 +539,13 @@ export const articleSchema = noteSchema
|
|
|
523
539
|
|
|
524
540
|
export type Article = z.infer<typeof articleSchema>;
|
|
525
541
|
|
|
542
|
+
/** Resource titles are library headings, so they stay much shorter than the description. */
|
|
543
|
+
export const RESOURCE_TITLE_MAX_LENGTH = 200;
|
|
544
|
+
|
|
526
545
|
export const resourcePostSchema = noteSchema
|
|
527
546
|
.extend({
|
|
528
547
|
type: z.literal('resource'),
|
|
529
|
-
title: z.string(),
|
|
548
|
+
title: z.string().max(RESOURCE_TITLE_MAX_LENGTH),
|
|
530
549
|
tags: z.array(z.string().min(1)).optional(),
|
|
531
550
|
categoryPath: z.array(z.string().min(1)).optional(),
|
|
532
551
|
resourceKind: resourceKindSchema,
|
|
@@ -592,6 +611,8 @@ export const eventSchema = noteSchema
|
|
|
592
611
|
end: eventIsoDatetimeSchema.optional(),
|
|
593
612
|
wholeDay: z.boolean(),
|
|
594
613
|
maxAttendees: z.number().int().positive().optional(),
|
|
614
|
+
/** Minutes the next waitlisted member has to claim a freed seat. */
|
|
615
|
+
waitlistOfferMinutes: z.number().int().positive().max(10080).optional(),
|
|
595
616
|
attendeeListPublic: z.boolean().optional(),
|
|
596
617
|
moderators: z.string().uuid().array().optional(),
|
|
597
618
|
jam: jamSchema.optional(),
|
|
@@ -600,6 +621,10 @@ export const eventSchema = noteSchema
|
|
|
600
621
|
recurrence: eventRecurrenceSchema.optional(),
|
|
601
622
|
exceptions: eventOccurrenceExceptionSchema.array().optional(),
|
|
602
623
|
})
|
|
624
|
+
.refine((data) => !data.end || new Date(data.end) > new Date(data.start), {
|
|
625
|
+
message: 'events.form.endBeforeStart',
|
|
626
|
+
path: ['end'],
|
|
627
|
+
})
|
|
603
628
|
.openapi('Event');
|
|
604
629
|
|
|
605
630
|
export type Event = z.infer<typeof eventSchema>;
|
|
@@ -634,18 +659,30 @@ export const answerSchema = z
|
|
|
634
659
|
|
|
635
660
|
export type Answer = z.infer<typeof answerSchema>;
|
|
636
661
|
|
|
637
|
-
export const rsvpResponseSchema = z.enum([
|
|
662
|
+
export const rsvpResponseSchema = z.enum([
|
|
663
|
+
'yes',
|
|
664
|
+
'no',
|
|
665
|
+
'tentative',
|
|
666
|
+
'removed',
|
|
667
|
+
'waitlist',
|
|
668
|
+
]);
|
|
638
669
|
export type RsvpResponse = z.infer<typeof rsvpResponseSchema>;
|
|
639
670
|
|
|
640
671
|
export const rsvpSchema = z.object({
|
|
641
672
|
response: rsvpResponseSchema,
|
|
642
673
|
recurrenceId: eventIsoDatetimeSchema.optional(),
|
|
674
|
+
/** Queue position. Copied onto later offer entries so a new write stays in line. */
|
|
675
|
+
waitlistJoinedAt: eventIsoDatetimeSchema.optional(),
|
|
676
|
+
/** When the current spot offer expires. Server-set; ignored on RSVP requests. */
|
|
677
|
+
offerExpiresAt: eventIsoDatetimeSchema.optional(),
|
|
643
678
|
});
|
|
644
679
|
export type RSVP = z.infer<typeof rsvpSchema>;
|
|
645
680
|
|
|
646
|
-
export const rsvpRequestSchema = rsvpSchema
|
|
647
|
-
|
|
648
|
-
|
|
681
|
+
export const rsvpRequestSchema = rsvpSchema
|
|
682
|
+
.omit({ waitlistJoinedAt: true, offerExpiresAt: true })
|
|
683
|
+
.extend({
|
|
684
|
+
recurrenceIds: z.array(eventIsoDatetimeSchema).min(1).optional(),
|
|
685
|
+
});
|
|
649
686
|
export type RsvpRequest = z.infer<typeof rsvpRequestSchema>;
|
|
650
687
|
|
|
651
688
|
export const entryReactionDataSchema = z.object({
|
|
@@ -68,11 +68,13 @@ export interface NotificationHandler {
|
|
|
68
68
|
export const notificationTypeSchema = z.object({
|
|
69
69
|
type: z.string(),
|
|
70
70
|
requiredCapabilities: z.enum(roleCapabilities).array().optional(),
|
|
71
|
-
defaultSettings: z
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
defaultSettings: z
|
|
72
|
+
.object({
|
|
73
|
+
create: z.boolean(),
|
|
74
|
+
push: z.boolean(),
|
|
75
|
+
email: z.boolean(),
|
|
76
|
+
})
|
|
77
|
+
.optional(),
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
export type NotificationType = z.infer<typeof notificationTypeSchema>;
|
|
@@ -88,5 +90,3 @@ export const notificationAll = {
|
|
|
88
90
|
push: true,
|
|
89
91
|
email: true,
|
|
90
92
|
} as const;
|
|
91
|
-
|
|
92
|
-
|