@omnibase/core-js 0.5.10 → 0.7.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.
@@ -28,7 +28,7 @@ import '@ory/client';
28
28
  * };
29
29
  * ```
30
30
  *
31
- * @since 1.0.0
31
+ * @since 0.6.0
32
32
  * @public
33
33
  */
34
34
  type ApiResponse<T> = {
@@ -53,20 +53,20 @@ type ApiResponse<T> = {
53
53
  * Configuration options for creating a Stripe checkout session
54
54
  *
55
55
  * Defines all parameters needed to create a checkout session for either
56
- * one-time payments or subscription billing. The session will redirect
57
- * users to Stripe's hosted checkout page.
56
+ * one-time payments or subscription billing. The checkout mode (payment vs
57
+ * subscription) is automatically determined by examining the price configuration
58
+ * - no need to specify it manually.
58
59
  *
59
60
  * @example
60
61
  * ```typescript
61
62
  * const options: CheckoutOptions = {
62
- * price_id: 'price_1234567890',
63
- * mode: 'subscription',
63
+ * price_id: 'price_monthly_pro',
64
64
  * success_url: 'https://app.com/success?session_id={CHECKOUT_SESSION_ID}',
65
65
  * cancel_url: 'https://app.com/pricing',
66
66
  * };
67
67
  * ```
68
68
  *
69
- * @since 1.0.0
69
+ * @since 0.6.0
70
70
  * @public
71
71
  * @group Checkout
72
72
  */
@@ -87,7 +87,7 @@ type CheckoutOptions = {
87
87
  * Contains the checkout session URL and ID for redirecting users
88
88
  * to Stripe's hosted checkout page and tracking the session.
89
89
  *
90
- * @since 1.0.0
90
+ * @since 0.6.0
91
91
  * @public
92
92
  * @group Checkout
93
93
  */
@@ -101,17 +101,18 @@ type CreateCheckoutResponse = ApiResponse<{
101
101
  * Manager for Stripe checkout session operations
102
102
  *
103
103
  * Handles creation and management of Stripe checkout sessions for both
104
- * one-time payments and subscription billing. Provides a simple interface
105
- * for redirecting users to Stripe's hosted checkout experience.
104
+ * one-time payments and subscription billing. The checkout mode is automatically
105
+ * determined by examining whether the price has a recurring interval - recurring
106
+ * prices create subscription checkouts, while non-recurring prices create one-time
107
+ * payment checkouts.
106
108
  *
107
- * Checkout sessions are the recommended way to accept payments as they
108
- * provide a secure, PCI-compliant payment flow without requiring
109
- * sensitive payment data to touch your servers.
109
+ * Checkout sessions provide a secure, PCI-compliant payment flow without requiring
110
+ * sensitive payment data to touch your servers. The API automatically fetches the
111
+ * price details from Stripe to determine the appropriate checkout mode.
110
112
  *
111
113
  * @example
112
- * Creating a checkout session (mode auto-detected from price):
113
114
  * ```typescript
114
- * const checkoutManager = new CheckoutManager(paymentHandler);
115
+ * const checkoutManager = new CheckoutManager(omnibaseClient);
115
116
  *
116
117
  * const session = await checkoutManager.createSession({
117
118
  * price_id: 'price_monthly_pro',
@@ -123,7 +124,7 @@ type CreateCheckoutResponse = ApiResponse<{
123
124
  * window.location.href = session.data.url;
124
125
  * ```
125
126
  *
126
- * @since 1.0.0
127
+ * @since 0.6.0
127
128
  * @public
128
129
  * @group Checkout
129
130
  */
@@ -157,31 +158,20 @@ declare class CheckoutManager {
157
158
  * @throws {ValidationError} When required parameters are missing or invalid
158
159
  *
159
160
  * @example
160
- * Creating a checkout session (mode is auto-detected):
161
161
  * ```typescript
162
162
  * const session = await checkoutManager.createSession({
163
- * price_id: 'price_one_time_product',
163
+ * price_id: 'price_monthly_pro',
164
164
  * success_url: 'https://app.com/success',
165
165
  * cancel_url: 'https://app.com/cancel'
166
166
  * });
167
167
  *
168
168
  * // Redirect to Stripe checkout
169
- * window.location.href = session.data.url;
170
- * ```
171
- *
172
- * @example
173
- * Checkout with session tracking:
174
- * ```typescript
175
- * const session = await checkoutManager.createSession({
176
- * price_id: 'price_monthly_plan',
177
- * success_url: 'https://app.com/dashboard?session_id={CHECKOUT_SESSION_ID}',
178
- * cancel_url: 'https://app.com/pricing',
179
- * });
180
- *
181
- * console.log(`Session created: ${session.data.sessionId}`);
169
+ * if (session.data?.url) {
170
+ * window.location.href = session.data.url;
171
+ * }
182
172
  * ```
183
173
  *
184
- * @since 1.0.0
174
+ * @since 0.6.0
185
175
  * @group Checkout
186
176
  */
187
177
  createSession(options: CheckoutOptions): Promise<CreateCheckoutResponse>;
@@ -194,7 +184,7 @@ declare class CheckoutManager {
194
184
  * and UI customization settings. This represents the complete billing
195
185
  * configuration loaded from the database.
196
186
  *
197
- * @since 1.0.0
187
+ * @since 0.6.0
198
188
  * @public
199
189
  * @group Configuration
200
190
  */
@@ -227,7 +217,7 @@ type StripeConfigResponse = ApiResponse<{
227
217
  * };
228
218
  * ```
229
219
  *
230
- * @since 1.0.0
220
+ * @since 0.6.0
231
221
  * @public
232
222
  * @group Configuration
233
223
  */
@@ -264,7 +254,7 @@ interface StripeConfiguration {
264
254
  * };
265
255
  * ```
266
256
  *
267
- * @since 1.0.0
257
+ * @since 0.6.0
268
258
  * @public
269
259
  * @group Configuration
270
260
  */
@@ -322,7 +312,7 @@ interface Product {
322
312
  * };
323
313
  * ```
324
314
  *
325
- * @since 1.0.0
315
+ * @since 0.6.0
326
316
  * @public
327
317
  * @group Configuration
328
318
  */
@@ -387,7 +377,7 @@ interface Price {
387
377
  * ];
388
378
  * ```
389
379
  *
390
- * @since 1.0.0
380
+ * @since 0.6.0
391
381
  * @public
392
382
  * @group Configuration
393
383
  */
@@ -427,7 +417,7 @@ interface Tier {
427
417
  * };
428
418
  * ```
429
419
  *
430
- * @since 1.0.0
420
+ * @since 0.6.0
431
421
  * @public
432
422
  * @group UI Configuration
433
423
  */
@@ -470,7 +460,7 @@ interface ProductUI {
470
460
  * };
471
461
  * ```
472
462
  *
473
- * @since 1.0.0
463
+ * @since 0.6.0
474
464
  * @public
475
465
  * @group UI Configuration
476
466
  */
@@ -501,7 +491,7 @@ interface PriceUI {
501
491
  * };
502
492
  * ```
503
493
  *
504
- * @since 1.0.0
494
+ * @since 0.6.0
505
495
  * @public
506
496
  * @group UI Configuration
507
497
  */
@@ -534,7 +524,7 @@ interface PriceDisplay {
534
524
  * ];
535
525
  * ```
536
526
  *
537
- * @since 1.0.0
527
+ * @since 0.6.0
538
528
  * @public
539
529
  * @group UI Configuration
540
530
  */
@@ -571,7 +561,7 @@ interface PriceLimit {
571
561
  * });
572
562
  * ```
573
563
  *
574
- * @since 1.0.0
564
+ * @since 0.6.0
575
565
  * @public
576
566
  * @group UI Configuration
577
567
  */
@@ -706,7 +696,7 @@ declare class ConfigManager {
706
696
  * };
707
697
  * ```
708
698
  *
709
- * @since 1.0.0
699
+ * @since 0.6.0
710
700
  * @public
711
701
  * @group Portal
712
702
  */
@@ -721,7 +711,7 @@ type PortalOptions = {
721
711
  * Stripe's hosted customer portal where they can manage their
722
712
  * billing and subscription settings.
723
713
  *
724
- * @since 1.0.0
714
+ * @since 0.6.0
725
715
  * @public
726
716
  * @group Portal
727
717
  */
@@ -741,9 +731,8 @@ type CreateCustomerPortalResponse = ApiResponse<{
741
731
  * billing tasks independently.
742
732
  *
743
733
  * @example
744
- * Creating a customer portal session:
745
734
  * ```typescript
746
- * const portalManager = new PortalManager(paymentHandler);
735
+ * const portalManager = new PortalManager(omnibaseClient);
747
736
  *
748
737
  * const portal = await portalManager.create({
749
738
  * return_url: 'https://app.com/billing'
@@ -753,7 +742,7 @@ type CreateCustomerPortalResponse = ApiResponse<{
753
742
  * window.location.href = portal.data.url;
754
743
  * ```
755
744
  *
756
- * @since 1.0.0
745
+ * @since 0.6.0
757
746
  * @public
758
747
  * @group Portal
759
748
  */
@@ -762,7 +751,7 @@ declare class PortalManager {
762
751
  /**
763
752
  * Initialize the portal manager
764
753
  *
765
- * @param paymentHandler - Payment handler instance for API communication
754
+ * @param omnibaseClient - OmnibaseClient instance for API communication
766
755
  *
767
756
  * @group Portal
768
757
  */
@@ -787,32 +776,18 @@ declare class PortalManager {
787
776
  * @throws {ValidationError} When required parameters are missing or invalid
788
777
  *
789
778
  * @example
790
- * Basic portal creation:
791
779
  * ```typescript
792
780
  * const portal = await portalManager.create({
793
781
  * return_url: 'https://myapp.com/account/billing'
794
782
  * });
795
783
  *
796
784
  * // Redirect user to portal
797
- * window.location.href = portal.data.url;
798
- * ```
799
- *
800
- * @example
801
- * With error handling:
802
- * ```typescript
803
- * try {
804
- * const portal = await portalManager.create({
805
- * return_url: window.location.origin + '/billing'
806
- * });
807
- *
785
+ * if (portal.data?.url) {
808
786
  * window.location.href = portal.data.url;
809
- * } catch (error) {
810
- * console.error('Failed to create portal session:', error);
811
- * showErrorMessage('Unable to access billing portal. Please try again.');
812
787
  * }
813
788
  * ```
814
789
  *
815
- * @since 1.0.0
790
+ * @since 0.6.0
816
791
  * @group Portal
817
792
  */
818
793
  create(options: PortalOptions): Promise<CreateCustomerPortalResponse>;
@@ -833,7 +808,7 @@ declare class PortalManager {
833
808
  * };
834
809
  * ```
835
810
  *
836
- * @since 1.0.0
811
+ * @since 0.6.0
837
812
  * @public
838
813
  * @group Usage
839
814
  */
@@ -860,9 +835,8 @@ type UsageOptions = {
860
835
  * transparency to customers about their consumption patterns.
861
836
  *
862
837
  * @example
863
- * Recording API usage:
864
838
  * ```typescript
865
- * const usageManager = new UsageManager(paymentHandler);
839
+ * const usageManager = new UsageManager(omnibaseClient);
866
840
  *
867
841
  * // Record a single API call
868
842
  * await usageManager.recordUsage({
@@ -877,7 +851,7 @@ type UsageOptions = {
877
851
  * });
878
852
  * ```
879
853
  *
880
- * @since 1.0.0
854
+ * @since 0.6.0
881
855
  * @public
882
856
  * @group Usage
883
857
  */
@@ -886,7 +860,7 @@ declare class UsageManager {
886
860
  /**
887
861
  * Initialize the usage manager
888
862
  *
889
- * @param paymentHandler - Payment handler instance for API communication
863
+ * @param omnibaseClient - OmnibaseClient instance for API communication
890
864
  *
891
865
  * @group Usage
892
866
  */
@@ -913,7 +887,6 @@ declare class UsageManager {
913
887
  * @throws {ValidationError} When required parameters are missing or invalid
914
888
  *
915
889
  * @example
916
- * API call tracking:
917
890
  * ```typescript
918
891
  * // Record each API call
919
892
  * await usageManager.recordUsage({
@@ -922,37 +895,7 @@ declare class UsageManager {
922
895
  * });
923
896
  * ```
924
897
  *
925
- * @example
926
- * Batch usage recording:
927
- * ```typescript
928
- * // Record multiple operations at once
929
- * const usageEvents = [
930
- * { meter_event_name: 'compute_hours', value: '0.5' },
931
- * { meter_event_name: 'storage_gb', value: '10' },
932
- * { meter_event_name: 'api_calls', value: '50' }
933
- * ];
934
- *
935
- * for (const event of usageEvents) {
936
- * await usageManager.recordUsage(event);
937
- * }
938
- * ```
939
- *
940
- * @example
941
- * With error handling:
942
- * ```typescript
943
- * try {
944
- * await usageManager.recordUsage({
945
- * meter_event_name: 'file_uploads',
946
- * value: String(uploadedFiles.length)
947
- * });
948
- * } catch (error) {
949
- * console.error('Failed to record usage:', error);
950
- * // Usage recording failure shouldn't block user operations
951
- * // but should be logged for billing accuracy
952
- * }
953
- * ```
954
- *
955
- * @since 1.0.0
898
+ * @since 0.6.0
956
899
  * @group Usage
957
900
  */
958
901
  recordUsage(options: UsageOptions): Promise<ApiResponse<"">>;
@@ -963,19 +906,20 @@ declare class UsageManager {
963
906
  *
964
907
  * This class serves as the central coordinator for all payment functionality,
965
908
  * providing access to checkout sessions, billing configuration, customer portals,
966
- * and usage tracking. It handles the low-level HTTP communication with the
967
- * payment API and delegates specific operations to specialized managers.
909
+ * and usage tracking. It delegates specific operations to specialized managers
910
+ * that handle checkout, configuration, portal, and usage operations.
968
911
  *
969
- * The handler automatically manages authentication, request formatting, and
970
- * provides a consistent interface across all payment operations.
912
+ * The handler provides a consistent interface across all payment operations,
913
+ * with automatic checkout mode detection (subscription vs one-time payment)
914
+ * based on the price configuration retrieved from Stripe.
971
915
  *
972
916
  * @example
973
917
  * ```typescript
974
- * const paymentHandler = new PaymentHandler('https://api.example.com');
918
+ * const paymentHandler = new PaymentHandler(omnibaseClient);
975
919
  *
976
920
  * // Create a checkout session (mode auto-detected from price)
977
921
  * const checkout = await paymentHandler.checkout.createSession({
978
- * price_id: 'price_123',
922
+ * price_id: 'price_monthly_pro',
979
923
  * success_url: 'https://app.com/success',
980
924
  * cancel_url: 'https://app.com/cancel'
981
925
  * });
@@ -984,27 +928,27 @@ declare class UsageManager {
984
928
  * const products = await paymentHandler.config.getAvailableProducts();
985
929
  * ```
986
930
  *
987
- * @since 1.0.0
931
+ * @since 0.6.0
988
932
  * @public
989
933
  * @group Client
990
934
  */
991
935
  declare class PaymentHandler {
992
936
  private omnibaseClient;
993
937
  /**
994
- * Initialize the payment handler with API configuration
938
+ * Initialize the payment handler with OmnibaseClient
995
939
  *
996
- * Creates a new payment handler instance that will communicate with
997
- * the specified API endpoint. The handler automatically handles
998
- * request formatting and authentication headers.
940
+ * Creates a new payment handler instance with access to all payment
941
+ * operations including checkout, configuration, portal, and usage tracking.
942
+ * The handler uses the provided OmnibaseClient for API communication.
999
943
  *
1000
- * @param apiUrl - Base URL for the payment API endpoint
944
+ * @param omnibaseClient - OmnibaseClient instance for API communication
1001
945
  *
1002
946
  * @example
1003
947
  * ```typescript
1004
- * const paymentHandler = new PaymentHandler('https://api.myapp.com');
948
+ * const paymentHandler = new PaymentHandler(omnibaseClient);
1005
949
  * ```
1006
950
  *
1007
- * @since 1.0.0
951
+ * @since 0.6.0
1008
952
  * @group Client
1009
953
  */
1010
954
  constructor(omnibaseClient: OmnibaseClient);
@@ -1017,10 +961,14 @@ declare class PaymentHandler {
1017
961
  * @example
1018
962
  * ```typescript
1019
963
  * const session = await paymentHandler.checkout.createSession({
1020
- * price_id: 'price_monthly',
964
+ * price_id: 'price_monthly_pro',
1021
965
  * success_url: window.location.origin + '/success',
1022
966
  * cancel_url: window.location.origin + '/pricing'
1023
967
  * });
968
+ *
969
+ * if (session.data?.url) {
970
+ * window.location.href = session.data.url;
971
+ * }
1024
972
  * ```
1025
973
  */
1026
974
  readonly checkout: CheckoutManager;
@@ -1068,6 +1016,117 @@ declare class PaymentHandler {
1068
1016
  readonly usage: UsageManager;
1069
1017
  }
1070
1018
 
1019
+ interface UploadOptions {
1020
+ /**
1021
+ * Custom metadata to attach to the file
1022
+ * This will be stored in the JSONB metadata column
1023
+ */
1024
+ metadata?: Record<string, any>;
1025
+ }
1026
+ interface UploadResult {
1027
+ /**
1028
+ * Pre-signed URL for uploading the file
1029
+ */
1030
+ upload_url: string;
1031
+ /**
1032
+ * Full path where the file is stored
1033
+ */
1034
+ path: string;
1035
+ }
1036
+ interface DownloadResult {
1037
+ /**
1038
+ * Pre-signed URL for downloading the file
1039
+ */
1040
+ download_url: string;
1041
+ }
1042
+ /**
1043
+ * Storage client for file operations with path-based organization
1044
+ *
1045
+ * Users control the full file path and define RLS policies based on path patterns.
1046
+ * Common patterns:
1047
+ * - `public/*` - Public files
1048
+ * - `users/{user_id}/*` - User private files
1049
+ * - `teams/{team_id}/*` - Team shared files
1050
+ *
1051
+ * @example
1052
+ * ```typescript
1053
+ * const storage = omnibase.storage();
1054
+ *
1055
+ * // Upload to public directory
1056
+ * await storage.upload('public/images/avatar.png', file);
1057
+ *
1058
+ * // Upload to user private directory
1059
+ * await storage.upload('users/123/documents/report.pdf', file, {
1060
+ * metadata: {
1061
+ * department: 'engineering',
1062
+ * confidential: true
1063
+ * }
1064
+ * });
1065
+ *
1066
+ * // Download file
1067
+ * const { download_url } = await storage.download('public/images/avatar.png');
1068
+ *
1069
+ * // Delete file
1070
+ * await storage.delete('users/123/documents/report.pdf');
1071
+ * ```
1072
+ */
1073
+ declare class StorageClient {
1074
+ private client;
1075
+ constructor(client: OmnibaseClient);
1076
+ /**
1077
+ * Upload a file to storage
1078
+ *
1079
+ * @param path - Full path for the file (e.g., "public/images/avatar.png", "users/123/private/doc.pdf")
1080
+ * @param file - File or Blob to upload
1081
+ * @param options - Upload options including custom metadata
1082
+ *
1083
+ * @example
1084
+ * ```typescript
1085
+ * const result = await storage.upload(
1086
+ * 'public/avatars/user-123.png',
1087
+ * file,
1088
+ * {
1089
+ * metadata: {
1090
+ * userId: '123',
1091
+ * uploadedBy: 'john@example.com',
1092
+ * tags: ['profile', 'avatar']
1093
+ * }
1094
+ * }
1095
+ * );
1096
+ *
1097
+ * // File is automatically uploaded to S3 via the presigned URL
1098
+ * console.log('File uploaded to:', result.path);
1099
+ * ```
1100
+ */
1101
+ upload(path: string, file: File | Blob, options?: UploadOptions): Promise<UploadResult>;
1102
+ /**
1103
+ * Download a file from storage
1104
+ *
1105
+ * @param path - Full path to the file
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * const { download_url } = await storage.download('public/images/logo.png');
1110
+ *
1111
+ * // Download the file
1112
+ * const response = await fetch(download_url);
1113
+ * const blob = await response.blob();
1114
+ * ```
1115
+ */
1116
+ download(path: string): Promise<DownloadResult>;
1117
+ /**
1118
+ * Delete a file from storage
1119
+ *
1120
+ * @param path - Full path to the file
1121
+ *
1122
+ * @example
1123
+ * ```typescript
1124
+ * await storage.delete('users/123/documents/old-report.pdf');
1125
+ * ```
1126
+ */
1127
+ delete(path: string): Promise<void>;
1128
+ }
1129
+
1071
1130
  /**
1072
1131
  * Request data for accepting a tenant invitation
1073
1132
  *
@@ -1082,9 +1141,9 @@ declare class PaymentHandler {
1082
1141
  * };
1083
1142
  * ```
1084
1143
  *
1085
- * @since 1.0.0
1144
+ * @since 0.6.0
1086
1145
  * @public
1087
- * @group User Management
1146
+ * @group Tenant Invitations
1088
1147
  */
1089
1148
  type AcceptTenantInviteRequest = {
1090
1149
  /** Secure invitation token from the email invitation */
@@ -1109,9 +1168,9 @@ type AcceptTenantInviteRequest = {
1109
1168
  * };
1110
1169
  * ```
1111
1170
  *
1112
- * @since 1.0.0
1171
+ * @since 0.6.0
1113
1172
  * @public
1114
- * @group User Management
1173
+ * @group Tenant Invitations
1115
1174
  */
1116
1175
  type AcceptTenantInviteResponse = ApiResponse<{
1117
1176
  /** ID of the tenant the user has joined */
@@ -1146,9 +1205,9 @@ type AcceptTenantInviteResponse = ApiResponse<{
1146
1205
  * };
1147
1206
  * ```
1148
1207
  *
1149
- * @since 1.0.0
1208
+ * @since 0.6.0
1150
1209
  * @public
1151
- * @group User Management
1210
+ * @group Tenant Invitations
1152
1211
  */
1153
1212
  type CreateTenantUserInviteResponse = ApiResponse<{
1154
1213
  /** The newly created tenant invite */
@@ -1178,9 +1237,9 @@ type CreateTenantUserInviteResponse = ApiResponse<{
1178
1237
  * };
1179
1238
  * ```
1180
1239
  *
1181
- * @since 1.0.0
1240
+ * @since 0.6.0
1182
1241
  * @public
1183
- * @group User Management
1242
+ * @group Tenant Invitations
1184
1243
  */
1185
1244
  type TenantInvite = {
1186
1245
  /** Unique identifier for the invitation */
@@ -1205,27 +1264,31 @@ type TenantInvite = {
1205
1264
  /**
1206
1265
  * Required data for creating a tenant user invitation
1207
1266
  *
1208
- * Specifies the email address of the user to invite and their intended
1209
- * role within the tenant. The role determines what permissions the user
1210
- * will have once they accept the invitation.
1267
+ * Specifies the email address of the user to invite, their intended
1268
+ * role within the tenant, and the invitation URL that will be sent in the email.
1269
+ * The role determines what permissions the user will have once they accept the invitation.
1270
+ * The invite_url will be automatically appended with ?token=XYZ when sent to the user.
1211
1271
  *
1212
1272
  * @example
1213
1273
  * ```typescript
1214
1274
  * const inviteData: CreateTenantUserInviteRequest = {
1215
1275
  * email: 'developer@company.com',
1216
- * role: 'admin'
1276
+ * role: 'admin',
1277
+ * invite_url: 'https://yourapp.com/accept-invite'
1217
1278
  * };
1218
1279
  * ```
1219
1280
  *
1220
- * @since 1.0.0
1281
+ * @since 0.6.0
1221
1282
  * @public
1222
- * @group User Management
1283
+ * @group Tenant Invitations
1223
1284
  */
1224
1285
  type CreateTenantUserInviteRequest = {
1225
1286
  /** Email address of the user to invite */
1226
1287
  email: string;
1227
1288
  /** Role the invited user will have in the tenant */
1228
1289
  role: string;
1290
+ /** Invite URL - the link that will be sent to the user's email, automatically suffixed with ?token=XYZ */
1291
+ invite_url: string;
1229
1292
  };
1230
1293
  /**
1231
1294
  * Tenant invitation management handler
@@ -1250,9 +1313,10 @@ type CreateTenantUserInviteRequest = {
1250
1313
  * const inviteManager = new TenantInviteManager(omnibaseClient);
1251
1314
  *
1252
1315
  * // Create an invitation
1253
- * const invite = await inviteManager.create('tenant_123', {
1316
+ * const invite = await inviteManager.create({
1254
1317
  * email: 'colleague@company.com',
1255
- * role: 'member'
1318
+ * role: 'member',
1319
+ * invite_url: 'https://yourapp.com/accept-invite'
1256
1320
  * });
1257
1321
  *
1258
1322
  * // Accept an invitation (from the invited user's session)
@@ -1260,7 +1324,7 @@ type CreateTenantUserInviteRequest = {
1260
1324
  * console.log(`Joined tenant: ${result.data.tenant_id}`);
1261
1325
  * ```
1262
1326
  *
1263
- * @since 1.0.0
1327
+ * @since 0.6.0
1264
1328
  * @public
1265
1329
  * @group Tenant Invitations
1266
1330
  */
@@ -1306,17 +1370,6 @@ declare class TenantInviteManager {
1306
1370
  * @throws {Error} When the server returns an error response (4xx, 5xx status codes)
1307
1371
  *
1308
1372
  * @example
1309
- * Basic invitation acceptance:
1310
- * ```typescript
1311
- * const result = await acceptTenantInvite('inv_secure_token_abc123');
1312
- *
1313
- * console.log(`Successfully joined tenant: ${result.data.tenant_id}`);
1314
- * // User can now access tenant resources
1315
- * await switchActiveTenant(result.data.tenant_id);
1316
- * ```
1317
- *
1318
- * @example
1319
- * Handling the invitation flow:
1320
1373
  * ```typescript
1321
1374
  * // Typically called from an invitation link like:
1322
1375
  * // https://app.com/accept-invite?token=inv_secure_token_abc123
@@ -1326,82 +1379,67 @@ declare class TenantInviteManager {
1326
1379
  *
1327
1380
  * if (inviteToken) {
1328
1381
  * try {
1329
- * const result = await acceptTenantInvite(inviteToken);
1382
+ * const result = await inviteManager.accept(inviteToken);
1330
1383
  *
1331
1384
  * // Success - redirect to tenant dashboard
1385
+ * console.log(`Successfully joined tenant: ${result.data.tenant_id}`);
1332
1386
  * window.location.href = `/dashboard?tenant=${result.data.tenant_id}`;
1333
1387
  * } catch (error) {
1334
1388
  * console.error('Failed to accept invitation:', error.message);
1335
- * // Show error to user
1336
1389
  * }
1337
1390
  * }
1338
1391
  * ```
1339
1392
  *
1340
- *
1341
- * @since 1.0.0
1393
+ * @since 0.6.0
1342
1394
  * @public
1343
- * @group User Management
1395
+ * @group Tenant Invitations
1344
1396
  */
1345
1397
  accept(token: string): Promise<AcceptTenantInviteResponse>;
1346
1398
  /**
1347
- * Creates a new user invitation for a specific tenant
1399
+ * Creates a new user invitation for the active tenant
1348
1400
  *
1349
- * Generates a secure invitation that allows a user to join the specified
1350
- * tenant with the defined role. The invitation is sent to the provided
1351
- * email address and includes a time-limited token for security.
1401
+ * Generates a secure invitation that allows a user to join the currently active
1402
+ * tenant with the defined role. The invitation is sent to the provided email address
1403
+ * and includes a time-limited token for security. The invite URL will be automatically
1404
+ * appended with ?token=XYZ when sent to the user.
1352
1405
  *
1353
- * The function creates the invitation record in the database and can
1354
- * trigger email notifications (depending on server configuration).
1355
- * The invitation expires after a predefined time period and can only
1406
+ * The function creates the invitation record in the database and triggers an email
1407
+ * notification to the invited user. The invitation expires after 7 days and can only
1356
1408
  * be used once.
1357
1409
  *
1358
- * Only existing tenant members with appropriate permissions can create
1359
- * invitations. The inviter's authentication is validated via HTTP-only
1360
- * cookies sent with the request.
1410
+ * Only existing tenant members with appropriate permissions (invite_user permission)
1411
+ * can create invitations. The inviter's authentication and tenant context are validated
1412
+ * via HTTP-only cookies sent with the request.
1361
1413
  *
1362
- * @param tenantId - Unique identifier of the tenant to invite the user to
1363
1414
  * @param inviteData - Configuration object for the invitation
1364
1415
  * @param inviteData.email - Email address of the user to invite
1365
1416
  * @param inviteData.role - Role the user will have after joining (e.g., 'member', 'admin')
1417
+ * @param inviteData.invite_url - Base URL for the invitation link (will be appended with ?token=XYZ)
1366
1418
  *
1367
1419
  * @returns Promise resolving to the created invitation with secure token
1368
1420
  *
1369
- * @throws {Error} When tenantId parameter is missing or empty
1370
- * @throws {Error} When required fields (email, role) are missing or empty
1421
+ * @throws {Error} When required fields (email, role, invite_url) are missing or empty
1422
+ * @throws {Error} When the user doesn't have permission to invite users to the tenant
1371
1423
  * @throws {Error} When the API request fails due to network issues
1372
1424
  * @throws {Error} When the server returns an error response (4xx, 5xx status codes)
1373
1425
  *
1374
1426
  * @example
1375
- * Basic invitation creation:
1376
1427
  * ```typescript
1377
- * const invite = await createTenantUserInvite('tenant_123', {
1428
+ * const invite = await inviteManager.create({
1378
1429
  * email: 'colleague@company.com',
1379
- * role: 'member'
1430
+ * role: 'member',
1431
+ * invite_url: 'https://yourapp.com/accept-invite'
1380
1432
  * });
1381
1433
  *
1382
1434
  * console.log(`Invite sent to: ${invite.data.invite.email}`);
1383
- * // The invite token can be used to generate invitation links
1384
- * const inviteLink = `https://app.com/accept-invite?token=${invite.data.invite.token}`;
1385
- * ```
1386
- *
1387
- * @example
1388
- * Creating admin invitation:
1389
- * ```typescript
1390
- * const adminInvite = await createTenantUserInvite('tenant_456', {
1391
- * email: 'admin@company.com',
1392
- * role: 'admin'
1393
- * });
1394
- *
1395
- * // Admin users get elevated permissions
1396
- * console.log(`Admin invite created with ID: ${adminInvite.data.invite.id}`);
1435
+ * console.log(`Invite token: ${invite.data.invite.token}`);
1397
1436
  * ```
1398
1437
  *
1399
- *
1400
- * @since 1.0.0
1438
+ * @since 0.6.0
1401
1439
  * @public
1402
- * @group User Management
1440
+ * @group Tenant Invitations
1403
1441
  */
1404
- create(tenantId: string, inviteData: CreateTenantUserInviteRequest): Promise<CreateTenantUserInviteResponse>;
1442
+ create(inviteData: CreateTenantUserInviteRequest): Promise<CreateTenantUserInviteResponse>;
1405
1443
  }
1406
1444
 
1407
1445
  /**
@@ -1427,7 +1465,7 @@ declare class TenantInviteManager {
1427
1465
  * };
1428
1466
  * ```
1429
1467
  *
1430
- * @since 1.0.0
1468
+ * @since 0.6.0
1431
1469
  * @public
1432
1470
  * @group Tenant Management
1433
1471
  */
@@ -1454,7 +1492,7 @@ type SwitchActiveTenantResponse = ApiResponse<{
1454
1492
  * };
1455
1493
  * ```
1456
1494
  *
1457
- * @since 1.0.0
1495
+ * @since 0.6.0
1458
1496
  * @public
1459
1497
  * @group Tenant Management
1460
1498
  */
@@ -1486,7 +1524,7 @@ type DeleteTenantResponse = ApiResponse<{
1486
1524
  * };
1487
1525
  * ```
1488
1526
  *
1489
- * @since 1.0.0
1527
+ * @since 0.6.0
1490
1528
  * @public
1491
1529
  * @group Tenant Management
1492
1530
  */
@@ -1517,7 +1555,7 @@ type CreateTenantResponse = ApiResponse<{
1517
1555
  * };
1518
1556
  * ```
1519
1557
  *
1520
- * @since 1.0.0
1558
+ * @since 0.6.0
1521
1559
  * @public
1522
1560
  * @group Tenant Management
1523
1561
  */
@@ -1550,7 +1588,7 @@ type Tenant = {
1550
1588
  * };
1551
1589
  * ```
1552
1590
  *
1553
- * @since 1.0.0
1591
+ * @since 0.6.0
1554
1592
  * @public
1555
1593
  * @group Tenant Management
1556
1594
  */
@@ -1597,7 +1635,7 @@ type CreateTenantRequest = {
1597
1635
  * await tenantManager.deleteTenant(tenant.data.tenant.id);
1598
1636
  * ```
1599
1637
  *
1600
- * @since 1.0.0
1638
+ * @since 0.6.0
1601
1639
  * @public
1602
1640
  * @group Tenant Management
1603
1641
  */
@@ -1638,21 +1676,17 @@ declare class TenantManger {
1638
1676
  * @throws {Error} When the server returns an error response (4xx, 5xx status codes)
1639
1677
  *
1640
1678
  * @example
1641
- * Basic tenant creation:
1642
1679
  * ```typescript
1643
- * const newTenant = await createTenant({
1680
+ * const newTenant = await tenantManager.createTenant({
1644
1681
  * name: 'Acme Corporation',
1645
1682
  * billing_email: 'billing@acme.com',
1646
1683
  * user_id: 'user_123'
1647
1684
  * });
1648
1685
  *
1649
- * console.log(`Created tenant: ${newTenant.data.tenant.name}`);
1650
- * // Store the token for authenticated requests
1651
- * localStorage.setItem('tenant_token', newTenant.data.token);
1686
+ * console.log(`Tenant created: ${newTenant.data.tenant.id}`);
1652
1687
  * ```
1653
1688
  *
1654
- *
1655
- * @since 1.0.0
1689
+ * @since 0.6.0
1656
1690
  * @public
1657
1691
  * @group Tenant Management
1658
1692
  */
@@ -1692,7 +1726,6 @@ declare class TenantManger {
1692
1726
  * @throws {Error} When the server returns an error response (4xx, 5xx status codes)
1693
1727
  *
1694
1728
  * @example
1695
- * Basic tenant deletion with confirmation:
1696
1729
  * ```typescript
1697
1730
  * const tenantToDelete = 'tenant_abc123';
1698
1731
  *
@@ -1703,8 +1736,8 @@ declare class TenantManger {
1703
1736
  *
1704
1737
  * if (userConfirmed) {
1705
1738
  * try {
1706
- * const result = await deleteTenant(tenantToDelete);
1707
- * console.log(result.data.message); // "Tenant deleted successfully"
1739
+ * const result = await tenantManager.deleteTenant(tenantToDelete);
1740
+ * console.log(result.data.message);
1708
1741
  *
1709
1742
  * // Redirect user away from deleted tenant
1710
1743
  * window.location.href = '/dashboard';
@@ -1714,7 +1747,7 @@ declare class TenantManger {
1714
1747
  * }
1715
1748
  * ```
1716
1749
  *
1717
- * @since 1.0.0
1750
+ * @since 0.6.0
1718
1751
  * @public
1719
1752
  * @group Tenant Management
1720
1753
  */
@@ -1750,63 +1783,224 @@ declare class TenantManger {
1750
1783
  * @throws {Error} When the server returns an error response (4xx, 5xx status codes)
1751
1784
  *
1752
1785
  * @example
1753
- * Basic tenant switching:
1754
1786
  * ```typescript
1755
- * const result = await switchActiveTenant('tenant_xyz789');
1787
+ * const result = await tenantManager.switchActiveTenant('tenant_xyz789');
1788
+ *
1789
+ * // Store the new token for future requests
1790
+ * console.log(`Switched to tenant. New token: ${result.data.token}`);
1756
1791
  *
1757
1792
  * // Now all API calls will be in the context of tenant_xyz789
1758
1793
  * const tenantData = await getCurrentTenantData();
1759
1794
  * ```
1760
1795
  *
1796
+ * @since 0.6.0
1797
+ * @public
1798
+ * @group Tenant Management
1799
+ */
1800
+ switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
1801
+ }
1802
+
1803
+ /**
1804
+ * Request parameters for updating a user's role within a tenant
1805
+ *
1806
+ * This interface defines the data required to change a user's role in the active tenant.
1807
+ * The operation requires appropriate permissions (typically admin or owner role) and will
1808
+ * fail if the requesting user doesn't have sufficient privileges.
1809
+ *
1810
+ * @example
1811
+ * ```typescript
1812
+ * const request: UpdateTenantUserRoleRequest = {
1813
+ * user_id: 'user_abc123',
1814
+ * role: 'admin'
1815
+ * };
1816
+ * ```
1817
+ *
1818
+ * @since 0.6.0
1819
+ * @public
1820
+ * @group Tenant User Management
1821
+ */
1822
+ type UpdateTenantUserRoleRequest = {
1823
+ /** New role to assign to the user (e.g., 'admin', 'member', 'viewer') */
1824
+ role: string;
1825
+ /** ID of the user whose role is being updated */
1826
+ user_id: string;
1827
+ };
1828
+ /**
1829
+ * Response from updating a user's role within a tenant
1830
+ *
1831
+ * This type represents the API response structure returned after successfully
1832
+ * updating a user's role in the tenant.
1833
+ *
1834
+ * @since 1.0.0
1835
+ * @public
1836
+ * @group Tenant User Management
1837
+ */
1838
+ type UpdateTenantUserRoleResponse = ApiResponse<{
1839
+ /** Confirmation message describing the role update */
1840
+ message: string;
1841
+ }>;
1842
+ /**
1843
+ * Request parameters for removing a user from a tenant
1844
+ *
1845
+ * This interface defines the data required to remove a user from the active tenant.
1846
+ * The operation requires appropriate permissions and will fail if the user doesn't
1847
+ * have the necessary rights to remove users from the tenant.
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * const request: RemoveUserRequest = {
1852
+ * user_id: 'user_abc123'
1853
+ * };
1854
+ * ```
1855
+ *
1856
+ * @since 0.6.0
1857
+ * @public
1858
+ * @group Tenant User Management
1859
+ */
1860
+ type RemoveUserRequest = {
1861
+ /** ID of the user being removed from the tenant */
1862
+ user_id: string;
1863
+ };
1864
+ /**
1865
+ * Manager for tenant user operations
1866
+ *
1867
+ * This class provides methods for managing users within a tenant, including
1868
+ * removing users from the active tenant. All operations are performed within
1869
+ * the context of the authenticated user and respect tenant-level permissions.
1870
+ *
1871
+ * User removal operations require appropriate permissions (typically admin or owner
1872
+ * role) and will fail if the requesting user doesn't have sufficient privileges.
1873
+ *
1874
+ * @example
1875
+ * ```typescript
1876
+ * import { OmnibaseClient } from '@omnibase/core-js';
1877
+ *
1878
+ * const client = new OmnibaseClient({ apiKey: 'your-api-key' });
1879
+ * const userManager = client.tenants.user;
1880
+ *
1881
+ * // Remove a user from the active tenant
1882
+ * await userManager.remove({ user_id: 'user_123' });
1883
+ * ```
1884
+ *
1885
+ * @since 0.6.0
1886
+ * @public
1887
+ * @group Tenant User Management
1888
+ */
1889
+ declare class TenantUserManager {
1890
+ private omnibaseClient;
1891
+ /**
1892
+ * Creates a new tenant user manager
1893
+ *
1894
+ * @param omnibaseClient - Configured OmnibaseClient instance for API communication
1895
+ *
1896
+ * @group Tenant User Management
1897
+ */
1898
+ constructor(omnibaseClient: OmnibaseClient);
1899
+ /**
1900
+ * Removes a user from the active tenant
1901
+ *
1902
+ * This method removes a specified user from the current active tenant. The operation
1903
+ * requires the requesting user to have appropriate permissions (admin or owner role).
1904
+ * The user being removed will lose access to the tenant and all its resources.
1905
+ *
1906
+ * Note: You cannot remove yourself from a tenant using this method. To leave a tenant,
1907
+ * use the appropriate leave or delete tenant operations instead.
1908
+ *
1909
+ * @param data - Request data containing the user ID to remove
1910
+ * @param data.user_id - ID of the user to remove from the tenant
1911
+ *
1912
+ * @returns Promise resolving to an API response confirming the removal
1913
+ *
1914
+ * @throws {Error} When user_id is not provided
1915
+ * @throws {Error} When the API request fails (includes status code and error details)
1916
+ * @throws {Error} When the user doesn't have permission to remove users
1917
+ * @throws {Error} When the specified user is not a member of the tenant
1918
+ *
1919
+ * @example
1920
+ * ```typescript
1921
+ * // Remove a user from the active tenant
1922
+ * try {
1923
+ * await userManager.remove({ user_id: 'user_abc123' });
1924
+ * console.log('User removed successfully');
1925
+ * } catch (error) {
1926
+ * if (error.message.includes('403')) {
1927
+ * console.error('Insufficient permissions to remove user');
1928
+ * } else if (error.message.includes('404')) {
1929
+ * console.error('User not found in tenant');
1930
+ * } else {
1931
+ * console.error('Failed to remove user:', error);
1932
+ * }
1933
+ * }
1934
+ * ```
1935
+ *
1936
+ * @since 0.6.0
1937
+ * @public
1938
+ * @group Tenant User Management
1939
+ */
1940
+ remove(data: RemoveUserRequest): Promise<ApiResponse<"">>;
1941
+ /**
1942
+ * Updates a user's role within the active tenant
1943
+ *
1944
+ * This method changes the role of a specified user in the current active tenant. The operation
1945
+ * requires the requesting user to have appropriate permissions (typically admin or owner role).
1946
+ * Role updates take effect immediately and affect the user's permissions and access rights
1947
+ * within the tenant.
1948
+ *
1949
+ * Common roles include 'admin', 'member', and 'viewer', but the exact roles available depend
1950
+ * on your tenant's configuration. Changing a user's role will modify their ability to perform
1951
+ * various operations within the tenant.
1952
+ *
1953
+ * @param data - Request data containing the user ID and new role
1954
+ * @param data.user_id - ID of the user whose role is being updated
1955
+ * @param data.role - New role to assign to the user
1956
+ *
1957
+ * @returns Promise resolving to an API response confirming the role update
1958
+ *
1959
+ * @throws {Error} When user_id or role is not provided
1960
+ * @throws {Error} When the API request fails (includes status code and error details)
1961
+ * @throws {Error} When the user doesn't have permission to update roles
1962
+ * @throws {Error} When the specified user is not a member of the tenant
1963
+ * @throws {Error} When the specified role is invalid or not allowed
1964
+ *
1761
1965
  * @example
1762
- * Using with tenant-aware data fetching:
1763
1966
  * ```typescript
1764
- * // Switch tenant and immediately fetch tenant-specific data
1765
- * const switchAndLoadTenant = async (tenantId: string) => {
1766
- * try {
1767
- * // Switch to new tenant context
1768
- * const switchResult = await switchActiveTenant(tenantId);
1769
- *
1770
- * // Update authentication token
1771
- * setAuthToken(switchResult.data.token);
1772
- *
1773
- * // Fetch data in new tenant context
1774
- * const [tenantInfo, userPermissions, tenantSettings] = await Promise.all([
1775
- * getTenantInfo(),
1776
- * getUserPermissions(),
1777
- * getTenantSettings()
1778
- * ]);
1779
- *
1780
- * return {
1781
- * tenant: tenantInfo,
1782
- * permissions: userPermissions,
1783
- * settings: tenantSettings
1784
- * };
1785
- * } catch (error) {
1786
- * console.error('Failed to switch tenant and load data:', error);
1787
- * throw error;
1967
+ * // Update a user's role to admin
1968
+ * try {
1969
+ * const result = await userManager.updateRole({
1970
+ * user_id: 'user_abc123',
1971
+ * role: 'admin'
1972
+ * });
1973
+ * console.log('Role updated successfully:', result.data.message);
1974
+ * } catch (error) {
1975
+ * if (error.message.includes('403')) {
1976
+ * console.error('Insufficient permissions to update roles');
1977
+ * } else if (error.message.includes('404')) {
1978
+ * console.error('User not found in tenant');
1979
+ * } else {
1980
+ * console.error('Failed to update role:', error);
1788
1981
  * }
1789
- * };
1982
+ * }
1790
1983
  * ```
1791
1984
  *
1792
- * @since 1.0.0
1985
+ * @since 0.6.0
1793
1986
  * @public
1794
- * @group Tenant Management
1987
+ * @group Tenant User Management
1795
1988
  */
1796
- switchActiveTenant(tenantId: string): Promise<SwitchActiveTenantResponse>;
1989
+ updateRole(data: UpdateTenantUserRoleRequest): Promise<UpdateTenantUserRoleResponse>;
1797
1990
  }
1798
1991
 
1799
1992
  /**
1800
1993
  * Main tenant management handler
1801
1994
  *
1802
1995
  * This is the primary entry point for all tenant-related operations in the
1803
- * Omnibase SDK. It provides a unified interface to both tenant management
1804
- * and invitation functionality through dedicated manager instances.
1996
+ * Omnibase SDK. It provides a unified interface to tenant management,
1997
+ * user management, and invitation functionality through dedicated manager instances.
1805
1998
  *
1806
1999
  * The handler follows the composition pattern, combining specialized managers
1807
2000
  * for different aspects of tenant functionality:
1808
- * - `tenants`: Core tenant operations (create, delete, switch)
2001
+ * - `manage`: Core tenant operations (create, delete, switch)
1809
2002
  * - `invites`: User invitation management (create, accept)
2003
+ * - `user`: Tenant user operations (remove, update role)
1810
2004
  *
1811
2005
  * All operations are performed within the context of the authenticated user
1812
2006
  * and respect tenant-level permissions and row-level security policies.
@@ -1820,28 +2014,28 @@ declare class TenantManger {
1820
2014
  * const tenantHandler = new TenantHandler(client);
1821
2015
  *
1822
2016
  * // Create a new tenant
1823
- * const tenant = await tenantHandler.tenants.createTenant({
2017
+ * const tenant = await tenantHandler.manage.createTenant({
1824
2018
  * name: 'My Company',
1825
2019
  * billing_email: 'billing@company.com',
1826
2020
  * user_id: 'user_123'
1827
2021
  * });
1828
2022
  *
1829
2023
  * // Invite users to the tenant
1830
- * const invite = await tenantHandler.invites.create(tenant.data.tenant.id, {
2024
+ * const invite = await tenantHandler.invites.create({
1831
2025
  * email: 'colleague@company.com',
1832
- * role: 'member'
2026
+ * role: 'member',
2027
+ * invite_url: 'https://yourapp.com/accept-invite'
1833
2028
  * });
1834
2029
  *
1835
2030
  * // Switch to the new tenant
1836
- * await tenantHandler.tenants.switchActiveTenant(tenant.data.tenant.id);
2031
+ * await tenantHandler.manage.switchActiveTenant(tenant.data.tenant.id);
1837
2032
  * ```
1838
2033
  *
1839
- * @since 1.0.0
2034
+ * @since 0.6.0
1840
2035
  * @public
1841
2036
  * @group Tenant Management
1842
2037
  */
1843
2038
  declare class TenantHandler {
1844
- private omnibaseClient;
1845
2039
  /**
1846
2040
  * Creates a new TenantHandler instance
1847
2041
  *
@@ -1863,6 +2057,23 @@ declare class TenantHandler {
1863
2057
  * @group Tenant Management
1864
2058
  */
1865
2059
  constructor(omnibaseClient: OmnibaseClient);
2060
+ /**
2061
+ * Tenant user management operations
2062
+ *
2063
+ * Provides access to operations for managing users within tenants, including
2064
+ * removing users from the active tenant. All operations respect user permissions
2065
+ * and tenant ownership rules.
2066
+ *
2067
+ * @example
2068
+ * ```typescript
2069
+ * // Remove a user from the active tenant
2070
+ * await tenantHandler.user.remove({ user_id: 'user_123' });
2071
+ * ```
2072
+ *
2073
+ * @since 0.6.0
2074
+ * @group Tenant Management
2075
+ */
2076
+ readonly user: TenantUserManager;
1866
2077
  /**
1867
2078
  * Core tenant management operations
1868
2079
  *
@@ -1873,17 +2084,17 @@ declare class TenantHandler {
1873
2084
  * @example
1874
2085
  * ```typescript
1875
2086
  * // Create a new tenant
1876
- * const tenant = await tenantHandler.tenants.createTenant({
2087
+ * const tenant = await tenantHandler.manage.createTenant({
1877
2088
  * name: 'New Company',
1878
2089
  * billing_email: 'billing@newcompany.com',
1879
2090
  * user_id: 'user_456'
1880
2091
  * });
1881
2092
  *
1882
2093
  * // Switch to the tenant
1883
- * await tenantHandler.tenants.switchActiveTenant(tenant.data.tenant.id);
2094
+ * await tenantHandler.manage.switchActiveTenant(tenant.data.tenant.id);
1884
2095
  *
1885
2096
  * // Delete the tenant (owner only)
1886
- * await tenantHandler.tenants.deleteTenant(tenant.data.tenant.id);
2097
+ * await tenantHandler.manage.deleteTenant(tenant.data.tenant.id);
1887
2098
  * ```
1888
2099
  */
1889
2100
  readonly manage: TenantManger;
@@ -1897,9 +2108,10 @@ declare class TenantHandler {
1897
2108
  * @example
1898
2109
  * ```typescript
1899
2110
  * // Create an invitation
1900
- * const invite = await tenantHandler.invites.create('tenant_123', {
2111
+ * const invite = await tenantHandler.invites.create({
1901
2112
  * email: 'newuser@company.com',
1902
- * role: 'admin'
2113
+ * role: 'admin',
2114
+ * invite_url: 'https://yourapp.com/accept-invite'
1903
2115
  * });
1904
2116
  *
1905
2117
  * // Accept an invitation (from the invited user's session)
@@ -1941,9 +2153,106 @@ declare class OmnibaseClient {
1941
2153
  * ```
1942
2154
  */
1943
2155
  readonly payments: PaymentHandler;
2156
+ /**
2157
+ * Main tenant management handler
2158
+ *
2159
+ * This is the primary entry point for all tenant-related operations in the
2160
+ * Omnibase SDK. It provides a unified interface to tenant management,
2161
+ * user management, and invitation functionality through dedicated manager instances.
2162
+ *
2163
+ * The handler follows the composition pattern, combining specialized managers
2164
+ * for different aspects of tenant functionality:
2165
+ * - `manage`: Core tenant operations (create, delete, switch)
2166
+ * - `invites`: User invitation management (create, accept)
2167
+ * - `user`: Tenant user operations (remove, update role)
2168
+ *
2169
+ * All operations are performed within the context of the authenticated user
2170
+ * and respect tenant-level permissions and row-level security policies.
2171
+ *
2172
+ * @example
2173
+ * ```typescript
2174
+ * // Create a new tenant
2175
+ * const tenant = await omnibase.tenants.manage.createTenant({
2176
+ * name: 'My Company',
2177
+ * billing_email: 'billing@company.com',
2178
+ * user_id: 'user_123'
2179
+ * });
2180
+ *
2181
+ * // Invite users to the tenant
2182
+ * const invite = await omnibase.tenants.invites.create({
2183
+ * email: 'colleague@company.com',
2184
+ * role: 'member',
2185
+ * invite_url: 'https://yourapp.com/accept-invite'
2186
+ * });
2187
+ *
2188
+ * // Switch to the new tenant
2189
+ * await omnibase.tenants.manage.switchActiveTenant(tenant.data.tenant.id);
2190
+ * ```
2191
+ *
2192
+ * @since 0.6.0
2193
+ * @public
2194
+ * @group Tenant Management
2195
+ */
1944
2196
  readonly tenants: TenantHandler;
2197
+ /**
2198
+ * Client for managing permissions and relationships using Ory Keto
2199
+ *
2200
+ * This client provides access to Ory Keto's permission system, allowing you to
2201
+ * create, manage, and check relationships between subjects and objects. It handles
2202
+ * both read operations (permission checks) and write operations (relationship management).
2203
+ *
2204
+ * The client automatically configures separate endpoints for read and write operations
2205
+ * to optimize performance and security by following Ory Keto's recommended architecture.
2206
+ *
2207
+ * @example
2208
+ * ```typescript
2209
+ * // Check if a user can view a tenant
2210
+ * const canView = await omnibase.permissions.permissions.checkPermission(
2211
+ * undefined,
2212
+ * {
2213
+ * namespace: 'Tenant',
2214
+ * object: 'tenant_123',
2215
+ * relation: 'view',
2216
+ * subjectId: 'user_456'
2217
+ * }
2218
+ * );
2219
+ *
2220
+ * if (canView.data.allowed) {
2221
+ * console.log('User can view the tenant');
2222
+ * }
2223
+ *
2224
+ * // Create a relationship making a user an owner of a tenant
2225
+ * await omnibase.permissions.relationships.createRelationship(
2226
+ * undefined,
2227
+ * {
2228
+ * namespace: 'Tenant',
2229
+ * object: 'tenant_123',
2230
+ * relation: 'owners',
2231
+ * subjectId: 'user_456'
2232
+ * }
2233
+ * );
2234
+ * ```
2235
+ *
2236
+ * @since 0.6.0
2237
+ * @public
2238
+ * @group Permissions
2239
+ */
1945
2240
  readonly permissions: PermissionsClient;
2241
+ /**
2242
+ * Storage client for file upload/download operations
2243
+ *
2244
+ * @example
2245
+ * ```typescript
2246
+ * // Upload with metadata
2247
+ * await omnibase.storage.bucket('documents').upload(
2248
+ * 'report.pdf',
2249
+ * file,
2250
+ * { metadata: { department: 'engineering' } }
2251
+ * );
2252
+ * ```
2253
+ */
2254
+ storage: StorageClient;
1946
2255
  fetch(endpoint: string, options?: RequestInit): Promise<Response>;
1947
2256
  }
1948
2257
 
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 };
2258
+ 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 };