@tinkerlandai/indiana-react-native 0.0.0-stage → 0.6.3
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 +52 -2
- package/THIRD_PARTY_NOTICES.md +27 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +379 -0
- package/dist/index.d.ts +379 -0
- package/dist/index.js +1 -0
- package/package.json +57 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const scopeSchema: z.ZodObject<{
|
|
4
|
+
projectId: z.ZodString;
|
|
5
|
+
environment: z.ZodEnum<{
|
|
6
|
+
sandbox: "sandbox";
|
|
7
|
+
live: "live";
|
|
8
|
+
}>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
type Scope = z.infer<typeof scopeSchema>;
|
|
11
|
+
|
|
12
|
+
declare const errorRecoverySchema: z.ZodEnum<{
|
|
13
|
+
fix_request: "fix_request";
|
|
14
|
+
authenticate: "authenticate";
|
|
15
|
+
check_permissions: "check_permissions";
|
|
16
|
+
check_scope: "check_scope";
|
|
17
|
+
resolve_conflict: "resolve_conflict";
|
|
18
|
+
reload_state: "reload_state";
|
|
19
|
+
retry_same_request: "retry_same_request";
|
|
20
|
+
configure_integration: "configure_integration";
|
|
21
|
+
check_availability: "check_availability";
|
|
22
|
+
upgrade_sdk: "upgrade_sdk";
|
|
23
|
+
recover_operation: "recover_operation";
|
|
24
|
+
contact_support: "contact_support";
|
|
25
|
+
}>;
|
|
26
|
+
type ErrorRecovery = z.infer<typeof errorRecoverySchema>;
|
|
27
|
+
/** Safe business reasons; never SQL text, resource IDs or provider responses. */
|
|
28
|
+
declare const errorReasonSchema: z.ZodEnum<{
|
|
29
|
+
CAPABILITY_NOT_ENABLED: "CAPABILITY_NOT_ENABLED";
|
|
30
|
+
INTEGRATION_MISSING: "INTEGRATION_MISSING";
|
|
31
|
+
PROVIDER_CREDENTIAL_REJECTED: "PROVIDER_CREDENTIAL_REJECTED";
|
|
32
|
+
PRICE_BINDING_REQUIRED: "PRICE_BINDING_REQUIRED";
|
|
33
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
34
|
+
RESULT_UNKNOWN: "RESULT_UNKNOWN";
|
|
35
|
+
STATE_CHANGED: "STATE_CHANGED";
|
|
36
|
+
OPERATION_IN_PROGRESS: "OPERATION_IN_PROGRESS";
|
|
37
|
+
FUNNEL_VERSION_RETIRED: "FUNNEL_VERSION_RETIRED";
|
|
38
|
+
}>;
|
|
39
|
+
type ErrorReason = z.infer<typeof errorReasonSchema>;
|
|
40
|
+
|
|
41
|
+
declare class IndianaError extends Error {
|
|
42
|
+
readonly code: string;
|
|
43
|
+
readonly status?: number | undefined;
|
|
44
|
+
readonly requestId?: string | undefined;
|
|
45
|
+
readonly retryable: boolean;
|
|
46
|
+
readonly recovery: ErrorRecovery;
|
|
47
|
+
readonly retryAfterSeconds?: number;
|
|
48
|
+
readonly reason?: ErrorReason;
|
|
49
|
+
constructor(code: string, message: string, status?: number | undefined, requestId?: string | undefined, metadata?: {
|
|
50
|
+
retryable?: boolean;
|
|
51
|
+
recovery?: ErrorRecovery;
|
|
52
|
+
retryAfterSeconds?: number;
|
|
53
|
+
reason?: ErrorReason;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const usageCommandSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
58
|
+
eventName: z.ZodString;
|
|
59
|
+
quantity: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
60
|
+
properties: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodTransform<{
|
|
61
|
+
[k: string]: string;
|
|
62
|
+
}, Record<string, string | number | boolean>>>>;
|
|
63
|
+
entityId: z.ZodOptional<z.ZodUUID>;
|
|
64
|
+
idempotencyKey: z.ZodString;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
internal_feature_id: z.ZodUUID;
|
|
67
|
+
quantity: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
68
|
+
properties: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodTransform<{
|
|
69
|
+
[k: string]: string;
|
|
70
|
+
}, Record<string, string | number | boolean>>>>;
|
|
71
|
+
entityId: z.ZodOptional<z.ZodUUID>;
|
|
72
|
+
idempotencyKey: z.ZodString;
|
|
73
|
+
}, z.core.$strict>]>;
|
|
74
|
+
declare const usageResponseSchema: z.ZodObject<{
|
|
75
|
+
requestId: z.ZodUUID;
|
|
76
|
+
scope: z.ZodObject<{
|
|
77
|
+
projectId: z.ZodString;
|
|
78
|
+
environment: z.ZodEnum<{
|
|
79
|
+
sandbox: "sandbox";
|
|
80
|
+
live: "live";
|
|
81
|
+
}>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
receipts: z.ZodArray<z.ZodObject<{
|
|
84
|
+
id: z.ZodUUID;
|
|
85
|
+
internal_feature_id: z.ZodUUID;
|
|
86
|
+
kind: z.ZodEnum<{
|
|
87
|
+
consume: "consume";
|
|
88
|
+
reserve: "reserve";
|
|
89
|
+
confirm: "confirm";
|
|
90
|
+
refund: "refund";
|
|
91
|
+
release: "release";
|
|
92
|
+
expire: "expire";
|
|
93
|
+
}>;
|
|
94
|
+
originalId: z.ZodNullable<z.ZodUUID>;
|
|
95
|
+
quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
96
|
+
requestedQuantity: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
97
|
+
overageBehavior: z.ZodOptional<z.ZodEnum<{
|
|
98
|
+
cap: "cap";
|
|
99
|
+
overflow: "overflow";
|
|
100
|
+
}>>;
|
|
101
|
+
accepted: z.ZodBoolean;
|
|
102
|
+
reason: z.ZodNullable<z.ZodEnum<{
|
|
103
|
+
expired: "expired";
|
|
104
|
+
unavailable: "unavailable";
|
|
105
|
+
insufficient_balance: "insufficient_balance";
|
|
106
|
+
limit_exceeded: "limit_exceeded";
|
|
107
|
+
awaiting_topup: "awaiting_topup";
|
|
108
|
+
authorization_required: "authorization_required";
|
|
109
|
+
payment_blocked: "payment_blocked";
|
|
110
|
+
cash_budget_exceeded: "cash_budget_exceeded";
|
|
111
|
+
}>>;
|
|
112
|
+
createdAt: z.ZodISODateTime;
|
|
113
|
+
reservationStatus: z.ZodNullable<z.ZodEnum<{
|
|
114
|
+
expired: "expired";
|
|
115
|
+
pending: "pending";
|
|
116
|
+
confirmed: "confirmed";
|
|
117
|
+
released: "released";
|
|
118
|
+
}>>;
|
|
119
|
+
expiresAt: z.ZodNullable<z.ZodISODateTime>;
|
|
120
|
+
allocations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
121
|
+
funding: z.ZodLiteral<"balance">;
|
|
122
|
+
sourceId: z.ZodUUID;
|
|
123
|
+
rolloverId: z.ZodNullable<z.ZodUUID>;
|
|
124
|
+
units: z.ZodString;
|
|
125
|
+
amount: z.ZodString;
|
|
126
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
127
|
+
funding: z.ZodLiteral<"unbilled">;
|
|
128
|
+
units: z.ZodString;
|
|
129
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
130
|
+
funding: z.ZodLiteral<"prepaid">;
|
|
131
|
+
sourceId: z.ZodUUID;
|
|
132
|
+
units: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
133
|
+
amount: z.ZodString;
|
|
134
|
+
pricing: z.ZodArray<z.ZodObject<{
|
|
135
|
+
internal_credit_feature_id: z.ZodNullable<z.ZodUUID>;
|
|
136
|
+
internal_metered_feature_id: z.ZodUUID;
|
|
137
|
+
dimension: z.ZodString;
|
|
138
|
+
counterKey: z.ZodString;
|
|
139
|
+
cycleStart: z.ZodISODateTime;
|
|
140
|
+
unitCost: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
141
|
+
units: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
142
|
+
amount: z.ZodString;
|
|
143
|
+
tier: z.ZodNullable<z.ZodNumber>;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
funding: z.ZodLiteral<"postpaid">;
|
|
147
|
+
invoiceLineId: z.ZodNullable<z.ZodUUID>;
|
|
148
|
+
units: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
149
|
+
authorizationId: z.ZodUUID;
|
|
150
|
+
}, z.core.$strict>], "funding">>;
|
|
151
|
+
}, z.core.$strict>>;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
declare const entitlementInputSchema: z.ZodObject<{
|
|
154
|
+
requirement: z.ZodObject<{
|
|
155
|
+
internal_feature_id: z.ZodUUID;
|
|
156
|
+
quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
157
|
+
properties: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodTransform<{
|
|
158
|
+
[k: string]: string;
|
|
159
|
+
}, Record<string, string | number | boolean>>>;
|
|
160
|
+
entityId: z.ZodOptional<z.ZodUUID>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
commerce: z.ZodOptional<z.ZodObject<{
|
|
163
|
+
provider: z.ZodEnum<{
|
|
164
|
+
apple: "apple";
|
|
165
|
+
google: "google";
|
|
166
|
+
stripe: "stripe";
|
|
167
|
+
}>;
|
|
168
|
+
currency: z.ZodEnum<{
|
|
169
|
+
USD: "USD";
|
|
170
|
+
EUR: "EUR";
|
|
171
|
+
CNY: "CNY";
|
|
172
|
+
GBP: "GBP";
|
|
173
|
+
JPY: "JPY";
|
|
174
|
+
CAD: "CAD";
|
|
175
|
+
AUD: "AUD";
|
|
176
|
+
NZD: "NZD";
|
|
177
|
+
CHF: "CHF";
|
|
178
|
+
HKD: "HKD";
|
|
179
|
+
SGD: "SGD";
|
|
180
|
+
KRW: "KRW";
|
|
181
|
+
INR: "INR";
|
|
182
|
+
BRL: "BRL";
|
|
183
|
+
MXN: "MXN";
|
|
184
|
+
TWD: "TWD";
|
|
185
|
+
THB: "THB";
|
|
186
|
+
IDR: "IDR";
|
|
187
|
+
MYR: "MYR";
|
|
188
|
+
PHP: "PHP";
|
|
189
|
+
VND: "VND";
|
|
190
|
+
ZAR: "ZAR";
|
|
191
|
+
AED: "AED";
|
|
192
|
+
SAR: "SAR";
|
|
193
|
+
SEK: "SEK";
|
|
194
|
+
NOK: "NOK";
|
|
195
|
+
DKK: "DKK";
|
|
196
|
+
PLN: "PLN";
|
|
197
|
+
CZK: "CZK";
|
|
198
|
+
HUF: "HUF";
|
|
199
|
+
ILS: "ILS";
|
|
200
|
+
TRY: "TRY";
|
|
201
|
+
RON: "RON";
|
|
202
|
+
}>;
|
|
203
|
+
}, z.core.$strict>>;
|
|
204
|
+
paywallId: z.ZodOptional<z.ZodUUID>;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
type UsageCommand = z.input<typeof usageCommandSchema>;
|
|
207
|
+
interface IndianaReactNativeOptions {
|
|
208
|
+
baseUrl?: string;
|
|
209
|
+
fetch?: typeof globalThis.fetch;
|
|
210
|
+
timeoutMs?: number;
|
|
211
|
+
scope: Scope;
|
|
212
|
+
/** Authenticate the app user on your backend and select its Customer there. No Indiana credential is passed to this callback. */
|
|
213
|
+
usageReporter?: (command: UsageCommand) => Promise<z.output<typeof usageResponseSchema>>;
|
|
214
|
+
}
|
|
215
|
+
/** React Native core APIs. No DOM, WebView, store SDK or server credential is required. */
|
|
216
|
+
declare function createIndianaReactNative(options: IndianaReactNativeOptions): {
|
|
217
|
+
identify(customerToken: string): void;
|
|
218
|
+
reset(): void;
|
|
219
|
+
readHoldings(): Promise<{
|
|
220
|
+
requestId: string;
|
|
221
|
+
scope: {
|
|
222
|
+
projectId: string;
|
|
223
|
+
environment: "sandbox" | "live";
|
|
224
|
+
};
|
|
225
|
+
holdings: {
|
|
226
|
+
customerId: string;
|
|
227
|
+
snapshotAt: string;
|
|
228
|
+
memberships: {
|
|
229
|
+
id: string;
|
|
230
|
+
productId: string;
|
|
231
|
+
productVersionId: string;
|
|
232
|
+
billingProductVersionId: string;
|
|
233
|
+
version: number;
|
|
234
|
+
key: string;
|
|
235
|
+
name: string;
|
|
236
|
+
groupId: string | null;
|
|
237
|
+
membershipType: "main" | "addon";
|
|
238
|
+
status: "active" | "scheduled" | "expired" | "past_due" | "unknown" | "pending" | "trial" | "paused" | "ended" | "trialing";
|
|
239
|
+
cancelAtPeriodEnd: boolean;
|
|
240
|
+
accessEnabled: boolean;
|
|
241
|
+
renewalChange: {
|
|
242
|
+
productVersionId: string;
|
|
243
|
+
name: string;
|
|
244
|
+
version: number;
|
|
245
|
+
effectiveAt: string;
|
|
246
|
+
benefitsAppliedAt: string | null;
|
|
247
|
+
timing: "immediate" | "renewal";
|
|
248
|
+
changeKind: "quantity" | "plan" | "seats";
|
|
249
|
+
seat: {
|
|
250
|
+
key: string;
|
|
251
|
+
fromQuantity: number;
|
|
252
|
+
toQuantity: number;
|
|
253
|
+
} | null;
|
|
254
|
+
status: "scheduled" | "pending" | "prepared" | "confirmed" | "quoted";
|
|
255
|
+
feature?: {
|
|
256
|
+
internal_feature_id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
fromQuantity: number;
|
|
259
|
+
toQuantity: number;
|
|
260
|
+
} | undefined;
|
|
261
|
+
} | null;
|
|
262
|
+
period: {
|
|
263
|
+
phase: "trial" | "paid";
|
|
264
|
+
startsAt: string;
|
|
265
|
+
endsAt: string | null;
|
|
266
|
+
} | null;
|
|
267
|
+
}[];
|
|
268
|
+
membershipsLimited: boolean;
|
|
269
|
+
balances: {
|
|
270
|
+
usageType: "consumable" | "non_consumable" | null;
|
|
271
|
+
accessible: boolean;
|
|
272
|
+
unlimited: boolean;
|
|
273
|
+
available: string;
|
|
274
|
+
held: string;
|
|
275
|
+
debt: string;
|
|
276
|
+
nextExpiresAt: string | null;
|
|
277
|
+
usage: {
|
|
278
|
+
internal_feature_id: string;
|
|
279
|
+
entityId: string | null;
|
|
280
|
+
operationId: string | null;
|
|
281
|
+
usage: string;
|
|
282
|
+
capacity: string | null;
|
|
283
|
+
remaining: string | null;
|
|
284
|
+
withinLimit: boolean;
|
|
285
|
+
revision: number;
|
|
286
|
+
updatedAt: string | null;
|
|
287
|
+
} | null;
|
|
288
|
+
internal_feature_id: string;
|
|
289
|
+
key: string;
|
|
290
|
+
name: string;
|
|
291
|
+
kind: "metered" | "access" | "credit";
|
|
292
|
+
}[];
|
|
293
|
+
balancesLimited: boolean;
|
|
294
|
+
};
|
|
295
|
+
}>;
|
|
296
|
+
checkEntitlement(input: z.input<typeof entitlementInputSchema>): Promise<{
|
|
297
|
+
requestId: string;
|
|
298
|
+
scope: {
|
|
299
|
+
projectId: string;
|
|
300
|
+
environment: "sandbox" | "live";
|
|
301
|
+
};
|
|
302
|
+
check: {
|
|
303
|
+
internal_feature_id: string;
|
|
304
|
+
name: string;
|
|
305
|
+
kind: "metered" | "access" | "credit";
|
|
306
|
+
quantity: string;
|
|
307
|
+
allowed: boolean;
|
|
308
|
+
reason: "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | "not_entitled" | "capacity_exceeded" | "authentication_required" | null;
|
|
309
|
+
preview: {
|
|
310
|
+
scenario: "usage_limit" | "feature_flag";
|
|
311
|
+
candidates: {
|
|
312
|
+
productId: string;
|
|
313
|
+
productVersionId: string;
|
|
314
|
+
name: string;
|
|
315
|
+
action: "upgrade" | "purchase" | "addon" | "topup";
|
|
316
|
+
membershipId: string | null;
|
|
317
|
+
currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
|
|
318
|
+
amountMinor: string;
|
|
319
|
+
interval: "week" | "month" | "year" | "free" | "one_time";
|
|
320
|
+
intervalCount: number;
|
|
321
|
+
}[];
|
|
322
|
+
} | null;
|
|
323
|
+
};
|
|
324
|
+
}>;
|
|
325
|
+
trackUsage(command: UsageCommand): Promise<{
|
|
326
|
+
requestId: string;
|
|
327
|
+
scope: {
|
|
328
|
+
projectId: string;
|
|
329
|
+
environment: "sandbox" | "live";
|
|
330
|
+
};
|
|
331
|
+
receipts: {
|
|
332
|
+
id: string;
|
|
333
|
+
internal_feature_id: string;
|
|
334
|
+
kind: "consume" | "reserve" | "confirm" | "refund" | "release" | "expire";
|
|
335
|
+
originalId: string | null;
|
|
336
|
+
quantity: string;
|
|
337
|
+
accepted: boolean;
|
|
338
|
+
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
339
|
+
createdAt: string;
|
|
340
|
+
reservationStatus: "expired" | "pending" | "confirmed" | "released" | null;
|
|
341
|
+
expiresAt: string | null;
|
|
342
|
+
allocations: ({
|
|
343
|
+
funding: "prepaid";
|
|
344
|
+
sourceId: string;
|
|
345
|
+
units: string;
|
|
346
|
+
amount: string;
|
|
347
|
+
pricing: {
|
|
348
|
+
internal_credit_feature_id: string | null;
|
|
349
|
+
internal_metered_feature_id: string;
|
|
350
|
+
dimension: string;
|
|
351
|
+
counterKey: string;
|
|
352
|
+
cycleStart: string;
|
|
353
|
+
unitCost: string;
|
|
354
|
+
units: string;
|
|
355
|
+
amount: string;
|
|
356
|
+
tier: number | null;
|
|
357
|
+
}[];
|
|
358
|
+
} | {
|
|
359
|
+
funding: "balance";
|
|
360
|
+
sourceId: string;
|
|
361
|
+
rolloverId: string | null;
|
|
362
|
+
units: string;
|
|
363
|
+
amount: string;
|
|
364
|
+
} | {
|
|
365
|
+
funding: "unbilled";
|
|
366
|
+
units: string;
|
|
367
|
+
} | {
|
|
368
|
+
funding: "postpaid";
|
|
369
|
+
invoiceLineId: string | null;
|
|
370
|
+
units: string;
|
|
371
|
+
authorizationId: string;
|
|
372
|
+
})[];
|
|
373
|
+
requestedQuantity?: string | undefined;
|
|
374
|
+
overageBehavior?: "cap" | "overflow" | undefined;
|
|
375
|
+
}[];
|
|
376
|
+
}>;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export { IndianaError, type IndianaReactNativeOptions, type UsageCommand, createIndianaReactNative };
|