@axium/core 0.15.0 → 0.15.2

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/user.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as z from 'zod';
2
+ import { Preferences } from './preferences.js';
2
3
  export declare const User: z.ZodObject<{
3
4
  id: z.ZodUUID;
4
5
  name: z.ZodString;
@@ -13,6 +14,7 @@ export declare const User: z.ZodObject<{
13
14
  isAdmin: z.ZodBoolean;
14
15
  }, z.core.$strip>;
15
16
  export interface User extends z.infer<typeof User> {
17
+ preferences: Preferences;
16
18
  }
17
19
  export interface UserInternal extends User {
18
20
  isSuspended: boolean;
@@ -37,14 +39,15 @@ export interface UserPublic extends z.infer<typeof UserPublic> {
37
39
  }
38
40
  export declare const userProtectedFields: ["email", "emailVerified", "preferences", "isAdmin"];
39
41
  export declare const UserChangeable: z.ZodObject<{
40
- email: z.ZodOptional<z.ZodEmail>;
41
- name: z.ZodOptional<z.ZodString>;
42
42
  preferences: z.ZodOptional<z.ZodObject<{
43
43
  debug: z.ZodBoolean;
44
44
  }, z.core.$strip>>;
45
+ email: z.ZodOptional<z.ZodEmail>;
46
+ name: z.ZodOptional<z.ZodString>;
45
47
  image: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodURL>>>;
46
48
  }, z.core.$strip>;
47
49
  export interface UserChangeable extends z.infer<typeof UserChangeable> {
50
+ preferences?: Preferences;
48
51
  }
49
52
  export declare function getUserImage(user: Partial<User>): string;
50
53
  export declare const UserRegistration: z.ZodObject<{
package/dist/user.js CHANGED
@@ -2,13 +2,16 @@ import * as z from 'zod';
2
2
  import { Preferences } from './preferences.js';
3
3
  import { PasskeyRegistration } from './passkeys.js';
4
4
  import { colorHash } from './color.js';
5
+ import { pick } from 'utilium';
5
6
  export const User = z.object({
6
7
  id: z.uuid(),
7
8
  name: z.string().min(1, 'Name is required').max(255, 'Name is too long'),
8
9
  email: z.email(),
9
10
  emailVerified: z.date().nullish(),
10
11
  image: z.url().nullish(),
11
- preferences: Preferences,
12
+ get preferences() {
13
+ return Preferences;
14
+ },
12
15
  roles: z.array(z.string()),
13
16
  registeredAt: z.coerce.date(),
14
17
  isAdmin: z.boolean(),
@@ -18,12 +21,14 @@ export const UserPublic = User.partial(Object.fromEntries(Object.keys(User.shape
18
21
  .filter((key) => !userPublicFields.includes(key))
19
22
  .map(key => [key, true])));
20
23
  export const userProtectedFields = ['email', 'emailVerified', 'preferences', 'isAdmin'];
21
- export const UserChangeable = User.pick({
22
- name: true,
23
- email: true,
24
- image: true,
25
- preferences: true,
26
- }).partial();
24
+ export const UserChangeable = z
25
+ .object({
26
+ ...pick(User.shape, 'name', 'email', 'image'),
27
+ get preferences() {
28
+ return Preferences;
29
+ },
30
+ })
31
+ .partial();
27
32
  export function getUserImage(user) {
28
33
  if (user.image)
29
34
  return user.image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/core",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",