@djangocfg/api 2.1.100 → 2.1.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "2.1.100",
3
+ "version": "2.1.101",
4
4
  "description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
5
5
  "keywords": [
6
6
  "django",
@@ -74,7 +74,7 @@
74
74
  "check": "tsc --noEmit"
75
75
  },
76
76
  "peerDependencies": {
77
- "@djangocfg/ui-nextjs": "^2.1.100",
77
+ "@djangocfg/ui-nextjs": "^2.1.101",
78
78
  "consola": "^3.4.2",
79
79
  "next": ">=16.0.0",
80
80
  "p-retry": "^7.0.0",
@@ -85,7 +85,7 @@
85
85
  "devDependencies": {
86
86
  "@types/node": "^24.7.2",
87
87
  "@types/react": "^19.0.0",
88
- "@djangocfg/typescript-config": "^2.1.100",
88
+ "@djangocfg/typescript-config": "^2.1.101",
89
89
  "next": "^16.0.0",
90
90
  "react": "^19.0.0",
91
91
  "tsup": "^8.5.0",
@@ -553,6 +553,24 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
553
553
  return Boolean(user?.is_staff || user?.is_superuser);
554
554
  }, [user]);
555
555
 
556
+ // Profile management: Update profile data
557
+ const updateProfile = useCallback(
558
+ async (data: { first_name?: string; last_name?: string; username?: string }): Promise<UserProfile> => {
559
+ const result = await accounts.partialUpdateProfile(data);
560
+ return result as UserProfile;
561
+ },
562
+ [accounts]
563
+ );
564
+
565
+ // Profile management: Upload avatar
566
+ const uploadAvatar = useCallback(
567
+ async (avatar: File | Blob): Promise<UserProfile> => {
568
+ const result = await accounts.uploadAvatar(avatar);
569
+ return result as UserProfile;
570
+ },
571
+ [accounts]
572
+ );
573
+
556
574
  // Memoized context value
557
575
  const value = useMemo<AuthContextType>(
558
576
  () => ({
@@ -580,6 +598,9 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
580
598
  getRedirectUrl: redirectManager.getFinalRedirectUrl,
581
599
  clearRedirectUrl: redirectManager.clearRedirect,
582
600
  hasRedirectUrl: redirectManager.hasRedirect,
601
+ // Profile management
602
+ updateProfile,
603
+ uploadAvatar,
583
604
  }),
584
605
  [
585
606
  user,
@@ -598,6 +619,8 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
598
619
  refreshToken,
599
620
  logout,
600
621
  redirectManager,
622
+ updateProfile,
623
+ uploadAvatar,
601
624
  ],
602
625
  );
603
626
 
@@ -661,6 +684,14 @@ const defaultAuthState: AuthContextType = {
661
684
  getRedirectUrl: () => null,
662
685
  clearRedirectUrl: () => {},
663
686
  hasRedirectUrl: () => false,
687
+ updateProfile: async () => {
688
+ authLogger.warn('useAuth: updateProfile called outside AuthProvider');
689
+ return {} as UserProfile;
690
+ },
691
+ uploadAvatar: async () => {
692
+ authLogger.warn('useAuth: uploadAvatar called outside AuthProvider');
693
+ return {} as UserProfile;
694
+ },
664
695
  };
665
696
 
666
697
  /**
@@ -64,6 +64,10 @@ export interface AuthContextType {
64
64
  getRedirectUrl: () => string;
65
65
  clearRedirectUrl: () => void;
66
66
  hasRedirectUrl: () => boolean;
67
+
68
+ // Profile Management Methods
69
+ updateProfile: (data: { first_name?: string; last_name?: string; username?: string }) => Promise<UserProfile>;
70
+ uploadAvatar: (avatar: File | Blob) => Promise<UserProfile>;
67
71
  }
68
72
 
69
73
  // Provider props