@omnibase/core-js 0.7.5 → 0.8.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/chunk-5B37CXXH.js +447 -0
- package/dist/chunk-TFAV5P6I.js +869 -0
- package/dist/index.cjs +263 -18
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/payments/index.d.cts +394 -90
- package/dist/payments/index.d.ts +394 -90
- package/dist/permissions/index.cjs +87 -18
- package/dist/permissions/index.js +1 -1
- package/dist/tenants/index.cjs +176 -0
- package/dist/tenants/index.d.cts +1 -1
- package/dist/tenants/index.d.ts +1 -1
- package/dist/tenants/index.js +1 -1
- package/package.json +1 -1
package/dist/payments/index.d.ts
CHANGED
|
@@ -79,6 +79,21 @@ type CheckoutOptions = {
|
|
|
79
79
|
success_url: string;
|
|
80
80
|
/** URL to redirect to if the user cancels the checkout */
|
|
81
81
|
cancel_url: string;
|
|
82
|
+
/**
|
|
83
|
+
* Number of days for the trial period (subscriptions only)
|
|
84
|
+
* Only applies when the price has a recurring interval
|
|
85
|
+
*/
|
|
86
|
+
trial_period_days?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Stripe promotion code ID to apply automatically
|
|
89
|
+
* Mutually exclusive with allow_promotion_codes
|
|
90
|
+
*/
|
|
91
|
+
promotion_code?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether to show promotion code input field in checkout
|
|
94
|
+
* Allows customers to enter their own promo codes
|
|
95
|
+
*/
|
|
96
|
+
allow_promotion_codes?: boolean;
|
|
82
97
|
};
|
|
83
98
|
/**
|
|
84
99
|
* Response from creating a checkout session
|
|
@@ -1451,97 +1466,80 @@ declare class RolesHandler {
|
|
|
1451
1466
|
/**
|
|
1452
1467
|
* Client for managing permissions and relationships using Ory Keto
|
|
1453
1468
|
*
|
|
1454
|
-
* This client provides access to Ory Keto's permission system
|
|
1455
|
-
* create, manage, and check relationships between subjects and objects.
|
|
1456
|
-
* both read operations (permission checks) and write operations (relationship management).
|
|
1469
|
+
* This client provides access to Ory Keto's permission system through Omnibase's API,
|
|
1470
|
+
* allowing you to create, manage, and check relationships between subjects and objects.
|
|
1471
|
+
* It handles both read operations (permission checks) and write operations (relationship management).
|
|
1457
1472
|
*
|
|
1458
|
-
* The client automatically configures separate endpoints for read and write operations
|
|
1459
|
-
*
|
|
1473
|
+
* The client automatically configures separate endpoints for read and write operations:
|
|
1474
|
+
* - Read operations (permission checks): `/api/v1/permissions/read`
|
|
1475
|
+
* - Write operations (relationship management): `/api/v1/permissions/write`
|
|
1476
|
+
*
|
|
1477
|
+
* This separation optimizes performance and security by following Ory Keto's recommended architecture.
|
|
1460
1478
|
*
|
|
1461
1479
|
* @example
|
|
1462
|
-
*
|
|
1480
|
+
* Initialize the permissions client:
|
|
1463
1481
|
* ```typescript
|
|
1464
|
-
* import {
|
|
1482
|
+
* import { OmnibaseClient } from '@omnibase/core-js';
|
|
1483
|
+
*
|
|
1484
|
+
* const omnibase = new OmnibaseClient({
|
|
1485
|
+
* apiUrl: 'https://api.example.com'
|
|
1486
|
+
* });
|
|
1465
1487
|
*
|
|
1466
|
-
*
|
|
1488
|
+
* // Access permissions client
|
|
1489
|
+
* const permissions = omnibase.permissions;
|
|
1490
|
+
* ```
|
|
1467
1491
|
*
|
|
1492
|
+
* @example
|
|
1493
|
+
* Check if a user has permission:
|
|
1494
|
+
* ```typescript
|
|
1468
1495
|
* // Check if a user can view a tenant
|
|
1469
|
-
* const
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1475
|
-
* subjectId: 'user_456'
|
|
1476
|
-
* }
|
|
1477
|
-
* );
|
|
1496
|
+
* const result = await omnibase.permissions.permissions.checkPermission({
|
|
1497
|
+
* namespace: 'Tenant',
|
|
1498
|
+
* object: 'tenant_123',
|
|
1499
|
+
* relation: 'view',
|
|
1500
|
+
* subjectId: 'user_456'
|
|
1501
|
+
* });
|
|
1478
1502
|
*
|
|
1479
|
-
* if (
|
|
1503
|
+
* if (result.data.allowed) {
|
|
1480
1504
|
* console.log('User can view the tenant');
|
|
1481
1505
|
* }
|
|
1482
1506
|
* ```
|
|
1483
1507
|
*
|
|
1484
1508
|
* @example
|
|
1485
|
-
*
|
|
1509
|
+
* Create relationships:
|
|
1486
1510
|
* ```typescript
|
|
1487
|
-
* //
|
|
1488
|
-
* await
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
* subjectId: 'user_456'
|
|
1495
|
-
* }
|
|
1496
|
-
* );
|
|
1497
|
-
*
|
|
1498
|
-
* // Now the user has owner permissions on the tenant
|
|
1499
|
-
* console.log('User is now an owner of the tenant');
|
|
1511
|
+
* // Make a user an owner of a tenant
|
|
1512
|
+
* await omnibase.permissions.relationships.createRelationship({
|
|
1513
|
+
* namespace: 'Tenant',
|
|
1514
|
+
* object: 'tenant_123',
|
|
1515
|
+
* relation: 'owners',
|
|
1516
|
+
* subjectId: 'user_456'
|
|
1517
|
+
* });
|
|
1500
1518
|
* ```
|
|
1501
1519
|
*
|
|
1502
1520
|
* @example
|
|
1503
|
-
*
|
|
1521
|
+
* Query existing relationships:
|
|
1504
1522
|
* ```typescript
|
|
1505
|
-
*
|
|
1506
|
-
* const
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
* {
|
|
1512
|
-
* namespace: 'Tenant',
|
|
1513
|
-
* object: tenantId,
|
|
1514
|
-
* relation: 'admins',
|
|
1515
|
-
* subjectId: userId
|
|
1516
|
-
* }
|
|
1517
|
-
* );
|
|
1518
|
-
*
|
|
1519
|
-
* // Check if user can manage members (admins and owners can)
|
|
1520
|
-
* const canManageMembers = await permissionsClient.permissions.checkPermission(
|
|
1521
|
-
* undefined,
|
|
1522
|
-
* {
|
|
1523
|
-
* namespace: 'Tenant',
|
|
1524
|
-
* object: tenantId,
|
|
1525
|
-
* relation: 'manage_members',
|
|
1526
|
-
* subjectId: userId
|
|
1527
|
-
* }
|
|
1528
|
-
* );
|
|
1523
|
+
* // Get all members of a tenant
|
|
1524
|
+
* const relationships = await omnibase.permissions.relationships.getRelationships({
|
|
1525
|
+
* namespace: 'Tenant',
|
|
1526
|
+
* object: 'tenant_123',
|
|
1527
|
+
* relation: 'members'
|
|
1528
|
+
* });
|
|
1529
1529
|
*
|
|
1530
|
-
*
|
|
1531
|
-
*
|
|
1532
|
-
* console.log('User can manage tenant members');
|
|
1533
|
-
* }
|
|
1530
|
+
* console.log('Tenant members:', relationships.data.relation_tuples);
|
|
1531
|
+
* ```
|
|
1534
1532
|
*
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1544
|
-
* );
|
|
1533
|
+
* @example
|
|
1534
|
+
* Delete relationships:
|
|
1535
|
+
* ```typescript
|
|
1536
|
+
* // Remove a user from tenant admins
|
|
1537
|
+
* await omnibase.permissions.relationships.deleteRelationships({
|
|
1538
|
+
* namespace: 'Tenant',
|
|
1539
|
+
* object: 'tenant_123',
|
|
1540
|
+
* relation: 'admins',
|
|
1541
|
+
* subjectId: 'user_456'
|
|
1542
|
+
* });
|
|
1545
1543
|
* ```
|
|
1546
1544
|
*
|
|
1547
1545
|
* @since 1.0.0
|
|
@@ -1587,25 +1585,56 @@ declare class PermissionsClient {
|
|
|
1587
1585
|
* on an object. This API handles read operations and is optimized for fast
|
|
1588
1586
|
* permission checks in your application logic.
|
|
1589
1587
|
*
|
|
1588
|
+
* All operations are proxied through Omnibase's API at `/api/v1/permissions/read`.
|
|
1589
|
+
*
|
|
1590
1590
|
* Key methods:
|
|
1591
|
-
* - `checkPermission()` - Checks if a subject has permission on an object
|
|
1592
|
-
* - `checkPermissionOrError()` - Same as above but throws error if denied
|
|
1593
|
-
* - `expandPermissions()` - Expands relationships to show all granted permissions
|
|
1591
|
+
* - `checkPermission(params)` - Checks if a subject has permission on an object
|
|
1592
|
+
* - `checkPermissionOrError(params)` - Same as above but throws error if denied
|
|
1593
|
+
* - `expandPermissions(namespace, object, relation, maxDepth?)` - Expands relationships to show all granted permissions
|
|
1594
|
+
* - `postCheckPermission(maxDepth?, body)` - POST variant of permission check
|
|
1594
1595
|
*
|
|
1595
1596
|
* @example
|
|
1597
|
+
* Check a single permission:
|
|
1596
1598
|
* ```typescript
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1599
|
+
* const result = await omnibase.permissions.permissions.checkPermission({
|
|
1600
|
+
* namespace: 'Tenant',
|
|
1601
|
+
* object: 'tenant_123',
|
|
1602
|
+
* relation: 'view',
|
|
1603
|
+
* subjectId: 'user_456'
|
|
1604
|
+
* });
|
|
1605
|
+
*
|
|
1606
|
+
* if (result.data.allowed) {
|
|
1607
|
+
* console.log('User has permission');
|
|
1608
|
+
* }
|
|
1609
|
+
* ```
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* Expand permission tree:
|
|
1613
|
+
* ```typescript
|
|
1614
|
+
* const tree = await omnibase.permissions.permissions.expandPermissions(
|
|
1615
|
+
* 'Tenant',
|
|
1616
|
+
* 'tenant_123',
|
|
1617
|
+
* 'view'
|
|
1618
|
+
* );
|
|
1619
|
+
*
|
|
1620
|
+
* console.log('Permission tree:', tree.data);
|
|
1621
|
+
* ```
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* Check permission or throw error:
|
|
1625
|
+
* ```typescript
|
|
1626
|
+
* try {
|
|
1627
|
+
* await omnibase.permissions.permissions.checkPermissionOrError({
|
|
1601
1628
|
* namespace: 'Tenant',
|
|
1602
1629
|
* object: 'tenant_123',
|
|
1603
|
-
* relation: '
|
|
1630
|
+
* relation: 'edit',
|
|
1604
1631
|
* subjectId: 'user_456'
|
|
1605
|
-
* }
|
|
1606
|
-
*
|
|
1607
|
-
*
|
|
1608
|
-
*
|
|
1632
|
+
* });
|
|
1633
|
+
* // Permission granted
|
|
1634
|
+
* } catch (error) {
|
|
1635
|
+
* // Permission denied
|
|
1636
|
+
* console.error('Access denied');
|
|
1637
|
+
* }
|
|
1609
1638
|
* ```
|
|
1610
1639
|
*
|
|
1611
1640
|
* @since 1.0.0
|
|
@@ -1619,20 +1648,34 @@ declare class PermissionsClient {
|
|
|
1619
1648
|
* and managing role assignments. Works alongside the Keto-based
|
|
1620
1649
|
* permissions system to provide dynamic RBAC capabilities.
|
|
1621
1650
|
*
|
|
1651
|
+
* Roles are stored in the database and automatically synchronized with
|
|
1652
|
+
* Ory Keto relationships, providing a higher-level abstraction over
|
|
1653
|
+
* raw relationship tuples.
|
|
1654
|
+
*
|
|
1622
1655
|
* @example
|
|
1656
|
+
* Create a custom role:
|
|
1623
1657
|
* ```typescript
|
|
1624
|
-
* // Create a custom role
|
|
1625
1658
|
* const role = await omnibase.permissions.roles.create({
|
|
1626
1659
|
* role_name: 'billing_manager',
|
|
1627
1660
|
* permissions: ['tenant#manage_billing', 'tenant#view_invoices']
|
|
1628
1661
|
* });
|
|
1662
|
+
* ```
|
|
1629
1663
|
*
|
|
1630
|
-
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* Assign role to a user:
|
|
1666
|
+
* ```typescript
|
|
1631
1667
|
* await omnibase.permissions.roles.assign('user_123', {
|
|
1632
1668
|
* role_id: role.id
|
|
1633
1669
|
* });
|
|
1634
1670
|
* ```
|
|
1635
1671
|
*
|
|
1672
|
+
* @example
|
|
1673
|
+
* List all roles:
|
|
1674
|
+
* ```typescript
|
|
1675
|
+
* const roles = await omnibase.permissions.roles.list();
|
|
1676
|
+
* console.log('Available roles:', roles);
|
|
1677
|
+
* ```
|
|
1678
|
+
*
|
|
1636
1679
|
* @since 0.7.0
|
|
1637
1680
|
* @group Roles
|
|
1638
1681
|
*/
|
|
@@ -1641,19 +1684,43 @@ declare class PermissionsClient {
|
|
|
1641
1684
|
* Creates a new PermissionsClient instance
|
|
1642
1685
|
*
|
|
1643
1686
|
* Initializes the client with separate endpoints for read and write operations.
|
|
1644
|
-
* The client automatically
|
|
1645
|
-
*
|
|
1687
|
+
* The client automatically configures the Ory Keto client libraries to use
|
|
1688
|
+
* Omnibase's permission proxy endpoints:
|
|
1689
|
+
* - Write endpoint: `${apiBaseUrl}/api/v1/permissions/write`
|
|
1690
|
+
* - Read endpoint: `${apiBaseUrl}/api/v1/permissions/read`
|
|
1691
|
+
*
|
|
1692
|
+
* This separation follows Ory Keto's recommended architecture for optimal
|
|
1693
|
+
* performance and security.
|
|
1646
1694
|
*
|
|
1647
|
-
* @param apiBaseUrl - The base URL for your Omnibase API instance
|
|
1648
|
-
* @param client - The main OmnibaseClient instance (for roles handler)
|
|
1695
|
+
* @param apiBaseUrl - The base URL for your Omnibase API instance (e.g., 'https://api.example.com')
|
|
1696
|
+
* @param client - The main OmnibaseClient instance (required for roles handler)
|
|
1649
1697
|
*
|
|
1650
1698
|
* @throws {Error} When the base URL is invalid or cannot be reached
|
|
1651
1699
|
*
|
|
1652
1700
|
* @example
|
|
1701
|
+
* Direct instantiation (not recommended - use OmnibaseClient instead):
|
|
1653
1702
|
* ```typescript
|
|
1654
1703
|
* const client = new PermissionsClient('https://api.example.com', omnibaseClient);
|
|
1655
1704
|
* ```
|
|
1656
1705
|
*
|
|
1706
|
+
* @example
|
|
1707
|
+
* Recommended usage via OmnibaseClient:
|
|
1708
|
+
* ```typescript
|
|
1709
|
+
* import { OmnibaseClient } from '@omnibase/core-js';
|
|
1710
|
+
*
|
|
1711
|
+
* const omnibase = new OmnibaseClient({
|
|
1712
|
+
* apiUrl: 'https://api.example.com'
|
|
1713
|
+
* });
|
|
1714
|
+
*
|
|
1715
|
+
* // Use the permissions client
|
|
1716
|
+
* await omnibase.permissions.permissions.checkPermission({
|
|
1717
|
+
* namespace: 'Tenant',
|
|
1718
|
+
* object: 'tenant_123',
|
|
1719
|
+
* relation: 'view',
|
|
1720
|
+
* subjectId: 'user_456'
|
|
1721
|
+
* });
|
|
1722
|
+
* ```
|
|
1723
|
+
*
|
|
1657
1724
|
* @since 1.0.0
|
|
1658
1725
|
* @group Client
|
|
1659
1726
|
*/
|
|
@@ -2440,6 +2507,219 @@ declare class TenantManger {
|
|
|
2440
2507
|
switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
|
|
2441
2508
|
}
|
|
2442
2509
|
|
|
2510
|
+
/**
|
|
2511
|
+
* Active subscription data returned from the API
|
|
2512
|
+
*
|
|
2513
|
+
* Represents a tenant's active Stripe subscription with config-based price IDs
|
|
2514
|
+
* instead of raw Stripe IDs. Includes legacy price detection for historical
|
|
2515
|
+
* billing configurations.
|
|
2516
|
+
*
|
|
2517
|
+
* @example
|
|
2518
|
+
* ```typescript
|
|
2519
|
+
* const subscription: TenantSubscription = {
|
|
2520
|
+
* subscription_id: 'sub_1234567890',
|
|
2521
|
+
* config_price_id: 'price_pro_monthly',
|
|
2522
|
+
* status: 'active',
|
|
2523
|
+
* is_legacy_price: false,
|
|
2524
|
+
* current_period_end: 1735416000
|
|
2525
|
+
* };
|
|
2526
|
+
* ```
|
|
2527
|
+
*
|
|
2528
|
+
* @since 0.6.0
|
|
2529
|
+
* @public
|
|
2530
|
+
* @group Tenant Subscriptions
|
|
2531
|
+
*/
|
|
2532
|
+
type TenantSubscription = {
|
|
2533
|
+
/** Stripe subscription ID */
|
|
2534
|
+
subscription_id: string;
|
|
2535
|
+
/** Config-based price ID from your billing configuration */
|
|
2536
|
+
config_price_id: string;
|
|
2537
|
+
/** Subscription status (active, trialing, past_due) */
|
|
2538
|
+
status: string;
|
|
2539
|
+
/** Whether this price is from a legacy billing configuration */
|
|
2540
|
+
is_legacy_price: boolean;
|
|
2541
|
+
/** Unix timestamp when the current billing period ends */
|
|
2542
|
+
current_period_end: number;
|
|
2543
|
+
};
|
|
2544
|
+
/**
|
|
2545
|
+
* Response structure for getting active subscriptions
|
|
2546
|
+
*
|
|
2547
|
+
* @since 0.6.0
|
|
2548
|
+
* @public
|
|
2549
|
+
* @group Tenant Subscriptions
|
|
2550
|
+
*/
|
|
2551
|
+
type GetActiveSubscriptionsResponse = ApiResponse<TenantSubscription[]>;
|
|
2552
|
+
/**
|
|
2553
|
+
* Billing status information for a tenant
|
|
2554
|
+
*
|
|
2555
|
+
* Indicates whether the tenant has valid billing information configured
|
|
2556
|
+
* in their Stripe customer account.
|
|
2557
|
+
*
|
|
2558
|
+
* @example
|
|
2559
|
+
* ```typescript
|
|
2560
|
+
* const status: BillingStatus = {
|
|
2561
|
+
* has_billing_info: true,
|
|
2562
|
+
* is_active: true
|
|
2563
|
+
* };
|
|
2564
|
+
* ```
|
|
2565
|
+
*
|
|
2566
|
+
* @since 0.6.0
|
|
2567
|
+
* @public
|
|
2568
|
+
* @group Tenant Subscriptions
|
|
2569
|
+
*/
|
|
2570
|
+
type BillingStatus = {
|
|
2571
|
+
/** Whether the tenant has payment method(s) configured */
|
|
2572
|
+
has_billing_info: boolean;
|
|
2573
|
+
/** Whether the billing information is active and valid */
|
|
2574
|
+
is_active: boolean;
|
|
2575
|
+
};
|
|
2576
|
+
/**
|
|
2577
|
+
* Response structure for billing status check
|
|
2578
|
+
*
|
|
2579
|
+
* @since 0.6.0
|
|
2580
|
+
* @public
|
|
2581
|
+
* @group Tenant Subscriptions
|
|
2582
|
+
*/
|
|
2583
|
+
type GetBillingStatusResponse = ApiResponse<BillingStatus>;
|
|
2584
|
+
/**
|
|
2585
|
+
* Tenant subscription and billing management
|
|
2586
|
+
*
|
|
2587
|
+
* Provides access to the active tenant's Stripe subscriptions and billing
|
|
2588
|
+
* status. All operations are automatically scoped to the user's currently
|
|
2589
|
+
* active tenant via session authentication.
|
|
2590
|
+
*
|
|
2591
|
+
* Key features:
|
|
2592
|
+
* - View all active subscriptions with config-based price IDs
|
|
2593
|
+
* - Legacy price detection for historical billing configurations
|
|
2594
|
+
* - Billing status verification (payment method availability)
|
|
2595
|
+
* - Automatic tenant scoping via session context
|
|
2596
|
+
*
|
|
2597
|
+
* @example
|
|
2598
|
+
* ```typescript
|
|
2599
|
+
* const subscriptionManager = new TenantSubscriptionManager(omnibaseClient);
|
|
2600
|
+
*
|
|
2601
|
+
* // Get all active subscriptions for the current tenant
|
|
2602
|
+
* const subscriptions = await subscriptionManager.getActive();
|
|
2603
|
+
* console.log(`Active subscriptions: ${subscriptions.data.length}`);
|
|
2604
|
+
*
|
|
2605
|
+
* // Check if tenant has billing configured
|
|
2606
|
+
* const status = await subscriptionManager.getBillingStatus();
|
|
2607
|
+
* if (!status.data.has_billing_info) {
|
|
2608
|
+
* console.log('Please add a payment method');
|
|
2609
|
+
* }
|
|
2610
|
+
* ```
|
|
2611
|
+
*
|
|
2612
|
+
* @since 0.6.0
|
|
2613
|
+
* @public
|
|
2614
|
+
* @group Tenant Subscriptions
|
|
2615
|
+
*/
|
|
2616
|
+
declare class TenantSubscriptionManager {
|
|
2617
|
+
private omnibaseClient;
|
|
2618
|
+
/**
|
|
2619
|
+
* Creates a new TenantSubscriptionManager instance
|
|
2620
|
+
*
|
|
2621
|
+
* @param omnibaseClient - Configured Omnibase client instance
|
|
2622
|
+
*
|
|
2623
|
+
* @group Tenant Subscriptions
|
|
2624
|
+
*/
|
|
2625
|
+
constructor(omnibaseClient: OmnibaseClient);
|
|
2626
|
+
/**
|
|
2627
|
+
* Get all active subscriptions for the current tenant
|
|
2628
|
+
*
|
|
2629
|
+
* Retrieves all active Stripe subscriptions associated with the user's
|
|
2630
|
+
* currently active tenant. Returns subscriptions with config-based price IDs
|
|
2631
|
+
* instead of raw Stripe IDs, making it easier to match against your billing
|
|
2632
|
+
* configuration.
|
|
2633
|
+
*
|
|
2634
|
+
* The endpoint automatically:
|
|
2635
|
+
* - Fetches subscriptions from Stripe API
|
|
2636
|
+
* - Maps Stripe price IDs to your config price IDs
|
|
2637
|
+
* - Checks both current and historical price mappings
|
|
2638
|
+
* - Flags legacy prices from old billing configurations
|
|
2639
|
+
* - Filters to only active/trialing/past_due subscriptions
|
|
2640
|
+
*
|
|
2641
|
+
* Returns an empty array if:
|
|
2642
|
+
* - Tenant has no Stripe customer ID configured
|
|
2643
|
+
* - Tenant has no active subscriptions
|
|
2644
|
+
* - User is not authenticated
|
|
2645
|
+
*
|
|
2646
|
+
* @returns Promise resolving to array of active subscriptions
|
|
2647
|
+
*
|
|
2648
|
+
* @throws {Error} When the user is not authenticated
|
|
2649
|
+
* @throws {Error} When the API request fails due to network issues
|
|
2650
|
+
* @throws {Error} When the server returns an error response (4xx, 5xx)
|
|
2651
|
+
*
|
|
2652
|
+
* @example
|
|
2653
|
+
* ```typescript
|
|
2654
|
+
* const response = await subscriptionManager.getActive();
|
|
2655
|
+
*
|
|
2656
|
+
* if (response.data.length === 0) {
|
|
2657
|
+
* console.log('No active subscriptions');
|
|
2658
|
+
* } else {
|
|
2659
|
+
* response.data.forEach(sub => {
|
|
2660
|
+
* console.log(`Plan: ${sub.config_price_id}`);
|
|
2661
|
+
* console.log(`Status: ${sub.status}`);
|
|
2662
|
+
* if (sub.is_legacy_price) {
|
|
2663
|
+
* console.log('⚠️ Using legacy pricing');
|
|
2664
|
+
* }
|
|
2665
|
+
* });
|
|
2666
|
+
* }
|
|
2667
|
+
* ```
|
|
2668
|
+
*
|
|
2669
|
+
* @since 0.6.0
|
|
2670
|
+
* @public
|
|
2671
|
+
* @group Tenant Subscriptions
|
|
2672
|
+
*/
|
|
2673
|
+
getActive(): Promise<GetActiveSubscriptionsResponse>;
|
|
2674
|
+
/**
|
|
2675
|
+
* Check if the current tenant has billing information configured
|
|
2676
|
+
*
|
|
2677
|
+
* Verifies whether the tenant has valid payment methods attached to their
|
|
2678
|
+
* Stripe customer account. This is useful for:
|
|
2679
|
+
* - Showing billing setup prompts
|
|
2680
|
+
* - Gating premium features behind payment method requirement
|
|
2681
|
+
* - Displaying billing status indicators in UI
|
|
2682
|
+
* - Determining if customer portal access should be shown
|
|
2683
|
+
*
|
|
2684
|
+
* The check verifies:
|
|
2685
|
+
* - Default payment source (card, bank account, etc.)
|
|
2686
|
+
* - Default payment method in invoice settings
|
|
2687
|
+
* - Whether the payment method is valid and active
|
|
2688
|
+
*
|
|
2689
|
+
* Returns `false` if:
|
|
2690
|
+
* - Tenant has no Stripe customer ID
|
|
2691
|
+
* - No payment methods are configured
|
|
2692
|
+
* - User is not authenticated
|
|
2693
|
+
*
|
|
2694
|
+
* @returns Promise resolving to billing status information
|
|
2695
|
+
*
|
|
2696
|
+
* @throws {Error} When the user is not authenticated
|
|
2697
|
+
* @throws {Error} When the API request fails due to network issues
|
|
2698
|
+
* @throws {Error} When the server returns an error response (4xx, 5xx)
|
|
2699
|
+
*
|
|
2700
|
+
* @example
|
|
2701
|
+
* ```typescript
|
|
2702
|
+
* const response = await subscriptionManager.getBillingStatus();
|
|
2703
|
+
*
|
|
2704
|
+
* if (!response.data.has_billing_info) {
|
|
2705
|
+
* // Show billing setup prompt
|
|
2706
|
+
* showBillingSetupModal();
|
|
2707
|
+
* } else if (!response.data.is_active) {
|
|
2708
|
+
* // Payment method exists but may be expired/invalid
|
|
2709
|
+
* showPaymentMethodUpdatePrompt();
|
|
2710
|
+
* } else {
|
|
2711
|
+
* // All good - show customer portal link
|
|
2712
|
+
* showManageBillingButton();
|
|
2713
|
+
* }
|
|
2714
|
+
* ```
|
|
2715
|
+
*
|
|
2716
|
+
* @since 0.6.0
|
|
2717
|
+
* @public
|
|
2718
|
+
* @group Tenant Subscriptions
|
|
2719
|
+
*/
|
|
2720
|
+
getBillingStatus(): Promise<GetBillingStatusResponse>;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2443
2723
|
/**
|
|
2444
2724
|
* Response structure for a tenant user
|
|
2445
2725
|
*
|
|
@@ -2844,6 +3124,30 @@ declare class TenantHandler {
|
|
|
2844
3124
|
* ```
|
|
2845
3125
|
*/
|
|
2846
3126
|
readonly invites: TenantInviteManager;
|
|
3127
|
+
/**
|
|
3128
|
+
* Tenant subscription and billing management
|
|
3129
|
+
*
|
|
3130
|
+
* Provides access to subscription data and billing status for the
|
|
3131
|
+
* active tenant, including legacy price detection and payment method
|
|
3132
|
+
* verification. All operations are automatically scoped to the user's
|
|
3133
|
+
* currently active tenant.
|
|
3134
|
+
*
|
|
3135
|
+
* @example
|
|
3136
|
+
* ```typescript
|
|
3137
|
+
* // Get active subscriptions
|
|
3138
|
+
* const subs = await tenantHandler.subscriptions.getActive();
|
|
3139
|
+
*
|
|
3140
|
+
* // Check billing status
|
|
3141
|
+
* const status = await tenantHandler.subscriptions.getBillingStatus();
|
|
3142
|
+
* if (!status.data.has_billing_info) {
|
|
3143
|
+
* console.log('No payment method configured');
|
|
3144
|
+
* }
|
|
3145
|
+
* ```
|
|
3146
|
+
*
|
|
3147
|
+
* @since 0.6.0
|
|
3148
|
+
* @group Tenant Management
|
|
3149
|
+
*/
|
|
3150
|
+
readonly subscriptions: TenantSubscriptionManager;
|
|
2847
3151
|
}
|
|
2848
3152
|
|
|
2849
3153
|
type OmnibaseClientConfig = {
|
|
@@ -2980,4 +3284,4 @@ declare class OmnibaseClient {
|
|
|
2980
3284
|
fetch(endpoint: string, options?: RequestInit): Promise<Response>;
|
|
2981
3285
|
}
|
|
2982
3286
|
|
|
2983
|
-
export { type AssignRoleRequest as A, type CreateRoleRequest as C, CheckoutManager, type CheckoutOptions, ConfigManager, type CreateCheckoutResponse, type CreateCustomerPortalResponse, type DownloadResult as D, type NamespaceDefinition as N, type OmnibaseClientConfig as O, PermissionsClient as P, PaymentHandler, PortalManager, type PortalOptions, type Price, type PriceDisplay, type PriceLimit, type PriceUI, type Product, type ProductUI, type ProductWithPricingUI, RolesHandler as R, StorageClient as S, type StripeConfigResponse, type StripeConfiguration, TenantHandler as T, type Tier, type UpdateRoleRequest as U, UsageManager, type UsageOptions, type Role as a, type UploadOptions as b, type UploadResult as c, type AcceptTenantInviteRequest as d, type AcceptTenantInviteResponse as e, type CreateTenantUserInviteResponse as f, type TenantInvite as g, type CreateTenantUserInviteRequest as h, TenantInviteManager as i, type SwitchActiveTenantResponse as j, type DeleteTenantResponse as k, type CreateTenantResponse as l, type Tenant as m, type CreateTenantRequest as n, TenantManger as o,
|
|
3287
|
+
export { type AssignRoleRequest as A, type BillingStatus as B, type CreateRoleRequest as C, CheckoutManager, type CheckoutOptions, ConfigManager, type CreateCheckoutResponse, type CreateCustomerPortalResponse, type DownloadResult as D, type GetActiveSubscriptionsResponse as G, type NamespaceDefinition as N, type OmnibaseClientConfig as O, PermissionsClient as P, PaymentHandler, PortalManager, type PortalOptions, type Price, type PriceDisplay, type PriceLimit, type PriceUI, type Product, type ProductUI, type ProductWithPricingUI, RolesHandler as R, StorageClient as S, type StripeConfigResponse, type StripeConfiguration, TenantHandler as T, type Tier, type UpdateRoleRequest as U, UsageManager, type UsageOptions, type Role as a, type UploadOptions as b, type UploadResult as c, type AcceptTenantInviteRequest as d, type AcceptTenantInviteResponse as e, type CreateTenantUserInviteResponse as f, type TenantInvite as g, type CreateTenantUserInviteRequest as h, TenantInviteManager as i, type SwitchActiveTenantResponse as j, type DeleteTenantResponse as k, type CreateTenantResponse as l, type Tenant as m, type CreateTenantRequest as n, TenantManger as o, type TenantSubscription as p, type GetBillingStatusResponse as q, TenantSubscriptionManager as r, OmnibaseClient as s, type ApiResponse as t };
|