@umituz/react-native-subscription 2.14.97 → 2.14.99
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/LICENSE +21 -0
- package/README.md +461 -0
- package/package.json +1 -3
- package/src/application/README.md +229 -0
- package/src/application/ports/README.md +103 -0
- package/src/domain/README.md +402 -0
- package/src/domain/constants/README.md +80 -0
- package/src/domain/entities/README.md +176 -0
- package/src/domain/errors/README.md +307 -0
- package/src/domain/value-objects/README.md +186 -0
- package/src/domains/README.md +240 -0
- package/src/domains/config/README.md +390 -0
- package/src/domains/config/domain/README.md +390 -0
- package/src/domains/config/domain/entities/README.md +350 -0
- package/src/domains/paywall/README.md +371 -0
- package/src/domains/paywall/components/PaywallHeader.tsx +8 -11
- package/src/domains/paywall/components/README.md +185 -0
- package/src/domains/paywall/entities/README.md +199 -0
- package/src/domains/paywall/hooks/README.md +129 -0
- package/src/domains/wallet/README.md +292 -0
- package/src/domains/wallet/domain/README.md +108 -0
- package/src/domains/wallet/domain/entities/README.md +122 -0
- package/src/domains/wallet/domain/errors/README.md +157 -0
- package/src/domains/wallet/infrastructure/README.md +96 -0
- package/src/domains/wallet/presentation/components/BalanceCard.tsx +6 -12
- package/src/domains/wallet/presentation/components/README.md +231 -0
- package/src/domains/wallet/presentation/hooks/README.md +255 -0
- package/src/infrastructure/README.md +514 -0
- package/src/infrastructure/mappers/README.md +34 -0
- package/src/infrastructure/models/README.md +26 -0
- package/src/infrastructure/repositories/README.md +385 -0
- package/src/infrastructure/services/README.md +374 -0
- package/src/presentation/README.md +410 -0
- package/src/presentation/components/README.md +183 -0
- package/src/presentation/components/details/CreditRow.md +337 -0
- package/src/presentation/components/details/DetailRow.md +283 -0
- package/src/presentation/components/details/PremiumDetailsCard.md +266 -0
- package/src/presentation/components/details/PremiumStatusBadge.md +266 -0
- package/src/presentation/components/details/README.md +449 -0
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +314 -0
- package/src/presentation/components/feedback/README.md +447 -0
- package/src/presentation/components/paywall/PaywallModal.md +444 -0
- package/src/presentation/components/paywall/README.md +190 -0
- package/src/presentation/components/sections/README.md +468 -0
- package/src/presentation/components/sections/SubscriptionSection.md +246 -0
- package/src/presentation/hooks/README.md +743 -0
- package/src/presentation/hooks/useAuthAwarePurchase.md +359 -0
- package/src/presentation/hooks/useAuthGate.md +403 -0
- package/src/presentation/hooks/useAuthSubscriptionSync.md +398 -0
- package/src/presentation/hooks/useCreditChecker.md +407 -0
- package/src/presentation/hooks/useCredits.md +342 -0
- package/src/presentation/hooks/useCreditsGate.md +346 -0
- package/src/presentation/hooks/useDeductCredit.md +176 -0
- package/src/presentation/hooks/useDevTestCallbacks.md +422 -0
- package/src/presentation/hooks/useFeatureGate.md +157 -0
- package/src/presentation/hooks/useInitializeCredits.md +458 -0
- package/src/presentation/hooks/usePaywall.md +334 -0
- package/src/presentation/hooks/usePaywallOperations.md +486 -0
- package/src/presentation/hooks/usePaywallVisibility.md +344 -0
- package/src/presentation/hooks/usePremium.md +230 -0
- package/src/presentation/hooks/usePremiumGate.md +423 -0
- package/src/presentation/hooks/usePremiumWithCredits.md +429 -0
- package/src/presentation/hooks/useSubscription.md +450 -0
- package/src/presentation/hooks/useSubscriptionDetails.md +438 -0
- package/src/presentation/hooks/useSubscriptionGate.md +168 -0
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +374 -0
- package/src/presentation/hooks/useSubscriptionStatus.md +424 -0
- package/src/presentation/hooks/useUserTier.md +356 -0
- package/src/presentation/hooks/useUserTierWithRepository.md +452 -0
- package/src/presentation/screens/README.md +194 -0
- package/src/presentation/types/README.md +38 -0
- package/src/presentation/utils/README.md +52 -0
- package/src/revenuecat/README.md +523 -0
- package/src/revenuecat/application/README.md +158 -0
- package/src/revenuecat/application/ports/README.md +169 -0
- package/src/revenuecat/domain/README.md +147 -0
- package/src/revenuecat/domain/constants/README.md +183 -0
- package/src/revenuecat/domain/entities/README.md +382 -0
- package/src/revenuecat/domain/errors/README.md +197 -0
- package/src/revenuecat/domain/types/README.md +373 -0
- package/src/revenuecat/domain/value-objects/README.md +441 -0
- package/src/revenuecat/infrastructure/README.md +50 -0
- package/src/revenuecat/infrastructure/config/README.md +40 -0
- package/src/revenuecat/infrastructure/handlers/README.md +218 -0
- package/src/revenuecat/infrastructure/managers/README.md +49 -0
- package/src/revenuecat/infrastructure/services/README.md +325 -0
- package/src/revenuecat/infrastructure/utils/README.md +382 -0
- package/src/revenuecat/presentation/README.md +184 -0
- package/src/revenuecat/presentation/hooks/README.md +56 -0
- package/src/utils/README.md +529 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
# RevenueCat Domain Value Objects
|
|
2
|
+
|
|
3
|
+
Value objects for RevenueCat integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This directory contains value objects - immutable types that represent concepts in the RevenueCat domain with no identity. Value objects are defined by their attributes rather than an identity.
|
|
8
|
+
|
|
9
|
+
## Value Objects
|
|
10
|
+
|
|
11
|
+
### EntitlementId
|
|
12
|
+
|
|
13
|
+
Represents an entitlement identifier.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
class EntitlementId {
|
|
17
|
+
private readonly value: string;
|
|
18
|
+
|
|
19
|
+
constructor(value: string) {
|
|
20
|
+
if (!value || value.trim().length === 0) {
|
|
21
|
+
throw new Error('Entitlement ID cannot be empty');
|
|
22
|
+
}
|
|
23
|
+
this.value = value.trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getValue(): string {
|
|
27
|
+
return this.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
equals(other: EntitlementId): boolean {
|
|
31
|
+
return this.value === other.value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
toString(): string {
|
|
35
|
+
return this.value;
|
|
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
|
+
|
|
439
|
+
- [RevenueCat Domain](../README.md)
|
|
440
|
+
- [RevenueCat Entities](../entities/README.md)
|
|
441
|
+
- [RevenueCat Types](../types/README.md)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# RevenueCat Infrastructure
|
|
2
|
+
|
|
3
|
+
Infrastructure layer for RevenueCat integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This directory contains concrete implementations of RevenueCat interfaces, handling communication with the RevenueCat SDK and external services.
|
|
8
|
+
|
|
9
|
+
## Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
infrastructure/
|
|
13
|
+
├── handlers/ # Event handlers and callbacks
|
|
14
|
+
├── services/ # Service implementations
|
|
15
|
+
└── utils/ # Utility functions
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Components
|
|
19
|
+
|
|
20
|
+
### Handlers
|
|
21
|
+
|
|
22
|
+
Event handlers for RevenueCat lifecycle events.
|
|
23
|
+
|
|
24
|
+
**See**: [Handlers README](./handlers/README.md)
|
|
25
|
+
|
|
26
|
+
### Services
|
|
27
|
+
|
|
28
|
+
Service implementations for RevenueCat operations.
|
|
29
|
+
|
|
30
|
+
**See**: [Services README](./services/README.md)
|
|
31
|
+
|
|
32
|
+
### Utils
|
|
33
|
+
|
|
34
|
+
Utility functions for common operations.
|
|
35
|
+
|
|
36
|
+
**See**: [Utils README](./utils/README.md)
|
|
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
|
+
|
|
48
|
+
- [RevenueCat Integration](../README.md)
|
|
49
|
+
- [RevenueCat Application](../application/README.md)
|
|
50
|
+
- [RevenueCat Domain](../domain/README.md)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# RevenueCat Infrastructure Config
|
|
2
|
+
|
|
3
|
+
RevenueCat SDK configuration and initialization.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This directory contains configuration utilities and setup for the RevenueCat SDK.
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- **revenueCatConfig.ts** - RevenueCat configuration object and setup
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
interface RevenueCatConfig {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
entitlementId: string;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Configure RevenueCat at app startup:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { revenueCatConfig } from './config/revenueCatConfig';
|
|
29
|
+
|
|
30
|
+
// In your app initializer
|
|
31
|
+
await Purchases.configure({
|
|
32
|
+
apiKey: revenueCatConfig.apiKey,
|
|
33
|
+
appUserID: userId,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Related
|
|
38
|
+
|
|
39
|
+
- [Managers](../managers/README.md)
|
|
40
|
+
- [Services](../services/README.md)
|