@omnibase/core-js 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -198
- package/dist/chunk-6OGESVXW.js +651 -0
- package/dist/chunk-QPW6G4PA.js +490 -0
- package/dist/database/index.cjs +187 -0
- package/dist/database/index.d.cts +194 -1
- package/dist/database/index.d.ts +194 -1
- package/dist/database/index.js +186 -0
- package/dist/index.cjs +150 -174
- package/dist/index.js +87 -4
- package/dist/payments/index.cjs +22 -74
- package/dist/payments/index.d.cts +230 -249
- package/dist/payments/index.d.ts +230 -249
- package/dist/payments/index.js +1 -1
- package/dist/tenants/index.cjs +45 -100
- package/dist/tenants/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -57,31 +57,20 @@ var CheckoutManager = class {
|
|
|
57
57
|
* @throws {ValidationError} When required parameters are missing or invalid
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
|
-
* Creating a checkout session (mode is auto-detected):
|
|
61
60
|
* ```typescript
|
|
62
61
|
* const session = await checkoutManager.createSession({
|
|
63
|
-
* price_id: '
|
|
62
|
+
* price_id: 'price_monthly_pro',
|
|
64
63
|
* success_url: 'https://app.com/success',
|
|
65
64
|
* cancel_url: 'https://app.com/cancel'
|
|
66
65
|
* });
|
|
67
66
|
*
|
|
68
67
|
* // Redirect to Stripe checkout
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* Checkout with session tracking:
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const session = await checkoutManager.createSession({
|
|
76
|
-
* price_id: 'price_monthly_plan',
|
|
77
|
-
* success_url: 'https://app.com/dashboard?session_id={CHECKOUT_SESSION_ID}',
|
|
78
|
-
* cancel_url: 'https://app.com/pricing',
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* console.log(`Session created: ${session.data.sessionId}`);
|
|
68
|
+
* if (session.data?.url) {
|
|
69
|
+
* window.location.href = session.data.url;
|
|
70
|
+
* }
|
|
82
71
|
* ```
|
|
83
72
|
*
|
|
84
|
-
* @since
|
|
73
|
+
* @since 0.6.0
|
|
85
74
|
* @group Checkout
|
|
86
75
|
*/
|
|
87
76
|
async createSession(options) {
|
|
@@ -302,7 +291,7 @@ var PortalManager = class {
|
|
|
302
291
|
/**
|
|
303
292
|
* Initialize the portal manager
|
|
304
293
|
*
|
|
305
|
-
* @param
|
|
294
|
+
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
306
295
|
*
|
|
307
296
|
* @group Portal
|
|
308
297
|
*/
|
|
@@ -329,32 +318,18 @@ var PortalManager = class {
|
|
|
329
318
|
* @throws {ValidationError} When required parameters are missing or invalid
|
|
330
319
|
*
|
|
331
320
|
* @example
|
|
332
|
-
* Basic portal creation:
|
|
333
321
|
* ```typescript
|
|
334
322
|
* const portal = await portalManager.create({
|
|
335
323
|
* return_url: 'https://myapp.com/account/billing'
|
|
336
324
|
* });
|
|
337
325
|
*
|
|
338
326
|
* // Redirect user to portal
|
|
339
|
-
*
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* With error handling:
|
|
344
|
-
* ```typescript
|
|
345
|
-
* try {
|
|
346
|
-
* const portal = await portalManager.create({
|
|
347
|
-
* return_url: window.location.origin + '/billing'
|
|
348
|
-
* });
|
|
349
|
-
*
|
|
327
|
+
* if (portal.data?.url) {
|
|
350
328
|
* window.location.href = portal.data.url;
|
|
351
|
-
* } catch (error) {
|
|
352
|
-
* console.error('Failed to create portal session:', error);
|
|
353
|
-
* showErrorMessage('Unable to access billing portal. Please try again.');
|
|
354
329
|
* }
|
|
355
330
|
* ```
|
|
356
331
|
*
|
|
357
|
-
* @since
|
|
332
|
+
* @since 0.6.0
|
|
358
333
|
* @group Portal
|
|
359
334
|
*/
|
|
360
335
|
async create(options) {
|
|
@@ -384,7 +359,7 @@ var UsageManager = class {
|
|
|
384
359
|
/**
|
|
385
360
|
* Initialize the usage manager
|
|
386
361
|
*
|
|
387
|
-
* @param
|
|
362
|
+
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
388
363
|
*
|
|
389
364
|
* @group Usage
|
|
390
365
|
*/
|
|
@@ -413,7 +388,6 @@ var UsageManager = class {
|
|
|
413
388
|
* @throws {ValidationError} When required parameters are missing or invalid
|
|
414
389
|
*
|
|
415
390
|
* @example
|
|
416
|
-
* API call tracking:
|
|
417
391
|
* ```typescript
|
|
418
392
|
* // Record each API call
|
|
419
393
|
* await usageManager.recordUsage({
|
|
@@ -422,37 +396,7 @@ var UsageManager = class {
|
|
|
422
396
|
* });
|
|
423
397
|
* ```
|
|
424
398
|
*
|
|
425
|
-
* @
|
|
426
|
-
* Batch usage recording:
|
|
427
|
-
* ```typescript
|
|
428
|
-
* // Record multiple operations at once
|
|
429
|
-
* const usageEvents = [
|
|
430
|
-
* { meter_event_name: 'compute_hours', value: '0.5' },
|
|
431
|
-
* { meter_event_name: 'storage_gb', value: '10' },
|
|
432
|
-
* { meter_event_name: 'api_calls', value: '50' }
|
|
433
|
-
* ];
|
|
434
|
-
*
|
|
435
|
-
* for (const event of usageEvents) {
|
|
436
|
-
* await usageManager.recordUsage(event);
|
|
437
|
-
* }
|
|
438
|
-
* ```
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* With error handling:
|
|
442
|
-
* ```typescript
|
|
443
|
-
* try {
|
|
444
|
-
* await usageManager.recordUsage({
|
|
445
|
-
* meter_event_name: 'file_uploads',
|
|
446
|
-
* value: String(uploadedFiles.length)
|
|
447
|
-
* });
|
|
448
|
-
* } catch (error) {
|
|
449
|
-
* console.error('Failed to record usage:', error);
|
|
450
|
-
* // Usage recording failure shouldn't block user operations
|
|
451
|
-
* // but should be logged for billing accuracy
|
|
452
|
-
* }
|
|
453
|
-
* ```
|
|
454
|
-
*
|
|
455
|
-
* @since 1.0.0
|
|
399
|
+
* @since 0.6.0
|
|
456
400
|
* @group Usage
|
|
457
401
|
*/
|
|
458
402
|
async recordUsage(options) {
|
|
@@ -477,20 +421,20 @@ var UsageManager = class {
|
|
|
477
421
|
// src/payments/handler.ts
|
|
478
422
|
var PaymentHandler = class {
|
|
479
423
|
/**
|
|
480
|
-
* Initialize the payment handler with
|
|
424
|
+
* Initialize the payment handler with OmnibaseClient
|
|
481
425
|
*
|
|
482
|
-
* Creates a new payment handler instance
|
|
483
|
-
*
|
|
484
|
-
*
|
|
426
|
+
* Creates a new payment handler instance with access to all payment
|
|
427
|
+
* operations including checkout, configuration, portal, and usage tracking.
|
|
428
|
+
* The handler uses the provided OmnibaseClient for API communication.
|
|
485
429
|
*
|
|
486
|
-
* @param
|
|
430
|
+
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
487
431
|
*
|
|
488
432
|
* @example
|
|
489
433
|
* ```typescript
|
|
490
|
-
* const paymentHandler = new PaymentHandler(
|
|
434
|
+
* const paymentHandler = new PaymentHandler(omnibaseClient);
|
|
491
435
|
* ```
|
|
492
436
|
*
|
|
493
|
-
* @since
|
|
437
|
+
* @since 0.6.0
|
|
494
438
|
* @group Client
|
|
495
439
|
*/
|
|
496
440
|
constructor(omnibaseClient) {
|
|
@@ -509,10 +453,14 @@ var PaymentHandler = class {
|
|
|
509
453
|
* @example
|
|
510
454
|
* ```typescript
|
|
511
455
|
* const session = await paymentHandler.checkout.createSession({
|
|
512
|
-
* price_id: '
|
|
456
|
+
* price_id: 'price_monthly_pro',
|
|
513
457
|
* success_url: window.location.origin + '/success',
|
|
514
458
|
* cancel_url: window.location.origin + '/pricing'
|
|
515
459
|
* });
|
|
460
|
+
*
|
|
461
|
+
* if (session.data?.url) {
|
|
462
|
+
* window.location.href = session.data.url;
|
|
463
|
+
* }
|
|
516
464
|
* ```
|
|
517
465
|
*/
|
|
518
466
|
checkout;
|
|
@@ -833,17 +781,6 @@ var TenantInviteManager = class {
|
|
|
833
781
|
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
834
782
|
*
|
|
835
783
|
* @example
|
|
836
|
-
* Basic invitation acceptance:
|
|
837
|
-
* ```typescript
|
|
838
|
-
* const result = await acceptTenantInvite('inv_secure_token_abc123');
|
|
839
|
-
*
|
|
840
|
-
* console.log(`Successfully joined tenant: ${result.data.tenant_id}`);
|
|
841
|
-
* // User can now access tenant resources
|
|
842
|
-
* await switchActiveTenant(result.data.tenant_id);
|
|
843
|
-
* ```
|
|
844
|
-
*
|
|
845
|
-
* @example
|
|
846
|
-
* Handling the invitation flow:
|
|
847
784
|
* ```typescript
|
|
848
785
|
* // Typically called from an invitation link like:
|
|
849
786
|
* // https://app.com/accept-invite?token=inv_secure_token_abc123
|
|
@@ -853,21 +790,20 @@ var TenantInviteManager = class {
|
|
|
853
790
|
*
|
|
854
791
|
* if (inviteToken) {
|
|
855
792
|
* try {
|
|
856
|
-
* const result = await
|
|
793
|
+
* const result = await inviteManager.accept(inviteToken);
|
|
857
794
|
*
|
|
858
795
|
* // Success - redirect to tenant dashboard
|
|
796
|
+
* console.log(`Successfully joined tenant: ${result.data.tenant_id}`);
|
|
859
797
|
* window.location.href = `/dashboard?tenant=${result.data.tenant_id}`;
|
|
860
798
|
* } catch (error) {
|
|
861
799
|
* console.error('Failed to accept invitation:', error.message);
|
|
862
|
-
* // Show error to user
|
|
863
800
|
* }
|
|
864
801
|
* }
|
|
865
802
|
* ```
|
|
866
803
|
*
|
|
867
|
-
*
|
|
868
|
-
* @since 1.0.0
|
|
804
|
+
* @since 0.6.0
|
|
869
805
|
* @public
|
|
870
|
-
* @group
|
|
806
|
+
* @group Tenant Invitations
|
|
871
807
|
*/
|
|
872
808
|
async accept(token) {
|
|
873
809
|
if (!token) {
|
|
@@ -902,67 +838,53 @@ var TenantInviteManager = class {
|
|
|
902
838
|
}
|
|
903
839
|
}
|
|
904
840
|
/**
|
|
905
|
-
* Creates a new user invitation for
|
|
841
|
+
* Creates a new user invitation for the active tenant
|
|
906
842
|
*
|
|
907
|
-
* Generates a secure invitation that allows a user to join the
|
|
908
|
-
* tenant with the defined role. The invitation is sent to the provided
|
|
909
|
-
*
|
|
843
|
+
* Generates a secure invitation that allows a user to join the currently active
|
|
844
|
+
* tenant with the defined role. The invitation is sent to the provided email address
|
|
845
|
+
* and includes a time-limited token for security. The invite URL will be automatically
|
|
846
|
+
* appended with ?token=XYZ when sent to the user.
|
|
910
847
|
*
|
|
911
|
-
* The function creates the invitation record in the database and
|
|
912
|
-
*
|
|
913
|
-
* The invitation expires after a predefined time period and can only
|
|
848
|
+
* The function creates the invitation record in the database and triggers an email
|
|
849
|
+
* notification to the invited user. The invitation expires after 7 days and can only
|
|
914
850
|
* be used once.
|
|
915
851
|
*
|
|
916
|
-
* Only existing tenant members with appropriate permissions
|
|
917
|
-
* invitations. The inviter's authentication
|
|
918
|
-
* cookies sent with the request.
|
|
852
|
+
* Only existing tenant members with appropriate permissions (invite_user permission)
|
|
853
|
+
* can create invitations. The inviter's authentication and tenant context are validated
|
|
854
|
+
* via HTTP-only cookies sent with the request.
|
|
919
855
|
*
|
|
920
|
-
* @param tenantId - Unique identifier of the tenant to invite the user to
|
|
921
856
|
* @param inviteData - Configuration object for the invitation
|
|
922
857
|
* @param inviteData.email - Email address of the user to invite
|
|
923
858
|
* @param inviteData.role - Role the user will have after joining (e.g., 'member', 'admin')
|
|
859
|
+
* @param inviteData.invite_url - Base URL for the invitation link (will be appended with ?token=XYZ)
|
|
924
860
|
*
|
|
925
861
|
* @returns Promise resolving to the created invitation with secure token
|
|
926
862
|
*
|
|
927
|
-
* @throws {Error} When
|
|
928
|
-
* @throws {Error} When
|
|
863
|
+
* @throws {Error} When required fields (email, role, invite_url) are missing or empty
|
|
864
|
+
* @throws {Error} When the user doesn't have permission to invite users to the tenant
|
|
929
865
|
* @throws {Error} When the API request fails due to network issues
|
|
930
866
|
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
931
867
|
*
|
|
932
868
|
* @example
|
|
933
|
-
* Basic invitation creation:
|
|
934
869
|
* ```typescript
|
|
935
|
-
* const invite = await
|
|
870
|
+
* const invite = await inviteManager.create({
|
|
936
871
|
* email: 'colleague@company.com',
|
|
937
|
-
* role: 'member'
|
|
872
|
+
* role: 'member',
|
|
873
|
+
* invite_url: 'https://yourapp.com/accept-invite'
|
|
938
874
|
* });
|
|
939
875
|
*
|
|
940
876
|
* console.log(`Invite sent to: ${invite.data.invite.email}`);
|
|
941
|
-
*
|
|
942
|
-
* const inviteLink = `https://app.com/accept-invite?token=${invite.data.invite.token}`;
|
|
877
|
+
* console.log(`Invite token: ${invite.data.invite.token}`);
|
|
943
878
|
* ```
|
|
944
879
|
*
|
|
945
|
-
* @
|
|
946
|
-
* Creating admin invitation:
|
|
947
|
-
* ```typescript
|
|
948
|
-
* const adminInvite = await createTenantUserInvite('tenant_456', {
|
|
949
|
-
* email: 'admin@company.com',
|
|
950
|
-
* role: 'admin'
|
|
951
|
-
* });
|
|
952
|
-
*
|
|
953
|
-
* // Admin users get elevated permissions
|
|
954
|
-
* console.log(`Admin invite created with ID: ${adminInvite.data.invite.id}`);
|
|
955
|
-
* ```
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
* @since 1.0.0
|
|
880
|
+
* @since 0.6.0
|
|
959
881
|
* @public
|
|
960
|
-
* @group
|
|
882
|
+
* @group Tenant Invitations
|
|
961
883
|
*/
|
|
962
884
|
async create(inviteData) {
|
|
963
885
|
if (!inviteData.email || !inviteData.role || !inviteData.invite_url) {
|
|
964
886
|
throw new Error(
|
|
965
|
-
"Missing data in `create` - email, role,
|
|
887
|
+
"Missing data in `create` - email, role, and invite_url are required"
|
|
966
888
|
);
|
|
967
889
|
}
|
|
968
890
|
try {
|
|
@@ -1031,17 +953,17 @@ var TenantManger = class {
|
|
|
1031
953
|
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1032
954
|
*
|
|
1033
955
|
* @example
|
|
1034
|
-
* Basic tenant creation:
|
|
1035
956
|
* ```typescript
|
|
1036
|
-
* const newTenant = await createTenant({
|
|
957
|
+
* const newTenant = await tenantManager.createTenant({
|
|
1037
958
|
* name: 'Acme Corporation',
|
|
1038
959
|
* billing_email: 'billing@acme.com',
|
|
1039
960
|
* user_id: 'user_123'
|
|
1040
961
|
* });
|
|
1041
|
-
* ```
|
|
1042
962
|
*
|
|
963
|
+
* console.log(`Tenant created: ${newTenant.data.tenant.id}`);
|
|
964
|
+
* ```
|
|
1043
965
|
*
|
|
1044
|
-
* @since
|
|
966
|
+
* @since 0.6.0
|
|
1045
967
|
* @public
|
|
1046
968
|
* @group Tenant Management
|
|
1047
969
|
*/
|
|
@@ -1106,7 +1028,6 @@ var TenantManger = class {
|
|
|
1106
1028
|
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1107
1029
|
*
|
|
1108
1030
|
* @example
|
|
1109
|
-
* Basic tenant deletion with confirmation:
|
|
1110
1031
|
* ```typescript
|
|
1111
1032
|
* const tenantToDelete = 'tenant_abc123';
|
|
1112
1033
|
*
|
|
@@ -1117,8 +1038,8 @@ var TenantManger = class {
|
|
|
1117
1038
|
*
|
|
1118
1039
|
* if (userConfirmed) {
|
|
1119
1040
|
* try {
|
|
1120
|
-
* const result = await deleteTenant(tenantToDelete);
|
|
1121
|
-
* console.log(result.data.message);
|
|
1041
|
+
* const result = await tenantManager.deleteTenant(tenantToDelete);
|
|
1042
|
+
* console.log(result.data.message);
|
|
1122
1043
|
*
|
|
1123
1044
|
* // Redirect user away from deleted tenant
|
|
1124
1045
|
* window.location.href = '/dashboard';
|
|
@@ -1128,7 +1049,7 @@ var TenantManger = class {
|
|
|
1128
1049
|
* }
|
|
1129
1050
|
* ```
|
|
1130
1051
|
*
|
|
1131
|
-
* @since
|
|
1052
|
+
* @since 0.6.0
|
|
1132
1053
|
* @public
|
|
1133
1054
|
* @group Tenant Management
|
|
1134
1055
|
*/
|
|
@@ -1191,46 +1112,17 @@ var TenantManger = class {
|
|
|
1191
1112
|
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1192
1113
|
*
|
|
1193
1114
|
* @example
|
|
1194
|
-
* Basic tenant switching:
|
|
1195
1115
|
* ```typescript
|
|
1196
|
-
* const result = await switchActiveTenant('tenant_xyz789');
|
|
1116
|
+
* const result = await tenantManager.switchActiveTenant('tenant_xyz789');
|
|
1117
|
+
*
|
|
1118
|
+
* // Store the new token for future requests
|
|
1119
|
+
* console.log(`Switched to tenant. New token: ${result.data.token}`);
|
|
1197
1120
|
*
|
|
1198
1121
|
* // Now all API calls will be in the context of tenant_xyz789
|
|
1199
1122
|
* const tenantData = await getCurrentTenantData();
|
|
1200
1123
|
* ```
|
|
1201
1124
|
*
|
|
1202
|
-
* @
|
|
1203
|
-
* Using with tenant-aware data fetching:
|
|
1204
|
-
* ```typescript
|
|
1205
|
-
* // Switch tenant and immediately fetch tenant-specific data
|
|
1206
|
-
* const switchAndLoadTenant = async (tenantId: string) => {
|
|
1207
|
-
* try {
|
|
1208
|
-
* // Switch to new tenant context
|
|
1209
|
-
* const switchResult = await switchActiveTenant(tenantId);
|
|
1210
|
-
*
|
|
1211
|
-
* // Update authentication token
|
|
1212
|
-
* setAuthToken(switchResult.data.token);
|
|
1213
|
-
*
|
|
1214
|
-
* // Fetch data in new tenant context
|
|
1215
|
-
* const [tenantInfo, userPermissions, tenantSettings] = await Promise.all([
|
|
1216
|
-
* getTenantInfo(),
|
|
1217
|
-
* getUserPermissions(),
|
|
1218
|
-
* getTenantSettings()
|
|
1219
|
-
* ]);
|
|
1220
|
-
*
|
|
1221
|
-
* return {
|
|
1222
|
-
* tenant: tenantInfo,
|
|
1223
|
-
* permissions: userPermissions,
|
|
1224
|
-
* settings: tenantSettings
|
|
1225
|
-
* };
|
|
1226
|
-
* } catch (error) {
|
|
1227
|
-
* console.error('Failed to switch tenant and load data:', error);
|
|
1228
|
-
* throw error;
|
|
1229
|
-
* }
|
|
1230
|
-
* };
|
|
1231
|
-
* ```
|
|
1232
|
-
*
|
|
1233
|
-
* @since 1.0.0
|
|
1125
|
+
* @since 0.6.0
|
|
1234
1126
|
* @public
|
|
1235
1127
|
* @group Tenant Management
|
|
1236
1128
|
*/
|
|
@@ -1317,7 +1209,7 @@ var TenantUserManager = class {
|
|
|
1317
1209
|
* }
|
|
1318
1210
|
* ```
|
|
1319
1211
|
*
|
|
1320
|
-
* @since
|
|
1212
|
+
* @since 0.6.0
|
|
1321
1213
|
* @public
|
|
1322
1214
|
* @group Tenant User Management
|
|
1323
1215
|
*/
|
|
@@ -1381,7 +1273,7 @@ var TenantUserManager = class {
|
|
|
1381
1273
|
* }
|
|
1382
1274
|
* ```
|
|
1383
1275
|
*
|
|
1384
|
-
* @since
|
|
1276
|
+
* @since 0.6.0
|
|
1385
1277
|
* @public
|
|
1386
1278
|
* @group Tenant User Management
|
|
1387
1279
|
*/
|
|
@@ -1442,7 +1334,7 @@ var TenantHandler = class {
|
|
|
1442
1334
|
* await tenantHandler.user.remove({ user_id: 'user_123' });
|
|
1443
1335
|
* ```
|
|
1444
1336
|
*
|
|
1445
|
-
* @since
|
|
1337
|
+
* @since 0.6.0
|
|
1446
1338
|
* @group Tenant Management
|
|
1447
1339
|
*/
|
|
1448
1340
|
user;
|
|
@@ -1456,17 +1348,17 @@ var TenantHandler = class {
|
|
|
1456
1348
|
* @example
|
|
1457
1349
|
* ```typescript
|
|
1458
1350
|
* // Create a new tenant
|
|
1459
|
-
* const tenant = await tenantHandler.
|
|
1351
|
+
* const tenant = await tenantHandler.manage.createTenant({
|
|
1460
1352
|
* name: 'New Company',
|
|
1461
1353
|
* billing_email: 'billing@newcompany.com',
|
|
1462
1354
|
* user_id: 'user_456'
|
|
1463
1355
|
* });
|
|
1464
1356
|
*
|
|
1465
1357
|
* // Switch to the tenant
|
|
1466
|
-
* await tenantHandler.
|
|
1358
|
+
* await tenantHandler.manage.switchActiveTenant(tenant.data.tenant.id);
|
|
1467
1359
|
*
|
|
1468
1360
|
* // Delete the tenant (owner only)
|
|
1469
|
-
* await tenantHandler.
|
|
1361
|
+
* await tenantHandler.manage.deleteTenant(tenant.data.tenant.id);
|
|
1470
1362
|
* ```
|
|
1471
1363
|
*/
|
|
1472
1364
|
manage;
|
|
@@ -1480,9 +1372,10 @@ var TenantHandler = class {
|
|
|
1480
1372
|
* @example
|
|
1481
1373
|
* ```typescript
|
|
1482
1374
|
* // Create an invitation
|
|
1483
|
-
* const invite = await tenantHandler.invites.create(
|
|
1375
|
+
* const invite = await tenantHandler.invites.create({
|
|
1484
1376
|
* email: 'newuser@company.com',
|
|
1485
|
-
* role: 'admin'
|
|
1377
|
+
* role: 'admin',
|
|
1378
|
+
* invite_url: 'https://yourapp.com/accept-invite'
|
|
1486
1379
|
* });
|
|
1487
1380
|
*
|
|
1488
1381
|
* // Accept an invitation (from the invited user's session)
|
|
@@ -1523,7 +1416,90 @@ var OmnibaseClient = class {
|
|
|
1523
1416
|
* ```
|
|
1524
1417
|
*/
|
|
1525
1418
|
payments = new PaymentHandler(this);
|
|
1419
|
+
/**
|
|
1420
|
+
* Main tenant management handler
|
|
1421
|
+
*
|
|
1422
|
+
* This is the primary entry point for all tenant-related operations in the
|
|
1423
|
+
* Omnibase SDK. It provides a unified interface to tenant management,
|
|
1424
|
+
* user management, and invitation functionality through dedicated manager instances.
|
|
1425
|
+
*
|
|
1426
|
+
* The handler follows the composition pattern, combining specialized managers
|
|
1427
|
+
* for different aspects of tenant functionality:
|
|
1428
|
+
* - `manage`: Core tenant operations (create, delete, switch)
|
|
1429
|
+
* - `invites`: User invitation management (create, accept)
|
|
1430
|
+
* - `user`: Tenant user operations (remove, update role)
|
|
1431
|
+
*
|
|
1432
|
+
* All operations are performed within the context of the authenticated user
|
|
1433
|
+
* and respect tenant-level permissions and row-level security policies.
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
* ```typescript
|
|
1437
|
+
* // Create a new tenant
|
|
1438
|
+
* const tenant = await omnibase.tenants.manage.createTenant({
|
|
1439
|
+
* name: 'My Company',
|
|
1440
|
+
* billing_email: 'billing@company.com',
|
|
1441
|
+
* user_id: 'user_123'
|
|
1442
|
+
* });
|
|
1443
|
+
*
|
|
1444
|
+
* // Invite users to the tenant
|
|
1445
|
+
* const invite = await omnibase.tenants.invites.create({
|
|
1446
|
+
* email: 'colleague@company.com',
|
|
1447
|
+
* role: 'member',
|
|
1448
|
+
* invite_url: 'https://yourapp.com/accept-invite'
|
|
1449
|
+
* });
|
|
1450
|
+
*
|
|
1451
|
+
* // Switch to the new tenant
|
|
1452
|
+
* await omnibase.tenants.manage.switchActiveTenant(tenant.data.tenant.id);
|
|
1453
|
+
* ```
|
|
1454
|
+
*
|
|
1455
|
+
* @since 0.6.0
|
|
1456
|
+
* @public
|
|
1457
|
+
* @group Tenant Management
|
|
1458
|
+
*/
|
|
1526
1459
|
tenants = new TenantHandler(this);
|
|
1460
|
+
/**
|
|
1461
|
+
* Client for managing permissions and relationships using Ory Keto
|
|
1462
|
+
*
|
|
1463
|
+
* This client provides access to Ory Keto's permission system, allowing you to
|
|
1464
|
+
* create, manage, and check relationships between subjects and objects. It handles
|
|
1465
|
+
* both read operations (permission checks) and write operations (relationship management).
|
|
1466
|
+
*
|
|
1467
|
+
* The client automatically configures separate endpoints for read and write operations
|
|
1468
|
+
* to optimize performance and security by following Ory Keto's recommended architecture.
|
|
1469
|
+
*
|
|
1470
|
+
* @example
|
|
1471
|
+
* ```typescript
|
|
1472
|
+
* // Check if a user can view a tenant
|
|
1473
|
+
* const canView = await omnibase.permissions.permissions.checkPermission(
|
|
1474
|
+
* undefined,
|
|
1475
|
+
* {
|
|
1476
|
+
* namespace: 'Tenant',
|
|
1477
|
+
* object: 'tenant_123',
|
|
1478
|
+
* relation: 'view',
|
|
1479
|
+
* subjectId: 'user_456'
|
|
1480
|
+
* }
|
|
1481
|
+
* );
|
|
1482
|
+
*
|
|
1483
|
+
* if (canView.data.allowed) {
|
|
1484
|
+
* console.log('User can view the tenant');
|
|
1485
|
+
* }
|
|
1486
|
+
*
|
|
1487
|
+
* // Create a relationship making a user an owner of a tenant
|
|
1488
|
+
* await omnibase.permissions.relationships.createRelationship(
|
|
1489
|
+
* undefined,
|
|
1490
|
+
* {
|
|
1491
|
+
* namespace: 'Tenant',
|
|
1492
|
+
* object: 'tenant_123',
|
|
1493
|
+
* relation: 'owners',
|
|
1494
|
+
* subjectId: 'user_456'
|
|
1495
|
+
* }
|
|
1496
|
+
* );
|
|
1497
|
+
* ```
|
|
1498
|
+
*
|
|
1499
|
+
* @since 0.6.0
|
|
1500
|
+
* @public
|
|
1501
|
+
* @group Permissions
|
|
1502
|
+
*/
|
|
1527
1503
|
permissions;
|
|
1528
1504
|
/**
|
|
1529
1505
|
* Storage client for file upload/download operations
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PaymentHandler
|
|
3
|
-
} from "./chunk-PNP3T7XU.js";
|
|
4
1
|
import {
|
|
5
2
|
PermissionsClient
|
|
6
3
|
} from "./chunk-DDFBRGMG.js";
|
|
4
|
+
import {
|
|
5
|
+
PaymentHandler
|
|
6
|
+
} from "./chunk-QPW6G4PA.js";
|
|
7
7
|
import {
|
|
8
8
|
StorageClient
|
|
9
9
|
} from "./chunk-I6DMWC32.js";
|
|
10
10
|
import {
|
|
11
11
|
TenantHandler
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6OGESVXW.js";
|
|
13
13
|
|
|
14
14
|
// src/client.ts
|
|
15
15
|
var OmnibaseClient = class {
|
|
@@ -42,7 +42,90 @@ var OmnibaseClient = class {
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
payments = new PaymentHandler(this);
|
|
45
|
+
/**
|
|
46
|
+
* Main tenant management handler
|
|
47
|
+
*
|
|
48
|
+
* This is the primary entry point for all tenant-related operations in the
|
|
49
|
+
* Omnibase SDK. It provides a unified interface to tenant management,
|
|
50
|
+
* user management, and invitation functionality through dedicated manager instances.
|
|
51
|
+
*
|
|
52
|
+
* The handler follows the composition pattern, combining specialized managers
|
|
53
|
+
* for different aspects of tenant functionality:
|
|
54
|
+
* - `manage`: Core tenant operations (create, delete, switch)
|
|
55
|
+
* - `invites`: User invitation management (create, accept)
|
|
56
|
+
* - `user`: Tenant user operations (remove, update role)
|
|
57
|
+
*
|
|
58
|
+
* All operations are performed within the context of the authenticated user
|
|
59
|
+
* and respect tenant-level permissions and row-level security policies.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Create a new tenant
|
|
64
|
+
* const tenant = await omnibase.tenants.manage.createTenant({
|
|
65
|
+
* name: 'My Company',
|
|
66
|
+
* billing_email: 'billing@company.com',
|
|
67
|
+
* user_id: 'user_123'
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Invite users to the tenant
|
|
71
|
+
* const invite = await omnibase.tenants.invites.create({
|
|
72
|
+
* email: 'colleague@company.com',
|
|
73
|
+
* role: 'member',
|
|
74
|
+
* invite_url: 'https://yourapp.com/accept-invite'
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* // Switch to the new tenant
|
|
78
|
+
* await omnibase.tenants.manage.switchActiveTenant(tenant.data.tenant.id);
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @since 0.6.0
|
|
82
|
+
* @public
|
|
83
|
+
* @group Tenant Management
|
|
84
|
+
*/
|
|
45
85
|
tenants = new TenantHandler(this);
|
|
86
|
+
/**
|
|
87
|
+
* Client for managing permissions and relationships using Ory Keto
|
|
88
|
+
*
|
|
89
|
+
* This client provides access to Ory Keto's permission system, allowing you to
|
|
90
|
+
* create, manage, and check relationships between subjects and objects. It handles
|
|
91
|
+
* both read operations (permission checks) and write operations (relationship management).
|
|
92
|
+
*
|
|
93
|
+
* The client automatically configures separate endpoints for read and write operations
|
|
94
|
+
* to optimize performance and security by following Ory Keto's recommended architecture.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Check if a user can view a tenant
|
|
99
|
+
* const canView = await omnibase.permissions.permissions.checkPermission(
|
|
100
|
+
* undefined,
|
|
101
|
+
* {
|
|
102
|
+
* namespace: 'Tenant',
|
|
103
|
+
* object: 'tenant_123',
|
|
104
|
+
* relation: 'view',
|
|
105
|
+
* subjectId: 'user_456'
|
|
106
|
+
* }
|
|
107
|
+
* );
|
|
108
|
+
*
|
|
109
|
+
* if (canView.data.allowed) {
|
|
110
|
+
* console.log('User can view the tenant');
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* // Create a relationship making a user an owner of a tenant
|
|
114
|
+
* await omnibase.permissions.relationships.createRelationship(
|
|
115
|
+
* undefined,
|
|
116
|
+
* {
|
|
117
|
+
* namespace: 'Tenant',
|
|
118
|
+
* object: 'tenant_123',
|
|
119
|
+
* relation: 'owners',
|
|
120
|
+
* subjectId: 'user_456'
|
|
121
|
+
* }
|
|
122
|
+
* );
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @since 0.6.0
|
|
126
|
+
* @public
|
|
127
|
+
* @group Permissions
|
|
128
|
+
*/
|
|
46
129
|
permissions;
|
|
47
130
|
/**
|
|
48
131
|
* Storage client for file upload/download operations
|