-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunity.ts
More file actions
140 lines (128 loc) · 4.3 KB
/
community.ts
File metadata and controls
140 lines (128 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { z } from 'zod'
const focusAreaLimit = 6
const linkLimit = 6
const tagLimit = 12
export const authorApplicationSchema = z
.object({
fullName: z.string().min(2).max(120),
email: z.string().email(),
pronouns: z
.string()
.max(60)
.optional()
.transform((value) => value?.trim() || undefined),
focusAreas: z
.array(z.string().min(2).max(64))
.min(1)
.max(focusAreaLimit),
experienceLevel: z.string().min(2).max(120),
currentRole: z.string().min(2).max(160),
communityParticipation: z
.string()
.max(600)
.optional()
.transform((value) => value?.trim() || undefined),
publishedLinks: z
.array(z.string().url())
.max(linkLimit)
.optional()
.default([]),
socialHandles: z
.record(z.string(), z.string().min(2).max(320))
.optional()
.default({}),
writingSampleUrl: z
.string()
.url()
.optional()
.or(z.literal(''))
.transform((value) => (value ? value : undefined)),
pitchFocus: z.string().min(10).max(600),
pitchAudience: z.string().min(10).max(600),
pitchCadence: z.string().min(3).max(160),
availability: z.string().min(3).max(200),
consent: z.literal(true),
editorialPolicyAcknowledged: z.literal(true),
newsletterOptIn: z.boolean().default(false),
captchaToken: z.string().min(10),
existingApplicationId: z.string().uuid().optional(),
})
.superRefine((value, ctx) => {
if (!value.focusAreas || value.focusAreas.length === 0) {
ctx.addIssue({
path: ['focusAreas'],
code: z.ZodIssueCode.custom,
message: 'Select at least one focus area.',
})
}
if ((value.publishedLinks ?? []).length === 0 && !value.writingSampleUrl) {
ctx.addIssue({
path: ['publishedLinks'],
code: z.ZodIssueCode.custom,
message: 'Provide at least one published link or a writing sample.',
})
}
})
export type AuthorApplicationInput = z.infer<typeof authorApplicationSchema>
export const editorialChecklistSchema = z.object({
toneReviewed: z.boolean().default(false),
accessibilityChecked: z.boolean().default(false),
linksVerified: z.boolean().default(false),
assetsIncluded: z.boolean().default(false),
aiDisclosureProvided: z.boolean().default(false),
})
export const submissionMetadataSchema = z.object({
canonicalUrl: z
.string()
.url()
.optional()
.or(z.literal(''))
.transform((value) => (value ? value : undefined)),
series: z
.string()
.max(120)
.optional()
.transform((value) => value?.trim() || undefined),
featuredImageUrl: z
.string()
.url()
.optional()
.or(z.literal(''))
.transform((value) => (value ? value : undefined)),
})
export const communitySubmissionSchema = z.object({
id: z.string().uuid().optional(),
title: z.string().min(10).max(160),
summary: z.string().min(40).max(400),
slug: z
.string()
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug may only contain lowercase letters, numbers, and hyphens.')
.max(120)
.optional(),
categories: z.array(z.string().min(2).max(64)).min(1).max(5),
tags: z.array(z.string().min(2).max(64)).max(tagLimit),
content: z.string().min(2000, 'Draft must be at least 2,000 characters to submit.').max(120_000),
notesToEditors: z
.string()
.max(2000)
.optional()
.transform((value) => value?.trim() || undefined),
coAuthorIds: z.array(z.string().uuid()).optional().default([]),
attachments: z.array(z.string().url()).optional().default([]),
checklist: editorialChecklistSchema,
metadata: submissionMetadataSchema,
intent: z.enum(['autosave', 'save', 'submit']),
})
export type CommunitySubmissionInput = z.infer<typeof communitySubmissionSchema>
export const submissionTransitionSchema = z.object({
submissionId: z.string().uuid(),
action: z.enum(['submit', 'withdraw', 'feedback', 'approve', 'decline']),
notes: z.string().max(2000).optional(),
})
export type SubmissionTransitionInput = z.infer<typeof submissionTransitionSchema>
export const authorApplicationReviewSchema = z.object({
applicationId: z.string().uuid(),
action: z.enum(['approve', 'decline', 'needs_more_info']),
notes: z.string().max(2000).optional(),
})
export type AuthorApplicationReviewInput = z.infer<typeof authorApplicationReviewSchema>