Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion convex/_generated/dataModel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
/**
* Generated data model types.
*
Expand Down
2 changes: 1 addition & 1 deletion convex/_generated/server.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
/**
* Generated utilities for implementing server-side Convex query and mutation functions.
*
Expand Down
2 changes: 1 addition & 1 deletion convex/_generated/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
/**
* Generated utilities for implementing server-side Convex query and mutation functions.
*
Expand Down
2 changes: 1 addition & 1 deletion convex/dictionary/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zodToConvex } from 'convex-helpers/server/zod';
import { zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { getBaseDbModel } from '../shared/models';
Expand Down
2 changes: 1 addition & 1 deletion convex/leaderboardEntries/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zid, zodToConvex } from 'convex-helpers/server/zod';
import { zid, zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { getBaseDbModel } from '../shared/models';
Expand Down
2 changes: 1 addition & 1 deletion convex/leaderboards/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zid, zodToConvex } from 'convex-helpers/server/zod';
import { zid, zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { getBaseDbModel } from '../shared/models';
Expand Down
16 changes: 8 additions & 8 deletions convex/leaderboards/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NamedTableInfo, type Query } from 'convex/server';
import { ConvexError } from 'convex/values';
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { internal } from '../_generated/api';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const list = query({
.collect();

const userJoinedLeaderboards =
type === leaderboardType.Enum.private
type === leaderboardType.enum.private
? leaderboards.filter((leaderboard) => leaderboard.users?.includes(userId))
: leaderboards;

Expand All @@ -42,7 +42,7 @@ export const list = query({
const leaderboardEntries = await ctx.db
.query('leaderboardEntries')
.withIndex('by_leaderboard_recordedAt', (q) => {
if (range === leaderboardRange.Enum.weekly) {
if (range === leaderboardRange.enum.weekly) {
const { lastMonday, nextSunday } = weekBounds(timestamp);
return q
.eq('leaderboardId', leaderboard._id)
Expand Down Expand Up @@ -103,7 +103,7 @@ export const readGlobalLeaderboard = query({

const globalLeaderboard = await ctx.db
.query('leaderboards')
.withIndex('by_type', (q) => q.eq('type', leaderboardType.Enum.global))
.withIndex('by_type', (q) => q.eq('type', leaderboardType.enum.global))
.unique();

if (!globalLeaderboard) {
Expand All @@ -112,7 +112,7 @@ export const readGlobalLeaderboard = query({

let leaderboardEntriesBaseQuery: Query<NamedTableInfo<DataModel, 'leaderboardEntries'>>;

if (range === leaderboardRange.Enum.weekly) {
if (range === leaderboardRange.enum.weekly) {
const { lastMonday, nextSunday } = weekBounds(timestamp);

leaderboardEntriesBaseQuery = ctx.db
Expand Down Expand Up @@ -180,7 +180,7 @@ export const populateLeaderboardWithExistingRecords = internalMutation({
async handler(ctx, { userId, leaderboardId }) {
const globalLeaderboard = await ctx.db
.query('leaderboards')
.withIndex('by_type', (q) => q.eq('type', leaderboardType.Enum.global))
.withIndex('by_type', (q) => q.eq('type', leaderboardType.enum.global))
.unique();
if (!globalLeaderboard) {
throw new ConvexError({ message: 'Global leaderboard not found', code: 500 });
Expand Down Expand Up @@ -222,7 +222,7 @@ export const createPrivateLeaderboard = mutation({

const createdLeaderboardId = await ctx.db.insert('leaderboards', {
name: data.name,
type: leaderboardType.Enum.private,
type: leaderboardType.enum.private,
creatorId: normalizedUserId,
users: [normalizedUserId],
inviteCode,
Expand Down Expand Up @@ -323,7 +323,7 @@ export const deletePrivateLeaderboard = mutation({
throw new ConvexError({ message: 'Leaderboard not found.', code: 404 });
}

if (leaderboard.type === leaderboardType.Enum.global) {
if (leaderboard.type === leaderboardType.enum.global) {
throw new ConvexError({ message: 'Cannot perform delete opration on a global leaderboard.', code: 403 });
}

Expand Down
2 changes: 1 addition & 1 deletion convex/notifications/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConvexError } from 'convex/values';
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { mutation, query } from '../shared/queries';
Expand Down
2 changes: 1 addition & 1 deletion convex/puzzleGuessAttempts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export function isAttemptCorrect(attempt?: Pick<PuzzleGuessAttempt, 'checkedLett
return false;
}

return attempt.checkedLetters.every((letter) => letter.status === checkedLetterStatus.Enum.correct);
return attempt.checkedLetters.every((letter) => letter.status === checkedLetterStatus.enum.correct);
}
2 changes: 1 addition & 1 deletion convex/puzzleGuessAttempts/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zodToConvex } from 'convex-helpers/server/zod';
import { zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { getBaseDbModel } from '../shared/models';
Expand Down
2 changes: 1 addition & 1 deletion convex/puzzleGuessAttempts/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConvexError } from 'convex/values';
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { checkWordleAttempt } from '@/utils/words';
Expand Down
4 changes: 2 additions & 2 deletions convex/puzzles/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const createDailyPuzzle = internalMutation({
const word = pickRandomWord(words);

await ctx.db.insert('puzzles', {
type: puzzleType.Enum.daily,
type: puzzleType.enum.daily,
creatorId: null,
solution: word,
solvedBy: [],
Expand All @@ -48,7 +48,7 @@ export const sendReminderForDailyChallenge = internalMutation({
.query('puzzles')
.withIndex('by_type_year_month_day', (q) =>
q
.eq('type', puzzleType.Enum.daily)
.eq('type', puzzleType.enum.daily)
.eq('year', today.getFullYear())
.eq('month', today.getMonth() + 1)
.eq('day', today.getDate())
Expand Down
2 changes: 1 addition & 1 deletion convex/puzzles/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zodToConvex } from 'convex-helpers/server/zod';
import { zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { puzzleGuessAttemptModel } from '../puzzleGuessAttempts/models';
Expand Down
16 changes: 8 additions & 8 deletions convex/puzzles/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConvexError } from 'convex/values';
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { pickRandomWord } from '@/utils/words';
Expand Down Expand Up @@ -41,7 +41,7 @@ export const list = query({

const baseQuery = ctx.db.query('puzzles');
const indexedQuery =
type === puzzleType.Enum.daily
type === puzzleType.enum.daily
? baseQuery.withIndex('by_type', (q) => q.eq('type', type).lte('_creationTime', currentDate.getTime()))
: baseQuery.withIndex('by_type_creator', (q) => q.eq('type', type).eq('creatorId', normalizedUserId));

Expand Down Expand Up @@ -76,7 +76,7 @@ export const readUserActiveTrainingPuzzle = query({

const userTrainingPuzzle = await ctx.db
.query('puzzles')
.withIndex('by_type_creator', (q) => q.eq('type', puzzleType.Enum.training).eq('creatorId', normalizedUserId))
.withIndex('by_type_creator', (q) => q.eq('type', puzzleType.enum.training).eq('creatorId', normalizedUserId))
.order('desc')
.first();

Expand All @@ -92,7 +92,7 @@ export const readActiveDailyPuzzle = query({
.query('puzzles')
.withIndex('by_type_year_month_day', (q) =>
q
.eq('type', puzzleType.Enum.daily)
.eq('type', puzzleType.enum.daily)
.eq('year', date.getFullYear())
.eq('month', date.getMonth() + 1)
.eq('day', date.getDate())
Expand All @@ -113,7 +113,7 @@ export const readUserPuzzlesStatistics = query({
}

const basePuzzlesQuery =
type === puzzleType.Enum.daily
type === puzzleType.enum.daily
? ctx.db.query('puzzles').withIndex('by_type', (q) => q.eq('type', type))
: ctx.db.query('puzzles').withIndex('by_type_creator', (q) => q.eq('type', type).eq('creatorId', userId));

Expand Down Expand Up @@ -150,7 +150,7 @@ export const readUserPuzzlesStatistics = query({
const numOfAttempts = attempts.length;
const lastAttempt = attempts.at(-1);
const isLastAttemptCorrect = lastAttempt?.checkedLetters.every(
(checkedLetter) => checkedLetter.status === checkedLetterStatus.Enum.correct
(checkedLetter) => checkedLetter.status === checkedLetterStatus.enum.correct
);

if (isLastAttemptCorrect) {
Expand Down Expand Up @@ -192,7 +192,7 @@ export const createTrainingPuzzle = mutation({
const word = pickRandomWord(words);

const puzzleId = await ctx.db.insert('puzzles', {
type: puzzleType.Enum.training,
type: puzzleType.enum.training,
creatorId: userId,
solution: word,
solvedBy: [],
Expand Down Expand Up @@ -272,7 +272,7 @@ export const markAsSolved = mutation({
});
}

if (puzzle.type === puzzleType.Enum.daily) {
if (puzzle.type === puzzleType.enum.daily) {
const globalLeaderboard = await ctx.db
.query('leaderboards')
.withIndex('by_type', (q) => q.eq('type', 'global'))
Expand Down
2 changes: 1 addition & 1 deletion convex/shared/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

export const getBaseDbModel = <const T extends string>(tablename: T) =>
Expand Down
2 changes: 1 addition & 1 deletion convex/shared/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NoOp } from 'convex-helpers/server/customFunctions';
import { zCustomQuery, zCustomAction, zCustomMutation } from 'convex-helpers/server/zod';
import { zCustomQuery, zCustomAction, zCustomMutation } from 'convex-helpers/server/zod4';

import {
query as baseQuery,
Expand Down
6 changes: 3 additions & 3 deletions convex/userPuzzleStatistics/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const readAllUsersQuery = internalQuery({
export const populateForUser = internalMutation({
args: { id: v.id('users') },
async handler(ctx, { id }) {
for (const type of [puzzleType.Enum.daily, puzzleType.Enum.training]) {
for (const type of [puzzleType.enum.daily, puzzleType.enum.training]) {
const existingUserStatistics = await ctx.db
.query('userPuzzleStatistics')
.withIndex('by_user_puzzle_type', (q) => q.eq('userId', id).eq('puzzleType', type))
Expand All @@ -25,7 +25,7 @@ export const populateForUser = internalMutation({
}

const basePuzzlesQuery =
type === puzzleType.Enum.daily
type === puzzleType.enum.daily
? ctx.db.query('puzzles').withIndex('by_type', (q) => q.eq('type', type))
: ctx.db.query('puzzles').withIndex('by_type_creator', (q) => q.eq('type', type).eq('creatorId', id));
const allPuzzles = await basePuzzlesQuery.order('desc').collect();
Expand Down Expand Up @@ -59,7 +59,7 @@ export const populateForUser = internalMutation({
const numOfAttempts = attempts.length;
const lastAttempt = attempts.at(-1);
const isLastAttemptCorrect = lastAttempt?.checkedLetters.every(
(checkedLetter) => checkedLetter.status === checkedLetterStatus.Enum.correct
(checkedLetter) => checkedLetter.status === checkedLetterStatus.enum.correct
);

if (isLastAttemptCorrect) {
Expand Down
2 changes: 1 addition & 1 deletion convex/userPuzzleStatistics/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zid, zodToConvex } from 'convex-helpers/server/zod';
import { zid, zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { puzzleType } from '../puzzles/models';
Expand Down
2 changes: 1 addition & 1 deletion convex/userPuzzleStatistics/queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';

import { puzzleType } from '../puzzles/models';
import { query } from '../shared/queries';
Expand Down
10 changes: 5 additions & 5 deletions convex/users/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTable } from 'convex/server';
import { zodToConvex } from 'convex-helpers/server/zod';
import { zodToConvex } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { getBaseDbModel } from '../shared/models';
Expand All @@ -13,13 +13,13 @@ export type User = z.infer<typeof userModel>;
export const createUserModel = z.object({
nickname: z
.string()
.min(3, { message: 'Vzdevek mora vsebovati vsaj 3 znake.' })
.max(20, { message: 'Vzdevek lahko vsebuje največ 20 znakov.' })
.min(3, { error: 'Vzdevek mora vsebovati vsaj 3 znake.' })
.max(20, { error: 'Vzdevek lahko vsebuje največ 20 znakov.' })
.regex(/^(?!.*(@|https?:\/\/|www\.|\.\w{2,})).*$/, {
message: 'Vzdevek ne sme vsebovati spletnih ali e-poštnih naslovov.',
error: 'Vzdevek ne sme vsebovati spletnih ali e-poštnih naslovov.',
})
.regex(/[a-zA-Z0-9]/, {
message: 'Vzdevek mora vsebovati vsaj eno črko ali številko.',
error: 'Vzdevek mora vsebovati vsaj eno črko ali številko.',
}),
});
export type CreateUser = z.infer<typeof createUserModel>;
Expand Down
6 changes: 3 additions & 3 deletions convex/users/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConvexError } from 'convex/values';
import { zid } from 'convex-helpers/server/zod';
import { zid } from 'convex-helpers/server/zod4';
import { z } from 'zod';

import { internal } from '../_generated/api';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const cleanupUserData = internalMutation({

const joinedLeaderboardsQuery = ctx.db
.query('leaderboards')
.withIndex('by_type', (q) => q.eq('type', leaderboardType.Enum.private));
.withIndex('by_type', (q) => q.eq('type', leaderboardType.enum.private));
for await (const joinedLeaderboard of joinedLeaderboardsQuery) {
await ctx.db.patch(joinedLeaderboard._id, { users: joinedLeaderboard.users?.filter((userId) => userId !== id) });
}
Expand All @@ -101,7 +101,7 @@ export const cleanupUserData = internalMutation({

const puzzlesQuery = ctx.db
.query('puzzles')
.withIndex('by_type_creator', (q) => q.eq('type', puzzleType.Enum.training).eq('creatorId', id));
.withIndex('by_type_creator', (q) => q.eq('type', puzzleType.enum.training).eq('creatorId', id));
for await (const puzzle of puzzlesQuery) {
await ctx.db.delete(puzzle._id);
}
Expand Down
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default defineConfig([
eslintPluginPrettierRecommended,
{
files: ['**/*.ts', '**/*.tsx'],
ignores: ['convex/_generated/**'],
plugins: {
'unused-imports': eslintPluginUnusedImports,
'import-x': importX,
Expand Down Expand Up @@ -55,6 +54,6 @@ export default defineConfig([
},
},
{
ignores: ['dist/*'],
ignores: ['dist/*', 'convex/_generated/**'],
},
]);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"require-from-string": "^2.0.2",
"sucrase": "^3.35.1",
"usehooks-ts": "^3.1.1",
"zod": "^3.25.76"
"zod": "^4.3.6"
},
"devDependencies": {
"@babel/core": "^7.28.3",
Expand Down
Loading
Loading