@tpmjs/types 0.1.2 → 0.2.1

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 ADDED
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const RESERVED_USERNAMES: readonly ["admin", "api", "auth", "dashboard", "help", "support", "system", "www", "settings", "login", "logout", "register", "signup", "signin", "agents", "collections", "tools", "tool", "playground", "explore", "search", "about", "blog", "docs", "pricing", "terms", "privacy", "contact", "status", "tpmjs", "tpm", "official"];
4
+ /**
5
+ * Username requirements:
6
+ * - 3-30 characters
7
+ * - Lowercase alphanumeric and hyphens only
8
+ * - Must start and end with alphanumeric (unless 1-2 chars)
9
+ * - No consecutive hyphens
10
+ */
11
+ declare const USERNAME_REGEX: RegExp;
12
+ declare const UsernameSchema: z.ZodString;
13
+ declare const UpdateUserProfileSchema: z.ZodObject<{
14
+ name: z.ZodOptional<z.ZodString>;
15
+ username: z.ZodOptional<z.ZodString>;
16
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ }, z.core.$strip>;
18
+ declare const CheckUsernameSchema: z.ZodObject<{
19
+ username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
20
+ }, z.core.$strip>;
21
+ declare const UserProfileSchema: z.ZodObject<{
22
+ id: z.ZodString;
23
+ name: z.ZodString;
24
+ username: z.ZodNullable<z.ZodString>;
25
+ email: z.ZodString;
26
+ image: z.ZodNullable<z.ZodString>;
27
+ createdAt: z.ZodDate;
28
+ }, z.core.$strip>;
29
+ declare const PublicUserSchema: z.ZodObject<{
30
+ id: z.ZodString;
31
+ username: z.ZodString;
32
+ name: z.ZodString;
33
+ image: z.ZodNullable<z.ZodString>;
34
+ }, z.core.$strip>;
35
+ declare const UsernameAvailabilitySchema: z.ZodObject<{
36
+ username: z.ZodString;
37
+ available: z.ZodBoolean;
38
+ reason: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ type UpdateUserProfileInput = z.infer<typeof UpdateUserProfileSchema>;
41
+ type CheckUsernameInput = z.infer<typeof CheckUsernameSchema>;
42
+ type UserProfile = z.infer<typeof UserProfileSchema>;
43
+ type PublicUser = z.infer<typeof PublicUserSchema>;
44
+ type UsernameAvailability = z.infer<typeof UsernameAvailabilitySchema>;
45
+ /**
46
+ * Convert a display name to a URL-friendly username suggestion.
47
+ */
48
+ declare function suggestUsername(name: string): string;
49
+ /**
50
+ * Check if a username is valid (without checking availability).
51
+ */
52
+ declare function isValidUsername(username: string): boolean;
53
+
54
+ export { type CheckUsernameInput, CheckUsernameSchema, type PublicUser, PublicUserSchema, RESERVED_USERNAMES, USERNAME_REGEX, type UpdateUserProfileInput, UpdateUserProfileSchema, type UserProfile, UserProfileSchema, type UsernameAvailability, UsernameAvailabilitySchema, UsernameSchema, isValidUsername, suggestUsername };
package/dist/user.js ADDED
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/user.ts
4
+ var RESERVED_USERNAMES = [
5
+ // System routes
6
+ "admin",
7
+ "api",
8
+ "auth",
9
+ "dashboard",
10
+ "help",
11
+ "support",
12
+ "system",
13
+ "www",
14
+ "settings",
15
+ "login",
16
+ "logout",
17
+ "register",
18
+ "signup",
19
+ "signin",
20
+ // Content routes
21
+ "agents",
22
+ "collections",
23
+ "tools",
24
+ "tool",
25
+ "playground",
26
+ "explore",
27
+ "search",
28
+ // Reserved for future
29
+ "about",
30
+ "blog",
31
+ "docs",
32
+ "pricing",
33
+ "terms",
34
+ "privacy",
35
+ "contact",
36
+ "status",
37
+ // Brand/official
38
+ "tpmjs",
39
+ "tpm",
40
+ "official"
41
+ ];
42
+ var USERNAME_REGEX = /^[a-z0-9](?:[a-z0-9]|(?:-(?!-))){1,28}[a-z0-9]$|^[a-z0-9]{1,2}$/;
43
+ var UsernameSchema = z.string().min(3, "Username must be at least 3 characters").max(30, "Username must be 30 characters or less").regex(USERNAME_REGEX, "Username must be lowercase, alphanumeric, with single hyphens only").refine(
44
+ (val) => !RESERVED_USERNAMES.includes(val),
45
+ "This username is reserved"
46
+ );
47
+ var UpdateUserProfileSchema = z.object({
48
+ name: z.string().min(1, "Name is required").max(100).optional(),
49
+ username: UsernameSchema.optional(),
50
+ image: z.string().url("Invalid image URL").nullable().optional()
51
+ });
52
+ var CheckUsernameSchema = z.object({
53
+ username: z.string().min(3, "Username must be at least 3 characters").max(30, "Username must be 30 characters or less").transform((val) => val.toLowerCase())
54
+ });
55
+ var UserProfileSchema = z.object({
56
+ id: z.string(),
57
+ name: z.string(),
58
+ username: z.string().nullable(),
59
+ email: z.string().email(),
60
+ image: z.string().nullable(),
61
+ createdAt: z.date()
62
+ });
63
+ var PublicUserSchema = z.object({
64
+ id: z.string(),
65
+ username: z.string(),
66
+ name: z.string(),
67
+ image: z.string().nullable()
68
+ });
69
+ var UsernameAvailabilitySchema = z.object({
70
+ username: z.string(),
71
+ available: z.boolean(),
72
+ reason: z.string().optional()
73
+ });
74
+ function suggestUsername(name) {
75
+ return name.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").slice(0, 30);
76
+ }
77
+ function isValidUsername(username) {
78
+ return UsernameSchema.safeParse(username).success;
79
+ }
80
+
81
+ export { CheckUsernameSchema, PublicUserSchema, RESERVED_USERNAMES, USERNAME_REGEX, UpdateUserProfileSchema, UserProfileSchema, UsernameAvailabilitySchema, UsernameSchema, isValidUsername, suggestUsername };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpmjs/types",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Shared TypeScript types and Zod schemas for TPMJS",
5
5
  "author": "TPMJS",
6
6
  "license": "MIT",
@@ -30,16 +30,32 @@
30
30
  "./tpmjs": {
31
31
  "types": "./dist/tpmjs.d.ts",
32
32
  "default": "./dist/tpmjs.js"
33
+ },
34
+ "./collection": {
35
+ "types": "./dist/collection.d.ts",
36
+ "default": "./dist/collection.js"
37
+ },
38
+ "./agent": {
39
+ "types": "./dist/agent.d.ts",
40
+ "default": "./dist/agent.js"
41
+ },
42
+ "./user": {
43
+ "types": "./dist/user.d.ts",
44
+ "default": "./dist/user.js"
45
+ },
46
+ "./executor": {
47
+ "types": "./dist/executor.d.ts",
48
+ "default": "./dist/executor.js"
33
49
  }
34
50
  },
35
51
  "files": [
36
52
  "dist"
37
53
  ],
38
54
  "dependencies": {
39
- "zod": "^4.1.13"
55
+ "zod": "^4.3.5"
40
56
  },
41
57
  "devDependencies": {
42
- "tsup": "^8.3.5",
58
+ "tsup": "^8.5.1",
43
59
  "typescript": "^5.9.3",
44
60
  "@tpmjs/tsconfig": "0.0.0"
45
61
  },