@dream-api/sdk 0.1.2 → 0.1.4
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 +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +25 -0
- package/dist/index.mjs +25 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -57,7 +57,7 @@ interface Tier {
|
|
|
57
57
|
limit: number;
|
|
58
58
|
priceId: string;
|
|
59
59
|
productId: string;
|
|
60
|
-
features?: string;
|
|
60
|
+
features?: string[];
|
|
61
61
|
popular?: boolean;
|
|
62
62
|
}
|
|
63
63
|
interface Product {
|
|
@@ -363,6 +363,8 @@ declare class DreamAPI {
|
|
|
363
363
|
readonly products: ProductAPI;
|
|
364
364
|
/** Dashboard metrics */
|
|
365
365
|
readonly dashboard: DashboardAPI;
|
|
366
|
+
/** Account management (self-service) */
|
|
367
|
+
readonly account: AccountAPI;
|
|
366
368
|
constructor(config: DreamAPIConfig);
|
|
367
369
|
/**
|
|
368
370
|
* Set the end-user JWT token.
|
|
@@ -549,5 +551,23 @@ declare class DashboardAPI {
|
|
|
549
551
|
totalMRR: number;
|
|
550
552
|
}>;
|
|
551
553
|
}
|
|
554
|
+
declare class AccountAPI {
|
|
555
|
+
private client;
|
|
556
|
+
constructor(client: DreamClient);
|
|
557
|
+
/**
|
|
558
|
+
* Delete the current user's account.
|
|
559
|
+
* This permanently removes all user data.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```typescript
|
|
563
|
+
* await api.account.delete();
|
|
564
|
+
* // User is now signed out and deleted
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
delete(): Promise<{
|
|
568
|
+
success: boolean;
|
|
569
|
+
message: string;
|
|
570
|
+
}>;
|
|
571
|
+
}
|
|
552
572
|
|
|
553
573
|
export { type CheckoutResult, type ClerkUser, type CreateCustomerParams, type Customer, type DashboardCustomer, type DashboardMetrics, DreamAPI, type DreamAPIConfig, type DreamAPIError, DreamAPIException, type Order, type PortalResult, type Product, type Tier, type Usage, type UsageTrackResult, type WebhookStatus, DreamAPI as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ interface Tier {
|
|
|
57
57
|
limit: number;
|
|
58
58
|
priceId: string;
|
|
59
59
|
productId: string;
|
|
60
|
-
features?: string;
|
|
60
|
+
features?: string[];
|
|
61
61
|
popular?: boolean;
|
|
62
62
|
}
|
|
63
63
|
interface Product {
|
|
@@ -363,6 +363,8 @@ declare class DreamAPI {
|
|
|
363
363
|
readonly products: ProductAPI;
|
|
364
364
|
/** Dashboard metrics */
|
|
365
365
|
readonly dashboard: DashboardAPI;
|
|
366
|
+
/** Account management (self-service) */
|
|
367
|
+
readonly account: AccountAPI;
|
|
366
368
|
constructor(config: DreamAPIConfig);
|
|
367
369
|
/**
|
|
368
370
|
* Set the end-user JWT token.
|
|
@@ -549,5 +551,23 @@ declare class DashboardAPI {
|
|
|
549
551
|
totalMRR: number;
|
|
550
552
|
}>;
|
|
551
553
|
}
|
|
554
|
+
declare class AccountAPI {
|
|
555
|
+
private client;
|
|
556
|
+
constructor(client: DreamClient);
|
|
557
|
+
/**
|
|
558
|
+
* Delete the current user's account.
|
|
559
|
+
* This permanently removes all user data.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```typescript
|
|
563
|
+
* await api.account.delete();
|
|
564
|
+
* // User is now signed out and deleted
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
delete(): Promise<{
|
|
568
|
+
success: boolean;
|
|
569
|
+
message: string;
|
|
570
|
+
}>;
|
|
571
|
+
}
|
|
552
572
|
|
|
553
573
|
export { type CheckoutResult, type ClerkUser, type CreateCustomerParams, type Customer, type DashboardCustomer, type DashboardMetrics, DreamAPI, type DreamAPIConfig, type DreamAPIError, DreamAPIException, type Order, type PortalResult, type Product, type Tier, type Usage, type UsageTrackResult, type WebhookStatus, DreamAPI as default };
|
package/dist/index.js
CHANGED
|
@@ -116,6 +116,9 @@ var DreamClient = class {
|
|
|
116
116
|
*/
|
|
117
117
|
async request(method, endpoint, options = {}) {
|
|
118
118
|
const { body, requiresUserToken = false } = options;
|
|
119
|
+
if (requiresUserToken || this.userToken) {
|
|
120
|
+
await this.ensureFreshToken();
|
|
121
|
+
}
|
|
119
122
|
const headers = {
|
|
120
123
|
"Content-Type": "application/json"
|
|
121
124
|
};
|
|
@@ -324,6 +327,9 @@ var AuthHelpers = class {
|
|
|
324
327
|
async init() {
|
|
325
328
|
if (this.initialized) return;
|
|
326
329
|
await this.clerk.load();
|
|
330
|
+
this.client.setTokenRefresher(async () => {
|
|
331
|
+
return await this.clerk.refreshToken();
|
|
332
|
+
});
|
|
327
333
|
this.initialized = true;
|
|
328
334
|
}
|
|
329
335
|
/**
|
|
@@ -428,6 +434,7 @@ var DreamAPI = class {
|
|
|
428
434
|
this.billing = new BillingAPI(this.client);
|
|
429
435
|
this.products = new ProductAPI(this.client);
|
|
430
436
|
this.dashboard = new DashboardAPI(this.client);
|
|
437
|
+
this.account = new AccountAPI(this.client);
|
|
431
438
|
}
|
|
432
439
|
/**
|
|
433
440
|
* Set the end-user JWT token.
|
|
@@ -623,6 +630,24 @@ var DashboardAPI = class {
|
|
|
623
630
|
return this.client.get("/api/dashboard/totals");
|
|
624
631
|
}
|
|
625
632
|
};
|
|
633
|
+
var AccountAPI = class {
|
|
634
|
+
constructor(client) {
|
|
635
|
+
this.client = client;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Delete the current user's account.
|
|
639
|
+
* This permanently removes all user data.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```typescript
|
|
643
|
+
* await api.account.delete();
|
|
644
|
+
* // User is now signed out and deleted
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
async delete() {
|
|
648
|
+
return this.client.delete("/api/me", true);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
626
651
|
var index_default = DreamAPI;
|
|
627
652
|
// Annotate the CommonJS export names for ESM import in node:
|
|
628
653
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -88,6 +88,9 @@ var DreamClient = class {
|
|
|
88
88
|
*/
|
|
89
89
|
async request(method, endpoint, options = {}) {
|
|
90
90
|
const { body, requiresUserToken = false } = options;
|
|
91
|
+
if (requiresUserToken || this.userToken) {
|
|
92
|
+
await this.ensureFreshToken();
|
|
93
|
+
}
|
|
91
94
|
const headers = {
|
|
92
95
|
"Content-Type": "application/json"
|
|
93
96
|
};
|
|
@@ -296,6 +299,9 @@ var AuthHelpers = class {
|
|
|
296
299
|
async init() {
|
|
297
300
|
if (this.initialized) return;
|
|
298
301
|
await this.clerk.load();
|
|
302
|
+
this.client.setTokenRefresher(async () => {
|
|
303
|
+
return await this.clerk.refreshToken();
|
|
304
|
+
});
|
|
299
305
|
this.initialized = true;
|
|
300
306
|
}
|
|
301
307
|
/**
|
|
@@ -400,6 +406,7 @@ var DreamAPI = class {
|
|
|
400
406
|
this.billing = new BillingAPI(this.client);
|
|
401
407
|
this.products = new ProductAPI(this.client);
|
|
402
408
|
this.dashboard = new DashboardAPI(this.client);
|
|
409
|
+
this.account = new AccountAPI(this.client);
|
|
403
410
|
}
|
|
404
411
|
/**
|
|
405
412
|
* Set the end-user JWT token.
|
|
@@ -595,6 +602,24 @@ var DashboardAPI = class {
|
|
|
595
602
|
return this.client.get("/api/dashboard/totals");
|
|
596
603
|
}
|
|
597
604
|
};
|
|
605
|
+
var AccountAPI = class {
|
|
606
|
+
constructor(client) {
|
|
607
|
+
this.client = client;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Delete the current user's account.
|
|
611
|
+
* This permanently removes all user data.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```typescript
|
|
615
|
+
* await api.account.delete();
|
|
616
|
+
* // User is now signed out and deleted
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
async delete() {
|
|
620
|
+
return this.client.delete("/api/me", true);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
598
623
|
var index_default = DreamAPI;
|
|
599
624
|
export {
|
|
600
625
|
DreamAPI,
|