@openpeepshq/common 0.1.43
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/LICENSE.md +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/adminSections.d.ts +53 -0
- package/dist/lib/adminSections.js +62 -0
- package/dist/lib/attachmentHelpers.d.ts +1 -0
- package/dist/lib/attachmentHelpers.js +13 -0
- package/dist/lib/capabilitiesHelpers.d.ts +118 -0
- package/dist/lib/capabilitiesHelpers.js +238 -0
- package/dist/lib/colors.d.ts +5 -0
- package/dist/lib/colors.js +17 -0
- package/dist/lib/csvHelpers.d.ts +6 -0
- package/dist/lib/csvHelpers.js +17 -0
- package/dist/lib/eventIcs.d.ts +4 -0
- package/dist/lib/eventIcs.js +83 -0
- package/dist/lib/groupHelpers.d.ts +134 -0
- package/dist/lib/groupHelpers.js +216 -0
- package/dist/lib/index.d.ts +17 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/jamHelpers.d.ts +5 -0
- package/dist/lib/jamHelpers.js +37 -0
- package/dist/lib/markdownHelpers.d.ts +1 -0
- package/dist/lib/markdownHelpers.js +24 -0
- package/dist/lib/mediaDimensions.d.ts +19 -0
- package/dist/lib/mediaDimensions.js +19 -0
- package/dist/lib/postHelpers.d.ts +146 -0
- package/dist/lib/postHelpers.js +144 -0
- package/dist/lib/profileHelpers.d.ts +30 -0
- package/dist/lib/profileHelpers.js +75 -0
- package/dist/lib/pushHelpers.d.ts +4 -0
- package/dist/lib/pushHelpers.js +6 -0
- package/dist/lib/scopeHelpers.d.ts +25 -0
- package/dist/lib/scopeHelpers.js +85 -0
- package/dist/lib/text.d.ts +3 -0
- package/dist/lib/text.js +18 -0
- package/dist/lib/tokenHelpers.d.ts +21 -0
- package/dist/lib/tokenHelpers.js +81 -0
- package/dist/lib/utils.d.ts +43 -0
- package/dist/lib/utils.js +200 -0
- package/dist/types/admin-db.d.ts +62 -0
- package/dist/types/admin-db.js +41 -0
- package/dist/types/admin-email.d.ts +39 -0
- package/dist/types/admin-email.js +41 -0
- package/dist/types/admin-jobs.d.ts +15 -0
- package/dist/types/admin-jobs.js +14 -0
- package/dist/types/admin-performance.d.ts +23 -0
- package/dist/types/admin-performance.js +14 -0
- package/dist/types/analytics.d.ts +583 -0
- package/dist/types/analytics.js +213 -0
- package/dist/types/api.d.ts +20076 -0
- package/dist/types/api.js +492 -0
- package/dist/types/apple-app-site-association.d.ts +50 -0
- package/dist/types/apple-app-site-association.js +38 -0
- package/dist/types/auth.d.ts +367 -0
- package/dist/types/auth.js +17 -0
- package/dist/types/capabilities.d.ts +24 -0
- package/dist/types/capabilities.js +144 -0
- package/dist/types/config.d.ts +858 -0
- package/dist/types/config.js +352 -0
- package/dist/types/db.d.ts +8780 -0
- package/dist/types/db.js +65 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +18 -0
- package/dist/types/internal.d.ts +44337 -0
- package/dist/types/internal.js +154 -0
- package/dist/types/models.d.ts +2619 -0
- package/dist/types/models.js +599 -0
- package/dist/types/notifications.d.ts +148 -0
- package/dist/types/notifications.js +40 -0
- package/dist/types/plugins.d.ts +66 -0
- package/dist/types/plugins.js +29 -0
- package/dist/types/stats.d.ts +10216 -0
- package/dist/types/stats.js +109 -0
- package/dist/types/stripe.d.ts +42 -0
- package/dist/types/stripe.js +35 -0
- package/dist/types/utils.d.ts +84 -0
- package/dist/types/utils.js +39 -0
- package/package.json +54 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { pushNotificationSchema } from './notifications.js';
|
|
3
|
+
import { accessTokenSchema, accountInteractionsSchema, accountNameSchema, accountSchema, answerSchema, applicationDataSchema, groupDataSchema, groupRoleSchema, groupSchema, guestDataSchema, hashtagSchema, inviteLinkSchema, latLngSchema, locationSchema, mediaAttachmentSchema, mentionDataSchema, postDataUnionSchema, postTypeSchema, profileDataSchema, profileStatsSchema, reactionDataSchema, reportDataSchema, reportSchema, resourceSchema, rsvpSchema, scopeSchema, visibilityTypeSchema, } from './models.js';
|
|
4
|
+
import { groupWithMetaSchema } from './internal.js';
|
|
5
|
+
import { communityConfigSchema } from './config.js';
|
|
6
|
+
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
7
|
+
extendZodWithOpenApi(z);
|
|
8
|
+
export const errorResponseBodySchema = z.object({
|
|
9
|
+
success: z.literal(false),
|
|
10
|
+
message: z.string(),
|
|
11
|
+
});
|
|
12
|
+
export const publicAccountSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
id: z.uuid(),
|
|
15
|
+
email: z.email(),
|
|
16
|
+
emailValidated: z.boolean().default(false),
|
|
17
|
+
})
|
|
18
|
+
.openapi('Account', { type: 'object' });
|
|
19
|
+
export const publicProfileSchema = z.object({
|
|
20
|
+
id: z.string().uuid(),
|
|
21
|
+
type: z.enum(['local', 'guest', 'federated']),
|
|
22
|
+
createdAt: z.string().datetime(),
|
|
23
|
+
updatedAt: z.string().datetime(),
|
|
24
|
+
deletedAt: z.string().datetime().nullable().optional(),
|
|
25
|
+
handle: accountNameSchema,
|
|
26
|
+
avatar: z.string().url().nullable().optional(),
|
|
27
|
+
header: z.string().url().nullable().optional(),
|
|
28
|
+
displayName: z.string().max(30).optional(),
|
|
29
|
+
bio: z.string().optional(),
|
|
30
|
+
location: locationSchema.optional(),
|
|
31
|
+
locked: z.boolean().optional(),
|
|
32
|
+
bot: z.boolean().optional(),
|
|
33
|
+
discoverable: z.boolean().optional(),
|
|
34
|
+
memberships: z
|
|
35
|
+
.array(groupRoleSchema.extend({
|
|
36
|
+
group: groupSchema,
|
|
37
|
+
}))
|
|
38
|
+
.optional()
|
|
39
|
+
.transform((memberships) => memberships === null || memberships === void 0 ? void 0 : memberships.filter((m) => { var _a, _b, _c; return (_c = (_b = (_a = m.group.capabilities) === null || _a === void 0 ? void 0 : _a.none) === null || _b === void 0 ? void 0 : _b.add) === null || _c === void 0 ? void 0 : _c.includes('core-groups-read'); })),
|
|
40
|
+
fields: z
|
|
41
|
+
.array(z.object({
|
|
42
|
+
name: z.string().max(255).min(1),
|
|
43
|
+
value: z.string().max(255),
|
|
44
|
+
}))
|
|
45
|
+
.max(4)
|
|
46
|
+
.optional(),
|
|
47
|
+
profileStats: profileStatsSchema.optional(),
|
|
48
|
+
});
|
|
49
|
+
export const publicAccessTokenSchema = accessTokenSchema
|
|
50
|
+
.omit({ signedToken: true })
|
|
51
|
+
.extend({
|
|
52
|
+
ownedBy: publicProfileSchema.optional(),
|
|
53
|
+
scopes: z.array(scopeSchema).optional(),
|
|
54
|
+
})
|
|
55
|
+
.openapi('PublicAccessToken');
|
|
56
|
+
export const jamParticipantProfileSchema = publicProfileSchema.extend(guestDataSchema.partial().shape);
|
|
57
|
+
export const mentionWithPublicProfileSchema = mentionDataSchema.extend({
|
|
58
|
+
profile: publicProfileSchema,
|
|
59
|
+
});
|
|
60
|
+
export const entryWithPublicProfileSchema = z.discriminatedUnion('type', [
|
|
61
|
+
z.object({
|
|
62
|
+
type: z.literal('create'),
|
|
63
|
+
data: postDataUnionSchema,
|
|
64
|
+
profile: publicProfileSchema,
|
|
65
|
+
createdAt: z.string().datetime(),
|
|
66
|
+
}),
|
|
67
|
+
z.object({
|
|
68
|
+
type: z.literal('edit'),
|
|
69
|
+
data: postDataUnionSchema,
|
|
70
|
+
profile: publicProfileSchema,
|
|
71
|
+
createdAt: z.string().datetime(),
|
|
72
|
+
}),
|
|
73
|
+
z.object({
|
|
74
|
+
type: z.literal('delete'),
|
|
75
|
+
data: z.any(),
|
|
76
|
+
profile: publicProfileSchema,
|
|
77
|
+
createdAt: z.string().datetime(),
|
|
78
|
+
}),
|
|
79
|
+
z.object({
|
|
80
|
+
type: z.literal('answer'),
|
|
81
|
+
data: answerSchema,
|
|
82
|
+
profile: publicProfileSchema,
|
|
83
|
+
createdAt: z.string().datetime(),
|
|
84
|
+
}),
|
|
85
|
+
z.object({
|
|
86
|
+
type: z.literal('rsvp'),
|
|
87
|
+
data: rsvpSchema,
|
|
88
|
+
profile: publicProfileSchema,
|
|
89
|
+
createdAt: z.string().datetime(),
|
|
90
|
+
}),
|
|
91
|
+
]);
|
|
92
|
+
const reactionWithPublicProfileSchema = reactionDataSchema.extend({
|
|
93
|
+
profile: publicProfileSchema,
|
|
94
|
+
});
|
|
95
|
+
export const publicReplyPostSchema = z.object({
|
|
96
|
+
id: z.string(),
|
|
97
|
+
type: postTypeSchema,
|
|
98
|
+
profile: publicProfileSchema,
|
|
99
|
+
data: postDataUnionSchema,
|
|
100
|
+
entries: entryWithPublicProfileSchema.array(),
|
|
101
|
+
createdAt: z.string().datetime(),
|
|
102
|
+
deletedAt: z.string().datetime().optional().nullable(),
|
|
103
|
+
visibility: visibilityTypeSchema,
|
|
104
|
+
group: groupWithMetaSchema.optional().nullable(),
|
|
105
|
+
audience: z.array(publicProfileSchema).optional().nullable(),
|
|
106
|
+
});
|
|
107
|
+
export const publicApplicationSchema = applicationDataSchema.pick({
|
|
108
|
+
name: true,
|
|
109
|
+
website: true,
|
|
110
|
+
});
|
|
111
|
+
const publicRsvpSchema = rsvpSchema.extend({
|
|
112
|
+
profile: publicProfileSchema,
|
|
113
|
+
createdAt: z.string().datetime(),
|
|
114
|
+
});
|
|
115
|
+
const basePublicPostSchema = publicReplyPostSchema.extend({
|
|
116
|
+
repostCount: z.number(),
|
|
117
|
+
replyCount: z.number(),
|
|
118
|
+
reactions: reactionWithPublicProfileSchema.array(),
|
|
119
|
+
application: publicApplicationSchema.optional(),
|
|
120
|
+
mentions: z.array(mentionWithPublicProfileSchema),
|
|
121
|
+
tags: z.array(hashtagSchema),
|
|
122
|
+
groupId: z.string().optional().nullable(),
|
|
123
|
+
groupDiscoverable: z.boolean().optional().nullable(),
|
|
124
|
+
updatedAt: z.string().datetime(),
|
|
125
|
+
accountInteractions: accountInteractionsSchema.optional(),
|
|
126
|
+
rsvps: publicRsvpSchema.array(),
|
|
127
|
+
seen: z.boolean().optional(),
|
|
128
|
+
});
|
|
129
|
+
const withReplyPostSchema = basePublicPostSchema.extend({
|
|
130
|
+
inReplyToId: z.string().optional().nullable(),
|
|
131
|
+
replyTo: publicReplyPostSchema.optional().nullable(),
|
|
132
|
+
});
|
|
133
|
+
export const publicPostSchema = withReplyPostSchema
|
|
134
|
+
.extend({
|
|
135
|
+
repost: basePublicPostSchema.optional().nullable(),
|
|
136
|
+
})
|
|
137
|
+
.openapi('Post');
|
|
138
|
+
export const publicJamEventSchema = z.object({
|
|
139
|
+
jamId: z.string(),
|
|
140
|
+
type: z.enum(['message', 'reaction', 'attendance', 'active']),
|
|
141
|
+
content: z.string(),
|
|
142
|
+
sender: z.object({
|
|
143
|
+
profile: publicProfileSchema.extend({
|
|
144
|
+
email: z.string().email().optional(),
|
|
145
|
+
}),
|
|
146
|
+
participantId: z.string(),
|
|
147
|
+
}),
|
|
148
|
+
joinTime: z.string().datetime().optional(),
|
|
149
|
+
leaveTime: z.string().datetime().optional(),
|
|
150
|
+
});
|
|
151
|
+
export const publicNotificationSchema = z.object({
|
|
152
|
+
id: z.string().uuid(),
|
|
153
|
+
type: z.string(),
|
|
154
|
+
seen: z.boolean().optional(),
|
|
155
|
+
read: z.boolean().optional(),
|
|
156
|
+
createdAt: z.string().datetime(),
|
|
157
|
+
senderProfile: publicProfileSchema.nullable().optional(),
|
|
158
|
+
group: groupSchema.nullable().optional(),
|
|
159
|
+
post: publicPostSchema.nullable().optional(),
|
|
160
|
+
data: z.any().optional(),
|
|
161
|
+
});
|
|
162
|
+
export const publicGroupMemberSchema = groupRoleSchema.extend({
|
|
163
|
+
profile: publicProfileSchema,
|
|
164
|
+
});
|
|
165
|
+
export const accountCreationDataSchema = z.object({
|
|
166
|
+
email: z.string().email(),
|
|
167
|
+
password: z.string().min(8),
|
|
168
|
+
emailValidated: z.boolean().optional(),
|
|
169
|
+
inviteCode: z.string().optional(),
|
|
170
|
+
profile: z.object({
|
|
171
|
+
handle: z.string().min(4).max(255),
|
|
172
|
+
avatar: z.string().url().optional(),
|
|
173
|
+
displayName: profileDataSchema.shape.displayName,
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
export const accountUpdateDataSchema = z.object({
|
|
177
|
+
account: accountSchema,
|
|
178
|
+
email: z.string().email().optional(),
|
|
179
|
+
password: z.string().min(8).optional(),
|
|
180
|
+
emailValidated: z.boolean().optional(),
|
|
181
|
+
});
|
|
182
|
+
export const serverInfoSchema = z.object({
|
|
183
|
+
version: z.string(),
|
|
184
|
+
environment: z.string(),
|
|
185
|
+
publicContent: z.boolean(),
|
|
186
|
+
maxProfiles: z.number().int().nonnegative().optional(),
|
|
187
|
+
communityConfig: communityConfigSchema,
|
|
188
|
+
jams: z.object({
|
|
189
|
+
livekit: z.object({
|
|
190
|
+
url: z.string(),
|
|
191
|
+
enabled: z.boolean(),
|
|
192
|
+
recordingEnabled: z.boolean(),
|
|
193
|
+
}),
|
|
194
|
+
}),
|
|
195
|
+
vapid: z.object({
|
|
196
|
+
publicKey: z.string().optional(),
|
|
197
|
+
}),
|
|
198
|
+
sentryConfig: z.object({
|
|
199
|
+
enabled: z.boolean(),
|
|
200
|
+
dsn: z.string().optional(),
|
|
201
|
+
replayEnabled: z.boolean().optional(),
|
|
202
|
+
}),
|
|
203
|
+
payments: z.object({
|
|
204
|
+
stripe: z.object({
|
|
205
|
+
paidMembership: z.object({
|
|
206
|
+
enabled: z.boolean(),
|
|
207
|
+
}),
|
|
208
|
+
}),
|
|
209
|
+
}),
|
|
210
|
+
sso: z.object({
|
|
211
|
+
oidc: z.array(z.object({
|
|
212
|
+
id: z.string(),
|
|
213
|
+
name: z.string(),
|
|
214
|
+
})),
|
|
215
|
+
}).optional(),
|
|
216
|
+
});
|
|
217
|
+
export const notificationStatsSchema = z.object({
|
|
218
|
+
unread: z.number(),
|
|
219
|
+
unseen: z.number(),
|
|
220
|
+
});
|
|
221
|
+
export const unseenPostCountsSchema = z.object({
|
|
222
|
+
groups: z.record(z.string(), z.number()),
|
|
223
|
+
direct: z.record(z.string(), z.number()),
|
|
224
|
+
});
|
|
225
|
+
export const pushPayloadSchema = z.object({
|
|
226
|
+
notification: pushNotificationSchema,
|
|
227
|
+
notificationStats: notificationStatsSchema,
|
|
228
|
+
});
|
|
229
|
+
export const webhookDataSchema = z.object({
|
|
230
|
+
type: z.literal('pushNotification'),
|
|
231
|
+
payload: pushPayloadSchema,
|
|
232
|
+
});
|
|
233
|
+
export const webhookKeyResponseSchema = z.object({
|
|
234
|
+
publicKey: z.string(),
|
|
235
|
+
});
|
|
236
|
+
export const webhookVerifyRequestSchema = z.object({
|
|
237
|
+
token: z.string(),
|
|
238
|
+
});
|
|
239
|
+
export const webhookVerifyResponseSchema = z.object({
|
|
240
|
+
success: z.literal(true),
|
|
241
|
+
payload: z.record(z.string(), z.unknown()),
|
|
242
|
+
});
|
|
243
|
+
export const publicInviteLinkSchema = inviteLinkSchema.extend({
|
|
244
|
+
profile: publicProfileSchema,
|
|
245
|
+
redemptions: publicProfileSchema.array(),
|
|
246
|
+
});
|
|
247
|
+
export const muteParticipantRequestSchema = z.object({
|
|
248
|
+
identity: z.string().uuid(),
|
|
249
|
+
trackSid: z.string(),
|
|
250
|
+
});
|
|
251
|
+
export const guestPassRequestSchema = z.object({
|
|
252
|
+
displayName: z.string().max(30),
|
|
253
|
+
email: z.string().email(),
|
|
254
|
+
resource: resourceSchema,
|
|
255
|
+
});
|
|
256
|
+
export const logRowSchema = z.object({
|
|
257
|
+
level: z.string(),
|
|
258
|
+
message: z.string(),
|
|
259
|
+
timestamp: z.string().date(),
|
|
260
|
+
meta: z.any(),
|
|
261
|
+
namespace: z.string(),
|
|
262
|
+
});
|
|
263
|
+
export const successResponseSchema = z.object({
|
|
264
|
+
success: z.literal(true),
|
|
265
|
+
});
|
|
266
|
+
export const successFailureResponseSchema = z.object({
|
|
267
|
+
success: z.boolean(),
|
|
268
|
+
message: z.string().optional(),
|
|
269
|
+
key: z.string().optional(),
|
|
270
|
+
});
|
|
271
|
+
export const fetchUrlRequestSchema = z.object({
|
|
272
|
+
url: z.url(),
|
|
273
|
+
});
|
|
274
|
+
export const fetchUrlReponseSchema = z.object({
|
|
275
|
+
statusCode: z.number(),
|
|
276
|
+
success: z.boolean(),
|
|
277
|
+
data: z.object({
|
|
278
|
+
image: z.string(),
|
|
279
|
+
title: z.string(),
|
|
280
|
+
description: z.string(),
|
|
281
|
+
url: z.string(),
|
|
282
|
+
}),
|
|
283
|
+
});
|
|
284
|
+
export const loginRequestSchema = z.object({
|
|
285
|
+
email: z.email(),
|
|
286
|
+
password: z.string().min(8),
|
|
287
|
+
});
|
|
288
|
+
export const registerRequestSchema = z.object({
|
|
289
|
+
handle: accountNameSchema,
|
|
290
|
+
email: z.email(),
|
|
291
|
+
password: z
|
|
292
|
+
.string()
|
|
293
|
+
.min(8, { message: 'Your password should be at least 8 characters long' }),
|
|
294
|
+
displayName: profileDataSchema.shape.displayName,
|
|
295
|
+
confirmPassword: z.string().optional(),
|
|
296
|
+
privacyPolicyAccepted: z.boolean(),
|
|
297
|
+
inviteCode: z.string().optional(),
|
|
298
|
+
});
|
|
299
|
+
export const registerFormSchema = registerRequestSchema
|
|
300
|
+
.refine((data) => data.password === data.confirmPassword, {
|
|
301
|
+
message: 'Passwords do not match',
|
|
302
|
+
path: ['confirmPassword'],
|
|
303
|
+
})
|
|
304
|
+
.refine((data) => data.privacyPolicyAccepted, {
|
|
305
|
+
message: 'You must agree to the privacy policy',
|
|
306
|
+
path: ['privacyPolicyAccepted'],
|
|
307
|
+
});
|
|
308
|
+
export const createGroupRequestSchema = groupDataSchema.extend({
|
|
309
|
+
members: publicProfileSchema.array().optional(),
|
|
310
|
+
});
|
|
311
|
+
export const requestResetPasswordRequestSchema = z.object({
|
|
312
|
+
email: z.string().email(),
|
|
313
|
+
});
|
|
314
|
+
export const resetPasswordRequestSchema = z.object({
|
|
315
|
+
password: z.string().min(8),
|
|
316
|
+
confirmPassword: z.string().optional(),
|
|
317
|
+
});
|
|
318
|
+
export const resetPasswordFormSchema = resetPasswordRequestSchema.refine((data) => data.password === data.confirmPassword, {
|
|
319
|
+
message: 'Passwords do not match',
|
|
320
|
+
path: ['confirmPassword'],
|
|
321
|
+
});
|
|
322
|
+
export const validateEmailQuerySchema = z.object({
|
|
323
|
+
token: z.string().min(1),
|
|
324
|
+
});
|
|
325
|
+
export const tokenResponseSchema = z.object({
|
|
326
|
+
success: z.literal(true),
|
|
327
|
+
token: z.string(),
|
|
328
|
+
checkoutUrl: z.string().optional(),
|
|
329
|
+
});
|
|
330
|
+
export const jamTokenResponseSchema = tokenResponseSchema.extend({
|
|
331
|
+
livekitUrl: z.string(),
|
|
332
|
+
});
|
|
333
|
+
const focusCoordinatesPattern = /^-?\d+,-?\d+$/;
|
|
334
|
+
// NOTE: `file` / `thumbnail` accept a `File` (browser) or any
|
|
335
|
+
// multipart body — modelled as `z.any()` for the API contract so the OpenAPI
|
|
336
|
+
// generator can produce a binary content schema. Handlers should runtime-check
|
|
337
|
+
// they actually got a `File` / `Blob` instance.
|
|
338
|
+
export const mediaStorageRequestSchema = z.object({
|
|
339
|
+
description: z.string().optional(),
|
|
340
|
+
file: z
|
|
341
|
+
.any()
|
|
342
|
+
.openapi({ type: 'string', format: 'binary' }),
|
|
343
|
+
thumbnail: z
|
|
344
|
+
.any()
|
|
345
|
+
.optional()
|
|
346
|
+
.openapi({ type: 'string', format: 'binary' }),
|
|
347
|
+
usage: z.string(),
|
|
348
|
+
focus: z
|
|
349
|
+
.string()
|
|
350
|
+
.regex(focusCoordinatesPattern, 'focus must be "<integer>,<integer>"')
|
|
351
|
+
.optional(),
|
|
352
|
+
});
|
|
353
|
+
export const mediaProgressEventSchema = z
|
|
354
|
+
.object({
|
|
355
|
+
mediaAttachment: mediaAttachmentSchema,
|
|
356
|
+
progressPercent: z.number().min(0).max(100),
|
|
357
|
+
estimatedRemainingMs: z.number().optional(),
|
|
358
|
+
})
|
|
359
|
+
.openapi('MediaProgressEvent');
|
|
360
|
+
export const mediaStreamStatusSchema = z
|
|
361
|
+
.enum(['processing', 'ready', 'error'])
|
|
362
|
+
.openapi('MediaStreamStatus');
|
|
363
|
+
export const mediaStreamSchema = z
|
|
364
|
+
.object({
|
|
365
|
+
storageId: z.string(),
|
|
366
|
+
status: mediaStreamStatusSchema,
|
|
367
|
+
error: z.string().optional(),
|
|
368
|
+
})
|
|
369
|
+
.openapi('MediaStream');
|
|
370
|
+
export const mediaStreamRequestSchema = z
|
|
371
|
+
.object({
|
|
372
|
+
url: z.string().url(),
|
|
373
|
+
})
|
|
374
|
+
.openapi('MediaStreamRequest');
|
|
375
|
+
export const updateProfileRequestSchema = profileDataSchema.partial({
|
|
376
|
+
handle: true,
|
|
377
|
+
});
|
|
378
|
+
export const updateAccountPasswordRequestSchema = z.object({
|
|
379
|
+
email: z.string().email().optional(),
|
|
380
|
+
newPassword: z.preprocess((s) => s || undefined, z.string().min(8).optional()),
|
|
381
|
+
oldPassword: z.string().min(8),
|
|
382
|
+
confirmPassword: z.preprocess((s) => s || undefined, z.string().min(8).optional()),
|
|
383
|
+
});
|
|
384
|
+
export const updateAccountPasswordFormSchema = updateAccountPasswordRequestSchema
|
|
385
|
+
.refine((data) => data.newPassword === data.confirmPassword, {
|
|
386
|
+
message: 'Passwords do not match',
|
|
387
|
+
path: ['confirmPassword'],
|
|
388
|
+
})
|
|
389
|
+
.refine((data) => data.oldPassword, {
|
|
390
|
+
message: 'You must provide your old password to change your password or email',
|
|
391
|
+
path: ['__form__'],
|
|
392
|
+
});
|
|
393
|
+
export const updateAccountEmailRequestSchema = z.object({
|
|
394
|
+
newEmail: z.email(),
|
|
395
|
+
oldEmail: z.email(),
|
|
396
|
+
});
|
|
397
|
+
export const geocodingResultSchema = z.object({
|
|
398
|
+
name: z.string(),
|
|
399
|
+
bbox: latLngSchema.array().length(2),
|
|
400
|
+
center: latLngSchema,
|
|
401
|
+
icon: z.string().optional(),
|
|
402
|
+
properties: z.record(z.string(), z.any()).optional(),
|
|
403
|
+
});
|
|
404
|
+
export const reportCreationDataSchema = z.object({
|
|
405
|
+
report: reportDataSchema,
|
|
406
|
+
profileId: z.string(),
|
|
407
|
+
postIds: z.string().array(),
|
|
408
|
+
});
|
|
409
|
+
export const jamStateSchema = z.object({
|
|
410
|
+
active: z.boolean(),
|
|
411
|
+
participants: z.uuid().array(),
|
|
412
|
+
});
|
|
413
|
+
export const publicReportSchema = reportSchema.extend({
|
|
414
|
+
reporterProfile: publicProfileSchema,
|
|
415
|
+
reportedProfile: publicProfileSchema,
|
|
416
|
+
reportedPosts: z.array(publicPostSchema),
|
|
417
|
+
});
|
|
418
|
+
export const chronologicalInfiniteQueryParamsSchema = z.object({
|
|
419
|
+
start: z.string().optional(),
|
|
420
|
+
limit: z.coerce.number().optional(),
|
|
421
|
+
});
|
|
422
|
+
export const offsetInfiniteQueryParamsSchema = z.object({
|
|
423
|
+
offset: z.coerce.number().optional(),
|
|
424
|
+
limit: z.coerce.number().optional(),
|
|
425
|
+
});
|
|
426
|
+
export const searchResultItemSchema = (baseSchema) => z.object({
|
|
427
|
+
score: z.number(),
|
|
428
|
+
data: baseSchema,
|
|
429
|
+
});
|
|
430
|
+
export const searchResultSchema = (baseSchema) => searchResultItemSchema(baseSchema).array();
|
|
431
|
+
export const searchResultCountsSchema = z.object({
|
|
432
|
+
groups: z.number(),
|
|
433
|
+
profiles: z.number(),
|
|
434
|
+
posts: z.number(),
|
|
435
|
+
events: z.number(),
|
|
436
|
+
jams: z.number(),
|
|
437
|
+
});
|
|
438
|
+
// Plain object schema — used as API contract & in OpenAPI generation. Cross-
|
|
439
|
+
// field validation lives on `postCreationDataFormSchema` below to keep this
|
|
440
|
+
// schema introspectable by zod-to-openapi (which can't walk zod-4 `.refine()`
|
|
441
|
+
// wrappers, as they appear as a `ZodCustom` with `def.type === 'custom'`).
|
|
442
|
+
export const postCreationDataSchema = z.object({
|
|
443
|
+
visibility: visibilityTypeSchema,
|
|
444
|
+
type: postTypeSchema,
|
|
445
|
+
data: postDataUnionSchema,
|
|
446
|
+
inReplyToId: z.uuid().nullable().optional(),
|
|
447
|
+
mentions: mentionWithPublicProfileSchema.array().nullable().optional(),
|
|
448
|
+
audience: publicProfileSchema.array().nullable().optional(),
|
|
449
|
+
groupId: z.uuid().nullable().optional(),
|
|
450
|
+
reportId: z.uuid().nullable().optional(),
|
|
451
|
+
capabilitiesNeeded: z.string().array().nullable().optional(),
|
|
452
|
+
});
|
|
453
|
+
export const postCreationDataFormSchema = postCreationDataSchema
|
|
454
|
+
.refine((data) => {
|
|
455
|
+
if (data.type !== "event")
|
|
456
|
+
return true;
|
|
457
|
+
if (data.data.type !== "event")
|
|
458
|
+
return true;
|
|
459
|
+
return !!data.data.name;
|
|
460
|
+
}, {
|
|
461
|
+
message: "Name is required",
|
|
462
|
+
path: ["data", "name"],
|
|
463
|
+
})
|
|
464
|
+
.refine((data) => {
|
|
465
|
+
if (data.type !== "event")
|
|
466
|
+
return true;
|
|
467
|
+
if (data.data.type !== "event")
|
|
468
|
+
return true;
|
|
469
|
+
const { start, end } = data.data;
|
|
470
|
+
if (end && start && new Date(end) < new Date(start)) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
return true;
|
|
474
|
+
}, {
|
|
475
|
+
message: "End date cannot be before start date",
|
|
476
|
+
path: ["data", "end"],
|
|
477
|
+
});
|
|
478
|
+
const answerWithPublicProfileSchema = answerSchema.extend({
|
|
479
|
+
profile: publicProfileSchema,
|
|
480
|
+
});
|
|
481
|
+
export const paymentCheckoutSchema = successFailureResponseSchema.extend({
|
|
482
|
+
url: z.url().nullable(),
|
|
483
|
+
});
|
|
484
|
+
export const jamObserverResponseSchema = z.object({
|
|
485
|
+
path: z.string().optional(),
|
|
486
|
+
});
|
|
487
|
+
export const accessTokenCreationDataSchema = z.object({
|
|
488
|
+
name: z.string(),
|
|
489
|
+
description: z.string().optional(),
|
|
490
|
+
scopes: z.array(scopeSchema).optional(),
|
|
491
|
+
expirationTime: z.string(),
|
|
492
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const appDetailsSchema: z.ZodObject<{
|
|
3
|
+
appID: z.ZodString;
|
|
4
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
+
appIDs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
components: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
7
|
+
path: z.ZodString;
|
|
8
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
fragment: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
declare const webCredentialsSchema: z.ZodObject<{
|
|
13
|
+
apps: z.ZodArray<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const activityContinuationSchema: z.ZodObject<{
|
|
16
|
+
apps: z.ZodArray<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const associatedDomainsSchema: z.ZodObject<{
|
|
19
|
+
domains: z.ZodArray<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const appleAppSiteAssociationSchema: z.ZodObject<{
|
|
22
|
+
applinks: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
apps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
appID: z.ZodString;
|
|
26
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
appIDs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
components: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
path: z.ZodString;
|
|
30
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
31
|
+
fragment: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
}, z.core.$strip>>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
webcredentials: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
apps: z.ZodArray<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
activitycontinuation: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
apps: z.ZodArray<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
associateddomains: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
domains: z.ZodArray<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type AppleAppSiteAssociation = z.infer<typeof appleAppSiteAssociationSchema>;
|
|
46
|
+
export type AppDetails = z.infer<typeof appDetailsSchema>;
|
|
47
|
+
export type WebCredentials = z.infer<typeof webCredentialsSchema>;
|
|
48
|
+
export type ActivityContinuation = z.infer<typeof activityContinuationSchema>;
|
|
49
|
+
export type AssociatedDomains = z.infer<typeof associatedDomainsSchema>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Schema for app details
|
|
3
|
+
const appDetailsSchema = z.object({
|
|
4
|
+
appID: z.string(), // Format: TeamID.BundleID
|
|
5
|
+
paths: z.array(z.string()).optional(), // Array of URL paths that the app can handle
|
|
6
|
+
appIDs: z.array(z.string()).optional(), // Alternative app IDs
|
|
7
|
+
components: z
|
|
8
|
+
.array(z.object({
|
|
9
|
+
path: z.string(),
|
|
10
|
+
query: z.record(z.string(), z.string()).optional(),
|
|
11
|
+
fragment: z.string().optional(),
|
|
12
|
+
}))
|
|
13
|
+
.optional(),
|
|
14
|
+
});
|
|
15
|
+
// Schema for webcredentials
|
|
16
|
+
const webCredentialsSchema = z.object({
|
|
17
|
+
apps: z.array(z.string()), // Array of app IDs that can use web credentials
|
|
18
|
+
});
|
|
19
|
+
// Schema for activitycontinuation
|
|
20
|
+
const activityContinuationSchema = z.object({
|
|
21
|
+
apps: z.array(z.string()), // Array of app IDs that can use activity continuation
|
|
22
|
+
});
|
|
23
|
+
// Schema for associateddomains
|
|
24
|
+
const associatedDomainsSchema = z.object({
|
|
25
|
+
domains: z.array(z.string()), // Array of domains that can use associated domains
|
|
26
|
+
});
|
|
27
|
+
// Main AASA schema
|
|
28
|
+
export const appleAppSiteAssociationSchema = z.object({
|
|
29
|
+
applinks: z
|
|
30
|
+
.object({
|
|
31
|
+
apps: z.array(z.string()).optional(), // Array of app IDs that can use universal links
|
|
32
|
+
details: z.array(appDetailsSchema).optional(), // Array of app details
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
webcredentials: webCredentialsSchema.optional(),
|
|
36
|
+
activitycontinuation: activityContinuationSchema.optional(),
|
|
37
|
+
associateddomains: associatedDomainsSchema.optional(),
|
|
38
|
+
});
|