@umituz/react-native-subscription 2.14.99 → 2.14.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/README.md +211 -394
- package/package.json +3 -3
- package/src/application/README.md +46 -225
- package/src/application/ports/README.md +42 -97
- package/src/domain/README.md +36 -384
- package/src/domain/constants/README.md +0 -56
- package/src/domain/entities/README.md +43 -169
- package/src/domain/entities/SubscriptionStatus.ts +1 -1
- package/src/domain/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +50 -238
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +23 -376
- package/src/domains/config/domain/entities/README.md +34 -343
- package/src/domains/paywall/README.md +99 -369
- package/src/domains/paywall/components/README.md +34 -178
- package/src/domains/paywall/entities/README.md +34 -193
- package/src/domains/paywall/hooks/README.md +34 -122
- package/src/domains/wallet/README.md +34 -275
- package/src/domains/wallet/README.md.bak +209 -0
- package/src/domains/wallet/domain/README.md +34 -101
- package/src/domains/wallet/domain/entities/README.md +34 -115
- package/src/domains/wallet/domain/errors/README.md +34 -151
- package/src/domains/wallet/infrastructure/README.md +34 -89
- package/src/domains/wallet/presentation/components/README.md +34 -224
- package/src/domains/wallet/presentation/components/TransactionItem.tsx +1 -1
- package/src/domains/wallet/presentation/hooks/README.md +34 -248
- package/src/infrastructure/README.md +37 -496
- package/src/infrastructure/mappers/README.md +0 -13
- package/src/infrastructure/repositories/README.md +74 -360
- package/src/infrastructure/services/ActivationHandler.ts +1 -1
- package/src/infrastructure/services/README.md +95 -370
- package/src/infrastructure/services/SubscriptionService.ts +1 -1
- package/src/presentation/README.md +123 -408
- package/src/presentation/README.md.bak +172 -0
- package/src/presentation/components/README.md +151 -179
- package/src/presentation/components/README.md.bak +217 -0
- package/src/presentation/components/details/CreditRow.md +65 -310
- package/src/presentation/components/details/DetailRow.md +63 -255
- package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
- package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
- package/src/presentation/components/details/README.md +97 -447
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
- package/src/presentation/components/feedback/README.md +97 -445
- package/src/presentation/components/paywall/PaywallModal.md +66 -416
- package/src/presentation/components/paywall/README.md +50 -186
- package/src/presentation/components/sections/README.md +97 -466
- package/src/presentation/components/sections/SubscriptionSection.md +92 -244
- package/src/presentation/hooks/README.md +154 -741
- package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
- package/src/presentation/hooks/useAuthGate.md +61 -375
- package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
- package/src/presentation/hooks/useCreditChecker.md +73 -378
- package/src/presentation/hooks/useCredits.md +74 -313
- package/src/presentation/hooks/useCredits.md.bak +231 -0
- package/src/presentation/hooks/useCreditsGate.md +66 -318
- package/src/presentation/hooks/useDeductCredit.md +0 -76
- package/src/presentation/hooks/useDeductCredit.ts +1 -1
- package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
- package/src/presentation/hooks/useFeatureGate.md +105 -150
- package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
- package/src/presentation/hooks/useInitializeCredits.md +64 -430
- package/src/presentation/hooks/usePaywall.md +61 -306
- package/src/presentation/hooks/usePaywallOperations.md +64 -458
- package/src/presentation/hooks/usePaywallVisibility.md +67 -316
- package/src/presentation/hooks/usePremium.md +84 -226
- package/src/presentation/hooks/usePremiumGate.md +60 -395
- package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
- package/src/presentation/hooks/useSubscription.md +66 -422
- package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
- package/src/presentation/hooks/useSubscriptionGate.md +80 -164
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
- package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
- package/src/presentation/hooks/useUserTier.md +63 -328
- package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
- package/src/presentation/screens/README.md +48 -190
- package/src/presentation/types/README.md +0 -16
- package/src/presentation/utils/README.md +0 -21
- package/src/presentation/utils/subscriptionDateUtils.ts +1 -1
- package/src/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +35 -150
- package/src/revenuecat/application/ports/README.md +34 -162
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +34 -176
- package/src/revenuecat/domain/entities/README.md +34 -374
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +34 -366
- package/src/revenuecat/domain/value-objects/README.md +34 -434
- package/src/revenuecat/infrastructure/README.md +34 -43
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +34 -211
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +35 -318
- package/src/revenuecat/infrastructure/utils/README.md +34 -375
- package/src/revenuecat/presentation/README.md +34 -176
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -1,441 +1,41 @@
|
|
|
1
1
|
# RevenueCat Domain Value Objects
|
|
2
2
|
|
|
3
|
+
## Location
|
|
3
4
|
Value objects for RevenueCat integration.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Usage
|
|
40
|
-
const premiumId = new EntitlementId('premium');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### OfferingId
|
|
44
|
-
|
|
45
|
-
Represents an offering identifier.
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
class OfferingId {
|
|
49
|
-
private readonly value: string;
|
|
50
|
-
|
|
51
|
-
constructor(value: string) {
|
|
52
|
-
const validIds = ['default', 'annual_offer', 'lifetime_offer'];
|
|
53
|
-
if (!validIds.includes(value)) {
|
|
54
|
-
throw new Error(`Invalid offering ID: ${value}`);
|
|
55
|
-
}
|
|
56
|
-
this.value = value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getValue(): string {
|
|
60
|
-
return this.value;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
isDefault(): boolean {
|
|
64
|
-
return this.value === 'default';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
equals(other: OfferingId): boolean {
|
|
68
|
-
return this.value === other.value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
toString(): string {
|
|
72
|
-
return this.value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Usage
|
|
77
|
-
const defaultOffering = new OfferingId('default');
|
|
78
|
-
const annualOffering = new OfferingId('annual_offer');
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### PackageIdentifier
|
|
82
|
-
|
|
83
|
-
Represents a package identifier.
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
class PackageIdentifier {
|
|
87
|
-
private readonly value: string;
|
|
88
|
-
|
|
89
|
-
constructor(value: string) {
|
|
90
|
-
if (!value || value.trim().length === 0) {
|
|
91
|
-
throw new Error('Package identifier cannot be empty');
|
|
92
|
-
}
|
|
93
|
-
this.value = value;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getValue(): string {
|
|
97
|
-
return this.value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getType(): PackageType {
|
|
101
|
-
if (this.value.includes('monthly')) return 'monthly';
|
|
102
|
-
if (this.value.includes('annual')) return 'annual';
|
|
103
|
-
if (this.value.includes('lifetime')) return 'lifetime';
|
|
104
|
-
if (this.value.includes('weekly')) return 'weekly';
|
|
105
|
-
return 'single_purchase';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
isSubscription(): boolean {
|
|
109
|
-
const type = this.getType();
|
|
110
|
-
return type === 'monthly' || type === 'annual' || type === 'weekly';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
equals(other: PackageIdentifier): boolean {
|
|
114
|
-
return this.value === other.value;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
toString(): string {
|
|
118
|
-
return this.value;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Usage
|
|
123
|
-
const monthlyPackage = new PackageIdentifier('$rc_monthly');
|
|
124
|
-
console.log(monthlyPackage.getType()); // 'monthly'
|
|
125
|
-
console.log(monthlyPackage.isSubscription()); // true
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### ProductId
|
|
129
|
-
|
|
130
|
-
Represents a product identifier.
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
class ProductId {
|
|
134
|
-
private readonly value: string;
|
|
135
|
-
|
|
136
|
-
constructor(value: string) {
|
|
137
|
-
if (!value || value.trim().length === 0) {
|
|
138
|
-
throw new Error('Product ID cannot be empty');
|
|
139
|
-
}
|
|
140
|
-
this.value = value;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
getValue(): string {
|
|
144
|
-
return this.value;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
equals(other: ProductId): boolean {
|
|
148
|
-
return this.value === other.value;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
toString(): string {
|
|
152
|
-
return this.value;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Usage
|
|
157
|
-
const productId = new ProductId('com.app.premium.monthly');
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Money
|
|
161
|
-
|
|
162
|
-
Represents monetary value with currency.
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
class Money {
|
|
166
|
-
private readonly amount: number;
|
|
167
|
-
private readonly currency: string;
|
|
168
|
-
|
|
169
|
-
constructor(amount: number, currency: string) {
|
|
170
|
-
if (amount < 0) {
|
|
171
|
-
throw new Error('Amount cannot be negative');
|
|
172
|
-
}
|
|
173
|
-
if (currency.length !== 3) {
|
|
174
|
-
throw new Error('Currency must be ISO 4217 code (3 letters)');
|
|
175
|
-
}
|
|
176
|
-
this.amount = amount;
|
|
177
|
-
this.currency = currency.toUpperCase();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
getAmount(): number {
|
|
181
|
-
return this.amount;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
getCurrency(): string {
|
|
185
|
-
return this.currency;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
format(locale: string = 'en-US'): string {
|
|
189
|
-
return new Intl.NumberFormat(locale, {
|
|
190
|
-
style: 'currency',
|
|
191
|
-
currency: this.currency,
|
|
192
|
-
}).format(this.amount);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
add(other: Money): Money {
|
|
196
|
-
if (this.currency !== other.currency) {
|
|
197
|
-
throw new Error('Cannot add different currencies');
|
|
198
|
-
}
|
|
199
|
-
return new Money(this.amount + other.amount, this.currency);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
multiply(factor: number): Money {
|
|
203
|
-
return new Money(this.amount * factor, this.currency);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
equals(other: Money): boolean {
|
|
207
|
-
return this.amount === other.amount && this.currency === other.currency;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
toString(): string {
|
|
211
|
-
return this.format();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Usage
|
|
216
|
-
const price = new Money(9.99, 'USD');
|
|
217
|
-
console.log(price.format()); // '$9.99'
|
|
218
|
-
console.log(price.format('tr-TR')); // '9,99 $'
|
|
219
|
-
|
|
220
|
-
const annualPrice = price.multiply(12);
|
|
221
|
-
console.log(annualPrice.format()); // '$119.88'
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### SubscriptionPeriod
|
|
225
|
-
|
|
226
|
-
Represents a subscription period.
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
class SubscriptionPeriod {
|
|
230
|
-
private readonly value: number;
|
|
231
|
-
private readonly unit: 'day' | 'week' | 'month' | 'year';
|
|
232
|
-
|
|
233
|
-
constructor(value: number, unit: 'day' | 'week' | 'month' | 'year') {
|
|
234
|
-
if (value <= 0) {
|
|
235
|
-
throw new Error('Period value must be positive');
|
|
236
|
-
}
|
|
237
|
-
this.value = value;
|
|
238
|
-
this.unit = unit;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
getValue(): number {
|
|
242
|
-
return this.value;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
getUnit(): string {
|
|
246
|
-
return this.unit;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
inDays(): number {
|
|
250
|
-
switch (this.unit) {
|
|
251
|
-
case 'day': return this.value;
|
|
252
|
-
case 'week': return this.value * 7;
|
|
253
|
-
case 'month': return this.value * 30; // Approximate
|
|
254
|
-
case 'year': return this.value * 365;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
inMonths(): number {
|
|
259
|
-
switch (this.unit) {
|
|
260
|
-
case 'day': return this.value / 30;
|
|
261
|
-
case 'week': return this.value / 4;
|
|
262
|
-
case 'month': return this.value;
|
|
263
|
-
case 'year': return this.value * 12;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
format(locale: string = 'en-US'): string {
|
|
268
|
-
const formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'always' });
|
|
269
|
-
return formatter.format(this.value, this.unit);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
equals(other: SubscriptionPeriod): boolean {
|
|
273
|
-
return this.value === other.value && this.unit === other.unit;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
toString(): string {
|
|
277
|
-
return this.format();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Usage
|
|
282
|
-
const monthly = new SubscriptionPeriod(1, 'month');
|
|
283
|
-
const annual = new SubscriptionPeriod(1, 'year');
|
|
284
|
-
|
|
285
|
-
console.log(monthly.format()); // '1 month'
|
|
286
|
-
console.log(annual.inDays()); // 365
|
|
287
|
-
console.log(annual.inMonths()); // 12
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### PurchaseToken
|
|
291
|
-
|
|
292
|
-
Represents a purchase transaction token.
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
class PurchaseToken {
|
|
296
|
-
private readonly value: string;
|
|
297
|
-
|
|
298
|
-
constructor(value: string) {
|
|
299
|
-
if (!value || value.trim().length === 0) {
|
|
300
|
-
throw new Error('Purchase token cannot be empty');
|
|
301
|
-
}
|
|
302
|
-
this.value = value;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
getValue(): string {
|
|
306
|
-
return this.value;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
equals(other: PurchaseToken): boolean {
|
|
310
|
-
return this.value === other.value;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
toString(): string {
|
|
314
|
-
return this.value;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Mask sensitive parts
|
|
318
|
-
mask(): string {
|
|
319
|
-
if (this.value.length <= 8) {
|
|
320
|
-
return '***';
|
|
321
|
-
}
|
|
322
|
-
const start = this.value.substring(0, 4);
|
|
323
|
-
const end = this.value.substring(this.value.length - 4);
|
|
324
|
-
return `${start}...${end}`;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Usage
|
|
329
|
-
const token = new PurchaseToken('abc123def456ghi789');
|
|
330
|
-
console.log(token.mask()); // 'abc1...i789'
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
## Usage Examples
|
|
334
|
-
|
|
335
|
-
### Creating Value Objects
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
import {
|
|
339
|
-
EntitlementId,
|
|
340
|
-
OfferingId,
|
|
341
|
-
PackageIdentifier,
|
|
342
|
-
Money,
|
|
343
|
-
SubscriptionPeriod,
|
|
344
|
-
} from './value-objects';
|
|
345
|
-
|
|
346
|
-
// Create entitlement ID
|
|
347
|
-
const premiumId = new EntitlementId('premium');
|
|
348
|
-
|
|
349
|
-
// Create offering ID
|
|
350
|
-
const defaultOffering = new OfferingId('default');
|
|
351
|
-
|
|
352
|
-
// Create package identifier
|
|
353
|
-
const monthlyPackage = new PackageIdentifier('$rc_monthly');
|
|
354
|
-
|
|
355
|
-
// Create price
|
|
356
|
-
const price = new Money(9.99, 'USD');
|
|
357
|
-
|
|
358
|
-
// Create subscription period
|
|
359
|
-
const period = new SubscriptionPeriod(1, 'month');
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### Comparing Value Objects
|
|
363
|
-
|
|
364
|
-
```typescript
|
|
365
|
-
const id1 = new EntitlementId('premium');
|
|
366
|
-
const id2 = new EntitlementId('premium');
|
|
367
|
-
const id3 = new EntitlementId('pro');
|
|
368
|
-
|
|
369
|
-
console.log(id1.equals(id2)); // true
|
|
370
|
-
console.log(id1.equals(id3)); // false
|
|
371
|
-
|
|
372
|
-
const price1 = new Money(9.99, 'USD');
|
|
373
|
-
const price2 = new Money(9.99, 'USD');
|
|
374
|
-
const price3 = new Money(19.99, 'USD');
|
|
375
|
-
|
|
376
|
-
console.log(price1.equals(price2)); // true
|
|
377
|
-
console.log(price1.equals(price3)); // false
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
### Performing Operations
|
|
381
|
-
|
|
382
|
-
```typescript
|
|
383
|
-
// Money arithmetic
|
|
384
|
-
const monthlyPrice = new Money(9.99, 'USD');
|
|
385
|
-
const annualPrice = monthlyPrice.multiply(12);
|
|
386
|
-
const withDiscount = annualPrice.multiply(0.8); // 20% off
|
|
387
|
-
|
|
388
|
-
console.log(monthlyPrice.format()); // '$9.99'
|
|
389
|
-
console.log(annualPrice.format()); // '$119.88'
|
|
390
|
-
console.log(withDiscount.format()); // '$95.90'
|
|
391
|
-
|
|
392
|
-
// Period conversions
|
|
393
|
-
const period = new SubscriptionPeriod(1, 'year');
|
|
394
|
-
console.log(period.inDays()); // 365
|
|
395
|
-
console.log(period.inMonths()); // 12
|
|
396
|
-
console.log(period.format('tr-TR')); // '1 yıl'
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### Validation
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
// Valid values
|
|
403
|
-
const validEntitlement = new EntitlementId('premium');
|
|
404
|
-
const validMoney = new Money(10.00, 'USD');
|
|
405
|
-
const validPeriod = new SubscriptionPeriod(1, 'month');
|
|
406
|
-
|
|
407
|
-
// Invalid values (will throw)
|
|
408
|
-
try {
|
|
409
|
-
new EntitlementId(''); // Error: Entitlement ID cannot be empty
|
|
410
|
-
} catch (error) {
|
|
411
|
-
console.error(error.message);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
try {
|
|
415
|
-
new Money(-10, 'USD'); // Error: Amount cannot be negative
|
|
416
|
-
} catch (error) {
|
|
417
|
-
console.error(error.message);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
try {
|
|
421
|
-
new SubscriptionPeriod(0, 'month'); // Error: Period value must be positive
|
|
422
|
-
} catch (error) {
|
|
423
|
-
console.error(error.message);
|
|
424
|
-
}
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
## Best Practices
|
|
428
|
-
|
|
429
|
-
1. **Immutability**: Never modify value objects after creation
|
|
430
|
-
2. **Validation**: Validate in constructor, fail fast
|
|
431
|
-
3. **Equality**: Implement proper equality based on values
|
|
432
|
-
4. **Formatting**: Provide locale-aware formatting
|
|
433
|
-
5. **Operations**: Return new instances for operations
|
|
434
|
-
6. **Type Safety**: Use TypeScript for compile-time checks
|
|
435
|
-
7. **Serialization**: Provide toString/JSON methods if needed
|
|
436
|
-
|
|
437
|
-
## Related
|
|
438
|
-
|
|
6
|
+
## Strategy
|
|
7
|
+
This directory contains value objects - immutable types that represent concepts in the RevenueCat domain with no identity, defined by their attributes rather than identity.
|
|
8
|
+
|
|
9
|
+
## Restrictions
|
|
10
|
+
|
|
11
|
+
### REQUIRED
|
|
12
|
+
- Must validate in constructor
|
|
13
|
+
- Must keep value objects immutable
|
|
14
|
+
- Must implement proper equality based on values
|
|
15
|
+
- Must provide locale-aware formatting
|
|
16
|
+
|
|
17
|
+
### PROHIBITED
|
|
18
|
+
- DO NOT modify value objects after creation
|
|
19
|
+
- DO NOT bypass validation in constructor
|
|
20
|
+
- DO NOT use identity-based equality
|
|
21
|
+
- DO NOT ignore locale in formatting
|
|
22
|
+
|
|
23
|
+
### CRITICAL SAFETY
|
|
24
|
+
- All value objects MUST be immutable
|
|
25
|
+
- Validation MUST happen in constructor
|
|
26
|
+
- Equality MUST be based on values, not identity
|
|
27
|
+
- Formatting MUST be locale-aware
|
|
28
|
+
|
|
29
|
+
## AI Agent Guidelines
|
|
30
|
+
1. Never modify value objects after creation
|
|
31
|
+
2. Validate all inputs in constructor with fail-fast
|
|
32
|
+
3. Implement proper equality based on values
|
|
33
|
+
4. Provide locale-aware formatting methods
|
|
34
|
+
5. Return new instances for all operations
|
|
35
|
+
6. Use TypeScript for compile-time type safety
|
|
36
|
+
7. Provide toString/JSON methods if needed for serialization
|
|
37
|
+
|
|
38
|
+
## Related Documentation
|
|
439
39
|
- [RevenueCat Domain](../README.md)
|
|
440
40
|
- [RevenueCat Entities](../entities/README.md)
|
|
441
41
|
- [RevenueCat Types](../types/README.md)
|
|
@@ -1,50 +1,41 @@
|
|
|
1
1
|
# RevenueCat Infrastructure
|
|
2
2
|
|
|
3
|
+
## Location
|
|
3
4
|
Infrastructure layer for RevenueCat integration.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## Key Responsibilities
|
|
39
|
-
|
|
40
|
-
1. **SDK Integration**: Direct integration with RevenueCat SDK
|
|
41
|
-
2. **Error Handling**: Converting SDK errors to domain errors
|
|
42
|
-
3. **Data Transformation**: Mapping SDK types to domain types
|
|
43
|
-
4. **Event Handling**: Managing purchase and customer info events
|
|
44
|
-
5. **Configuration**: Setting up and configuring RevenueCat
|
|
45
|
-
|
|
46
|
-
## Related
|
|
47
|
-
|
|
6
|
+
## Strategy
|
|
7
|
+
This directory contains concrete implementations of RevenueCat interfaces, handling communication with the RevenueCat SDK and external services with proper error handling and data transformation.
|
|
8
|
+
|
|
9
|
+
## Restrictions
|
|
10
|
+
|
|
11
|
+
### REQUIRED
|
|
12
|
+
- Must integrate directly with RevenueCat SDK
|
|
13
|
+
- Must convert SDK errors to domain errors
|
|
14
|
+
- Must map SDK types to domain types
|
|
15
|
+
- Must manage purchase and customer info events
|
|
16
|
+
|
|
17
|
+
### PROHIBITED
|
|
18
|
+
- DO NOT expose SDK errors directly to application
|
|
19
|
+
- DO NOT use SDK types in domain layer
|
|
20
|
+
- DO NOT skip error mapping
|
|
21
|
+
- DO NOT ignore lifecycle events
|
|
22
|
+
|
|
23
|
+
### CRITICAL SAFETY
|
|
24
|
+
- All SDK errors MUST be converted to domain errors
|
|
25
|
+
- All SDK types MUST be mapped to domain types
|
|
26
|
+
- All events MUST be handled appropriately
|
|
27
|
+
- Configuration MUST be set up correctly
|
|
28
|
+
|
|
29
|
+
## AI Agent Guidelines
|
|
30
|
+
1. Integrate directly with RevenueCat SDK
|
|
31
|
+
2. Convert all SDK errors to domain errors
|
|
32
|
+
3. Map all SDK types to domain types
|
|
33
|
+
4. Manage purchase and customer info events properly
|
|
34
|
+
5. Set up and configure RevenueCat correctly
|
|
35
|
+
6. Test SDK integration thoroughly
|
|
36
|
+
7. Handle all edge cases in SDK communication
|
|
37
|
+
|
|
38
|
+
## Related Documentation
|
|
48
39
|
- [RevenueCat Integration](../README.md)
|
|
49
40
|
- [RevenueCat Application](../application/README.md)
|
|
50
41
|
- [RevenueCat Domain](../domain/README.md)
|
|
@@ -2,39 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
RevenueCat SDK configuration and initialization.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Location
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`src/revenuecat/infrastructure/config/`
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Strategy
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Configuration utilities and setup for the RevenueCat SDK, providing centralized configuration management for the subscription system.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Restrictions
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
interface RevenueCatConfig {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
entitlementId: string;
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
}
|
|
21
|
-
```
|
|
15
|
+
### REQUIRED
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
- MUST configure RevenueCat at app startup
|
|
18
|
+
- MUST use valid API keys from environment configuration
|
|
19
|
+
- MUST initialize before any purchase operations
|
|
20
|
+
- MUST handle configuration errors gracefully
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
### PROHIBITED
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
- MUST NOT expose API keys in source code
|
|
25
|
+
- MUST NOT hardcode configuration values
|
|
26
|
+
- MUST NOT initialize RevenueCat multiple times
|
|
27
|
+
- MUST NOT bypass configuration validation
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
await Purchases.configure({
|
|
32
|
-
apiKey: revenueCatConfig.apiKey,
|
|
33
|
-
appUserID: userId,
|
|
34
|
-
});
|
|
35
|
-
```
|
|
29
|
+
### CRITICAL
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
- Always validate configuration before initialization
|
|
32
|
+
- Never expose sensitive API keys or tokens
|
|
33
|
+
- Handle all configuration errors gracefully
|
|
34
|
+
- Ensure configuration is loaded before any operations
|
|
35
|
+
|
|
36
|
+
## AI Agent Guidelines
|
|
37
|
+
|
|
38
|
+
When working with RevenueCat configuration:
|
|
39
|
+
1. Always validate configuration before use
|
|
40
|
+
2. Never hardcode API keys or secrets
|
|
41
|
+
3. Handle all configuration errors gracefully
|
|
42
|
+
4. Ensure proper initialization order
|
|
43
|
+
5. Test with both valid and invalid configurations
|
|
44
|
+
|
|
45
|
+
## Related Documentation
|
|
38
46
|
|
|
39
47
|
- [Managers](../managers/README.md)
|
|
40
48
|
- [Services](../services/README.md)
|
|
49
|
+
- [RevenueCat README](../../README.md)
|