@jlandis1/guessphrase-shared 1.0.27 → 1.0.29

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/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Contains types and Zod schemas used in both frontend and backend applications.
4
4
 
5
5
  ### Workflow when updating package:
6
- - Commit changes (run lint and prettier)
6
+ - Run lint and prettier
7
+ - Commit changes
7
8
  - Increment version number in **package.json** by running ```npm version patch```
8
9
  - Push changes to Github - Github Actions will automatically publish the package
9
10
  - Install the latest version of the package in other repositories by running ```npm install @jlandis1/guessphrase-shared@latest```
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export type { ZodTypeAny, ZodError } from 'zod';
1
+ export { ZodError } from 'zod';
2
+ export type { ZodTypeAny } from 'zod';
2
3
  export { usernameSchema, registerSchema, loginSchema, tokenSchema, emailSchema, resetPasswordSchema } from './src/auth.js';
3
4
  export type { TUsernameSchema, TRegisterSchema, TLoginSchema, TTokenSchema, TEmailSchema, TResetPasswordSchema } from './src/auth.js';
4
5
  export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema, wordsSchema } from './src/phrase.js';
5
6
  export type { TDateSchema, TDateUserSchema, TPhraseIdSchema, TSubmitPhraseAttemptSchema, TCreatePhraseSchema, TUpdatePhraseSchema, TWordsSchema, TPhraseSchema, } from './src/phrase.js';
6
- export type { TUserStatsCollectionSchema, TUserStatsDateDataSchema } from './src/user.js';
7
+ export type { TUserStatsCollectionSchema, TUserStatsDateDataSchema, TUserPhraseManagementCollectionSchema, TUserPhraseManagementDateDataSchema } from './src/user.js';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export { ZodError } from 'zod';
1
2
  export { usernameSchema, registerSchema, loginSchema, tokenSchema, emailSchema, resetPasswordSchema } from './src/auth.js';
2
3
  export { dateSchema, dateUserSchema, phraseIdSchema, submitPhraseAttemptSchema, createPhraseSchema, updatePhraseSchema, wordsSchema } from './src/phrase.js';
@@ -28,17 +28,17 @@ export declare const phraseIdSchema: z.ZodObject<{
28
28
  export type TPhraseIdSchema = z.infer<typeof phraseIdSchema>;
29
29
  export declare const submitPhraseAttemptSchema: z.ZodObject<{
30
30
  phrase_id: z.ZodNumber;
31
- phrase: z.ZodEffects<z.ZodString, string, string>;
31
+ phrase: z.ZodEffects<z.ZodString, string, unknown>;
32
32
  }, "strip", z.ZodTypeAny, {
33
33
  phrase_id: number;
34
34
  phrase: string;
35
35
  }, {
36
36
  phrase_id: number;
37
- phrase: string;
37
+ phrase?: unknown;
38
38
  }>;
39
39
  export type TSubmitPhraseAttemptSchema = z.infer<typeof submitPhraseAttemptSchema>;
40
40
  export declare const createPhraseSchema: z.ZodObject<{
41
- phrase: z.ZodEffects<z.ZodString, string, string>;
41
+ phrase: z.ZodEffects<z.ZodString, string, unknown>;
42
42
  hint: z.ZodNullable<z.ZodString>;
43
43
  date: z.ZodString;
44
44
  to_user: z.ZodString;
@@ -49,14 +49,14 @@ export declare const createPhraseSchema: z.ZodObject<{
49
49
  to_user: string;
50
50
  }, {
51
51
  date: string;
52
- phrase: string;
53
52
  hint: string | null;
54
53
  to_user: string;
54
+ phrase?: unknown;
55
55
  }>;
56
56
  export type TCreatePhraseSchema = z.infer<typeof createPhraseSchema>;
57
57
  export declare const updatePhraseSchema: z.ZodObject<{
58
58
  phrase_id: z.ZodNumber;
59
- phrase: z.ZodEffects<z.ZodString, string, string>;
59
+ phrase: z.ZodEffects<z.ZodString, string, unknown>;
60
60
  hint: z.ZodNullable<z.ZodString>;
61
61
  }, "strip", z.ZodTypeAny, {
62
62
  phrase_id: number;
@@ -64,8 +64,8 @@ export declare const updatePhraseSchema: z.ZodObject<{
64
64
  hint: string | null;
65
65
  }, {
66
66
  phrase_id: number;
67
- phrase: string;
68
67
  hint: string | null;
68
+ phrase?: unknown;
69
69
  }>;
70
70
  export type TUpdatePhraseSchema = z.infer<typeof updatePhraseSchema>;
71
71
  export declare const wordsSchema: z.ZodObject<{
@@ -1,12 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { username } from './auth.js';
3
3
  const phrase_id = z.coerce.number();
4
- const phrase = z
4
+ const phrase = z.preprocess((v) => (typeof v === 'string' ? v.toLowerCase().trim() : v), z
5
5
  .string()
6
6
  .min(1, 'Phrase is required')
7
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')
9
- .transform((val) => val.toLowerCase());
8
+ .regex(/^[A-Za-z]+( [A-Za-z]+)*$/, 'Only letters and single spaces are allowed'));
10
9
  const hint = z.string().max(50, 'Hint cannot be more than 50 characters').nullable();
11
10
  const date = z.string().regex(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/, {
12
11
  message: 'Date must be in format YYYY-MM-DD'
@@ -16,3 +16,11 @@ export type TUserStatsDateDataSchema = {
16
16
  attempts: number;
17
17
  solved: boolean;
18
18
  };
19
+ export type TUserPhraseManagementCollectionSchema = {
20
+ date_data: Record<string, Record<string, TUserPhraseManagementDateDataSchema>>;
21
+ };
22
+ export type TUserPhraseManagementDateDataSchema = {
23
+ phrase_id: number;
24
+ phrase: string;
25
+ hint: string | null;
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jlandis1/guessphrase-shared",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "type": "module",
5
5
  "description": "Shared library between Frontend and Backend for GuessPhrase",
6
6
  "main": "dist/index.js",