@omnibase/core-js 0.7.3 → 0.7.5
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-DQBFDKRC.js +641 -0
- package/dist/chunk-V6HVRJCU.js +693 -0
- package/dist/index.cjs +61 -19
- package/dist/index.js +4 -4
- package/dist/payments/index.d.cts +87 -6
- package/dist/payments/index.d.ts +87 -6
- package/dist/tenants/index.cjs +61 -19
- package/dist/tenants/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1289,8 +1289,6 @@ var TenantManger = class {
|
|
|
1289
1289
|
* - Billing subscriptions are cancelled (if applicable)
|
|
1290
1290
|
* - Audit logs for deletion are maintained for compliance
|
|
1291
1291
|
*
|
|
1292
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
1293
|
-
*
|
|
1294
1292
|
* @returns Promise resolving to a confirmation message
|
|
1295
1293
|
*
|
|
1296
1294
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -1302,8 +1300,6 @@ var TenantManger = class {
|
|
|
1302
1300
|
*
|
|
1303
1301
|
* @example
|
|
1304
1302
|
* ```typescript
|
|
1305
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
1306
|
-
*
|
|
1307
1303
|
* // Always confirm before deleting
|
|
1308
1304
|
* const userConfirmed = confirm(
|
|
1309
1305
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -1311,7 +1307,7 @@ var TenantManger = class {
|
|
|
1311
1307
|
*
|
|
1312
1308
|
* if (userConfirmed) {
|
|
1313
1309
|
* try {
|
|
1314
|
-
* const result = await tenantManager.deleteTenant(
|
|
1310
|
+
* const result = await tenantManager.deleteTenant();
|
|
1315
1311
|
* console.log(result.data.message);
|
|
1316
1312
|
*
|
|
1317
1313
|
* // Redirect user away from deleted tenant
|
|
@@ -1326,21 +1322,15 @@ var TenantManger = class {
|
|
|
1326
1322
|
* @public
|
|
1327
1323
|
* @group Tenant Management
|
|
1328
1324
|
*/
|
|
1329
|
-
async deleteTenant(
|
|
1330
|
-
if (!tenantId) {
|
|
1331
|
-
throw new Error("Tenant ID is required");
|
|
1332
|
-
}
|
|
1325
|
+
async deleteTenant() {
|
|
1333
1326
|
try {
|
|
1334
|
-
const response = await this.omnibaseClient.fetch(
|
|
1335
|
-
|
|
1336
|
-
{
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
credentials: "include"
|
|
1342
|
-
}
|
|
1343
|
-
);
|
|
1327
|
+
const response = await this.omnibaseClient.fetch(`/api/v1/tenants`, {
|
|
1328
|
+
method: "DELETE",
|
|
1329
|
+
headers: {
|
|
1330
|
+
"Content-Type": "application/json"
|
|
1331
|
+
},
|
|
1332
|
+
credentials: "include"
|
|
1333
|
+
});
|
|
1344
1334
|
if (!response.ok) {
|
|
1345
1335
|
const errorData = await response.text();
|
|
1346
1336
|
throw new Error(
|
|
@@ -1445,6 +1435,58 @@ var TenantUserManager = class {
|
|
|
1445
1435
|
constructor(omnibaseClient) {
|
|
1446
1436
|
this.omnibaseClient = omnibaseClient;
|
|
1447
1437
|
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Retrieves all users in the active tenant
|
|
1440
|
+
*
|
|
1441
|
+
* This method fetches a list of all users who are members of the current active tenant,
|
|
1442
|
+
* including their basic information (name, email) and assigned role. The operation
|
|
1443
|
+
* requires the requesting user to have appropriate permissions to view tenant users
|
|
1444
|
+
* (typically requires `view_users` permission).
|
|
1445
|
+
*
|
|
1446
|
+
* The returned list includes all tenant members regardless of their role, ordered by
|
|
1447
|
+
* when they joined the tenant (newest first).
|
|
1448
|
+
*
|
|
1449
|
+
* @returns Promise resolving to an array of tenant users with their details
|
|
1450
|
+
*
|
|
1451
|
+
* @throws {Error} When the API request fails (includes status code and error details)
|
|
1452
|
+
* @throws {Error} When the user doesn't have permission to view users
|
|
1453
|
+
* @throws {Error} When the user is not authenticated or no active tenant is set
|
|
1454
|
+
*
|
|
1455
|
+
* @example
|
|
1456
|
+
* ```typescript
|
|
1457
|
+
* // Fetch all users in the active tenant
|
|
1458
|
+
* try {
|
|
1459
|
+
* const result = await userManager.getAll();
|
|
1460
|
+
* console.log(`Found ${result.data.length} users`);
|
|
1461
|
+
*
|
|
1462
|
+
* result.data.forEach(user => {
|
|
1463
|
+
* console.log(`${user.first_name} ${user.last_name} (${user.email}) - ${user.role}`);
|
|
1464
|
+
* });
|
|
1465
|
+
* } catch (error) {
|
|
1466
|
+
* if (error.message.includes('403')) {
|
|
1467
|
+
* console.error('Insufficient permissions to view users');
|
|
1468
|
+
* } else {
|
|
1469
|
+
* console.error('Failed to fetch users:', error);
|
|
1470
|
+
* }
|
|
1471
|
+
* }
|
|
1472
|
+
* ```
|
|
1473
|
+
*
|
|
1474
|
+
* @since 1.0.0
|
|
1475
|
+
* @public
|
|
1476
|
+
* @group Tenant User Management
|
|
1477
|
+
*/
|
|
1478
|
+
async getAll() {
|
|
1479
|
+
const response = await this.omnibaseClient.fetch("/api/v1/tenants/users", {
|
|
1480
|
+
method: "GET"
|
|
1481
|
+
});
|
|
1482
|
+
if (!response.ok) {
|
|
1483
|
+
const errorData = await response.text();
|
|
1484
|
+
throw new Error(
|
|
1485
|
+
`Failed to fetch tenant users: ${response.status} - ${errorData}`
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
return await response.json();
|
|
1489
|
+
}
|
|
1448
1490
|
/**
|
|
1449
1491
|
* Removes a user from the active tenant
|
|
1450
1492
|
*
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,15 @@ import {
|
|
|
2
2
|
PermissionsClient,
|
|
3
3
|
RolesHandler
|
|
4
4
|
} from "./chunk-V4FWENQQ.js";
|
|
5
|
-
import {
|
|
6
|
-
StorageClient
|
|
7
|
-
} from "./chunk-I6DMWC32.js";
|
|
8
5
|
import {
|
|
9
6
|
PaymentHandler
|
|
10
7
|
} from "./chunk-QPW6G4PA.js";
|
|
8
|
+
import {
|
|
9
|
+
StorageClient
|
|
10
|
+
} from "./chunk-I6DMWC32.js";
|
|
11
11
|
import {
|
|
12
12
|
TenantHandler
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-V6HVRJCU.js";
|
|
14
14
|
|
|
15
15
|
// src/client.ts
|
|
16
16
|
var OmnibaseClient = class {
|
|
@@ -2358,8 +2358,6 @@ declare class TenantManger {
|
|
|
2358
2358
|
* - Billing subscriptions are cancelled (if applicable)
|
|
2359
2359
|
* - Audit logs for deletion are maintained for compliance
|
|
2360
2360
|
*
|
|
2361
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
2362
|
-
*
|
|
2363
2361
|
* @returns Promise resolving to a confirmation message
|
|
2364
2362
|
*
|
|
2365
2363
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -2371,8 +2369,6 @@ declare class TenantManger {
|
|
|
2371
2369
|
*
|
|
2372
2370
|
* @example
|
|
2373
2371
|
* ```typescript
|
|
2374
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
2375
|
-
*
|
|
2376
2372
|
* // Always confirm before deleting
|
|
2377
2373
|
* const userConfirmed = confirm(
|
|
2378
2374
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -2380,7 +2376,7 @@ declare class TenantManger {
|
|
|
2380
2376
|
*
|
|
2381
2377
|
* if (userConfirmed) {
|
|
2382
2378
|
* try {
|
|
2383
|
-
* const result = await tenantManager.deleteTenant(
|
|
2379
|
+
* const result = await tenantManager.deleteTenant();
|
|
2384
2380
|
* console.log(result.data.message);
|
|
2385
2381
|
*
|
|
2386
2382
|
* // Redirect user away from deleted tenant
|
|
@@ -2395,7 +2391,7 @@ declare class TenantManger {
|
|
|
2395
2391
|
* @public
|
|
2396
2392
|
* @group Tenant Management
|
|
2397
2393
|
*/
|
|
2398
|
-
deleteTenant(
|
|
2394
|
+
deleteTenant(): Promise<DeleteTenantResponse>;
|
|
2399
2395
|
/**
|
|
2400
2396
|
* Switches the user's active tenant context
|
|
2401
2397
|
*
|
|
@@ -2444,6 +2440,50 @@ declare class TenantManger {
|
|
|
2444
2440
|
switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
|
|
2445
2441
|
}
|
|
2446
2442
|
|
|
2443
|
+
/**
|
|
2444
|
+
* Response structure for a tenant user
|
|
2445
|
+
*
|
|
2446
|
+
* Represents a user's information within a tenant, including their
|
|
2447
|
+
* identification details and assigned role.
|
|
2448
|
+
*
|
|
2449
|
+
* @example
|
|
2450
|
+
* ```typescript
|
|
2451
|
+
* const user: TenantUser = {
|
|
2452
|
+
* user_id: 'user_abc123',
|
|
2453
|
+
* first_name: 'John',
|
|
2454
|
+
* last_name: 'Doe',
|
|
2455
|
+
* email: 'john@example.com',
|
|
2456
|
+
* role: 'admin'
|
|
2457
|
+
* };
|
|
2458
|
+
* ```
|
|
2459
|
+
*
|
|
2460
|
+
* @since 1.0.0
|
|
2461
|
+
* @public
|
|
2462
|
+
* @group Tenant User Management
|
|
2463
|
+
*/
|
|
2464
|
+
type TenantUser = {
|
|
2465
|
+
/** Unique identifier for the user */
|
|
2466
|
+
user_id: string;
|
|
2467
|
+
/** User's first name */
|
|
2468
|
+
first_name: string;
|
|
2469
|
+
/** User's last name */
|
|
2470
|
+
last_name: string;
|
|
2471
|
+
/** User's email address */
|
|
2472
|
+
email: string;
|
|
2473
|
+
/** User's role within the tenant */
|
|
2474
|
+
role: string;
|
|
2475
|
+
};
|
|
2476
|
+
/**
|
|
2477
|
+
* Response from fetching all users in a tenant
|
|
2478
|
+
*
|
|
2479
|
+
* This type represents the API response structure returned when fetching
|
|
2480
|
+
* the list of all users in the active tenant.
|
|
2481
|
+
*
|
|
2482
|
+
* @since 1.0.0
|
|
2483
|
+
* @public
|
|
2484
|
+
* @group Tenant User Management
|
|
2485
|
+
*/
|
|
2486
|
+
type GetAllUsersResponse = ApiResponse<TenantUser[]>;
|
|
2447
2487
|
/**
|
|
2448
2488
|
* Request parameters for updating a user's role within a tenant
|
|
2449
2489
|
*
|
|
@@ -2540,6 +2580,47 @@ declare class TenantUserManager {
|
|
|
2540
2580
|
* @group Tenant User Management
|
|
2541
2581
|
*/
|
|
2542
2582
|
constructor(omnibaseClient: OmnibaseClient);
|
|
2583
|
+
/**
|
|
2584
|
+
* Retrieves all users in the active tenant
|
|
2585
|
+
*
|
|
2586
|
+
* This method fetches a list of all users who are members of the current active tenant,
|
|
2587
|
+
* including their basic information (name, email) and assigned role. The operation
|
|
2588
|
+
* requires the requesting user to have appropriate permissions to view tenant users
|
|
2589
|
+
* (typically requires `view_users` permission).
|
|
2590
|
+
*
|
|
2591
|
+
* The returned list includes all tenant members regardless of their role, ordered by
|
|
2592
|
+
* when they joined the tenant (newest first).
|
|
2593
|
+
*
|
|
2594
|
+
* @returns Promise resolving to an array of tenant users with their details
|
|
2595
|
+
*
|
|
2596
|
+
* @throws {Error} When the API request fails (includes status code and error details)
|
|
2597
|
+
* @throws {Error} When the user doesn't have permission to view users
|
|
2598
|
+
* @throws {Error} When the user is not authenticated or no active tenant is set
|
|
2599
|
+
*
|
|
2600
|
+
* @example
|
|
2601
|
+
* ```typescript
|
|
2602
|
+
* // Fetch all users in the active tenant
|
|
2603
|
+
* try {
|
|
2604
|
+
* const result = await userManager.getAll();
|
|
2605
|
+
* console.log(`Found ${result.data.length} users`);
|
|
2606
|
+
*
|
|
2607
|
+
* result.data.forEach(user => {
|
|
2608
|
+
* console.log(`${user.first_name} ${user.last_name} (${user.email}) - ${user.role}`);
|
|
2609
|
+
* });
|
|
2610
|
+
* } catch (error) {
|
|
2611
|
+
* if (error.message.includes('403')) {
|
|
2612
|
+
* console.error('Insufficient permissions to view users');
|
|
2613
|
+
* } else {
|
|
2614
|
+
* console.error('Failed to fetch users:', error);
|
|
2615
|
+
* }
|
|
2616
|
+
* }
|
|
2617
|
+
* ```
|
|
2618
|
+
*
|
|
2619
|
+
* @since 1.0.0
|
|
2620
|
+
* @public
|
|
2621
|
+
* @group Tenant User Management
|
|
2622
|
+
*/
|
|
2623
|
+
getAll(): Promise<GetAllUsersResponse>;
|
|
2543
2624
|
/**
|
|
2544
2625
|
* Removes a user from the active tenant
|
|
2545
2626
|
*
|
package/dist/payments/index.d.ts
CHANGED
|
@@ -2358,8 +2358,6 @@ declare class TenantManger {
|
|
|
2358
2358
|
* - Billing subscriptions are cancelled (if applicable)
|
|
2359
2359
|
* - Audit logs for deletion are maintained for compliance
|
|
2360
2360
|
*
|
|
2361
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
2362
|
-
*
|
|
2363
2361
|
* @returns Promise resolving to a confirmation message
|
|
2364
2362
|
*
|
|
2365
2363
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -2371,8 +2369,6 @@ declare class TenantManger {
|
|
|
2371
2369
|
*
|
|
2372
2370
|
* @example
|
|
2373
2371
|
* ```typescript
|
|
2374
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
2375
|
-
*
|
|
2376
2372
|
* // Always confirm before deleting
|
|
2377
2373
|
* const userConfirmed = confirm(
|
|
2378
2374
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -2380,7 +2376,7 @@ declare class TenantManger {
|
|
|
2380
2376
|
*
|
|
2381
2377
|
* if (userConfirmed) {
|
|
2382
2378
|
* try {
|
|
2383
|
-
* const result = await tenantManager.deleteTenant(
|
|
2379
|
+
* const result = await tenantManager.deleteTenant();
|
|
2384
2380
|
* console.log(result.data.message);
|
|
2385
2381
|
*
|
|
2386
2382
|
* // Redirect user away from deleted tenant
|
|
@@ -2395,7 +2391,7 @@ declare class TenantManger {
|
|
|
2395
2391
|
* @public
|
|
2396
2392
|
* @group Tenant Management
|
|
2397
2393
|
*/
|
|
2398
|
-
deleteTenant(
|
|
2394
|
+
deleteTenant(): Promise<DeleteTenantResponse>;
|
|
2399
2395
|
/**
|
|
2400
2396
|
* Switches the user's active tenant context
|
|
2401
2397
|
*
|
|
@@ -2444,6 +2440,50 @@ declare class TenantManger {
|
|
|
2444
2440
|
switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
|
|
2445
2441
|
}
|
|
2446
2442
|
|
|
2443
|
+
/**
|
|
2444
|
+
* Response structure for a tenant user
|
|
2445
|
+
*
|
|
2446
|
+
* Represents a user's information within a tenant, including their
|
|
2447
|
+
* identification details and assigned role.
|
|
2448
|
+
*
|
|
2449
|
+
* @example
|
|
2450
|
+
* ```typescript
|
|
2451
|
+
* const user: TenantUser = {
|
|
2452
|
+
* user_id: 'user_abc123',
|
|
2453
|
+
* first_name: 'John',
|
|
2454
|
+
* last_name: 'Doe',
|
|
2455
|
+
* email: 'john@example.com',
|
|
2456
|
+
* role: 'admin'
|
|
2457
|
+
* };
|
|
2458
|
+
* ```
|
|
2459
|
+
*
|
|
2460
|
+
* @since 1.0.0
|
|
2461
|
+
* @public
|
|
2462
|
+
* @group Tenant User Management
|
|
2463
|
+
*/
|
|
2464
|
+
type TenantUser = {
|
|
2465
|
+
/** Unique identifier for the user */
|
|
2466
|
+
user_id: string;
|
|
2467
|
+
/** User's first name */
|
|
2468
|
+
first_name: string;
|
|
2469
|
+
/** User's last name */
|
|
2470
|
+
last_name: string;
|
|
2471
|
+
/** User's email address */
|
|
2472
|
+
email: string;
|
|
2473
|
+
/** User's role within the tenant */
|
|
2474
|
+
role: string;
|
|
2475
|
+
};
|
|
2476
|
+
/**
|
|
2477
|
+
* Response from fetching all users in a tenant
|
|
2478
|
+
*
|
|
2479
|
+
* This type represents the API response structure returned when fetching
|
|
2480
|
+
* the list of all users in the active tenant.
|
|
2481
|
+
*
|
|
2482
|
+
* @since 1.0.0
|
|
2483
|
+
* @public
|
|
2484
|
+
* @group Tenant User Management
|
|
2485
|
+
*/
|
|
2486
|
+
type GetAllUsersResponse = ApiResponse<TenantUser[]>;
|
|
2447
2487
|
/**
|
|
2448
2488
|
* Request parameters for updating a user's role within a tenant
|
|
2449
2489
|
*
|
|
@@ -2540,6 +2580,47 @@ declare class TenantUserManager {
|
|
|
2540
2580
|
* @group Tenant User Management
|
|
2541
2581
|
*/
|
|
2542
2582
|
constructor(omnibaseClient: OmnibaseClient);
|
|
2583
|
+
/**
|
|
2584
|
+
* Retrieves all users in the active tenant
|
|
2585
|
+
*
|
|
2586
|
+
* This method fetches a list of all users who are members of the current active tenant,
|
|
2587
|
+
* including their basic information (name, email) and assigned role. The operation
|
|
2588
|
+
* requires the requesting user to have appropriate permissions to view tenant users
|
|
2589
|
+
* (typically requires `view_users` permission).
|
|
2590
|
+
*
|
|
2591
|
+
* The returned list includes all tenant members regardless of their role, ordered by
|
|
2592
|
+
* when they joined the tenant (newest first).
|
|
2593
|
+
*
|
|
2594
|
+
* @returns Promise resolving to an array of tenant users with their details
|
|
2595
|
+
*
|
|
2596
|
+
* @throws {Error} When the API request fails (includes status code and error details)
|
|
2597
|
+
* @throws {Error} When the user doesn't have permission to view users
|
|
2598
|
+
* @throws {Error} When the user is not authenticated or no active tenant is set
|
|
2599
|
+
*
|
|
2600
|
+
* @example
|
|
2601
|
+
* ```typescript
|
|
2602
|
+
* // Fetch all users in the active tenant
|
|
2603
|
+
* try {
|
|
2604
|
+
* const result = await userManager.getAll();
|
|
2605
|
+
* console.log(`Found ${result.data.length} users`);
|
|
2606
|
+
*
|
|
2607
|
+
* result.data.forEach(user => {
|
|
2608
|
+
* console.log(`${user.first_name} ${user.last_name} (${user.email}) - ${user.role}`);
|
|
2609
|
+
* });
|
|
2610
|
+
* } catch (error) {
|
|
2611
|
+
* if (error.message.includes('403')) {
|
|
2612
|
+
* console.error('Insufficient permissions to view users');
|
|
2613
|
+
* } else {
|
|
2614
|
+
* console.error('Failed to fetch users:', error);
|
|
2615
|
+
* }
|
|
2616
|
+
* }
|
|
2617
|
+
* ```
|
|
2618
|
+
*
|
|
2619
|
+
* @since 1.0.0
|
|
2620
|
+
* @public
|
|
2621
|
+
* @group Tenant User Management
|
|
2622
|
+
*/
|
|
2623
|
+
getAll(): Promise<GetAllUsersResponse>;
|
|
2543
2624
|
/**
|
|
2544
2625
|
* Removes a user from the active tenant
|
|
2545
2626
|
*
|
package/dist/tenants/index.cjs
CHANGED
|
@@ -303,8 +303,6 @@ var TenantManger = class {
|
|
|
303
303
|
* - Billing subscriptions are cancelled (if applicable)
|
|
304
304
|
* - Audit logs for deletion are maintained for compliance
|
|
305
305
|
*
|
|
306
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
307
|
-
*
|
|
308
306
|
* @returns Promise resolving to a confirmation message
|
|
309
307
|
*
|
|
310
308
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -316,8 +314,6 @@ var TenantManger = class {
|
|
|
316
314
|
*
|
|
317
315
|
* @example
|
|
318
316
|
* ```typescript
|
|
319
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
320
|
-
*
|
|
321
317
|
* // Always confirm before deleting
|
|
322
318
|
* const userConfirmed = confirm(
|
|
323
319
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -325,7 +321,7 @@ var TenantManger = class {
|
|
|
325
321
|
*
|
|
326
322
|
* if (userConfirmed) {
|
|
327
323
|
* try {
|
|
328
|
-
* const result = await tenantManager.deleteTenant(
|
|
324
|
+
* const result = await tenantManager.deleteTenant();
|
|
329
325
|
* console.log(result.data.message);
|
|
330
326
|
*
|
|
331
327
|
* // Redirect user away from deleted tenant
|
|
@@ -340,21 +336,15 @@ var TenantManger = class {
|
|
|
340
336
|
* @public
|
|
341
337
|
* @group Tenant Management
|
|
342
338
|
*/
|
|
343
|
-
async deleteTenant(
|
|
344
|
-
if (!tenantId) {
|
|
345
|
-
throw new Error("Tenant ID is required");
|
|
346
|
-
}
|
|
339
|
+
async deleteTenant() {
|
|
347
340
|
try {
|
|
348
|
-
const response = await this.omnibaseClient.fetch(
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
credentials: "include"
|
|
356
|
-
}
|
|
357
|
-
);
|
|
341
|
+
const response = await this.omnibaseClient.fetch(`/api/v1/tenants`, {
|
|
342
|
+
method: "DELETE",
|
|
343
|
+
headers: {
|
|
344
|
+
"Content-Type": "application/json"
|
|
345
|
+
},
|
|
346
|
+
credentials: "include"
|
|
347
|
+
});
|
|
358
348
|
if (!response.ok) {
|
|
359
349
|
const errorData = await response.text();
|
|
360
350
|
throw new Error(
|
|
@@ -459,6 +449,58 @@ var TenantUserManager = class {
|
|
|
459
449
|
constructor(omnibaseClient) {
|
|
460
450
|
this.omnibaseClient = omnibaseClient;
|
|
461
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Retrieves all users in the active tenant
|
|
454
|
+
*
|
|
455
|
+
* This method fetches a list of all users who are members of the current active tenant,
|
|
456
|
+
* including their basic information (name, email) and assigned role. The operation
|
|
457
|
+
* requires the requesting user to have appropriate permissions to view tenant users
|
|
458
|
+
* (typically requires `view_users` permission).
|
|
459
|
+
*
|
|
460
|
+
* The returned list includes all tenant members regardless of their role, ordered by
|
|
461
|
+
* when they joined the tenant (newest first).
|
|
462
|
+
*
|
|
463
|
+
* @returns Promise resolving to an array of tenant users with their details
|
|
464
|
+
*
|
|
465
|
+
* @throws {Error} When the API request fails (includes status code and error details)
|
|
466
|
+
* @throws {Error} When the user doesn't have permission to view users
|
|
467
|
+
* @throws {Error} When the user is not authenticated or no active tenant is set
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* // Fetch all users in the active tenant
|
|
472
|
+
* try {
|
|
473
|
+
* const result = await userManager.getAll();
|
|
474
|
+
* console.log(`Found ${result.data.length} users`);
|
|
475
|
+
*
|
|
476
|
+
* result.data.forEach(user => {
|
|
477
|
+
* console.log(`${user.first_name} ${user.last_name} (${user.email}) - ${user.role}`);
|
|
478
|
+
* });
|
|
479
|
+
* } catch (error) {
|
|
480
|
+
* if (error.message.includes('403')) {
|
|
481
|
+
* console.error('Insufficient permissions to view users');
|
|
482
|
+
* } else {
|
|
483
|
+
* console.error('Failed to fetch users:', error);
|
|
484
|
+
* }
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*
|
|
488
|
+
* @since 1.0.0
|
|
489
|
+
* @public
|
|
490
|
+
* @group Tenant User Management
|
|
491
|
+
*/
|
|
492
|
+
async getAll() {
|
|
493
|
+
const response = await this.omnibaseClient.fetch("/api/v1/tenants/users", {
|
|
494
|
+
method: "GET"
|
|
495
|
+
});
|
|
496
|
+
if (!response.ok) {
|
|
497
|
+
const errorData = await response.text();
|
|
498
|
+
throw new Error(
|
|
499
|
+
`Failed to fetch tenant users: ${response.status} - ${errorData}`
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
return await response.json();
|
|
503
|
+
}
|
|
462
504
|
/**
|
|
463
505
|
* Removes a user from the active tenant
|
|
464
506
|
*
|
package/dist/tenants/index.js
CHANGED