feat(shared): ownership types and marketplace schemas
This commit is contained in:
@@ -18,6 +18,10 @@ function rowToLesson(r: typeof lessons.$inferSelect): Lesson {
|
|||||||
description: r.description ?? null,
|
description: r.description ?? null,
|
||||||
position: r.position,
|
position: r.position,
|
||||||
bidirectional: r.bidirectional,
|
bidirectional: r.bidirectional,
|
||||||
|
ownerId: r.ownerId ?? null,
|
||||||
|
visibility: r.visibility,
|
||||||
|
isCurated: r.isCurated,
|
||||||
|
sourceLessonId: r.sourceLessonId ?? null,
|
||||||
createdAt: r.createdAt,
|
createdAt: r.createdAt,
|
||||||
updatedAt: r.updatedAt,
|
updatedAt: r.updatedAt,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,3 +108,22 @@ export type ChangePasswordInput = z.infer<typeof changePasswordSchema>;
|
|||||||
export type AcceptInviteInput = z.infer<typeof acceptInviteSchema>;
|
export type AcceptInviteInput = z.infer<typeof acceptInviteSchema>;
|
||||||
export type InviteUserInput = z.infer<typeof inviteUserSchema>;
|
export type InviteUserInput = z.infer<typeof inviteUserSchema>;
|
||||||
export type AdminUserUpdateInput = z.infer<typeof adminUserUpdateSchema>;
|
export type AdminUserUpdateInput = z.infer<typeof adminUserUpdateSchema>;
|
||||||
|
|
||||||
|
export const lessonVisibilityUpdateSchema = z.object({
|
||||||
|
visibility: z.enum(['private', 'shared']),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const adminLessonCuratedSchema = z.object({
|
||||||
|
isCurated: z.boolean(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const marketplaceQuerySchema = z.object({
|
||||||
|
q: z.string().trim().max(120).optional(),
|
||||||
|
curated: z.enum(['true', 'false']).optional(),
|
||||||
|
limit: z.coerce.number().int().min(1).max(100).optional(),
|
||||||
|
offset: z.coerce.number().int().min(0).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type LessonVisibilityUpdateInput = z.infer<typeof lessonVisibilityUpdateSchema>;
|
||||||
|
export type AdminLessonCuratedInput = z.infer<typeof adminLessonCuratedSchema>;
|
||||||
|
export type MarketplaceQuery = z.infer<typeof marketplaceQuerySchema>;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ export type Direction = 'forward' | 'backward';
|
|||||||
export type AttemptResult = 'correct' | 'incorrect';
|
export type AttemptResult = 'correct' | 'incorrect';
|
||||||
export type SessionStatus = 'active' | 'completed' | 'abandoned';
|
export type SessionStatus = 'active' | 'completed' | 'abandoned';
|
||||||
|
|
||||||
|
export type Visibility = 'private' | 'shared';
|
||||||
|
|
||||||
export interface Lesson {
|
export interface Lesson {
|
||||||
id: number;
|
id: number;
|
||||||
parentId: number | null;
|
parentId: number | null;
|
||||||
@@ -9,6 +11,10 @@ export interface Lesson {
|
|||||||
description: string | null;
|
description: string | null;
|
||||||
position: number;
|
position: number;
|
||||||
bidirectional: boolean;
|
bidirectional: boolean;
|
||||||
|
ownerId: number | null;
|
||||||
|
visibility: Visibility;
|
||||||
|
isCurated: boolean;
|
||||||
|
sourceLessonId: number | null;
|
||||||
createdAt: number;
|
createdAt: number;
|
||||||
updatedAt: number;
|
updatedAt: number;
|
||||||
}
|
}
|
||||||
@@ -92,3 +98,28 @@ export interface PublicUser {
|
|||||||
displayName: string;
|
displayName: string;
|
||||||
role: Role;
|
role: Role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LessonAccess {
|
||||||
|
canEdit: boolean;
|
||||||
|
isOwner: boolean;
|
||||||
|
isSubscribed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketplaceLesson {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
ownerDisplayName: string;
|
||||||
|
totalCards: number;
|
||||||
|
subscribersCount: number;
|
||||||
|
isCurated: boolean;
|
||||||
|
isFork: boolean;
|
||||||
|
createdAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SubscriptionEntry {
|
||||||
|
lessonId: number;
|
||||||
|
name: string;
|
||||||
|
ownerDisplayName: string;
|
||||||
|
subscribedAt: number;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user