@umituz/react-native-gamification 1.2.0 → 1.3.0

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.
@@ -1,235 +0,0 @@
1
- /**
2
- * Gamification Repository Interface
3
- *
4
- * Unified repository interface for all gamification operations
5
- * App-specific implementations should extend this interface
6
- */
7
-
8
- import type { Achievement, AchievementDefinition, AchievementProgress } from "../entities/Achievement";
9
- import type { Point, PointBalance, PointTransaction } from "../entities/Point";
10
- import type { Level, LevelDefinition, LevelProgress } from "../entities/Level";
11
- import type { Streak, StreakDefinition, StreakProgress } from "../entities/Streak";
12
- import type { Leaderboard, LeaderboardEntry, LeaderboardRanking } from "../entities/Leaderboard";
13
- import type { Reward, RewardDefinition, RewardClaim } from "../entities/Reward";
14
- import type { Progress, ProgressUpdate, ProgressMilestone } from "../entities/Progress";
15
-
16
- export interface GamificationError extends Error {
17
- code: "LOAD_FAILED" | "SAVE_FAILED" | "NOT_FOUND" | "INVALID_DATA" | "OPERATION_FAILED";
18
- }
19
-
20
- export type GamificationResult<T> =
21
- | {
22
- success: true;
23
- data: T;
24
- }
25
- | {
26
- success: false;
27
- error: GamificationError;
28
- };
29
-
30
- /**
31
- * Unified Gamification Repository Interface
32
- *
33
- * Provides a single interface for all gamification operations
34
- * App-specific implementations should implement this interface
35
- */
36
- export interface IGamificationRepository {
37
- // =============================================================================
38
- // ACHIEVEMENTS
39
- // =============================================================================
40
-
41
- /**
42
- * Load all achievements for a user
43
- */
44
- loadAchievements(userId: string): Promise<GamificationResult<Achievement[]>>;
45
-
46
- /**
47
- * Save achievements
48
- */
49
- saveAchievements(achievements: Achievement[]): Promise<GamificationResult<void>>;
50
-
51
- /**
52
- * Get achievement by ID
53
- */
54
- getAchievementById(userId: string, achievementId: string): Promise<GamificationResult<Achievement>>;
55
-
56
- /**
57
- * Update achievement progress
58
- */
59
- updateAchievementProgress(
60
- userId: string,
61
- achievementId: string,
62
- progress: number,
63
- ): Promise<GamificationResult<Achievement>>;
64
-
65
- /**
66
- * Unlock achievement
67
- */
68
- unlockAchievement(userId: string, achievementId: string): Promise<GamificationResult<Achievement>>;
69
-
70
- // =============================================================================
71
- // POINTS
72
- // =============================================================================
73
-
74
- /**
75
- * Load point balance for a user
76
- */
77
- loadPointBalance(userId: string): Promise<GamificationResult<PointBalance>>;
78
-
79
- /**
80
- * Load point transactions for a user
81
- */
82
- loadPointTransactions(
83
- userId: string,
84
- limit?: number,
85
- ): Promise<GamificationResult<PointTransaction[]>>;
86
-
87
- /**
88
- * Add points to user
89
- */
90
- addPoints(
91
- userId: string,
92
- amount: number,
93
- source: string,
94
- sourceId?: string,
95
- category?: string,
96
- description?: string,
97
- ): Promise<GamificationResult<PointTransaction>>;
98
-
99
- /**
100
- * Deduct points from user
101
- */
102
- deductPoints(
103
- userId: string,
104
- amount: number,
105
- source: string,
106
- sourceId?: string,
107
- description?: string,
108
- ): Promise<GamificationResult<PointTransaction>>;
109
-
110
- // =============================================================================
111
- // LEVELS
112
- // =============================================================================
113
-
114
- /**
115
- * Load user level
116
- */
117
- loadLevel(userId: string): Promise<GamificationResult<Level>>;
118
-
119
- /**
120
- * Save user level
121
- */
122
- saveLevel(level: Level): Promise<GamificationResult<void>>;
123
-
124
- /**
125
- * Add experience to user
126
- */
127
- addExperience(
128
- userId: string,
129
- amount: number,
130
- source?: string,
131
- ): Promise<GamificationResult<LevelProgress>>;
132
-
133
- // =============================================================================
134
- // STREAKS
135
- // =============================================================================
136
-
137
- /**
138
- * Load streaks for a user
139
- */
140
- loadStreaks(userId: string): Promise<GamificationResult<Streak[]>>;
141
-
142
- /**
143
- * Load streak by type
144
- */
145
- loadStreakByType(userId: string, type: string): Promise<GamificationResult<Streak>>;
146
-
147
- /**
148
- * Save streak
149
- */
150
- saveStreak(streak: Streak): Promise<GamificationResult<void>>;
151
-
152
- /**
153
- * Update streak activity
154
- */
155
- updateStreakActivity(
156
- userId: string,
157
- type: string,
158
- activityDate: string,
159
- ): Promise<GamificationResult<Streak>>;
160
-
161
- // =============================================================================
162
- // LEADERBOARDS
163
- // =============================================================================
164
-
165
- /**
166
- * Load leaderboard
167
- */
168
- loadLeaderboard(
169
- leaderboardId: string,
170
- limit?: number,
171
- offset?: number,
172
- ): Promise<GamificationResult<Leaderboard>>;
173
-
174
- /**
175
- * Get user ranking in leaderboard
176
- */
177
- getUserRanking(
178
- userId: string,
179
- leaderboardId: string,
180
- ): Promise<GamificationResult<LeaderboardRanking>>;
181
-
182
- /**
183
- * Update leaderboard entry
184
- */
185
- updateLeaderboardEntry(
186
- entry: LeaderboardEntry,
187
- ): Promise<GamificationResult<LeaderboardEntry>>;
188
-
189
- // =============================================================================
190
- // REWARDS
191
- // =============================================================================
192
-
193
- /**
194
- * Load rewards for a user
195
- */
196
- loadRewards(userId: string): Promise<GamificationResult<Reward[]>>;
197
-
198
- /**
199
- * Save reward
200
- */
201
- saveReward(reward: Reward): Promise<GamificationResult<void>>;
202
-
203
- /**
204
- * Claim reward
205
- */
206
- claimReward(
207
- userId: string,
208
- rewardId: string,
209
- ): Promise<GamificationResult<RewardClaim>>;
210
-
211
- // =============================================================================
212
- // PROGRESS
213
- // =============================================================================
214
-
215
- /**
216
- * Load progress for a user
217
- */
218
- loadProgress(
219
- userId: string,
220
- metric?: string,
221
- ): Promise<GamificationResult<Progress[]>>;
222
-
223
- /**
224
- * Save progress
225
- */
226
- saveProgress(progress: Progress): Promise<GamificationResult<void>>;
227
-
228
- /**
229
- * Update progress
230
- */
231
- updateProgress(update: ProgressUpdate): Promise<GamificationResult<Progress>>;
232
- }
233
-
234
-
235
-