@stackbe/sdk 0.11.1 → 0.12.1
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 +3 -0
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +25 -4
- package/dist/index.mjs +25 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -298,6 +298,9 @@ const org = await stackbe.organizations.create({
|
|
|
298
298
|
// List all organizations
|
|
299
299
|
const orgs = await stackbe.organizations.list();
|
|
300
300
|
|
|
301
|
+
// List organizations for a specific customer (for org switchers)
|
|
302
|
+
const customerOrgs = await stackbe.organizations.listByCustomer('cust_123');
|
|
303
|
+
|
|
301
304
|
// Get organization by ID
|
|
302
305
|
const org = await stackbe.organizations.get('org_123');
|
|
303
306
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1502,6 +1502,17 @@ declare class OrganizationsClient {
|
|
|
1502
1502
|
offset?: number;
|
|
1503
1503
|
search?: string;
|
|
1504
1504
|
}): Promise<Organization[]>;
|
|
1505
|
+
/**
|
|
1506
|
+
* List organizations where a specific customer is a member.
|
|
1507
|
+
* Useful for building org switchers or checking what orgs a user belongs to.
|
|
1508
|
+
*
|
|
1509
|
+
* @example
|
|
1510
|
+
* ```typescript
|
|
1511
|
+
* const orgs = await stackbe.organizations.listByCustomer('cust_123');
|
|
1512
|
+
* orgs.forEach(org => console.log(`${org.name} - ${org.members.find(m => m.customerId === 'cust_123')?.role}`));
|
|
1513
|
+
* ```
|
|
1514
|
+
*/
|
|
1515
|
+
listByCustomer(customerId: string): Promise<Organization[]>;
|
|
1505
1516
|
/**
|
|
1506
1517
|
* Get an organization by ID.
|
|
1507
1518
|
*
|
|
@@ -1523,15 +1534,25 @@ declare class OrganizationsClient {
|
|
|
1523
1534
|
*/
|
|
1524
1535
|
update(orgId: string, options: UpdateOrganizationOptions): Promise<Organization>;
|
|
1525
1536
|
/**
|
|
1526
|
-
* Delete an organization.
|
|
1527
|
-
*
|
|
1537
|
+
* Delete an organization (soft-delete).
|
|
1538
|
+
* By default, fails if org has active subscriptions.
|
|
1539
|
+
* Pass cancelSubscriptions: true to auto-cancel them first.
|
|
1528
1540
|
*
|
|
1529
1541
|
* @example
|
|
1530
1542
|
* ```typescript
|
|
1543
|
+
* // Basic delete (fails if active subscriptions)
|
|
1531
1544
|
* await stackbe.organizations.delete('org_123');
|
|
1545
|
+
*
|
|
1546
|
+
* // Force delete with subscription cancellation
|
|
1547
|
+
* await stackbe.organizations.delete('org_123', { cancelSubscriptions: true });
|
|
1532
1548
|
* ```
|
|
1533
1549
|
*/
|
|
1534
|
-
delete(orgId: string
|
|
1550
|
+
delete(orgId: string, options?: {
|
|
1551
|
+
cancelSubscriptions?: boolean;
|
|
1552
|
+
}): Promise<{
|
|
1553
|
+
success: boolean;
|
|
1554
|
+
cancelledSubscriptions: number;
|
|
1555
|
+
}>;
|
|
1535
1556
|
/**
|
|
1536
1557
|
* Add a customer as a member of an organization.
|
|
1537
1558
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1502,6 +1502,17 @@ declare class OrganizationsClient {
|
|
|
1502
1502
|
offset?: number;
|
|
1503
1503
|
search?: string;
|
|
1504
1504
|
}): Promise<Organization[]>;
|
|
1505
|
+
/**
|
|
1506
|
+
* List organizations where a specific customer is a member.
|
|
1507
|
+
* Useful for building org switchers or checking what orgs a user belongs to.
|
|
1508
|
+
*
|
|
1509
|
+
* @example
|
|
1510
|
+
* ```typescript
|
|
1511
|
+
* const orgs = await stackbe.organizations.listByCustomer('cust_123');
|
|
1512
|
+
* orgs.forEach(org => console.log(`${org.name} - ${org.members.find(m => m.customerId === 'cust_123')?.role}`));
|
|
1513
|
+
* ```
|
|
1514
|
+
*/
|
|
1515
|
+
listByCustomer(customerId: string): Promise<Organization[]>;
|
|
1505
1516
|
/**
|
|
1506
1517
|
* Get an organization by ID.
|
|
1507
1518
|
*
|
|
@@ -1523,15 +1534,25 @@ declare class OrganizationsClient {
|
|
|
1523
1534
|
*/
|
|
1524
1535
|
update(orgId: string, options: UpdateOrganizationOptions): Promise<Organization>;
|
|
1525
1536
|
/**
|
|
1526
|
-
* Delete an organization.
|
|
1527
|
-
*
|
|
1537
|
+
* Delete an organization (soft-delete).
|
|
1538
|
+
* By default, fails if org has active subscriptions.
|
|
1539
|
+
* Pass cancelSubscriptions: true to auto-cancel them first.
|
|
1528
1540
|
*
|
|
1529
1541
|
* @example
|
|
1530
1542
|
* ```typescript
|
|
1543
|
+
* // Basic delete (fails if active subscriptions)
|
|
1531
1544
|
* await stackbe.organizations.delete('org_123');
|
|
1545
|
+
*
|
|
1546
|
+
* // Force delete with subscription cancellation
|
|
1547
|
+
* await stackbe.organizations.delete('org_123', { cancelSubscriptions: true });
|
|
1532
1548
|
* ```
|
|
1533
1549
|
*/
|
|
1534
|
-
delete(orgId: string
|
|
1550
|
+
delete(orgId: string, options?: {
|
|
1551
|
+
cancelSubscriptions?: boolean;
|
|
1552
|
+
}): Promise<{
|
|
1553
|
+
success: boolean;
|
|
1554
|
+
cancelledSubscriptions: number;
|
|
1555
|
+
}>;
|
|
1535
1556
|
/**
|
|
1536
1557
|
* Add a customer as a member of an organization.
|
|
1537
1558
|
*
|
package/dist/index.js
CHANGED
|
@@ -1504,6 +1504,21 @@ var OrganizationsClient = class {
|
|
|
1504
1504
|
const path = `/v1/apps/${this.appId}/admin/organizations${query ? `?${query}` : ""}`;
|
|
1505
1505
|
return this.http.get(path);
|
|
1506
1506
|
}
|
|
1507
|
+
/**
|
|
1508
|
+
* List organizations where a specific customer is a member.
|
|
1509
|
+
* Useful for building org switchers or checking what orgs a user belongs to.
|
|
1510
|
+
*
|
|
1511
|
+
* @example
|
|
1512
|
+
* ```typescript
|
|
1513
|
+
* const orgs = await stackbe.organizations.listByCustomer('cust_123');
|
|
1514
|
+
* orgs.forEach(org => console.log(`${org.name} - ${org.members.find(m => m.customerId === 'cust_123')?.role}`));
|
|
1515
|
+
* ```
|
|
1516
|
+
*/
|
|
1517
|
+
async listByCustomer(customerId) {
|
|
1518
|
+
return this.http.get(
|
|
1519
|
+
`/v1/apps/${this.appId}/admin/organizations/by-customer/${customerId}`
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1507
1522
|
/**
|
|
1508
1523
|
* Get an organization by ID.
|
|
1509
1524
|
*
|
|
@@ -1534,17 +1549,23 @@ var OrganizationsClient = class {
|
|
|
1534
1549
|
);
|
|
1535
1550
|
}
|
|
1536
1551
|
/**
|
|
1537
|
-
* Delete an organization.
|
|
1538
|
-
*
|
|
1552
|
+
* Delete an organization (soft-delete).
|
|
1553
|
+
* By default, fails if org has active subscriptions.
|
|
1554
|
+
* Pass cancelSubscriptions: true to auto-cancel them first.
|
|
1539
1555
|
*
|
|
1540
1556
|
* @example
|
|
1541
1557
|
* ```typescript
|
|
1558
|
+
* // Basic delete (fails if active subscriptions)
|
|
1542
1559
|
* await stackbe.organizations.delete('org_123');
|
|
1560
|
+
*
|
|
1561
|
+
* // Force delete with subscription cancellation
|
|
1562
|
+
* await stackbe.organizations.delete('org_123', { cancelSubscriptions: true });
|
|
1543
1563
|
* ```
|
|
1544
1564
|
*/
|
|
1545
|
-
async delete(orgId) {
|
|
1565
|
+
async delete(orgId, options) {
|
|
1566
|
+
const query = options?.cancelSubscriptions ? "?cancelSubscriptions=true" : "";
|
|
1546
1567
|
return this.http.delete(
|
|
1547
|
-
`/v1/apps/${this.appId}/admin/organizations/${orgId}`
|
|
1568
|
+
`/v1/apps/${this.appId}/admin/organizations/${orgId}${query}`
|
|
1548
1569
|
);
|
|
1549
1570
|
}
|
|
1550
1571
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1463,6 +1463,21 @@ var OrganizationsClient = class {
|
|
|
1463
1463
|
const path = `/v1/apps/${this.appId}/admin/organizations${query ? `?${query}` : ""}`;
|
|
1464
1464
|
return this.http.get(path);
|
|
1465
1465
|
}
|
|
1466
|
+
/**
|
|
1467
|
+
* List organizations where a specific customer is a member.
|
|
1468
|
+
* Useful for building org switchers or checking what orgs a user belongs to.
|
|
1469
|
+
*
|
|
1470
|
+
* @example
|
|
1471
|
+
* ```typescript
|
|
1472
|
+
* const orgs = await stackbe.organizations.listByCustomer('cust_123');
|
|
1473
|
+
* orgs.forEach(org => console.log(`${org.name} - ${org.members.find(m => m.customerId === 'cust_123')?.role}`));
|
|
1474
|
+
* ```
|
|
1475
|
+
*/
|
|
1476
|
+
async listByCustomer(customerId) {
|
|
1477
|
+
return this.http.get(
|
|
1478
|
+
`/v1/apps/${this.appId}/admin/organizations/by-customer/${customerId}`
|
|
1479
|
+
);
|
|
1480
|
+
}
|
|
1466
1481
|
/**
|
|
1467
1482
|
* Get an organization by ID.
|
|
1468
1483
|
*
|
|
@@ -1493,17 +1508,23 @@ var OrganizationsClient = class {
|
|
|
1493
1508
|
);
|
|
1494
1509
|
}
|
|
1495
1510
|
/**
|
|
1496
|
-
* Delete an organization.
|
|
1497
|
-
*
|
|
1511
|
+
* Delete an organization (soft-delete).
|
|
1512
|
+
* By default, fails if org has active subscriptions.
|
|
1513
|
+
* Pass cancelSubscriptions: true to auto-cancel them first.
|
|
1498
1514
|
*
|
|
1499
1515
|
* @example
|
|
1500
1516
|
* ```typescript
|
|
1517
|
+
* // Basic delete (fails if active subscriptions)
|
|
1501
1518
|
* await stackbe.organizations.delete('org_123');
|
|
1519
|
+
*
|
|
1520
|
+
* // Force delete with subscription cancellation
|
|
1521
|
+
* await stackbe.organizations.delete('org_123', { cancelSubscriptions: true });
|
|
1502
1522
|
* ```
|
|
1503
1523
|
*/
|
|
1504
|
-
async delete(orgId) {
|
|
1524
|
+
async delete(orgId, options) {
|
|
1525
|
+
const query = options?.cancelSubscriptions ? "?cancelSubscriptions=true" : "";
|
|
1505
1526
|
return this.http.delete(
|
|
1506
|
-
`/v1/apps/${this.appId}/admin/organizations/${orgId}`
|
|
1527
|
+
`/v1/apps/${this.appId}/admin/organizations/${orgId}${query}`
|
|
1507
1528
|
);
|
|
1508
1529
|
}
|
|
1509
1530
|
/**
|
package/package.json
CHANGED