@stackbe/sdk 0.7.1 → 0.7.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/dist/index.d.mts +44 -10
- package/dist/index.d.ts +44 -10
- package/dist/index.js +56 -14
- package/dist/index.mjs +56 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -13,7 +13,7 @@ declare class HttpClient {
|
|
|
13
13
|
post<T>(path: string, body?: unknown, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
14
14
|
put<T>(path: string, body?: unknown, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
15
15
|
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
16
|
-
delete<T>(path: string): Promise<T>;
|
|
16
|
+
delete<T>(path: string, body?: unknown): Promise<T>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
interface StackBEConfig {
|
|
@@ -779,9 +779,13 @@ declare class CustomersClient {
|
|
|
779
779
|
/**
|
|
780
780
|
* Send a magic link to a customer for passwordless authentication.
|
|
781
781
|
*
|
|
782
|
+
* @deprecated Use `stackbe.auth.sendMagicLink()` instead, which uses the app-specific endpoint
|
|
783
|
+
* and supports dev callback URLs.
|
|
784
|
+
*
|
|
782
785
|
* @example
|
|
783
786
|
* ```typescript
|
|
784
|
-
*
|
|
787
|
+
* // Deprecated - use auth.sendMagicLink instead:
|
|
788
|
+
* await stackbe.auth.sendMagicLink('user@example.com', {
|
|
785
789
|
* redirectUrl: 'https://myapp.com/dashboard'
|
|
786
790
|
* });
|
|
787
791
|
* ```
|
|
@@ -793,10 +797,14 @@ declare class CustomersClient {
|
|
|
793
797
|
* Get the current session for a customer token.
|
|
794
798
|
* Use this to validate tokens and get customer data.
|
|
795
799
|
*
|
|
800
|
+
* @deprecated Use `stackbe.auth.getSession()` instead, which includes caching,
|
|
801
|
+
* tenant/org context extraction, and proper error handling.
|
|
802
|
+
*
|
|
796
803
|
* @example
|
|
797
804
|
* ```typescript
|
|
798
|
-
*
|
|
799
|
-
*
|
|
805
|
+
* // Deprecated - use auth.getSession instead:
|
|
806
|
+
* const session = await stackbe.auth.getSession(token);
|
|
807
|
+
* console.log(session.customerId);
|
|
800
808
|
* console.log(session.entitlements);
|
|
801
809
|
* ```
|
|
802
810
|
*/
|
|
@@ -1413,6 +1421,8 @@ interface CreateFeatureRequestOptions {
|
|
|
1413
1421
|
title: string;
|
|
1414
1422
|
description?: string;
|
|
1415
1423
|
category?: string;
|
|
1424
|
+
/** Customer ID for server-side creation with API key */
|
|
1425
|
+
customerId?: string;
|
|
1416
1426
|
}
|
|
1417
1427
|
interface ListFeatureRequestsOptions {
|
|
1418
1428
|
status?: 'new' | 'under_review' | 'planned' | 'in_progress' | 'completed' | 'declined';
|
|
@@ -1486,15 +1496,23 @@ declare class FeatureRequestsClient {
|
|
|
1486
1496
|
list(options?: ListFeatureRequestsOptions): Promise<FeatureRequestListResponse>;
|
|
1487
1497
|
/**
|
|
1488
1498
|
* Submit a new feature request.
|
|
1489
|
-
* Requires customer session token.
|
|
1499
|
+
* Requires customer session token, OR API key with customerId.
|
|
1490
1500
|
*
|
|
1491
1501
|
* @example
|
|
1492
1502
|
* ```typescript
|
|
1503
|
+
* // With customer session token
|
|
1493
1504
|
* const request = await stackbe.featureRequests.create({
|
|
1494
1505
|
* title: 'Dark mode support',
|
|
1495
1506
|
* description: 'Would love to have a dark theme option',
|
|
1496
1507
|
* category: 'UI',
|
|
1497
1508
|
* });
|
|
1509
|
+
*
|
|
1510
|
+
* // With API key (server-side)
|
|
1511
|
+
* const request = await stackbe.featureRequests.create({
|
|
1512
|
+
* title: 'Dark mode support',
|
|
1513
|
+
* description: 'Would love to have a dark theme option',
|
|
1514
|
+
* customerId: 'cust_123',
|
|
1515
|
+
* });
|
|
1498
1516
|
* ```
|
|
1499
1517
|
*/
|
|
1500
1518
|
create(options: CreateFeatureRequestOptions): Promise<FeatureRequest>;
|
|
@@ -1512,44 +1530,60 @@ declare class FeatureRequestsClient {
|
|
|
1512
1530
|
}>;
|
|
1513
1531
|
/**
|
|
1514
1532
|
* Upvote a feature request.
|
|
1515
|
-
* Requires customer session token
|
|
1533
|
+
* Requires customer session token, OR API key with customerId.
|
|
1516
1534
|
*
|
|
1517
1535
|
* @example
|
|
1518
1536
|
* ```typescript
|
|
1537
|
+
* // With customer session token
|
|
1519
1538
|
* await stackbe.featureRequests.vote('req_123');
|
|
1539
|
+
*
|
|
1540
|
+
* // With API key (server-side)
|
|
1541
|
+
* await stackbe.featureRequests.vote('req_123', 'cust_456');
|
|
1520
1542
|
* ```
|
|
1521
1543
|
*/
|
|
1522
|
-
vote(requestId: string): Promise<{
|
|
1544
|
+
vote(requestId: string, customerId?: string): Promise<{
|
|
1523
1545
|
success?: boolean;
|
|
1524
1546
|
alreadyVoted?: boolean;
|
|
1525
1547
|
voteCount: number;
|
|
1526
1548
|
}>;
|
|
1527
1549
|
/**
|
|
1528
1550
|
* Remove your vote from a feature request.
|
|
1529
|
-
* Requires customer session token.
|
|
1551
|
+
* Requires customer session token, OR API key with customerId.
|
|
1530
1552
|
*
|
|
1531
1553
|
* @example
|
|
1532
1554
|
* ```typescript
|
|
1555
|
+
* // With customer session token
|
|
1533
1556
|
* await stackbe.featureRequests.removeVote('req_123');
|
|
1557
|
+
*
|
|
1558
|
+
* // With API key (server-side)
|
|
1559
|
+
* await stackbe.featureRequests.removeVote('req_123', 'cust_456');
|
|
1534
1560
|
* ```
|
|
1535
1561
|
*/
|
|
1536
|
-
removeVote(requestId: string): Promise<{
|
|
1562
|
+
removeVote(requestId: string, customerId?: string): Promise<{
|
|
1537
1563
|
success: boolean;
|
|
1538
1564
|
voteCount: number;
|
|
1539
1565
|
}>;
|
|
1540
1566
|
/**
|
|
1541
1567
|
* Add a comment to a feature request.
|
|
1542
|
-
* Requires customer session token.
|
|
1568
|
+
* Requires customer session token, OR API key with customerId.
|
|
1543
1569
|
*
|
|
1544
1570
|
* @example
|
|
1545
1571
|
* ```typescript
|
|
1572
|
+
* // With customer session token
|
|
1546
1573
|
* await stackbe.featureRequests.addComment('req_123', {
|
|
1547
1574
|
* content: 'This would be really helpful for my workflow!',
|
|
1548
1575
|
* });
|
|
1576
|
+
*
|
|
1577
|
+
* // With API key (server-side)
|
|
1578
|
+
* await stackbe.featureRequests.addComment('req_123', {
|
|
1579
|
+
* content: 'This would be really helpful for my workflow!',
|
|
1580
|
+
* customerId: 'cust_456',
|
|
1581
|
+
* });
|
|
1549
1582
|
* ```
|
|
1550
1583
|
*/
|
|
1551
1584
|
addComment(requestId: string, options: {
|
|
1552
1585
|
content: string;
|
|
1586
|
+
customerId?: string;
|
|
1553
1587
|
}): Promise<FeatureRequestComment>;
|
|
1554
1588
|
/**
|
|
1555
1589
|
* Update a feature request status or category.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare class HttpClient {
|
|
|
13
13
|
post<T>(path: string, body?: unknown, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
14
14
|
put<T>(path: string, body?: unknown, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
15
15
|
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
16
|
-
delete<T>(path: string): Promise<T>;
|
|
16
|
+
delete<T>(path: string, body?: unknown): Promise<T>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
interface StackBEConfig {
|
|
@@ -779,9 +779,13 @@ declare class CustomersClient {
|
|
|
779
779
|
/**
|
|
780
780
|
* Send a magic link to a customer for passwordless authentication.
|
|
781
781
|
*
|
|
782
|
+
* @deprecated Use `stackbe.auth.sendMagicLink()` instead, which uses the app-specific endpoint
|
|
783
|
+
* and supports dev callback URLs.
|
|
784
|
+
*
|
|
782
785
|
* @example
|
|
783
786
|
* ```typescript
|
|
784
|
-
*
|
|
787
|
+
* // Deprecated - use auth.sendMagicLink instead:
|
|
788
|
+
* await stackbe.auth.sendMagicLink('user@example.com', {
|
|
785
789
|
* redirectUrl: 'https://myapp.com/dashboard'
|
|
786
790
|
* });
|
|
787
791
|
* ```
|
|
@@ -793,10 +797,14 @@ declare class CustomersClient {
|
|
|
793
797
|
* Get the current session for a customer token.
|
|
794
798
|
* Use this to validate tokens and get customer data.
|
|
795
799
|
*
|
|
800
|
+
* @deprecated Use `stackbe.auth.getSession()` instead, which includes caching,
|
|
801
|
+
* tenant/org context extraction, and proper error handling.
|
|
802
|
+
*
|
|
796
803
|
* @example
|
|
797
804
|
* ```typescript
|
|
798
|
-
*
|
|
799
|
-
*
|
|
805
|
+
* // Deprecated - use auth.getSession instead:
|
|
806
|
+
* const session = await stackbe.auth.getSession(token);
|
|
807
|
+
* console.log(session.customerId);
|
|
800
808
|
* console.log(session.entitlements);
|
|
801
809
|
* ```
|
|
802
810
|
*/
|
|
@@ -1413,6 +1421,8 @@ interface CreateFeatureRequestOptions {
|
|
|
1413
1421
|
title: string;
|
|
1414
1422
|
description?: string;
|
|
1415
1423
|
category?: string;
|
|
1424
|
+
/** Customer ID for server-side creation with API key */
|
|
1425
|
+
customerId?: string;
|
|
1416
1426
|
}
|
|
1417
1427
|
interface ListFeatureRequestsOptions {
|
|
1418
1428
|
status?: 'new' | 'under_review' | 'planned' | 'in_progress' | 'completed' | 'declined';
|
|
@@ -1486,15 +1496,23 @@ declare class FeatureRequestsClient {
|
|
|
1486
1496
|
list(options?: ListFeatureRequestsOptions): Promise<FeatureRequestListResponse>;
|
|
1487
1497
|
/**
|
|
1488
1498
|
* Submit a new feature request.
|
|
1489
|
-
* Requires customer session token.
|
|
1499
|
+
* Requires customer session token, OR API key with customerId.
|
|
1490
1500
|
*
|
|
1491
1501
|
* @example
|
|
1492
1502
|
* ```typescript
|
|
1503
|
+
* // With customer session token
|
|
1493
1504
|
* const request = await stackbe.featureRequests.create({
|
|
1494
1505
|
* title: 'Dark mode support',
|
|
1495
1506
|
* description: 'Would love to have a dark theme option',
|
|
1496
1507
|
* category: 'UI',
|
|
1497
1508
|
* });
|
|
1509
|
+
*
|
|
1510
|
+
* // With API key (server-side)
|
|
1511
|
+
* const request = await stackbe.featureRequests.create({
|
|
1512
|
+
* title: 'Dark mode support',
|
|
1513
|
+
* description: 'Would love to have a dark theme option',
|
|
1514
|
+
* customerId: 'cust_123',
|
|
1515
|
+
* });
|
|
1498
1516
|
* ```
|
|
1499
1517
|
*/
|
|
1500
1518
|
create(options: CreateFeatureRequestOptions): Promise<FeatureRequest>;
|
|
@@ -1512,44 +1530,60 @@ declare class FeatureRequestsClient {
|
|
|
1512
1530
|
}>;
|
|
1513
1531
|
/**
|
|
1514
1532
|
* Upvote a feature request.
|
|
1515
|
-
* Requires customer session token
|
|
1533
|
+
* Requires customer session token, OR API key with customerId.
|
|
1516
1534
|
*
|
|
1517
1535
|
* @example
|
|
1518
1536
|
* ```typescript
|
|
1537
|
+
* // With customer session token
|
|
1519
1538
|
* await stackbe.featureRequests.vote('req_123');
|
|
1539
|
+
*
|
|
1540
|
+
* // With API key (server-side)
|
|
1541
|
+
* await stackbe.featureRequests.vote('req_123', 'cust_456');
|
|
1520
1542
|
* ```
|
|
1521
1543
|
*/
|
|
1522
|
-
vote(requestId: string): Promise<{
|
|
1544
|
+
vote(requestId: string, customerId?: string): Promise<{
|
|
1523
1545
|
success?: boolean;
|
|
1524
1546
|
alreadyVoted?: boolean;
|
|
1525
1547
|
voteCount: number;
|
|
1526
1548
|
}>;
|
|
1527
1549
|
/**
|
|
1528
1550
|
* Remove your vote from a feature request.
|
|
1529
|
-
* Requires customer session token.
|
|
1551
|
+
* Requires customer session token, OR API key with customerId.
|
|
1530
1552
|
*
|
|
1531
1553
|
* @example
|
|
1532
1554
|
* ```typescript
|
|
1555
|
+
* // With customer session token
|
|
1533
1556
|
* await stackbe.featureRequests.removeVote('req_123');
|
|
1557
|
+
*
|
|
1558
|
+
* // With API key (server-side)
|
|
1559
|
+
* await stackbe.featureRequests.removeVote('req_123', 'cust_456');
|
|
1534
1560
|
* ```
|
|
1535
1561
|
*/
|
|
1536
|
-
removeVote(requestId: string): Promise<{
|
|
1562
|
+
removeVote(requestId: string, customerId?: string): Promise<{
|
|
1537
1563
|
success: boolean;
|
|
1538
1564
|
voteCount: number;
|
|
1539
1565
|
}>;
|
|
1540
1566
|
/**
|
|
1541
1567
|
* Add a comment to a feature request.
|
|
1542
|
-
* Requires customer session token.
|
|
1568
|
+
* Requires customer session token, OR API key with customerId.
|
|
1543
1569
|
*
|
|
1544
1570
|
* @example
|
|
1545
1571
|
* ```typescript
|
|
1572
|
+
* // With customer session token
|
|
1546
1573
|
* await stackbe.featureRequests.addComment('req_123', {
|
|
1547
1574
|
* content: 'This would be really helpful for my workflow!',
|
|
1548
1575
|
* });
|
|
1576
|
+
*
|
|
1577
|
+
* // With API key (server-side)
|
|
1578
|
+
* await stackbe.featureRequests.addComment('req_123', {
|
|
1579
|
+
* content: 'This would be really helpful for my workflow!',
|
|
1580
|
+
* customerId: 'cust_456',
|
|
1581
|
+
* });
|
|
1549
1582
|
* ```
|
|
1550
1583
|
*/
|
|
1551
1584
|
addComment(requestId: string, options: {
|
|
1552
1585
|
content: string;
|
|
1586
|
+
customerId?: string;
|
|
1553
1587
|
}): Promise<FeatureRequestComment>;
|
|
1554
1588
|
/**
|
|
1555
1589
|
* Update a feature request status or category.
|
package/dist/index.js
CHANGED
|
@@ -169,8 +169,8 @@ var HttpClient = class {
|
|
|
169
169
|
async patch(path, body) {
|
|
170
170
|
return this.request("PATCH", path, { body });
|
|
171
171
|
}
|
|
172
|
-
async delete(path) {
|
|
173
|
-
return this.request("DELETE", path);
|
|
172
|
+
async delete(path, body) {
|
|
173
|
+
return this.request("DELETE", path, body ? { body } : void 0);
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
@@ -566,9 +566,13 @@ var CustomersClient = class {
|
|
|
566
566
|
/**
|
|
567
567
|
* Send a magic link to a customer for passwordless authentication.
|
|
568
568
|
*
|
|
569
|
+
* @deprecated Use `stackbe.auth.sendMagicLink()` instead, which uses the app-specific endpoint
|
|
570
|
+
* and supports dev callback URLs.
|
|
571
|
+
*
|
|
569
572
|
* @example
|
|
570
573
|
* ```typescript
|
|
571
|
-
*
|
|
574
|
+
* // Deprecated - use auth.sendMagicLink instead:
|
|
575
|
+
* await stackbe.auth.sendMagicLink('user@example.com', {
|
|
572
576
|
* redirectUrl: 'https://myapp.com/dashboard'
|
|
573
577
|
* });
|
|
574
578
|
* ```
|
|
@@ -583,15 +587,28 @@ var CustomersClient = class {
|
|
|
583
587
|
* Get the current session for a customer token.
|
|
584
588
|
* Use this to validate tokens and get customer data.
|
|
585
589
|
*
|
|
590
|
+
* @deprecated Use `stackbe.auth.getSession()` instead, which includes caching,
|
|
591
|
+
* tenant/org context extraction, and proper error handling.
|
|
592
|
+
*
|
|
586
593
|
* @example
|
|
587
594
|
* ```typescript
|
|
588
|
-
*
|
|
589
|
-
*
|
|
595
|
+
* // Deprecated - use auth.getSession instead:
|
|
596
|
+
* const session = await stackbe.auth.getSession(token);
|
|
597
|
+
* console.log(session.customerId);
|
|
590
598
|
* console.log(session.entitlements);
|
|
591
599
|
* ```
|
|
592
600
|
*/
|
|
593
601
|
async getSession(token) {
|
|
594
|
-
|
|
602
|
+
const response = await fetch(`${this.http.baseUrl}/v1/apps/${this.appId}/auth/session`, {
|
|
603
|
+
headers: {
|
|
604
|
+
Authorization: `Bearer ${token}`,
|
|
605
|
+
"Content-Type": "application/json"
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
if (!response.ok) {
|
|
609
|
+
throw new Error("Failed to get session");
|
|
610
|
+
}
|
|
611
|
+
return response.json();
|
|
595
612
|
}
|
|
596
613
|
};
|
|
597
614
|
|
|
@@ -1496,15 +1513,23 @@ var FeatureRequestsClient = class {
|
|
|
1496
1513
|
}
|
|
1497
1514
|
/**
|
|
1498
1515
|
* Submit a new feature request.
|
|
1499
|
-
* Requires customer session token.
|
|
1516
|
+
* Requires customer session token, OR API key with customerId.
|
|
1500
1517
|
*
|
|
1501
1518
|
* @example
|
|
1502
1519
|
* ```typescript
|
|
1520
|
+
* // With customer session token
|
|
1503
1521
|
* const request = await stackbe.featureRequests.create({
|
|
1504
1522
|
* title: 'Dark mode support',
|
|
1505
1523
|
* description: 'Would love to have a dark theme option',
|
|
1506
1524
|
* category: 'UI',
|
|
1507
1525
|
* });
|
|
1526
|
+
*
|
|
1527
|
+
* // With API key (server-side)
|
|
1528
|
+
* const request = await stackbe.featureRequests.create({
|
|
1529
|
+
* title: 'Dark mode support',
|
|
1530
|
+
* description: 'Would love to have a dark theme option',
|
|
1531
|
+
* customerId: 'cust_123',
|
|
1532
|
+
* });
|
|
1508
1533
|
* ```
|
|
1509
1534
|
*/
|
|
1510
1535
|
async create(options) {
|
|
@@ -1529,41 +1554,58 @@ var FeatureRequestsClient = class {
|
|
|
1529
1554
|
}
|
|
1530
1555
|
/**
|
|
1531
1556
|
* Upvote a feature request.
|
|
1532
|
-
* Requires customer session token
|
|
1557
|
+
* Requires customer session token, OR API key with customerId.
|
|
1533
1558
|
*
|
|
1534
1559
|
* @example
|
|
1535
1560
|
* ```typescript
|
|
1561
|
+
* // With customer session token
|
|
1536
1562
|
* await stackbe.featureRequests.vote('req_123');
|
|
1563
|
+
*
|
|
1564
|
+
* // With API key (server-side)
|
|
1565
|
+
* await stackbe.featureRequests.vote('req_123', 'cust_456');
|
|
1537
1566
|
* ```
|
|
1538
1567
|
*/
|
|
1539
|
-
async vote(requestId) {
|
|
1568
|
+
async vote(requestId, customerId) {
|
|
1540
1569
|
return this.http.post(
|
|
1541
|
-
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote
|
|
1570
|
+
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote`,
|
|
1571
|
+
customerId ? { customerId } : void 0
|
|
1542
1572
|
);
|
|
1543
1573
|
}
|
|
1544
1574
|
/**
|
|
1545
1575
|
* Remove your vote from a feature request.
|
|
1546
|
-
* Requires customer session token.
|
|
1576
|
+
* Requires customer session token, OR API key with customerId.
|
|
1547
1577
|
*
|
|
1548
1578
|
* @example
|
|
1549
1579
|
* ```typescript
|
|
1580
|
+
* // With customer session token
|
|
1550
1581
|
* await stackbe.featureRequests.removeVote('req_123');
|
|
1582
|
+
*
|
|
1583
|
+
* // With API key (server-side)
|
|
1584
|
+
* await stackbe.featureRequests.removeVote('req_123', 'cust_456');
|
|
1551
1585
|
* ```
|
|
1552
1586
|
*/
|
|
1553
|
-
async removeVote(requestId) {
|
|
1587
|
+
async removeVote(requestId, customerId) {
|
|
1554
1588
|
return this.http.delete(
|
|
1555
|
-
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote
|
|
1589
|
+
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote`,
|
|
1590
|
+
customerId ? { customerId } : void 0
|
|
1556
1591
|
);
|
|
1557
1592
|
}
|
|
1558
1593
|
/**
|
|
1559
1594
|
* Add a comment to a feature request.
|
|
1560
|
-
* Requires customer session token.
|
|
1595
|
+
* Requires customer session token, OR API key with customerId.
|
|
1561
1596
|
*
|
|
1562
1597
|
* @example
|
|
1563
1598
|
* ```typescript
|
|
1599
|
+
* // With customer session token
|
|
1564
1600
|
* await stackbe.featureRequests.addComment('req_123', {
|
|
1565
1601
|
* content: 'This would be really helpful for my workflow!',
|
|
1566
1602
|
* });
|
|
1603
|
+
*
|
|
1604
|
+
* // With API key (server-side)
|
|
1605
|
+
* await stackbe.featureRequests.addComment('req_123', {
|
|
1606
|
+
* content: 'This would be really helpful for my workflow!',
|
|
1607
|
+
* customerId: 'cust_456',
|
|
1608
|
+
* });
|
|
1567
1609
|
* ```
|
|
1568
1610
|
*/
|
|
1569
1611
|
async addComment(requestId, options) {
|
package/dist/index.mjs
CHANGED
|
@@ -132,8 +132,8 @@ var HttpClient = class {
|
|
|
132
132
|
async patch(path, body) {
|
|
133
133
|
return this.request("PATCH", path, { body });
|
|
134
134
|
}
|
|
135
|
-
async delete(path) {
|
|
136
|
-
return this.request("DELETE", path);
|
|
135
|
+
async delete(path, body) {
|
|
136
|
+
return this.request("DELETE", path, body ? { body } : void 0);
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
|
|
@@ -529,9 +529,13 @@ var CustomersClient = class {
|
|
|
529
529
|
/**
|
|
530
530
|
* Send a magic link to a customer for passwordless authentication.
|
|
531
531
|
*
|
|
532
|
+
* @deprecated Use `stackbe.auth.sendMagicLink()` instead, which uses the app-specific endpoint
|
|
533
|
+
* and supports dev callback URLs.
|
|
534
|
+
*
|
|
532
535
|
* @example
|
|
533
536
|
* ```typescript
|
|
534
|
-
*
|
|
537
|
+
* // Deprecated - use auth.sendMagicLink instead:
|
|
538
|
+
* await stackbe.auth.sendMagicLink('user@example.com', {
|
|
535
539
|
* redirectUrl: 'https://myapp.com/dashboard'
|
|
536
540
|
* });
|
|
537
541
|
* ```
|
|
@@ -546,15 +550,28 @@ var CustomersClient = class {
|
|
|
546
550
|
* Get the current session for a customer token.
|
|
547
551
|
* Use this to validate tokens and get customer data.
|
|
548
552
|
*
|
|
553
|
+
* @deprecated Use `stackbe.auth.getSession()` instead, which includes caching,
|
|
554
|
+
* tenant/org context extraction, and proper error handling.
|
|
555
|
+
*
|
|
549
556
|
* @example
|
|
550
557
|
* ```typescript
|
|
551
|
-
*
|
|
552
|
-
*
|
|
558
|
+
* // Deprecated - use auth.getSession instead:
|
|
559
|
+
* const session = await stackbe.auth.getSession(token);
|
|
560
|
+
* console.log(session.customerId);
|
|
553
561
|
* console.log(session.entitlements);
|
|
554
562
|
* ```
|
|
555
563
|
*/
|
|
556
564
|
async getSession(token) {
|
|
557
|
-
|
|
565
|
+
const response = await fetch(`${this.http.baseUrl}/v1/apps/${this.appId}/auth/session`, {
|
|
566
|
+
headers: {
|
|
567
|
+
Authorization: `Bearer ${token}`,
|
|
568
|
+
"Content-Type": "application/json"
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
if (!response.ok) {
|
|
572
|
+
throw new Error("Failed to get session");
|
|
573
|
+
}
|
|
574
|
+
return response.json();
|
|
558
575
|
}
|
|
559
576
|
};
|
|
560
577
|
|
|
@@ -1459,15 +1476,23 @@ var FeatureRequestsClient = class {
|
|
|
1459
1476
|
}
|
|
1460
1477
|
/**
|
|
1461
1478
|
* Submit a new feature request.
|
|
1462
|
-
* Requires customer session token.
|
|
1479
|
+
* Requires customer session token, OR API key with customerId.
|
|
1463
1480
|
*
|
|
1464
1481
|
* @example
|
|
1465
1482
|
* ```typescript
|
|
1483
|
+
* // With customer session token
|
|
1466
1484
|
* const request = await stackbe.featureRequests.create({
|
|
1467
1485
|
* title: 'Dark mode support',
|
|
1468
1486
|
* description: 'Would love to have a dark theme option',
|
|
1469
1487
|
* category: 'UI',
|
|
1470
1488
|
* });
|
|
1489
|
+
*
|
|
1490
|
+
* // With API key (server-side)
|
|
1491
|
+
* const request = await stackbe.featureRequests.create({
|
|
1492
|
+
* title: 'Dark mode support',
|
|
1493
|
+
* description: 'Would love to have a dark theme option',
|
|
1494
|
+
* customerId: 'cust_123',
|
|
1495
|
+
* });
|
|
1471
1496
|
* ```
|
|
1472
1497
|
*/
|
|
1473
1498
|
async create(options) {
|
|
@@ -1492,41 +1517,58 @@ var FeatureRequestsClient = class {
|
|
|
1492
1517
|
}
|
|
1493
1518
|
/**
|
|
1494
1519
|
* Upvote a feature request.
|
|
1495
|
-
* Requires customer session token
|
|
1520
|
+
* Requires customer session token, OR API key with customerId.
|
|
1496
1521
|
*
|
|
1497
1522
|
* @example
|
|
1498
1523
|
* ```typescript
|
|
1524
|
+
* // With customer session token
|
|
1499
1525
|
* await stackbe.featureRequests.vote('req_123');
|
|
1526
|
+
*
|
|
1527
|
+
* // With API key (server-side)
|
|
1528
|
+
* await stackbe.featureRequests.vote('req_123', 'cust_456');
|
|
1500
1529
|
* ```
|
|
1501
1530
|
*/
|
|
1502
|
-
async vote(requestId) {
|
|
1531
|
+
async vote(requestId, customerId) {
|
|
1503
1532
|
return this.http.post(
|
|
1504
|
-
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote
|
|
1533
|
+
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote`,
|
|
1534
|
+
customerId ? { customerId } : void 0
|
|
1505
1535
|
);
|
|
1506
1536
|
}
|
|
1507
1537
|
/**
|
|
1508
1538
|
* Remove your vote from a feature request.
|
|
1509
|
-
* Requires customer session token.
|
|
1539
|
+
* Requires customer session token, OR API key with customerId.
|
|
1510
1540
|
*
|
|
1511
1541
|
* @example
|
|
1512
1542
|
* ```typescript
|
|
1543
|
+
* // With customer session token
|
|
1513
1544
|
* await stackbe.featureRequests.removeVote('req_123');
|
|
1545
|
+
*
|
|
1546
|
+
* // With API key (server-side)
|
|
1547
|
+
* await stackbe.featureRequests.removeVote('req_123', 'cust_456');
|
|
1514
1548
|
* ```
|
|
1515
1549
|
*/
|
|
1516
|
-
async removeVote(requestId) {
|
|
1550
|
+
async removeVote(requestId, customerId) {
|
|
1517
1551
|
return this.http.delete(
|
|
1518
|
-
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote
|
|
1552
|
+
`/v1/apps/${this.appId}/feature-requests/${requestId}/vote`,
|
|
1553
|
+
customerId ? { customerId } : void 0
|
|
1519
1554
|
);
|
|
1520
1555
|
}
|
|
1521
1556
|
/**
|
|
1522
1557
|
* Add a comment to a feature request.
|
|
1523
|
-
* Requires customer session token.
|
|
1558
|
+
* Requires customer session token, OR API key with customerId.
|
|
1524
1559
|
*
|
|
1525
1560
|
* @example
|
|
1526
1561
|
* ```typescript
|
|
1562
|
+
* // With customer session token
|
|
1527
1563
|
* await stackbe.featureRequests.addComment('req_123', {
|
|
1528
1564
|
* content: 'This would be really helpful for my workflow!',
|
|
1529
1565
|
* });
|
|
1566
|
+
*
|
|
1567
|
+
* // With API key (server-side)
|
|
1568
|
+
* await stackbe.featureRequests.addComment('req_123', {
|
|
1569
|
+
* content: 'This would be really helpful for my workflow!',
|
|
1570
|
+
* customerId: 'cust_456',
|
|
1571
|
+
* });
|
|
1530
1572
|
* ```
|
|
1531
1573
|
*/
|
|
1532
1574
|
async addComment(requestId, options) {
|
package/package.json
CHANGED