@axium/core 0.0.1 → 0.0.3

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 CHANGED
@@ -1 +1,2 @@
1
- export * as api from './api.js';
1
+ export * as schemas from './schemas.js';
2
+ export * from './user.js';
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- export * as api from './api.js';
1
+ export * as schemas from './schemas.js';
2
+ export * from './user.js';
@@ -1,41 +1,46 @@
1
1
  import * as z from 'zod';
2
+ export declare const Name: z.ZodString;
3
+ export type Name = z.infer<typeof Name>;
2
4
  export declare const User: z.ZodObject<{
5
+ id: z.ZodString;
3
6
  email: z.ZodString;
4
7
  name: z.ZodString;
5
8
  image: z.ZodString;
6
9
  }, "strip", z.ZodTypeAny, {
7
10
  name: string;
8
11
  email: string;
12
+ id: string;
9
13
  image: string;
10
14
  }, {
11
15
  name: string;
12
16
  email: string;
17
+ id: string;
13
18
  image: string;
14
19
  }>;
15
20
  export type User = z.infer<typeof User>;
16
21
  export declare const Login: z.ZodObject<{
17
22
  email: z.ZodString;
18
- password: z.ZodString;
23
+ password: z.ZodOptional<z.ZodString>;
19
24
  }, "strip", z.ZodTypeAny, {
20
25
  email: string;
21
- password: string;
26
+ password?: string | undefined;
22
27
  }, {
23
28
  email: string;
24
- password: string;
29
+ password?: string | undefined;
25
30
  }>;
26
31
  export type Login = z.infer<typeof Login>;
27
32
  export declare const Registration: z.ZodObject<z.objectUtil.extendShape<{
28
33
  email: z.ZodString;
29
- password: z.ZodString;
34
+ password: z.ZodOptional<z.ZodString>;
30
35
  }, {
31
36
  name: z.ZodString;
32
37
  }>, "strip", z.ZodTypeAny, {
33
38
  name: string;
34
39
  email: string;
35
- password: string;
40
+ password?: string | undefined;
36
41
  }, {
37
42
  name: string;
38
43
  email: string;
39
- password: string;
44
+ password?: string | undefined;
40
45
  }>;
41
46
  export type Registration = z.infer<typeof Registration>;
@@ -1,16 +1,14 @@
1
1
  import * as z from 'zod';
2
+ export const Name = z.string().min(1, 'Name is required').max(255, 'Name is too long');
2
3
  export const User = z.object({
4
+ id: z.string().uuid(),
3
5
  email: z.string().email(),
4
- name: z.string(),
6
+ name: Name,
5
7
  image: z.string().url(),
6
8
  });
7
9
  export const Login = z.object({
8
10
  email: z.string({ required_error: 'Email is required' }).min(1, 'Email is required').max(255, 'Email is too long').email('Invalid email'),
9
- password: z
10
- .string({ required_error: 'Password is required' })
11
- .min(1, 'Password is required')
12
- .min(8, 'Password must be more than 8 characters')
13
- .max(255, 'Password must be less than 255 characters'),
11
+ password: z.string().max(255, 'Password must be less than 255 characters').optional(),
14
12
  });
15
13
  export const Registration = Login.extend({
16
14
  name: z.string({ required_error: 'Name is required' }),
package/dist/user.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function getUserImage(user: {
2
+ name?: string;
3
+ image?: string;
4
+ }): string;
package/dist/user.js ADDED
@@ -0,0 +1,16 @@
1
+ export function getUserImage(user) {
2
+ if (user.image)
3
+ return user.image;
4
+ user.name ??= '\0';
5
+ let color = user.name.charCodeAt(0);
6
+ for (let i = 1; i < user.name.length; i++) {
7
+ color *= user.name.charCodeAt(i);
8
+ }
9
+ color &= 0xbfbfbf;
10
+ const r = (color >> 16) & 0xff;
11
+ const g = (color >> 8) & 0xff;
12
+ const b = color & 0xff;
13
+ return `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" style="background-color:rgb(${r},${g},${b});display:flex;align-items:center;justify-content:center;">
14
+ <text x="23" y="28" style="font-family:sans-serif;font-weight:bold;" fill="white">${user.name.replaceAll(/\W/g, '')[0]}</text>
15
+ </svg>`.replaceAll(/[\t\n]/g, '');
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -19,7 +19,7 @@
19
19
  "types": "dist/index.d.ts",
20
20
  "exports": {
21
21
  ".": "./dist/index.js",
22
- "./api": "./dist/api.js"
22
+ "./schemas": "./dist/schemas.js"
23
23
  },
24
24
  "files": [
25
25
  "dist"