@omnibase/core-js 0.5.9 → 0.6.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.
@@ -1068,6 +1068,117 @@ declare class PaymentHandler {
1068
1068
  readonly usage: UsageManager;
1069
1069
  }
1070
1070
 
1071
+ interface UploadOptions {
1072
+ /**
1073
+ * Custom metadata to attach to the file
1074
+ * This will be stored in the JSONB metadata column
1075
+ */
1076
+ metadata?: Record<string, any>;
1077
+ }
1078
+ interface UploadResult {
1079
+ /**
1080
+ * Pre-signed URL for uploading the file
1081
+ */
1082
+ upload_url: string;
1083
+ /**
1084
+ * Full path where the file is stored
1085
+ */
1086
+ path: string;
1087
+ }
1088
+ interface DownloadResult {
1089
+ /**
1090
+ * Pre-signed URL for downloading the file
1091
+ */
1092
+ download_url: string;
1093
+ }
1094
+ /**
1095
+ * Storage client for file operations with path-based organization
1096
+ *
1097
+ * Users control the full file path and define RLS policies based on path patterns.
1098
+ * Common patterns:
1099
+ * - `public/*` - Public files
1100
+ * - `users/{user_id}/*` - User private files
1101
+ * - `teams/{team_id}/*` - Team shared files
1102
+ *
1103
+ * @example
1104
+ * ```typescript
1105
+ * const storage = omnibase.storage();
1106
+ *
1107
+ * // Upload to public directory
1108
+ * await storage.upload('public/images/avatar.png', file);
1109
+ *
1110
+ * // Upload to user private directory
1111
+ * await storage.upload('users/123/documents/report.pdf', file, {
1112
+ * metadata: {
1113
+ * department: 'engineering',
1114
+ * confidential: true
1115
+ * }
1116
+ * });
1117
+ *
1118
+ * // Download file
1119
+ * const { download_url } = await storage.download('public/images/avatar.png');
1120
+ *
1121
+ * // Delete file
1122
+ * await storage.delete('users/123/documents/report.pdf');
1123
+ * ```
1124
+ */
1125
+ declare class StorageClient {
1126
+ private client;
1127
+ constructor(client: OmnibaseClient);
1128
+ /**
1129
+ * Upload a file to storage
1130
+ *
1131
+ * @param path - Full path for the file (e.g., "public/images/avatar.png", "users/123/private/doc.pdf")
1132
+ * @param file - File or Blob to upload
1133
+ * @param options - Upload options including custom metadata
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * const result = await storage.upload(
1138
+ * 'public/avatars/user-123.png',
1139
+ * file,
1140
+ * {
1141
+ * metadata: {
1142
+ * userId: '123',
1143
+ * uploadedBy: 'john@example.com',
1144
+ * tags: ['profile', 'avatar']
1145
+ * }
1146
+ * }
1147
+ * );
1148
+ *
1149
+ * // File is automatically uploaded to S3 via the presigned URL
1150
+ * console.log('File uploaded to:', result.path);
1151
+ * ```
1152
+ */
1153
+ upload(path: string, file: File | Blob, options?: UploadOptions): Promise<UploadResult>;
1154
+ /**
1155
+ * Download a file from storage
1156
+ *
1157
+ * @param path - Full path to the file
1158
+ *
1159
+ * @example
1160
+ * ```typescript
1161
+ * const { download_url } = await storage.download('public/images/logo.png');
1162
+ *
1163
+ * // Download the file
1164
+ * const response = await fetch(download_url);
1165
+ * const blob = await response.blob();
1166
+ * ```
1167
+ */
1168
+ download(path: string): Promise<DownloadResult>;
1169
+ /**
1170
+ * Delete a file from storage
1171
+ *
1172
+ * @param path - Full path to the file
1173
+ *
1174
+ * @example
1175
+ * ```typescript
1176
+ * await storage.delete('users/123/documents/old-report.pdf');
1177
+ * ```
1178
+ */
1179
+ delete(path: string): Promise<void>;
1180
+ }
1181
+
1071
1182
  /**
1072
1183
  * Request data for accepting a tenant invitation
1073
1184
  *
@@ -1226,6 +1337,8 @@ type CreateTenantUserInviteRequest = {
1226
1337
  email: string;
1227
1338
  /** Role the invited user will have in the tenant */
1228
1339
  role: string;
1340
+ /** Invite URL - the link that will be sent to the users email suffixed automatically w/ ?token=XYZ */
1341
+ invite_url: string;
1229
1342
  };
1230
1343
  /**
1231
1344
  * Tenant invitation management handler
@@ -1401,7 +1514,7 @@ declare class TenantInviteManager {
1401
1514
  * @public
1402
1515
  * @group User Management
1403
1516
  */
1404
- create(tenantId: string, inviteData: CreateTenantUserInviteRequest): Promise<CreateTenantUserInviteResponse>;
1517
+ create(inviteData: CreateTenantUserInviteRequest): Promise<CreateTenantUserInviteResponse>;
1405
1518
  }
1406
1519
 
1407
1520
  /**
@@ -1645,10 +1758,6 @@ declare class TenantManger {
1645
1758
  * billing_email: 'billing@acme.com',
1646
1759
  * user_id: 'user_123'
1647
1760
  * });
1648
- *
1649
- * console.log(`Created tenant: ${newTenant.data.tenant.name}`);
1650
- * // Store the token for authenticated requests
1651
- * localStorage.setItem('tenant_token', newTenant.data.token);
1652
1761
  * ```
1653
1762
  *
1654
1763
  *
@@ -1796,6 +1905,195 @@ declare class TenantManger {
1796
1905
  switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
1797
1906
  }
1798
1907
 
1908
+ /**
1909
+ * Request parameters for updating a user's role within a tenant
1910
+ *
1911
+ * This interface defines the data required to change a user's role in the active tenant.
1912
+ * The operation requires appropriate permissions (typically admin or owner role) and will
1913
+ * fail if the requesting user doesn't have sufficient privileges.
1914
+ *
1915
+ * @example
1916
+ * ```typescript
1917
+ * const request: UpdateTenantUserRoleRequest = {
1918
+ * user_id: 'user_abc123',
1919
+ * role: 'admin'
1920
+ * };
1921
+ * ```
1922
+ *
1923
+ * @since 1.0.0
1924
+ * @public
1925
+ * @group Tenant User Management
1926
+ */
1927
+ type UpdateTenantUserRoleRequest = {
1928
+ /** New role to assign to the user (e.g., 'admin', 'member', 'viewer') */
1929
+ role: string;
1930
+ /** ID of the user whose role is being updated */
1931
+ user_id: string;
1932
+ };
1933
+ /**
1934
+ * Response from updating a user's role within a tenant
1935
+ *
1936
+ * This type represents the API response structure returned after successfully
1937
+ * updating a user's role in the tenant.
1938
+ *
1939
+ * @since 1.0.0
1940
+ * @public
1941
+ * @group Tenant User Management
1942
+ */
1943
+ type UpdateTenantUserRoleResponse = ApiResponse<{
1944
+ /** Confirmation message describing the role update */
1945
+ message: string;
1946
+ }>;
1947
+ /**
1948
+ * Request parameters for removing a user from a tenant
1949
+ *
1950
+ * This interface defines the data required to remove a user from the active tenant.
1951
+ * The operation requires appropriate permissions and will fail if the user doesn't
1952
+ * have the necessary rights to remove users from the tenant.
1953
+ *
1954
+ * @example
1955
+ * ```typescript
1956
+ * const request: RemoveUserRequest = {
1957
+ * user_id: 'user_abc123'
1958
+ * };
1959
+ * ```
1960
+ *
1961
+ * @since 1.0.0
1962
+ * @public
1963
+ * @group Tenant User Management
1964
+ */
1965
+ type RemoveUserRequest = {
1966
+ /** ID of the user being removed from the tenant */
1967
+ user_id: string;
1968
+ };
1969
+ /**
1970
+ * Manager for tenant user operations
1971
+ *
1972
+ * This class provides methods for managing users within a tenant, including
1973
+ * removing users from the active tenant. All operations are performed within
1974
+ * the context of the authenticated user and respect tenant-level permissions.
1975
+ *
1976
+ * User removal operations require appropriate permissions (typically admin or owner
1977
+ * role) and will fail if the requesting user doesn't have sufficient privileges.
1978
+ *
1979
+ * @example
1980
+ * ```typescript
1981
+ * import { OmnibaseClient } from '@omnibase/core-js';
1982
+ *
1983
+ * const client = new OmnibaseClient({ apiKey: 'your-api-key' });
1984
+ * const userManager = client.tenants.user;
1985
+ *
1986
+ * // Remove a user from the active tenant
1987
+ * await userManager.remove({ user_id: 'user_123' });
1988
+ * ```
1989
+ *
1990
+ * @since 1.0.0
1991
+ * @public
1992
+ * @group Tenant User Management
1993
+ */
1994
+ declare class TenantUserManager {
1995
+ private omnibaseClient;
1996
+ /**
1997
+ * Creates a new tenant user manager
1998
+ *
1999
+ * @param omnibaseClient - Configured OmnibaseClient instance for API communication
2000
+ *
2001
+ * @group Tenant User Management
2002
+ */
2003
+ constructor(omnibaseClient: OmnibaseClient);
2004
+ /**
2005
+ * Removes a user from the active tenant
2006
+ *
2007
+ * This method removes a specified user from the current active tenant. The operation
2008
+ * requires the requesting user to have appropriate permissions (admin or owner role).
2009
+ * The user being removed will lose access to the tenant and all its resources.
2010
+ *
2011
+ * Note: You cannot remove yourself from a tenant using this method. To leave a tenant,
2012
+ * use the appropriate leave or delete tenant operations instead.
2013
+ *
2014
+ * @param data - Request data containing the user ID to remove
2015
+ * @param data.user_id - ID of the user to remove from the tenant
2016
+ *
2017
+ * @returns Promise resolving to an API response confirming the removal
2018
+ *
2019
+ * @throws {Error} When user_id is not provided
2020
+ * @throws {Error} When the API request fails (includes status code and error details)
2021
+ * @throws {Error} When the user doesn't have permission to remove users
2022
+ * @throws {Error} When the specified user is not a member of the tenant
2023
+ *
2024
+ * @example
2025
+ * ```typescript
2026
+ * // Remove a user from the active tenant
2027
+ * try {
2028
+ * await userManager.remove({ user_id: 'user_abc123' });
2029
+ * console.log('User removed successfully');
2030
+ * } catch (error) {
2031
+ * if (error.message.includes('403')) {
2032
+ * console.error('Insufficient permissions to remove user');
2033
+ * } else if (error.message.includes('404')) {
2034
+ * console.error('User not found in tenant');
2035
+ * } else {
2036
+ * console.error('Failed to remove user:', error);
2037
+ * }
2038
+ * }
2039
+ * ```
2040
+ *
2041
+ * @since 1.0.0
2042
+ * @public
2043
+ * @group Tenant User Management
2044
+ */
2045
+ remove(data: RemoveUserRequest): Promise<ApiResponse<"">>;
2046
+ /**
2047
+ * Updates a user's role within the active tenant
2048
+ *
2049
+ * This method changes the role of a specified user in the current active tenant. The operation
2050
+ * requires the requesting user to have appropriate permissions (typically admin or owner role).
2051
+ * Role updates take effect immediately and affect the user's permissions and access rights
2052
+ * within the tenant.
2053
+ *
2054
+ * Common roles include 'admin', 'member', and 'viewer', but the exact roles available depend
2055
+ * on your tenant's configuration. Changing a user's role will modify their ability to perform
2056
+ * various operations within the tenant.
2057
+ *
2058
+ * @param data - Request data containing the user ID and new role
2059
+ * @param data.user_id - ID of the user whose role is being updated
2060
+ * @param data.role - New role to assign to the user
2061
+ *
2062
+ * @returns Promise resolving to an API response confirming the role update
2063
+ *
2064
+ * @throws {Error} When user_id or role is not provided
2065
+ * @throws {Error} When the API request fails (includes status code and error details)
2066
+ * @throws {Error} When the user doesn't have permission to update roles
2067
+ * @throws {Error} When the specified user is not a member of the tenant
2068
+ * @throws {Error} When the specified role is invalid or not allowed
2069
+ *
2070
+ * @example
2071
+ * ```typescript
2072
+ * // Update a user's role to admin
2073
+ * try {
2074
+ * const result = await userManager.updateRole({
2075
+ * user_id: 'user_abc123',
2076
+ * role: 'admin'
2077
+ * });
2078
+ * console.log('Role updated successfully:', result.data.message);
2079
+ * } catch (error) {
2080
+ * if (error.message.includes('403')) {
2081
+ * console.error('Insufficient permissions to update roles');
2082
+ * } else if (error.message.includes('404')) {
2083
+ * console.error('User not found in tenant');
2084
+ * } else {
2085
+ * console.error('Failed to update role:', error);
2086
+ * }
2087
+ * }
2088
+ * ```
2089
+ *
2090
+ * @since 1.0.0
2091
+ * @public
2092
+ * @group Tenant User Management
2093
+ */
2094
+ updateRole(data: UpdateTenantUserRoleRequest): Promise<UpdateTenantUserRoleResponse>;
2095
+ }
2096
+
1799
2097
  /**
1800
2098
  * Main tenant management handler
1801
2099
  *
@@ -1841,7 +2139,6 @@ declare class TenantManger {
1841
2139
  * @group Tenant Management
1842
2140
  */
1843
2141
  declare class TenantHandler {
1844
- private omnibaseClient;
1845
2142
  /**
1846
2143
  * Creates a new TenantHandler instance
1847
2144
  *
@@ -1863,6 +2160,23 @@ declare class TenantHandler {
1863
2160
  * @group Tenant Management
1864
2161
  */
1865
2162
  constructor(omnibaseClient: OmnibaseClient);
2163
+ /**
2164
+ * Tenant user management operations
2165
+ *
2166
+ * Provides access to operations for managing users within tenants, including
2167
+ * removing users from the active tenant. All operations respect user permissions
2168
+ * and tenant ownership rules.
2169
+ *
2170
+ * @example
2171
+ * ```typescript
2172
+ * // Remove a user from the active tenant
2173
+ * await tenantHandler.user.remove({ user_id: 'user_123' });
2174
+ * ```
2175
+ *
2176
+ * @since 1.0.0
2177
+ * @group Tenant Management
2178
+ */
2179
+ readonly user: TenantUserManager;
1866
2180
  /**
1867
2181
  * Core tenant management operations
1868
2182
  *
@@ -1943,7 +2257,21 @@ declare class OmnibaseClient {
1943
2257
  readonly payments: PaymentHandler;
1944
2258
  readonly tenants: TenantHandler;
1945
2259
  readonly permissions: PermissionsClient;
2260
+ /**
2261
+ * Storage client for file upload/download operations
2262
+ *
2263
+ * @example
2264
+ * ```typescript
2265
+ * // Upload with metadata
2266
+ * await omnibase.storage.bucket('documents').upload(
2267
+ * 'report.pdf',
2268
+ * file,
2269
+ * { metadata: { department: 'engineering' } }
2270
+ * );
2271
+ * ```
2272
+ */
2273
+ storage: StorageClient;
1946
2274
  fetch(endpoint: string, options?: RequestInit): Promise<Response>;
1947
2275
  }
1948
2276
 
1949
- export { type AcceptTenantInviteRequest as A, type CreateTenantUserInviteResponse as C, CheckoutManager, type CheckoutOptions, ConfigManager, type CreateCheckoutResponse, type CreateCustomerPortalResponse, type DeleteTenantResponse as D, type OmnibaseClientConfig as O, PaymentHandler, PortalManager, type PortalOptions, type Price, type PriceDisplay, type PriceLimit, type PriceUI, type Product, type ProductUI, type ProductWithPricingUI, type SwitchActiveTenantResponse as S, type StripeConfigResponse, type StripeConfiguration, TenantHandler as T, type Tier, UsageManager, type UsageOptions, type AcceptTenantInviteResponse as a, type TenantInvite as b, type CreateTenantUserInviteRequest as c, TenantInviteManager as d, type CreateTenantResponse as e, type Tenant as f, type CreateTenantRequest as g, TenantManger as h, OmnibaseClient as i, type ApiResponse as j };
2277
+ export { type AcceptTenantInviteRequest as A, type CreateTenantUserInviteResponse as C, CheckoutManager, type CheckoutOptions, ConfigManager, type CreateCheckoutResponse, type CreateCustomerPortalResponse, type DownloadResult as D, type OmnibaseClientConfig as O, PaymentHandler, PortalManager, type PortalOptions, type Price, type PriceDisplay, type PriceLimit, type PriceUI, type Product, type ProductUI, type ProductWithPricingUI, StorageClient as S, type StripeConfigResponse, type StripeConfiguration, TenantHandler as T, type Tier, type UploadOptions as U, UsageManager, type UsageOptions, type UploadResult as a, type AcceptTenantInviteResponse as b, type TenantInvite as c, type CreateTenantUserInviteRequest as d, TenantInviteManager as e, type SwitchActiveTenantResponse as f, type DeleteTenantResponse as g, type CreateTenantResponse as h, type Tenant as i, type CreateTenantRequest as j, TenantManger as k, OmnibaseClient as l, type ApiResponse as m };