@lumnsh/node 0.1.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.
- package/dist/index.d.mts +448 -0
- package/dist/index.d.ts +448 -0
- package/dist/index.js +436 -0
- package/dist/index.mjs +400 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
interface PaginationParams {
|
|
2
|
+
cursor?: string;
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
interface PaginatedList<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
hasMore: boolean;
|
|
8
|
+
cursor: string | null;
|
|
9
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
10
|
+
}
|
|
11
|
+
interface LumnApiErrorBody {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
suggestion?: string;
|
|
15
|
+
details?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare abstract class ApiResource {
|
|
19
|
+
protected readonly _client: Lumn;
|
|
20
|
+
constructor(_client: Lumn);
|
|
21
|
+
protected get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
22
|
+
protected post<T>(path: string, body?: unknown): Promise<T>;
|
|
23
|
+
protected del<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
24
|
+
protected _list<T>(path: string, params?: object): Promise<PaginatedList<T>>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface Customer {
|
|
28
|
+
id: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
environment: 'development' | 'production';
|
|
31
|
+
externalId: string;
|
|
32
|
+
email: string | null;
|
|
33
|
+
name: string | null;
|
|
34
|
+
providerCustomerId: string | null;
|
|
35
|
+
connectionId: string | null;
|
|
36
|
+
lastSyncedAt: string | null;
|
|
37
|
+
metadata: Record<string, unknown> | null;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface CustomerCreateParams {
|
|
42
|
+
external_id: string;
|
|
43
|
+
email?: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
}
|
|
46
|
+
interface CustomerListParams extends PaginationParams {
|
|
47
|
+
search?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class Customers extends ApiResource {
|
|
51
|
+
create(params: CustomerCreateParams): Promise<Customer>;
|
|
52
|
+
list(params?: CustomerListParams): Promise<PaginatedList<Customer>>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface ProductPricing {
|
|
56
|
+
monthly?: {
|
|
57
|
+
amount: number;
|
|
58
|
+
currency: string;
|
|
59
|
+
discount?: number;
|
|
60
|
+
};
|
|
61
|
+
quarterly?: {
|
|
62
|
+
amount: number;
|
|
63
|
+
currency: string;
|
|
64
|
+
discount?: number;
|
|
65
|
+
};
|
|
66
|
+
yearly?: {
|
|
67
|
+
amount: number;
|
|
68
|
+
currency: string;
|
|
69
|
+
discount?: number;
|
|
70
|
+
};
|
|
71
|
+
trial?: {
|
|
72
|
+
days: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
interface Product {
|
|
76
|
+
id: string;
|
|
77
|
+
projectId: string;
|
|
78
|
+
environment: 'development' | 'production';
|
|
79
|
+
name: string;
|
|
80
|
+
slug: string;
|
|
81
|
+
description: string | null;
|
|
82
|
+
active: boolean;
|
|
83
|
+
pricing: ProductPricing | null;
|
|
84
|
+
providerProductId: string | null;
|
|
85
|
+
providerPriceIds: Record<string, string> | null;
|
|
86
|
+
metadata: Record<string, unknown> | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
}
|
|
90
|
+
interface ProductCreateParams {
|
|
91
|
+
slug: string;
|
|
92
|
+
name: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
pricing?: ProductPricing;
|
|
95
|
+
active?: boolean;
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
type ProductListParams = PaginationParams;
|
|
99
|
+
|
|
100
|
+
declare class Products extends ApiResource {
|
|
101
|
+
create(params: ProductCreateParams): Promise<Product>;
|
|
102
|
+
list(params?: ProductListParams): Promise<PaginatedList<Product>>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type FeatureType = 'boolean' | 'limit' | 'metered';
|
|
106
|
+
interface Feature {
|
|
107
|
+
id: string;
|
|
108
|
+
projectId: string;
|
|
109
|
+
environment: 'development' | 'production';
|
|
110
|
+
key: string;
|
|
111
|
+
name: string;
|
|
112
|
+
description: string | null;
|
|
113
|
+
type: FeatureType;
|
|
114
|
+
metadata: Record<string, unknown> | null;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
updatedAt: string;
|
|
117
|
+
}
|
|
118
|
+
interface FeatureCreateParams {
|
|
119
|
+
key: string;
|
|
120
|
+
name: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
type: FeatureType;
|
|
123
|
+
}
|
|
124
|
+
type FeatureListParams = PaginationParams;
|
|
125
|
+
|
|
126
|
+
declare class Features extends ApiResource {
|
|
127
|
+
create(params: FeatureCreateParams): Promise<Feature>;
|
|
128
|
+
list(params?: FeatureListParams): Promise<PaginatedList<Feature>>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface EntitlementCheck {
|
|
132
|
+
entitled: boolean;
|
|
133
|
+
feature_key: string;
|
|
134
|
+
reason?: string;
|
|
135
|
+
feature_type?: FeatureType;
|
|
136
|
+
limit?: number | null;
|
|
137
|
+
unit_price_cents?: number | null;
|
|
138
|
+
}
|
|
139
|
+
interface EntitlementCheckParams {
|
|
140
|
+
customer_id: string;
|
|
141
|
+
feature_key: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare class Entitlements extends ApiResource {
|
|
145
|
+
check(params: EntitlementCheckParams): Promise<EntitlementCheck>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type PaymentStatus = 'pending' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'refunded';
|
|
149
|
+
interface Payment {
|
|
150
|
+
id: string;
|
|
151
|
+
projectId: string;
|
|
152
|
+
customerId: string | null;
|
|
153
|
+
subscriptionId: string | null;
|
|
154
|
+
providerPaymentId: string | null;
|
|
155
|
+
providerInvoiceId: string | null;
|
|
156
|
+
amount: number;
|
|
157
|
+
currency: string;
|
|
158
|
+
amountRefunded: number;
|
|
159
|
+
status: PaymentStatus;
|
|
160
|
+
failureCode: string | null;
|
|
161
|
+
failureMessage: string | null;
|
|
162
|
+
idempotencyKey: string | null;
|
|
163
|
+
metadata: Record<string, unknown> | null;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
succeededAt: string | null;
|
|
166
|
+
failedAt: string | null;
|
|
167
|
+
}
|
|
168
|
+
interface PaymentListParams extends PaginationParams {
|
|
169
|
+
customer_id?: string;
|
|
170
|
+
status?: PaymentStatus;
|
|
171
|
+
from?: string;
|
|
172
|
+
to?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare class Payments extends ApiResource {
|
|
176
|
+
list(params?: PaymentListParams): Promise<PaginatedList<Payment>>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type SubscriptionStatus = 'active' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'past_due' | 'paused' | 'trialing' | 'unpaid';
|
|
180
|
+
interface Subscription {
|
|
181
|
+
id: string;
|
|
182
|
+
projectId: string;
|
|
183
|
+
customerId: string;
|
|
184
|
+
providerSubscriptionId: string | null;
|
|
185
|
+
providerCustomerId: string | null;
|
|
186
|
+
status: SubscriptionStatus;
|
|
187
|
+
currentPeriodStart: string | null;
|
|
188
|
+
currentPeriodEnd: string | null;
|
|
189
|
+
cancelAtPeriodEnd: boolean;
|
|
190
|
+
canceledAt: string | null;
|
|
191
|
+
trialEnd: string | null;
|
|
192
|
+
syncedData: Record<string, unknown> | null;
|
|
193
|
+
lastSyncedAt: string | null;
|
|
194
|
+
metadata: Record<string, unknown> | null;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
}
|
|
198
|
+
interface SubscriptionListParams extends PaginationParams {
|
|
199
|
+
customer_id?: string;
|
|
200
|
+
status?: SubscriptionStatus;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare class Subscriptions extends ApiResource {
|
|
204
|
+
list(params?: SubscriptionListParams): Promise<PaginatedList<Subscription>>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type EventStatus = 'pending' | 'processing' | 'processed' | 'failed' | 'skipped';
|
|
208
|
+
interface LumnEvent {
|
|
209
|
+
id: string;
|
|
210
|
+
providerEventId: string;
|
|
211
|
+
eventType: string;
|
|
212
|
+
objectType: string | null;
|
|
213
|
+
objectId: string | null;
|
|
214
|
+
status: EventStatus;
|
|
215
|
+
retryCount: number;
|
|
216
|
+
processingError: string | null;
|
|
217
|
+
processedAt: string | null;
|
|
218
|
+
createdAt: string;
|
|
219
|
+
}
|
|
220
|
+
interface EventListParams extends PaginationParams {
|
|
221
|
+
type?: string;
|
|
222
|
+
status?: EventStatus;
|
|
223
|
+
from?: string;
|
|
224
|
+
to?: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare class Events extends ApiResource {
|
|
228
|
+
list(params?: EventListParams): Promise<PaginatedList<LumnEvent>>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface MeterEvent {
|
|
232
|
+
id: string;
|
|
233
|
+
customer_id: string;
|
|
234
|
+
feature_key: string;
|
|
235
|
+
value: number;
|
|
236
|
+
idempotency_key: string;
|
|
237
|
+
cached: boolean;
|
|
238
|
+
timestamp: string;
|
|
239
|
+
created_at: string;
|
|
240
|
+
}
|
|
241
|
+
interface MeterRecordParams {
|
|
242
|
+
customer_id: string;
|
|
243
|
+
feature_key: string;
|
|
244
|
+
value?: number;
|
|
245
|
+
idempotency_key: string;
|
|
246
|
+
timestamp?: string;
|
|
247
|
+
properties?: Record<string, unknown>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
declare class Meter extends ApiResource {
|
|
251
|
+
record(params: MeterRecordParams): Promise<MeterEvent>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface SyncResult {
|
|
255
|
+
customer_id: string;
|
|
256
|
+
status: 'completed';
|
|
257
|
+
synced_at: string;
|
|
258
|
+
changes: {
|
|
259
|
+
subscriptions: number;
|
|
260
|
+
payments: number;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
interface SyncTriggerParams {
|
|
264
|
+
customer_id: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare class Sync extends ApiResource {
|
|
268
|
+
trigger(params: SyncTriggerParams): Promise<SyncResult>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
type Provider = 'stripe' | 'paypal' | 'paddle' | 'airwallex' | 'lemonsqueezy' | 'polar';
|
|
272
|
+
interface ConnectionCapabilities {
|
|
273
|
+
payments: boolean;
|
|
274
|
+
subscriptions: boolean;
|
|
275
|
+
invoices: boolean;
|
|
276
|
+
usageBilling: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface Connection {
|
|
279
|
+
id: string;
|
|
280
|
+
provider: Provider;
|
|
281
|
+
environment: 'development' | 'staging' | 'production';
|
|
282
|
+
status: 'pending' | 'active' | 'error' | 'disconnected';
|
|
283
|
+
capabilities: ConnectionCapabilities | null;
|
|
284
|
+
lastHealthCheck: string | null;
|
|
285
|
+
healthCheckError: string | null;
|
|
286
|
+
createdAt: string;
|
|
287
|
+
}
|
|
288
|
+
interface ConnectionCreateParams {
|
|
289
|
+
provider: Provider;
|
|
290
|
+
api_key: string;
|
|
291
|
+
publishable_key?: string;
|
|
292
|
+
webhook_secret?: string;
|
|
293
|
+
environment?: 'development' | 'staging' | 'production';
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
declare class Connections extends ApiResource {
|
|
297
|
+
create(params: ConnectionCreateParams): Promise<Connection>;
|
|
298
|
+
list(): Promise<Connection[]>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface ApiKey {
|
|
302
|
+
id: string;
|
|
303
|
+
name: string;
|
|
304
|
+
environment: 'development' | 'staging' | 'production';
|
|
305
|
+
keyPrefix: string;
|
|
306
|
+
scopes: string[] | null;
|
|
307
|
+
lastUsedAt: string | null;
|
|
308
|
+
expiresAt: string | null;
|
|
309
|
+
createdAt: string;
|
|
310
|
+
}
|
|
311
|
+
interface ApiKeyWithSecret extends ApiKey {
|
|
312
|
+
key: string;
|
|
313
|
+
}
|
|
314
|
+
interface ApiKeyCreateParams {
|
|
315
|
+
name: string;
|
|
316
|
+
environment?: 'development' | 'staging' | 'production';
|
|
317
|
+
scopes?: string[];
|
|
318
|
+
expires_in_days?: number;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare class ApiKeys extends ApiResource {
|
|
322
|
+
create(params: ApiKeyCreateParams): Promise<ApiKeyWithSecret>;
|
|
323
|
+
list(): Promise<ApiKey[]>;
|
|
324
|
+
revoke(id: string): Promise<{
|
|
325
|
+
id: string;
|
|
326
|
+
revoked: boolean;
|
|
327
|
+
}>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface CopyConfigParams {
|
|
331
|
+
from: 'development' | 'production';
|
|
332
|
+
to: 'development' | 'production';
|
|
333
|
+
}
|
|
334
|
+
interface CopyConfigResult {
|
|
335
|
+
products_copied: number;
|
|
336
|
+
features_copied: number;
|
|
337
|
+
product_features_copied: number;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class CopyConfig extends ApiResource {
|
|
341
|
+
copy(params: CopyConfigParams): Promise<CopyConfigResult>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface CheckoutSession {
|
|
345
|
+
checkout_url: string;
|
|
346
|
+
session_id: string;
|
|
347
|
+
publishable_key: string | null;
|
|
348
|
+
}
|
|
349
|
+
interface CheckoutCreateParams {
|
|
350
|
+
customer_id: string;
|
|
351
|
+
product_slug: string;
|
|
352
|
+
price_interval: 'monthly' | 'quarterly' | 'yearly';
|
|
353
|
+
success_url: string;
|
|
354
|
+
cancel_url: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
declare class Checkout extends ApiResource {
|
|
358
|
+
create(params: CheckoutCreateParams): Promise<CheckoutSession>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface LumnConfig {
|
|
362
|
+
apiKey: string;
|
|
363
|
+
baseUrl?: string;
|
|
364
|
+
timeout?: number;
|
|
365
|
+
maxRetries?: number;
|
|
366
|
+
fetch?: typeof globalThis.fetch;
|
|
367
|
+
}
|
|
368
|
+
declare class Lumn {
|
|
369
|
+
private readonly _apiKey;
|
|
370
|
+
private readonly _baseUrl;
|
|
371
|
+
private readonly _timeout;
|
|
372
|
+
private readonly _maxRetries;
|
|
373
|
+
private readonly _fetch;
|
|
374
|
+
readonly customers: Customers;
|
|
375
|
+
readonly products: Products;
|
|
376
|
+
readonly features: Features;
|
|
377
|
+
readonly entitlements: Entitlements;
|
|
378
|
+
readonly payments: Payments;
|
|
379
|
+
readonly subscriptions: Subscriptions;
|
|
380
|
+
readonly events: Events;
|
|
381
|
+
readonly meter: Meter;
|
|
382
|
+
readonly sync: Sync;
|
|
383
|
+
readonly connections: Connections;
|
|
384
|
+
readonly apiKeys: ApiKeys;
|
|
385
|
+
readonly copyConfig: CopyConfig;
|
|
386
|
+
readonly checkout: Checkout;
|
|
387
|
+
constructor(config: string | LumnConfig | undefined);
|
|
388
|
+
/** @internal */
|
|
389
|
+
_request<T>(method: string, path: string, body?: unknown, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
390
|
+
private _buildUrl;
|
|
391
|
+
private _throwTypedError;
|
|
392
|
+
private _sleep;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
declare class LumnError extends Error {
|
|
396
|
+
constructor(message: string);
|
|
397
|
+
}
|
|
398
|
+
declare class LumnApiError extends LumnError {
|
|
399
|
+
readonly status: number;
|
|
400
|
+
readonly code: string;
|
|
401
|
+
readonly suggestion?: string;
|
|
402
|
+
readonly details?: Record<string, unknown>;
|
|
403
|
+
constructor(status: number, body: {
|
|
404
|
+
code: string;
|
|
405
|
+
message: string;
|
|
406
|
+
suggestion?: string;
|
|
407
|
+
details?: Record<string, unknown>;
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
declare class LumnAuthenticationError extends LumnApiError {
|
|
411
|
+
constructor(body: {
|
|
412
|
+
code: string;
|
|
413
|
+
message: string;
|
|
414
|
+
suggestion?: string;
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
declare class LumnValidationError extends LumnApiError {
|
|
418
|
+
constructor(body: {
|
|
419
|
+
code: string;
|
|
420
|
+
message: string;
|
|
421
|
+
suggestion?: string;
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
declare class LumnNotFoundError extends LumnApiError {
|
|
425
|
+
constructor(body: {
|
|
426
|
+
code: string;
|
|
427
|
+
message: string;
|
|
428
|
+
suggestion?: string;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
declare class LumnRateLimitError extends LumnApiError {
|
|
432
|
+
readonly retryAfter: number | null;
|
|
433
|
+
constructor(body: {
|
|
434
|
+
code: string;
|
|
435
|
+
message: string;
|
|
436
|
+
}, retryAfter: number | null);
|
|
437
|
+
}
|
|
438
|
+
declare class LumnConnectionError extends LumnError {
|
|
439
|
+
readonly cause?: Error | undefined;
|
|
440
|
+
constructor(message: string, cause?: Error | undefined);
|
|
441
|
+
}
|
|
442
|
+
declare class LumnTimeoutError extends LumnError {
|
|
443
|
+
constructor(timeoutMs: number);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
declare const SDK_VERSION = "0.1.0";
|
|
447
|
+
|
|
448
|
+
export { type ApiKey, type ApiKeyCreateParams, type ApiKeyWithSecret, type CheckoutCreateParams, type CheckoutSession, type Connection, type ConnectionCapabilities, type ConnectionCreateParams, type CopyConfigParams, type CopyConfigResult, type Customer, type CustomerCreateParams, type CustomerListParams, type EntitlementCheck, type EntitlementCheckParams, type EventListParams, type EventStatus, type Feature, type FeatureCreateParams, type FeatureListParams, type FeatureType, Lumn, LumnApiError, type LumnApiErrorBody, LumnAuthenticationError, type LumnConfig, LumnConnectionError, LumnError, type LumnEvent, LumnNotFoundError, LumnRateLimitError, LumnTimeoutError, LumnValidationError, type MeterEvent, type MeterRecordParams, type PaginatedList, type PaginationParams, type Payment, type PaymentListParams, type PaymentStatus, type Product, type ProductCreateParams, type ProductListParams, type ProductPricing, type Provider, SDK_VERSION, type Subscription, type SubscriptionListParams, type SubscriptionStatus, type SyncResult, type SyncTriggerParams, Lumn as default };
|