@jlandis1/guessphrase-shared 1.0.22 → 1.0.24
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/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/src/auth.js +2 -2
- package/dist/src/phrase.d.ts +6 -40
- package/dist/src/phrase.js +5 -22
- package/dist/src/user.d.ts +15 -0
- package/dist/src/user.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { ZodTypeAny } from 'zod';
|
|
2
2
|
export { usernameSchema, registerSchema, loginSchema, tokenSchema, emailSchema, resetPasswordSchema } from './src/auth.js';
|
|
3
3
|
export type { TUsernameSchema, TRegisterSchema, TLoginSchema, TTokenSchema, TEmailSchema, TResetPasswordSchema } from './src/auth.js';
|
|
4
|
-
export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema,
|
|
5
|
-
export type { TDateSchema, TDateUserSchema, TPhraseIdSchema, TSubmitPhraseAttemptSchema, TCreatePhraseSchema, TUpdatePhraseSchema,
|
|
4
|
+
export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema, wordsSchema } from './src/phrase.js';
|
|
5
|
+
export type { TDateSchema, TDateUserSchema, TPhraseIdSchema, TSubmitPhraseAttemptSchema, TCreatePhraseSchema, TUpdatePhraseSchema, TWordsSchema, TPhraseSchema, } from './src/phrase.js';
|
|
6
|
+
export type { TUserStatsCollectionSchema, TUserStatsDateDataSchema } from './src/user.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { usernameSchema, registerSchema, loginSchema, tokenSchema, emailSchema, resetPasswordSchema } from './src/auth.js';
|
|
2
|
-
export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema,
|
|
2
|
+
export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema, wordsSchema } from './src/phrase.js';
|
package/dist/src/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ export const username = z.string().min(1, 'Username is required').max(30, 'Usern
|
|
|
3
3
|
const email = z
|
|
4
4
|
.string()
|
|
5
5
|
.email('Email is invalid')
|
|
6
|
-
.max(
|
|
6
|
+
.max(254, 'Email cannot be more than 254 characters')
|
|
7
7
|
.transform((val) => val.toLowerCase());
|
|
8
8
|
const password = z
|
|
9
9
|
.string()
|
|
@@ -13,7 +13,7 @@ const password = z
|
|
|
13
13
|
.max(128, 'Password cannot be more than 128 characters');
|
|
14
14
|
const confirmPassword = z.string();
|
|
15
15
|
const token = z.string().min(1, 'Token is required');
|
|
16
|
-
//
|
|
16
|
+
// VALIDATION SCHEMAS
|
|
17
17
|
export const usernameSchema = z.object({
|
|
18
18
|
username: username
|
|
19
19
|
});
|
package/dist/src/phrase.d.ts
CHANGED
|
@@ -68,46 +68,6 @@ export declare const updatePhraseSchema: z.ZodObject<{
|
|
|
68
68
|
hint: string | null;
|
|
69
69
|
}>;
|
|
70
70
|
export type TUpdatePhraseSchema = z.infer<typeof updatePhraseSchema>;
|
|
71
|
-
export declare const globalPhraseSchema: z.ZodObject<{
|
|
72
|
-
phrase_id: z.ZodNumber;
|
|
73
|
-
phrase: z.ZodEffects<z.ZodString, string, string>;
|
|
74
|
-
hint: z.ZodNullable<z.ZodString>;
|
|
75
|
-
date: z.ZodString;
|
|
76
|
-
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
date: string;
|
|
78
|
-
phrase_id: number;
|
|
79
|
-
phrase: string;
|
|
80
|
-
hint: string | null;
|
|
81
|
-
}, {
|
|
82
|
-
date: string;
|
|
83
|
-
phrase_id: number;
|
|
84
|
-
phrase: string;
|
|
85
|
-
hint: string | null;
|
|
86
|
-
}>;
|
|
87
|
-
export type TGlobalPhraseSchema = z.infer<typeof globalPhraseSchema>;
|
|
88
|
-
export declare const userPhraseSchema: z.ZodObject<{
|
|
89
|
-
phrase_id: z.ZodNumber;
|
|
90
|
-
phrase: z.ZodEffects<z.ZodString, string, string>;
|
|
91
|
-
hint: z.ZodNullable<z.ZodString>;
|
|
92
|
-
date: z.ZodString;
|
|
93
|
-
from_user: z.ZodString;
|
|
94
|
-
to_user: z.ZodString;
|
|
95
|
-
}, "strip", z.ZodTypeAny, {
|
|
96
|
-
date: string;
|
|
97
|
-
phrase_id: number;
|
|
98
|
-
phrase: string;
|
|
99
|
-
hint: string | null;
|
|
100
|
-
to_user: string;
|
|
101
|
-
from_user: string;
|
|
102
|
-
}, {
|
|
103
|
-
date: string;
|
|
104
|
-
phrase_id: number;
|
|
105
|
-
phrase: string;
|
|
106
|
-
hint: string | null;
|
|
107
|
-
to_user: string;
|
|
108
|
-
from_user: string;
|
|
109
|
-
}>;
|
|
110
|
-
export type TUserPhraseSchema = z.infer<typeof userPhraseSchema>;
|
|
111
71
|
export declare const wordsSchema: z.ZodObject<{
|
|
112
72
|
words: z.ZodArray<z.ZodString, "many">;
|
|
113
73
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -116,3 +76,9 @@ export declare const wordsSchema: z.ZodObject<{
|
|
|
116
76
|
words: string[];
|
|
117
77
|
}>;
|
|
118
78
|
export type TWordsSchema = z.infer<typeof wordsSchema>;
|
|
79
|
+
export type TPhraseSchema = {
|
|
80
|
+
phrase_id: number;
|
|
81
|
+
phrase: string;
|
|
82
|
+
hint: string;
|
|
83
|
+
date: string;
|
|
84
|
+
};
|
package/dist/src/phrase.js
CHANGED
|
@@ -4,16 +4,15 @@ const phrase_id = z.coerce.number();
|
|
|
4
4
|
const phrase = z
|
|
5
5
|
.string()
|
|
6
6
|
.min(1, 'Phrase is required')
|
|
7
|
-
.max(
|
|
7
|
+
.max(150, 'Phrase cannot be more than 150 characters')
|
|
8
|
+
.regex(/^[A-Za-z]+( [A-Za-z]+)*$/, 'Only letters and single spaces are allowed')
|
|
8
9
|
.transform((val) => val.toLowerCase());
|
|
9
|
-
const hint = z.string().max(
|
|
10
|
+
const hint = z.string().max(50, 'Hint cannot be more than 50 characters').nullable();
|
|
10
11
|
const date = z.string().regex(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/, {
|
|
11
12
|
message: 'Date must be in format YYYY-MM-DD'
|
|
12
13
|
});
|
|
13
|
-
const words = z
|
|
14
|
-
|
|
15
|
-
.min(1, 'At least one word is required');
|
|
16
|
-
// ----------------------------------------------------------------------
|
|
14
|
+
const words = z.array(z.string().min(1, 'Word cannot be empty')).min(1, 'At least one word is required');
|
|
15
|
+
// VALIDATION SCHEMAS
|
|
17
16
|
export const dateSchema = z.object({
|
|
18
17
|
date: date
|
|
19
18
|
});
|
|
@@ -45,22 +44,6 @@ export const updatePhraseSchema = z.object({
|
|
|
45
44
|
hint: hint
|
|
46
45
|
});
|
|
47
46
|
// ----------------------------------------------------------------------
|
|
48
|
-
export const globalPhraseSchema = z.object({
|
|
49
|
-
phrase_id: phrase_id,
|
|
50
|
-
phrase: phrase,
|
|
51
|
-
hint: hint,
|
|
52
|
-
date: date
|
|
53
|
-
});
|
|
54
|
-
// ----------------------------------------------------------------------
|
|
55
|
-
export const userPhraseSchema = z.object({
|
|
56
|
-
phrase_id: phrase_id,
|
|
57
|
-
phrase: phrase,
|
|
58
|
-
hint: hint,
|
|
59
|
-
date: date,
|
|
60
|
-
from_user: username,
|
|
61
|
-
to_user: username
|
|
62
|
-
});
|
|
63
|
-
// ----------------------------------------------------------------------
|
|
64
47
|
export const wordsSchema = z.object({
|
|
65
48
|
words: words
|
|
66
49
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type TUserStatsCollectionSchema = {
|
|
2
|
+
phrases: Record<number | string, number>;
|
|
3
|
+
attempts: Record<number | string, number>;
|
|
4
|
+
solved_phrases: Record<number | string, number>;
|
|
5
|
+
percentage_phrases_solved: Record<number | string, number>;
|
|
6
|
+
average_attempts_for_solve: Record<number | string, number>;
|
|
7
|
+
date_data: Record<number | string, Record<string, TUserStatsDateDataSchema>>;
|
|
8
|
+
};
|
|
9
|
+
export type TUserStatsDateDataSchema = {
|
|
10
|
+
date: string;
|
|
11
|
+
phrase: string;
|
|
12
|
+
creator: string | null;
|
|
13
|
+
attempts: number;
|
|
14
|
+
solved: 'X' | '';
|
|
15
|
+
};
|
package/dist/src/user.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../index.ts","../src/auth.ts","../src/phrase.ts"],"version":"5.9.2"}
|
|
1
|
+
{"root":["../index.ts","../src/auth.ts","../src/phrase.ts","../src/user.ts"],"version":"5.9.2"}
|