@omnibase/core-js 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.openapi-generator/FILES +228 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/README.md +240 -169
- package/dist/apis/DatabaseApi.d.ts +31 -0
- package/dist/apis/DatabaseApi.js +86 -0
- package/dist/apis/PaymentsApi.d.ts +57 -0
- package/dist/apis/PaymentsApi.js +141 -0
- package/dist/apis/PermissionsApi.d.ts +57 -0
- package/dist/apis/PermissionsApi.js +158 -0
- package/dist/apis/StorageApi.d.ts +57 -0
- package/dist/apis/StorageApi.js +141 -0
- package/dist/apis/StripeApi.d.ts +112 -0
- package/dist/apis/StripeApi.js +291 -0
- package/dist/apis/TenantsApi.d.ts +220 -0
- package/dist/apis/TenantsApi.js +617 -0
- package/dist/apis/index.d.ts +6 -0
- package/dist/apis/index.js +24 -0
- package/dist/esm/apis/DatabaseApi.d.ts +31 -0
- package/dist/esm/apis/DatabaseApi.js +82 -0
- package/dist/esm/apis/PaymentsApi.d.ts +57 -0
- package/dist/esm/apis/PaymentsApi.js +137 -0
- package/dist/esm/apis/PermissionsApi.d.ts +57 -0
- package/dist/esm/apis/PermissionsApi.js +154 -0
- package/dist/esm/apis/StorageApi.d.ts +57 -0
- package/dist/esm/apis/StorageApi.js +137 -0
- package/dist/esm/apis/StripeApi.d.ts +112 -0
- package/dist/esm/apis/StripeApi.js +287 -0
- package/dist/esm/apis/TenantsApi.d.ts +220 -0
- package/dist/esm/apis/TenantsApi.js +613 -0
- package/dist/esm/apis/index.d.ts +6 -0
- package/dist/esm/apis/index.js +8 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/models/AcceptInvite200Response.d.ts +39 -0
- package/dist/esm/models/AcceptInvite200Response.js +44 -0
- package/dist/esm/models/AssignRole200Response.d.ts +39 -0
- package/dist/esm/models/AssignRole200Response.js +44 -0
- package/dist/esm/models/CheckPermission200Response.d.ts +39 -0
- package/dist/esm/models/CheckPermission200Response.js +44 -0
- package/dist/esm/models/ClientRelationship.d.ts +57 -0
- package/dist/esm/models/ClientRelationship.js +50 -0
- package/dist/esm/models/ClientSubjectSet.d.ts +44 -0
- package/dist/esm/models/ClientSubjectSet.js +45 -0
- package/dist/esm/models/CreateCheckout200Response.d.ts +39 -0
- package/dist/esm/models/CreateCheckout200Response.js +44 -0
- package/dist/esm/models/CreateCustomerPortal200Response.d.ts +39 -0
- package/dist/esm/models/CreateCustomerPortal200Response.js +44 -0
- package/dist/esm/models/CreateInvite200Response.d.ts +39 -0
- package/dist/esm/models/CreateInvite200Response.js +44 -0
- package/dist/esm/models/CreateRelationship200Response.d.ts +39 -0
- package/dist/esm/models/CreateRelationship200Response.js +44 -0
- package/dist/esm/models/CreateRole200Response.d.ts +39 -0
- package/dist/esm/models/CreateRole200Response.js +44 -0
- package/dist/esm/models/CreateTenant200Response.d.ts +39 -0
- package/dist/esm/models/CreateTenant200Response.js +44 -0
- package/dist/esm/models/DeleteRole200Response.d.ts +39 -0
- package/dist/esm/models/DeleteRole200Response.js +44 -0
- package/dist/esm/models/DeleteTenant200Response.d.ts +39 -0
- package/dist/esm/models/DeleteTenant200Response.js +44 -0
- package/dist/esm/models/DeployPermissionNamespaces200Response.d.ts +39 -0
- package/dist/esm/models/DeployPermissionNamespaces200Response.js +44 -0
- package/dist/esm/models/GetRoleDefinitions200Response.d.ts +39 -0
- package/dist/esm/models/GetRoleDefinitions200Response.js +44 -0
- package/dist/esm/models/GetTenantBillingStatus200Response.d.ts +39 -0
- package/dist/esm/models/GetTenantBillingStatus200Response.js +44 -0
- package/dist/esm/models/GetTenantJWT200Response.d.ts +39 -0
- package/dist/esm/models/GetTenantJWT200Response.js +44 -0
- package/dist/esm/models/HandlersBadRequestResponse.d.ts +38 -0
- package/dist/esm/models/HandlersBadRequestResponse.js +43 -0
- package/dist/esm/models/HandlersForbiddenResponse.d.ts +38 -0
- package/dist/esm/models/HandlersForbiddenResponse.js +43 -0
- package/dist/esm/models/HandlersInternalServerErrorResponse.d.ts +38 -0
- package/dist/esm/models/HandlersInternalServerErrorResponse.js +43 -0
- package/dist/esm/models/HandlersNotFoundErrorResponse.d.ts +38 -0
- package/dist/esm/models/HandlersNotFoundErrorResponse.js +43 -0
- package/dist/esm/models/HandlersSuccessResponse.d.ts +38 -0
- package/dist/esm/models/HandlersSuccessResponse.js +43 -0
- package/dist/esm/models/HandlersUnauthorizedResponse.d.ts +38 -0
- package/dist/esm/models/HandlersUnauthorizedResponse.js +43 -0
- package/dist/esm/models/ListRoles200Response.d.ts +39 -0
- package/dist/esm/models/ListRoles200Response.js +44 -0
- package/dist/esm/models/ListTenantSubscriptions200Response.d.ts +39 -0
- package/dist/esm/models/ListTenantSubscriptions200Response.js +44 -0
- package/dist/esm/models/ListTenantUsers200Response.d.ts +39 -0
- package/dist/esm/models/ListTenantUsers200Response.js +44 -0
- package/dist/esm/models/ModelsBillingStatusResponse.d.ts +38 -0
- package/dist/esm/models/ModelsBillingStatusResponse.js +43 -0
- package/dist/esm/models/ModelsDeleteObjectRequest.d.ts +32 -0
- package/dist/esm/models/ModelsDeleteObjectRequest.js +43 -0
- package/dist/esm/models/ModelsDownloadRequest.d.ts +32 -0
- package/dist/esm/models/ModelsDownloadRequest.js +43 -0
- package/dist/esm/models/ModelsDownloadResponse.d.ts +32 -0
- package/dist/esm/models/ModelsDownloadResponse.js +41 -0
- package/dist/esm/models/ModelsMessageResponse.d.ts +32 -0
- package/dist/esm/models/ModelsMessageResponse.js +41 -0
- package/dist/esm/models/ModelsMeter.d.ts +65 -0
- package/dist/esm/models/ModelsMeter.js +62 -0
- package/dist/esm/models/ModelsMeterCustomerMapping.d.ts +45 -0
- package/dist/esm/models/ModelsMeterCustomerMapping.js +53 -0
- package/dist/esm/models/ModelsMeterDefaultAggregation.d.ts +41 -0
- package/dist/esm/models/ModelsMeterDefaultAggregation.js +51 -0
- package/dist/esm/models/ModelsMeterValueSettings.d.ts +32 -0
- package/dist/esm/models/ModelsMeterValueSettings.js +43 -0
- package/dist/esm/models/ModelsMeterWithStripeID.d.ts +71 -0
- package/dist/esm/models/ModelsMeterWithStripeID.js +64 -0
- package/dist/esm/models/ModelsNamespaceDefinition.d.ts +50 -0
- package/dist/esm/models/ModelsNamespaceDefinition.js +47 -0
- package/dist/esm/models/ModelsPrice.d.ts +112 -0
- package/dist/esm/models/ModelsPrice.js +73 -0
- package/dist/esm/models/ModelsPriceDisplay.d.ts +44 -0
- package/dist/esm/models/ModelsPriceDisplay.js +45 -0
- package/dist/esm/models/ModelsPriceLimit.d.ts +44 -0
- package/dist/esm/models/ModelsPriceLimit.js +45 -0
- package/dist/esm/models/ModelsPriceUI.d.ts +58 -0
- package/dist/esm/models/ModelsPriceUI.js +51 -0
- package/dist/esm/models/ModelsPriceWithStripeID.d.ts +118 -0
- package/dist/esm/models/ModelsPriceWithStripeID.js +75 -0
- package/dist/esm/models/ModelsProduct.d.ts +64 -0
- package/dist/esm/models/ModelsProduct.js +59 -0
- package/dist/esm/models/ModelsProductUI.d.ts +68 -0
- package/dist/esm/models/ModelsProductUI.js +53 -0
- package/dist/esm/models/ModelsProductWithStripeIDs.d.ts +70 -0
- package/dist/esm/models/ModelsProductWithStripeIDs.js +61 -0
- package/dist/esm/models/ModelsRole.d.ts +68 -0
- package/dist/esm/models/ModelsRole.js +53 -0
- package/dist/esm/models/ModelsStripeConfiguration.d.ts +46 -0
- package/dist/esm/models/ModelsStripeConfiguration.js +51 -0
- package/dist/esm/models/ModelsStripeConfigurationWithIDs.d.ts +46 -0
- package/dist/esm/models/ModelsStripeConfigurationWithIDs.js +51 -0
- package/dist/esm/models/ModelsSubscriptionResponse.d.ts +56 -0
- package/dist/esm/models/ModelsSubscriptionResponse.js +49 -0
- package/dist/esm/models/ModelsTenant.d.ts +69 -0
- package/dist/esm/models/ModelsTenant.js +54 -0
- package/dist/esm/models/ModelsTenantInvite.d.ts +87 -0
- package/dist/esm/models/ModelsTenantInvite.js +60 -0
- package/dist/esm/models/ModelsTenantSettings.d.ts +44 -0
- package/dist/esm/models/ModelsTenantSettings.js +45 -0
- package/dist/esm/models/ModelsTier.d.ts +44 -0
- package/dist/esm/models/ModelsTier.js +45 -0
- package/dist/esm/models/ModelsUploadRequest.d.ts +40 -0
- package/dist/esm/models/ModelsUploadRequest.js +45 -0
- package/dist/esm/models/ModelsUploadResponse.d.ts +38 -0
- package/dist/esm/models/ModelsUploadResponse.js +43 -0
- package/dist/esm/models/StorageDownloadPost200Response.d.ts +39 -0
- package/dist/esm/models/StorageDownloadPost200Response.js +44 -0
- package/dist/esm/models/StorageObjectDelete200Response.d.ts +39 -0
- package/dist/esm/models/StorageObjectDelete200Response.js +44 -0
- package/dist/esm/models/StorageUploadPost200Response.d.ts +39 -0
- package/dist/esm/models/StorageUploadPost200Response.js +44 -0
- package/dist/esm/models/StripeConfigArchiveAllPost200Response.d.ts +39 -0
- package/dist/esm/models/StripeConfigArchiveAllPost200Response.js +44 -0
- package/dist/esm/models/StripeConfigGet200Response.d.ts +39 -0
- package/dist/esm/models/StripeConfigGet200Response.js +44 -0
- package/dist/esm/models/StripeConfigHistoryGet200Response.d.ts +39 -0
- package/dist/esm/models/StripeConfigHistoryGet200Response.js +44 -0
- package/dist/esm/models/StripeConfigPullGet200Response.d.ts +39 -0
- package/dist/esm/models/StripeConfigPullGet200Response.js +44 -0
- package/dist/esm/models/SwitchActiveTenant200Response.d.ts +39 -0
- package/dist/esm/models/SwitchActiveTenant200Response.js +44 -0
- package/dist/esm/models/TenantsAcceptInviteRequest.d.ts +32 -0
- package/dist/esm/models/TenantsAcceptInviteRequest.js +43 -0
- package/dist/esm/models/TenantsAcceptInviteResponse.d.ts +44 -0
- package/dist/esm/models/TenantsAcceptInviteResponse.js +45 -0
- package/dist/esm/models/TenantsAssignRoleRequest.d.ts +38 -0
- package/dist/esm/models/TenantsAssignRoleRequest.js +43 -0
- package/dist/esm/models/TenantsAssignRoleResponse.d.ts +32 -0
- package/dist/esm/models/TenantsAssignRoleResponse.js +41 -0
- package/dist/esm/models/TenantsCreateRoleRequest.d.ts +38 -0
- package/dist/esm/models/TenantsCreateRoleRequest.js +47 -0
- package/dist/esm/models/TenantsCreateTenantRequest.d.ts +44 -0
- package/dist/esm/models/TenantsCreateTenantRequest.js +49 -0
- package/dist/esm/models/TenantsCreateTenantResponse.d.ts +45 -0
- package/dist/esm/models/TenantsCreateTenantResponse.js +46 -0
- package/dist/esm/models/TenantsCreateTenantUserInviteRequest.d.ts +44 -0
- package/dist/esm/models/TenantsCreateTenantUserInviteRequest.js +51 -0
- package/dist/esm/models/TenantsCreateTenantUserInviteResponse.d.ts +39 -0
- package/dist/esm/models/TenantsCreateTenantUserInviteResponse.js +44 -0
- package/dist/esm/models/TenantsDeleteRoleResponse.d.ts +32 -0
- package/dist/esm/models/TenantsDeleteRoleResponse.js +41 -0
- package/dist/esm/models/TenantsDeleteTenantResponse.d.ts +32 -0
- package/dist/esm/models/TenantsDeleteTenantResponse.js +41 -0
- package/dist/esm/models/TenantsDeleteTenantUserRequest.d.ts +32 -0
- package/dist/esm/models/TenantsDeleteTenantUserRequest.js +43 -0
- package/dist/esm/models/TenantsJWTTokenResponse.d.ts +32 -0
- package/dist/esm/models/TenantsJWTTokenResponse.js +41 -0
- package/dist/esm/models/TenantsNamespaceDefinitionsResponse.d.ts +33 -0
- package/dist/esm/models/TenantsNamespaceDefinitionsResponse.js +42 -0
- package/dist/esm/models/TenantsRolesListResponse.d.ts +33 -0
- package/dist/esm/models/TenantsRolesListResponse.js +42 -0
- package/dist/esm/models/TenantsSwitchTenantRequest.d.ts +32 -0
- package/dist/esm/models/TenantsSwitchTenantRequest.js +43 -0
- package/dist/esm/models/TenantsSwitchTenantResponse.d.ts +38 -0
- package/dist/esm/models/TenantsSwitchTenantResponse.js +43 -0
- package/dist/esm/models/TenantsTenantUserResponse.d.ts +56 -0
- package/dist/esm/models/TenantsTenantUserResponse.js +49 -0
- package/dist/esm/models/TenantsUpdateRoleRequest.d.ts +32 -0
- package/dist/esm/models/TenantsUpdateRoleRequest.js +43 -0
- package/dist/esm/models/TenantsUpdateTenantUserRoleRequest.d.ts +38 -0
- package/dist/esm/models/TenantsUpdateTenantUserRoleRequest.js +47 -0
- package/dist/esm/models/TenantsUpdateTenantUserRoleResponse.d.ts +32 -0
- package/dist/esm/models/TenantsUpdateTenantUserRoleResponse.js +41 -0
- package/dist/esm/models/UpdateTenantUserRole200Response.d.ts +39 -0
- package/dist/esm/models/UpdateTenantUserRole200Response.js +44 -0
- package/dist/esm/models/V1ArchiveAllResponse.d.ts +62 -0
- package/dist/esm/models/V1ArchiveAllResponse.js +51 -0
- package/dist/esm/models/V1CheckPermissionRequest.d.ts +57 -0
- package/dist/esm/models/V1CheckPermissionRequest.js +56 -0
- package/dist/esm/models/V1CheckPermissionResponse.d.ts +32 -0
- package/dist/esm/models/V1CheckPermissionResponse.js +41 -0
- package/dist/esm/models/V1ConfigHistoryItem.d.ts +63 -0
- package/dist/esm/models/V1ConfigHistoryItem.js +52 -0
- package/dist/esm/models/V1ConfigHistoryPagination.d.ts +62 -0
- package/dist/esm/models/V1ConfigHistoryPagination.js +51 -0
- package/dist/esm/models/V1ConfigHistoryResponse.d.ts +40 -0
- package/dist/esm/models/V1ConfigHistoryResponse.js +45 -0
- package/dist/esm/models/V1CreateCheckoutRequest.d.ts +62 -0
- package/dist/esm/models/V1CreateCheckoutRequest.js +57 -0
- package/dist/esm/models/V1CreateCheckoutResponse.d.ts +38 -0
- package/dist/esm/models/V1CreateCheckoutResponse.js +43 -0
- package/dist/esm/models/V1CreatePortalRequest.d.ts +32 -0
- package/dist/esm/models/V1CreatePortalRequest.js +43 -0
- package/dist/esm/models/V1CreatePortalResponse.d.ts +32 -0
- package/dist/esm/models/V1CreatePortalResponse.js +43 -0
- package/dist/esm/models/V1CreateRelationshipRequest.d.ts +57 -0
- package/dist/esm/models/V1CreateRelationshipRequest.js +56 -0
- package/dist/esm/models/V1CreateRelationshipResponse.d.ts +39 -0
- package/dist/esm/models/V1CreateRelationshipResponse.js +44 -0
- package/dist/esm/models/V1MigrationErrorResponse.d.ts +38 -0
- package/dist/esm/models/V1MigrationErrorResponse.js +43 -0
- package/dist/esm/models/V1MigrationSuccessResponse.d.ts +38 -0
- package/dist/esm/models/V1MigrationSuccessResponse.js +43 -0
- package/dist/esm/models/V1NamespaceDeploymentResponse.d.ts +56 -0
- package/dist/esm/models/V1NamespaceDeploymentResponse.js +49 -0
- package/dist/esm/models/V1RecordUsageRequest.d.ts +38 -0
- package/dist/esm/models/V1RecordUsageRequest.js +47 -0
- package/dist/esm/models/V1StripeConfigResponse.d.ts +57 -0
- package/dist/esm/models/V1StripeConfigResponse.js +50 -0
- package/dist/esm/models/V1SubjectSetRequest.d.ts +44 -0
- package/dist/esm/models/V1SubjectSetRequest.js +49 -0
- package/dist/esm/models/index.d.ts +103 -0
- package/dist/esm/models/index.js +105 -0
- package/dist/esm/runtime.d.ts +184 -0
- package/dist/esm/runtime.js +334 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +20 -158
- package/dist/models/AcceptInvite200Response.d.ts +39 -0
- package/dist/models/AcceptInvite200Response.js +51 -0
- package/dist/models/AssignRole200Response.d.ts +39 -0
- package/dist/models/AssignRole200Response.js +51 -0
- package/dist/models/CheckPermission200Response.d.ts +39 -0
- package/dist/models/CheckPermission200Response.js +51 -0
- package/dist/models/ClientRelationship.d.ts +57 -0
- package/dist/models/ClientRelationship.js +57 -0
- package/dist/models/ClientSubjectSet.d.ts +44 -0
- package/dist/models/ClientSubjectSet.js +52 -0
- package/dist/models/CreateCheckout200Response.d.ts +39 -0
- package/dist/models/CreateCheckout200Response.js +51 -0
- package/dist/models/CreateCustomerPortal200Response.d.ts +39 -0
- package/dist/models/CreateCustomerPortal200Response.js +51 -0
- package/dist/models/CreateInvite200Response.d.ts +39 -0
- package/dist/models/CreateInvite200Response.js +51 -0
- package/dist/models/CreateRelationship200Response.d.ts +39 -0
- package/dist/models/CreateRelationship200Response.js +51 -0
- package/dist/models/CreateRole200Response.d.ts +39 -0
- package/dist/models/CreateRole200Response.js +51 -0
- package/dist/models/CreateTenant200Response.d.ts +39 -0
- package/dist/models/CreateTenant200Response.js +51 -0
- package/dist/models/DeleteRole200Response.d.ts +39 -0
- package/dist/models/DeleteRole200Response.js +51 -0
- package/dist/models/DeleteTenant200Response.d.ts +39 -0
- package/dist/models/DeleteTenant200Response.js +51 -0
- package/dist/models/DeployPermissionNamespaces200Response.d.ts +39 -0
- package/dist/models/DeployPermissionNamespaces200Response.js +51 -0
- package/dist/models/GetRoleDefinitions200Response.d.ts +39 -0
- package/dist/models/GetRoleDefinitions200Response.js +51 -0
- package/dist/models/GetTenantBillingStatus200Response.d.ts +39 -0
- package/dist/models/GetTenantBillingStatus200Response.js +51 -0
- package/dist/models/GetTenantJWT200Response.d.ts +39 -0
- package/dist/models/GetTenantJWT200Response.js +51 -0
- package/dist/models/HandlersBadRequestResponse.d.ts +38 -0
- package/dist/models/HandlersBadRequestResponse.js +50 -0
- package/dist/models/HandlersForbiddenResponse.d.ts +38 -0
- package/dist/models/HandlersForbiddenResponse.js +50 -0
- package/dist/models/HandlersInternalServerErrorResponse.d.ts +38 -0
- package/dist/models/HandlersInternalServerErrorResponse.js +50 -0
- package/dist/models/HandlersNotFoundErrorResponse.d.ts +38 -0
- package/dist/models/HandlersNotFoundErrorResponse.js +50 -0
- package/dist/models/HandlersSuccessResponse.d.ts +38 -0
- package/dist/models/HandlersSuccessResponse.js +50 -0
- package/dist/models/HandlersUnauthorizedResponse.d.ts +38 -0
- package/dist/models/HandlersUnauthorizedResponse.js +50 -0
- package/dist/models/ListRoles200Response.d.ts +39 -0
- package/dist/models/ListRoles200Response.js +51 -0
- package/dist/models/ListTenantSubscriptions200Response.d.ts +39 -0
- package/dist/models/ListTenantSubscriptions200Response.js +51 -0
- package/dist/models/ListTenantUsers200Response.d.ts +39 -0
- package/dist/models/ListTenantUsers200Response.js +51 -0
- package/dist/models/ModelsBillingStatusResponse.d.ts +38 -0
- package/dist/models/ModelsBillingStatusResponse.js +50 -0
- package/dist/models/ModelsDeleteObjectRequest.d.ts +32 -0
- package/dist/models/ModelsDeleteObjectRequest.js +50 -0
- package/dist/models/ModelsDownloadRequest.d.ts +32 -0
- package/dist/models/ModelsDownloadRequest.js +50 -0
- package/dist/models/ModelsDownloadResponse.d.ts +32 -0
- package/dist/models/ModelsDownloadResponse.js +48 -0
- package/dist/models/ModelsMessageResponse.d.ts +32 -0
- package/dist/models/ModelsMessageResponse.js +48 -0
- package/dist/models/ModelsMeter.d.ts +65 -0
- package/dist/models/ModelsMeter.js +69 -0
- package/dist/models/ModelsMeterCustomerMapping.d.ts +45 -0
- package/dist/models/ModelsMeterCustomerMapping.js +61 -0
- package/dist/models/ModelsMeterDefaultAggregation.d.ts +41 -0
- package/dist/models/ModelsMeterDefaultAggregation.js +59 -0
- package/dist/models/ModelsMeterValueSettings.d.ts +32 -0
- package/dist/models/ModelsMeterValueSettings.js +50 -0
- package/dist/models/ModelsMeterWithStripeID.d.ts +71 -0
- package/dist/models/ModelsMeterWithStripeID.js +71 -0
- package/dist/models/ModelsNamespaceDefinition.d.ts +50 -0
- package/dist/models/ModelsNamespaceDefinition.js +54 -0
- package/dist/models/ModelsPrice.d.ts +112 -0
- package/dist/models/ModelsPrice.js +80 -0
- package/dist/models/ModelsPriceDisplay.d.ts +44 -0
- package/dist/models/ModelsPriceDisplay.js +52 -0
- package/dist/models/ModelsPriceLimit.d.ts +44 -0
- package/dist/models/ModelsPriceLimit.js +52 -0
- package/dist/models/ModelsPriceUI.d.ts +58 -0
- package/dist/models/ModelsPriceUI.js +58 -0
- package/dist/models/ModelsPriceWithStripeID.d.ts +118 -0
- package/dist/models/ModelsPriceWithStripeID.js +82 -0
- package/dist/models/ModelsProduct.d.ts +64 -0
- package/dist/models/ModelsProduct.js +66 -0
- package/dist/models/ModelsProductUI.d.ts +68 -0
- package/dist/models/ModelsProductUI.js +60 -0
- package/dist/models/ModelsProductWithStripeIDs.d.ts +70 -0
- package/dist/models/ModelsProductWithStripeIDs.js +68 -0
- package/dist/models/ModelsRole.d.ts +68 -0
- package/dist/models/ModelsRole.js +60 -0
- package/dist/models/ModelsStripeConfiguration.d.ts +46 -0
- package/dist/models/ModelsStripeConfiguration.js +58 -0
- package/dist/models/ModelsStripeConfigurationWithIDs.d.ts +46 -0
- package/dist/models/ModelsStripeConfigurationWithIDs.js +58 -0
- package/dist/models/ModelsSubscriptionResponse.d.ts +56 -0
- package/dist/models/ModelsSubscriptionResponse.js +56 -0
- package/dist/models/ModelsTenant.d.ts +69 -0
- package/dist/models/ModelsTenant.js +61 -0
- package/dist/models/ModelsTenantInvite.d.ts +87 -0
- package/dist/models/ModelsTenantInvite.js +67 -0
- package/dist/models/ModelsTenantSettings.d.ts +44 -0
- package/dist/models/ModelsTenantSettings.js +52 -0
- package/dist/models/ModelsTier.d.ts +44 -0
- package/dist/models/ModelsTier.js +52 -0
- package/dist/models/ModelsUploadRequest.d.ts +40 -0
- package/dist/models/ModelsUploadRequest.js +52 -0
- package/dist/models/ModelsUploadResponse.d.ts +38 -0
- package/dist/models/ModelsUploadResponse.js +50 -0
- package/dist/models/StorageDownloadPost200Response.d.ts +39 -0
- package/dist/models/StorageDownloadPost200Response.js +51 -0
- package/dist/models/StorageObjectDelete200Response.d.ts +39 -0
- package/dist/models/StorageObjectDelete200Response.js +51 -0
- package/dist/models/StorageUploadPost200Response.d.ts +39 -0
- package/dist/models/StorageUploadPost200Response.js +51 -0
- package/dist/models/StripeConfigArchiveAllPost200Response.d.ts +39 -0
- package/dist/models/StripeConfigArchiveAllPost200Response.js +51 -0
- package/dist/models/StripeConfigGet200Response.d.ts +39 -0
- package/dist/models/StripeConfigGet200Response.js +51 -0
- package/dist/models/StripeConfigHistoryGet200Response.d.ts +39 -0
- package/dist/models/StripeConfigHistoryGet200Response.js +51 -0
- package/dist/models/StripeConfigPullGet200Response.d.ts +39 -0
- package/dist/models/StripeConfigPullGet200Response.js +51 -0
- package/dist/models/SwitchActiveTenant200Response.d.ts +39 -0
- package/dist/models/SwitchActiveTenant200Response.js +51 -0
- package/dist/models/TenantsAcceptInviteRequest.d.ts +32 -0
- package/dist/models/TenantsAcceptInviteRequest.js +50 -0
- package/dist/models/TenantsAcceptInviteResponse.d.ts +44 -0
- package/dist/models/TenantsAcceptInviteResponse.js +52 -0
- package/dist/models/TenantsAssignRoleRequest.d.ts +38 -0
- package/dist/models/TenantsAssignRoleRequest.js +50 -0
- package/dist/models/TenantsAssignRoleResponse.d.ts +32 -0
- package/dist/models/TenantsAssignRoleResponse.js +48 -0
- package/dist/models/TenantsCreateRoleRequest.d.ts +38 -0
- package/dist/models/TenantsCreateRoleRequest.js +54 -0
- package/dist/models/TenantsCreateTenantRequest.d.ts +44 -0
- package/dist/models/TenantsCreateTenantRequest.js +56 -0
- package/dist/models/TenantsCreateTenantResponse.d.ts +45 -0
- package/dist/models/TenantsCreateTenantResponse.js +53 -0
- package/dist/models/TenantsCreateTenantUserInviteRequest.d.ts +44 -0
- package/dist/models/TenantsCreateTenantUserInviteRequest.js +58 -0
- package/dist/models/TenantsCreateTenantUserInviteResponse.d.ts +39 -0
- package/dist/models/TenantsCreateTenantUserInviteResponse.js +51 -0
- package/dist/models/TenantsDeleteRoleResponse.d.ts +32 -0
- package/dist/models/TenantsDeleteRoleResponse.js +48 -0
- package/dist/models/TenantsDeleteTenantResponse.d.ts +32 -0
- package/dist/models/TenantsDeleteTenantResponse.js +48 -0
- package/dist/models/TenantsDeleteTenantUserRequest.d.ts +32 -0
- package/dist/models/TenantsDeleteTenantUserRequest.js +50 -0
- package/dist/models/TenantsJWTTokenResponse.d.ts +32 -0
- package/dist/models/TenantsJWTTokenResponse.js +48 -0
- package/dist/models/TenantsNamespaceDefinitionsResponse.d.ts +33 -0
- package/dist/models/TenantsNamespaceDefinitionsResponse.js +49 -0
- package/dist/models/TenantsRolesListResponse.d.ts +33 -0
- package/dist/models/TenantsRolesListResponse.js +49 -0
- package/dist/models/TenantsSwitchTenantRequest.d.ts +32 -0
- package/dist/models/TenantsSwitchTenantRequest.js +50 -0
- package/dist/models/TenantsSwitchTenantResponse.d.ts +38 -0
- package/dist/models/TenantsSwitchTenantResponse.js +50 -0
- package/dist/models/TenantsTenantUserResponse.d.ts +56 -0
- package/dist/models/TenantsTenantUserResponse.js +56 -0
- package/dist/models/TenantsUpdateRoleRequest.d.ts +32 -0
- package/dist/models/TenantsUpdateRoleRequest.js +50 -0
- package/dist/models/TenantsUpdateTenantUserRoleRequest.d.ts +38 -0
- package/dist/models/TenantsUpdateTenantUserRoleRequest.js +54 -0
- package/dist/models/TenantsUpdateTenantUserRoleResponse.d.ts +32 -0
- package/dist/models/TenantsUpdateTenantUserRoleResponse.js +48 -0
- package/dist/models/UpdateTenantUserRole200Response.d.ts +39 -0
- package/dist/models/UpdateTenantUserRole200Response.js +51 -0
- package/dist/models/V1ArchiveAllResponse.d.ts +62 -0
- package/dist/models/V1ArchiveAllResponse.js +58 -0
- package/dist/models/V1CheckPermissionRequest.d.ts +57 -0
- package/dist/models/V1CheckPermissionRequest.js +63 -0
- package/dist/models/V1CheckPermissionResponse.d.ts +32 -0
- package/dist/models/V1CheckPermissionResponse.js +48 -0
- package/dist/models/V1ConfigHistoryItem.d.ts +63 -0
- package/dist/models/V1ConfigHistoryItem.js +59 -0
- package/dist/models/V1ConfigHistoryPagination.d.ts +62 -0
- package/dist/models/V1ConfigHistoryPagination.js +58 -0
- package/dist/models/V1ConfigHistoryResponse.d.ts +40 -0
- package/dist/models/V1ConfigHistoryResponse.js +52 -0
- package/dist/models/V1CreateCheckoutRequest.d.ts +62 -0
- package/dist/models/V1CreateCheckoutRequest.js +64 -0
- package/dist/models/V1CreateCheckoutResponse.d.ts +38 -0
- package/dist/models/V1CreateCheckoutResponse.js +50 -0
- package/dist/models/V1CreatePortalRequest.d.ts +32 -0
- package/dist/models/V1CreatePortalRequest.js +50 -0
- package/dist/models/V1CreatePortalResponse.d.ts +32 -0
- package/dist/models/V1CreatePortalResponse.js +50 -0
- package/dist/models/V1CreateRelationshipRequest.d.ts +57 -0
- package/dist/models/V1CreateRelationshipRequest.js +63 -0
- package/dist/models/V1CreateRelationshipResponse.d.ts +39 -0
- package/dist/models/V1CreateRelationshipResponse.js +51 -0
- package/dist/models/V1MigrationErrorResponse.d.ts +38 -0
- package/dist/models/V1MigrationErrorResponse.js +50 -0
- package/dist/models/V1MigrationSuccessResponse.d.ts +38 -0
- package/dist/models/V1MigrationSuccessResponse.js +50 -0
- package/dist/models/V1NamespaceDeploymentResponse.d.ts +56 -0
- package/dist/models/V1NamespaceDeploymentResponse.js +56 -0
- package/dist/models/V1RecordUsageRequest.d.ts +38 -0
- package/dist/models/V1RecordUsageRequest.js +54 -0
- package/dist/models/V1StripeConfigResponse.d.ts +57 -0
- package/dist/models/V1StripeConfigResponse.js +57 -0
- package/dist/models/V1SubjectSetRequest.d.ts +44 -0
- package/dist/models/V1SubjectSetRequest.js +56 -0
- package/dist/models/index.d.ts +103 -0
- package/dist/models/index.js +121 -0
- package/dist/runtime.d.ts +184 -0
- package/dist/runtime.js +350 -0
- package/docs/AcceptInvite200Response.md +36 -0
- package/docs/AssignRole200Response.md +36 -0
- package/docs/CheckPermission200Response.md +36 -0
- package/docs/ClientRelationship.md +42 -0
- package/docs/ClientSubjectSet.md +38 -0
- package/docs/CreateCheckout200Response.md +36 -0
- package/docs/CreateCustomerPortal200Response.md +36 -0
- package/docs/CreateInvite200Response.md +36 -0
- package/docs/CreateRelationship200Response.md +36 -0
- package/docs/CreateRole200Response.md +36 -0
- package/docs/CreateTenant200Response.md +36 -0
- package/docs/DatabaseApi.md +83 -0
- package/docs/DeleteRole200Response.md +36 -0
- package/docs/DeleteTenant200Response.md +36 -0
- package/docs/DeployPermissionNamespaces200Response.md +36 -0
- package/docs/GetRoleDefinitions200Response.md +36 -0
- package/docs/GetTenantBillingStatus200Response.md +36 -0
- package/docs/GetTenantJWT200Response.md +36 -0
- package/docs/HandlersBadRequestResponse.md +36 -0
- package/docs/HandlersForbiddenResponse.md +36 -0
- package/docs/HandlersInternalServerErrorResponse.md +36 -0
- package/docs/HandlersNotFoundErrorResponse.md +36 -0
- package/docs/HandlersSuccessResponse.md +36 -0
- package/docs/HandlersUnauthorizedResponse.md +36 -0
- package/docs/ListRoles200Response.md +36 -0
- package/docs/ListTenantSubscriptions200Response.md +36 -0
- package/docs/ListTenantUsers200Response.md +36 -0
- package/docs/ModelsBillingStatusResponse.md +36 -0
- package/docs/ModelsDeleteObjectRequest.md +34 -0
- package/docs/ModelsDownloadRequest.md +34 -0
- package/docs/ModelsDownloadResponse.md +34 -0
- package/docs/ModelsMessageResponse.md +34 -0
- package/docs/ModelsMeter.md +44 -0
- package/docs/ModelsMeterCustomerMapping.md +36 -0
- package/docs/ModelsMeterDefaultAggregation.md +34 -0
- package/docs/ModelsMeterValueSettings.md +34 -0
- package/docs/ModelsMeterWithStripeID.md +46 -0
- package/docs/ModelsNamespaceDefinition.md +40 -0
- package/docs/ModelsPrice.md +60 -0
- package/docs/ModelsPriceDisplay.md +38 -0
- package/docs/ModelsPriceLimit.md +38 -0
- package/docs/ModelsPriceUI.md +42 -0
- package/docs/ModelsPriceWithStripeID.md +62 -0
- package/docs/ModelsProduct.md +44 -0
- package/docs/ModelsProductUI.md +46 -0
- package/docs/ModelsProductWithStripeIDs.md +46 -0
- package/docs/ModelsRole.md +46 -0
- package/docs/ModelsStripeConfiguration.md +38 -0
- package/docs/ModelsStripeConfigurationWithIDs.md +38 -0
- package/docs/ModelsSubscriptionResponse.md +42 -0
- package/docs/ModelsTenant.md +46 -0
- package/docs/ModelsTenantInvite.md +52 -0
- package/docs/ModelsTenantSettings.md +38 -0
- package/docs/ModelsTier.md +38 -0
- package/docs/ModelsUploadRequest.md +36 -0
- package/docs/ModelsUploadResponse.md +36 -0
- package/docs/PaymentsApi.md +233 -0
- package/docs/PermissionsApi.md +233 -0
- package/docs/StorageApi.md +237 -0
- package/docs/StorageDownloadPost200Response.md +36 -0
- package/docs/StorageObjectDelete200Response.md +36 -0
- package/docs/StorageUploadPost200Response.md +36 -0
- package/docs/StripeApi.md +553 -0
- package/docs/StripeConfigArchiveAllPost200Response.md +36 -0
- package/docs/StripeConfigGet200Response.md +36 -0
- package/docs/StripeConfigHistoryGet200Response.md +36 -0
- package/docs/StripeConfigPullGet200Response.md +36 -0
- package/docs/SwitchActiveTenant200Response.md +36 -0
- package/docs/TenantsAcceptInviteRequest.md +34 -0
- package/docs/TenantsAcceptInviteResponse.md +38 -0
- package/docs/TenantsApi.md +1243 -0
- package/docs/TenantsAssignRoleRequest.md +36 -0
- package/docs/TenantsAssignRoleResponse.md +34 -0
- package/docs/TenantsCreateRoleRequest.md +36 -0
- package/docs/TenantsCreateTenantRequest.md +38 -0
- package/docs/TenantsCreateTenantResponse.md +38 -0
- package/docs/TenantsCreateTenantUserInviteRequest.md +38 -0
- package/docs/TenantsCreateTenantUserInviteResponse.md +36 -0
- package/docs/TenantsDeleteRoleResponse.md +34 -0
- package/docs/TenantsDeleteTenantResponse.md +34 -0
- package/docs/TenantsDeleteTenantUserRequest.md +34 -0
- package/docs/TenantsJWTTokenResponse.md +34 -0
- package/docs/TenantsNamespaceDefinitionsResponse.md +34 -0
- package/docs/TenantsRolesListResponse.md +34 -0
- package/docs/TenantsSwitchTenantRequest.md +34 -0
- package/docs/TenantsSwitchTenantResponse.md +36 -0
- package/docs/TenantsTenantUserResponse.md +42 -0
- package/docs/TenantsUpdateRoleRequest.md +34 -0
- package/docs/TenantsUpdateTenantUserRoleRequest.md +36 -0
- package/docs/TenantsUpdateTenantUserRoleResponse.md +34 -0
- package/docs/UpdateTenantUserRole200Response.md +36 -0
- package/docs/V1ArchiveAllResponse.md +44 -0
- package/docs/V1CheckPermissionRequest.md +42 -0
- package/docs/V1CheckPermissionResponse.md +34 -0
- package/docs/V1ConfigHistoryItem.md +44 -0
- package/docs/V1ConfigHistoryPagination.md +44 -0
- package/docs/V1ConfigHistoryResponse.md +36 -0
- package/docs/V1CreateCheckoutRequest.md +44 -0
- package/docs/V1CreateCheckoutResponse.md +36 -0
- package/docs/V1CreatePortalRequest.md +34 -0
- package/docs/V1CreatePortalResponse.md +34 -0
- package/docs/V1CreateRelationshipRequest.md +42 -0
- package/docs/V1CreateRelationshipResponse.md +36 -0
- package/docs/V1MigrationErrorResponse.md +36 -0
- package/docs/V1MigrationSuccessResponse.md +36 -0
- package/docs/V1NamespaceDeploymentResponse.md +42 -0
- package/docs/V1RecordUsageRequest.md +36 -0
- package/docs/V1StripeConfigResponse.md +42 -0
- package/docs/V1SubjectSetRequest.md +38 -0
- package/package.json +14 -65
- package/src/apis/DatabaseApi.ts +106 -0
- package/src/apis/PaymentsApi.ts +201 -0
- package/src/apis/PermissionsApi.ts +216 -0
- package/src/apis/StorageApi.ts +207 -0
- package/src/apis/StripeApi.ts +364 -0
- package/src/apis/TenantsApi.ts +868 -0
- package/src/apis/index.ts +8 -0
- package/src/index.ts +5 -0
- package/src/models/AcceptInvite200Response.ts +81 -0
- package/src/models/AssignRole200Response.ts +81 -0
- package/src/models/CheckPermission200Response.ts +81 -0
- package/src/models/ClientRelationship.ts +105 -0
- package/src/models/ClientSubjectSet.ts +81 -0
- package/src/models/CreateCheckout200Response.ts +81 -0
- package/src/models/CreateCustomerPortal200Response.ts +81 -0
- package/src/models/CreateInvite200Response.ts +81 -0
- package/src/models/CreateRelationship200Response.ts +81 -0
- package/src/models/CreateRole200Response.ts +81 -0
- package/src/models/CreateTenant200Response.ts +81 -0
- package/src/models/DeleteRole200Response.ts +81 -0
- package/src/models/DeleteTenant200Response.ts +81 -0
- package/src/models/DeployPermissionNamespaces200Response.ts +81 -0
- package/src/models/GetRoleDefinitions200Response.ts +81 -0
- package/src/models/GetTenantBillingStatus200Response.ts +81 -0
- package/src/models/GetTenantJWT200Response.ts +81 -0
- package/src/models/HandlersBadRequestResponse.ts +73 -0
- package/src/models/HandlersForbiddenResponse.ts +73 -0
- package/src/models/HandlersInternalServerErrorResponse.ts +73 -0
- package/src/models/HandlersNotFoundErrorResponse.ts +73 -0
- package/src/models/HandlersSuccessResponse.ts +73 -0
- package/src/models/HandlersUnauthorizedResponse.ts +73 -0
- package/src/models/ListRoles200Response.ts +81 -0
- package/src/models/ListTenantSubscriptions200Response.ts +81 -0
- package/src/models/ListTenantUsers200Response.ts +81 -0
- package/src/models/ModelsBillingStatusResponse.ts +73 -0
- package/src/models/ModelsDeleteObjectRequest.ts +66 -0
- package/src/models/ModelsDownloadRequest.ts +66 -0
- package/src/models/ModelsDownloadResponse.ts +65 -0
- package/src/models/ModelsMessageResponse.ts +65 -0
- package/src/models/ModelsMeter.ts +131 -0
- package/src/models/ModelsMeterCustomerMapping.ts +85 -0
- package/src/models/ModelsMeterDefaultAggregation.ts +78 -0
- package/src/models/ModelsMeterValueSettings.ts +66 -0
- package/src/models/ModelsMeterWithStripeID.ts +139 -0
- package/src/models/ModelsNamespaceDefinition.ts +89 -0
- package/src/models/ModelsPrice.ts +186 -0
- package/src/models/ModelsPriceDisplay.ts +81 -0
- package/src/models/ModelsPriceLimit.ts +81 -0
- package/src/models/ModelsPriceUI.ts +112 -0
- package/src/models/ModelsPriceWithStripeID.ts +194 -0
- package/src/models/ModelsProduct.ts +123 -0
- package/src/models/ModelsProductUI.ts +113 -0
- package/src/models/ModelsProductWithStripeIDs.ts +131 -0
- package/src/models/ModelsRole.ts +113 -0
- package/src/models/ModelsStripeConfiguration.ts +98 -0
- package/src/models/ModelsStripeConfigurationWithIDs.ts +98 -0
- package/src/models/ModelsSubscriptionResponse.ts +97 -0
- package/src/models/ModelsTenant.ts +121 -0
- package/src/models/ModelsTenantInvite.ts +145 -0
- package/src/models/ModelsTenantSettings.ts +81 -0
- package/src/models/ModelsTier.ts +81 -0
- package/src/models/ModelsUploadRequest.ts +74 -0
- package/src/models/ModelsUploadResponse.ts +73 -0
- package/src/models/StorageDownloadPost200Response.ts +81 -0
- package/src/models/StorageObjectDelete200Response.ts +81 -0
- package/src/models/StorageUploadPost200Response.ts +81 -0
- package/src/models/StripeConfigArchiveAllPost200Response.ts +81 -0
- package/src/models/StripeConfigGet200Response.ts +81 -0
- package/src/models/StripeConfigHistoryGet200Response.ts +81 -0
- package/src/models/StripeConfigPullGet200Response.ts +81 -0
- package/src/models/SwitchActiveTenant200Response.ts +81 -0
- package/src/models/TenantsAcceptInviteRequest.ts +66 -0
- package/src/models/TenantsAcceptInviteResponse.ts +81 -0
- package/src/models/TenantsAssignRoleRequest.ts +73 -0
- package/src/models/TenantsAssignRoleResponse.ts +65 -0
- package/src/models/TenantsCreateRoleRequest.ts +75 -0
- package/src/models/TenantsCreateTenantRequest.ts +83 -0
- package/src/models/TenantsCreateTenantResponse.ts +89 -0
- package/src/models/TenantsCreateTenantUserInviteRequest.ts +84 -0
- package/src/models/TenantsCreateTenantUserInviteResponse.ts +81 -0
- package/src/models/TenantsDeleteRoleResponse.ts +65 -0
- package/src/models/TenantsDeleteTenantResponse.ts +65 -0
- package/src/models/TenantsDeleteTenantUserRequest.ts +66 -0
- package/src/models/TenantsJWTTokenResponse.ts +65 -0
- package/src/models/TenantsNamespaceDefinitionsResponse.ts +73 -0
- package/src/models/TenantsRolesListResponse.ts +73 -0
- package/src/models/TenantsSwitchTenantRequest.ts +66 -0
- package/src/models/TenantsSwitchTenantResponse.ts +73 -0
- package/src/models/TenantsTenantUserResponse.ts +97 -0
- package/src/models/TenantsUpdateRoleRequest.ts +66 -0
- package/src/models/TenantsUpdateTenantUserRoleRequest.ts +75 -0
- package/src/models/TenantsUpdateTenantUserRoleResponse.ts +65 -0
- package/src/models/UpdateTenantUserRole200Response.ts +81 -0
- package/src/models/V1ArchiveAllResponse.ts +105 -0
- package/src/models/V1CheckPermissionRequest.ts +108 -0
- package/src/models/V1CheckPermissionResponse.ts +65 -0
- package/src/models/V1ConfigHistoryItem.ts +113 -0
- package/src/models/V1ConfigHistoryPagination.ts +105 -0
- package/src/models/V1ConfigHistoryResponse.ts +88 -0
- package/src/models/V1CreateCheckoutRequest.ts +108 -0
- package/src/models/V1CreateCheckoutResponse.ts +73 -0
- package/src/models/V1CreatePortalRequest.ts +66 -0
- package/src/models/V1CreatePortalResponse.ts +66 -0
- package/src/models/V1CreateRelationshipRequest.ts +108 -0
- package/src/models/V1CreateRelationshipResponse.ts +81 -0
- package/src/models/V1MigrationErrorResponse.ts +73 -0
- package/src/models/V1MigrationSuccessResponse.ts +73 -0
- package/src/models/V1NamespaceDeploymentResponse.ts +97 -0
- package/src/models/V1RecordUsageRequest.ts +75 -0
- package/src/models/V1StripeConfigResponse.ts +105 -0
- package/src/models/V1SubjectSetRequest.ts +83 -0
- package/src/models/index.ts +105 -0
- package/src/runtime.ts +432 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +16 -0
- package/dist/auth/index.cjs +0 -18
- package/dist/auth/index.d.cts +0 -461
- package/dist/auth/index.d.ts +0 -461
- package/dist/auth/index.js +0 -0
- package/dist/auth/types.cjs +0 -18
- package/dist/auth/types.d.cts +0 -103
- package/dist/auth/types.d.ts +0 -103
- package/dist/auth/types.js +0 -0
- package/dist/chunk-4VFICD7B.js +0 -563
- package/dist/chunk-4WXOODCF.js +0 -579
- package/dist/chunk-5MDBFHTF.js +0 -555
- package/dist/chunk-6OGESVXW.js +0 -651
- package/dist/chunk-767PUXYD.js +0 -556
- package/dist/chunk-BZSZVT4V.js +0 -152
- package/dist/chunk-CUBJFCZH.js +0 -579
- package/dist/chunk-DDFBRGMG.js +0 -106
- package/dist/chunk-DQBFDKRC.js +0 -641
- package/dist/chunk-I6DMWC32.js +0 -129
- package/dist/chunk-IVPULXIA.js +0 -150
- package/dist/chunk-JNM7XP7L.js +0 -345
- package/dist/chunk-KGG7T6KJ.js +0 -546
- package/dist/chunk-L7EZC6WP.js +0 -560
- package/dist/chunk-LCEBQTB7.js +0 -563
- package/dist/chunk-LIS5WD3H.js +0 -560
- package/dist/chunk-LMDKQ6Z2.js +0 -706
- package/dist/chunk-NBPRDG6O.js +0 -643
- package/dist/chunk-PNP3T7XU.js +0 -542
- package/dist/chunk-QPW6G4PA.js +0 -490
- package/dist/chunk-QXPPBLH4.js +0 -556
- package/dist/chunk-TFAV5P6I.js +0 -869
- package/dist/chunk-V4FWENQQ.js +0 -378
- package/dist/chunk-V56G36FZ.js +0 -558
- package/dist/chunk-V6HVRJCU.js +0 -693
- package/dist/chunk-ZBRAIBZZ.js +0 -658
- package/dist/chunk-ZYLNNK7H.js +0 -555
- package/dist/database/index.cjs +0 -227
- package/dist/database/index.d.cts +0 -298
- package/dist/database/index.d.ts +0 -298
- package/dist/database/index.js +0 -199
- package/dist/index.cjs +0 -2024
- package/dist/index.d.cts +0 -2
- package/dist/payments/index.cjs +0 -520
- package/dist/payments/index.d.cts +0 -3220
- package/dist/payments/index.d.ts +0 -3220
- package/dist/payments/index.js +0 -14
- package/dist/permissions/index.cjs +0 -405
- package/dist/permissions/index.d.cts +0 -2
- package/dist/permissions/index.d.ts +0 -2
- package/dist/permissions/index.js +0 -8
- package/dist/storage/index.cjs +0 -153
- package/dist/storage/index.d.cts +0 -2
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -6
- package/dist/stripe/index.cjs +0 -153
- package/dist/stripe/index.d.cts +0 -162
- package/dist/stripe/index.d.ts +0 -162
- package/dist/stripe/index.js +0 -124
- package/dist/tenants/index.cjs +0 -895
- package/dist/tenants/index.d.cts +0 -2
- package/dist/tenants/index.d.ts +0 -2
- package/dist/tenants/index.js +0 -6
- package/dist/types-DgsX5kVK.d.cts +0 -49
- package/dist/types-DgsX5kVK.d.ts +0 -49
package/dist/index.cjs
DELETED
|
@@ -1,2024 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
OmnibaseClient: () => OmnibaseClient,
|
|
24
|
-
PermissionsClient: () => PermissionsClient,
|
|
25
|
-
RolesHandler: () => RolesHandler,
|
|
26
|
-
StorageClient: () => StorageClient
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/payments/checkout.ts
|
|
31
|
-
var CheckoutManager = class {
|
|
32
|
-
/**
|
|
33
|
-
* Initialize the checkout manager
|
|
34
|
-
*
|
|
35
|
-
* @param paymentHandler - Payment handler instance for API communication
|
|
36
|
-
*
|
|
37
|
-
* @group Checkout
|
|
38
|
-
*/
|
|
39
|
-
constructor(omnibaseClient) {
|
|
40
|
-
this.omnibaseClient = omnibaseClient;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Create a new Stripe checkout session
|
|
44
|
-
*
|
|
45
|
-
* Creates a checkout session with the specified options and returns
|
|
46
|
-
* the session URL for redirecting the user to complete payment.
|
|
47
|
-
* The checkout mode (one-time payment or subscription) is automatically
|
|
48
|
-
* determined from the price's configuration - no need to specify it manually.
|
|
49
|
-
*
|
|
50
|
-
* @param options - Configuration options for the checkout session
|
|
51
|
-
* @param options.price_id - Stripe price ID for the product/service
|
|
52
|
-
* @param options.success_url - URL to redirect after successful payment
|
|
53
|
-
* @param options.cancel_url - URL to redirect if user cancels
|
|
54
|
-
*
|
|
55
|
-
* @returns Promise resolving to checkout session response with URL and session ID
|
|
56
|
-
*
|
|
57
|
-
* @throws {Error} When the API request fails due to network issues
|
|
58
|
-
* @throws {Error} When the server returns an error response (invalid price_id, etc.)
|
|
59
|
-
* @throws {ValidationError} When required parameters are missing or invalid
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const session = await checkoutManager.createSession({
|
|
64
|
-
* price_id: 'price_monthly_pro',
|
|
65
|
-
* success_url: 'https://app.com/success',
|
|
66
|
-
* cancel_url: 'https://app.com/cancel'
|
|
67
|
-
* });
|
|
68
|
-
*
|
|
69
|
-
* // Redirect to Stripe checkout
|
|
70
|
-
* if (session.data?.url) {
|
|
71
|
-
* window.location.href = session.data.url;
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @since 0.6.0
|
|
76
|
-
* @group Checkout
|
|
77
|
-
*/
|
|
78
|
-
async createSession(options) {
|
|
79
|
-
const response = await this.omnibaseClient.fetch(
|
|
80
|
-
"/api/v1/payments/checkout",
|
|
81
|
-
{
|
|
82
|
-
method: "POST",
|
|
83
|
-
headers: {
|
|
84
|
-
"Content-Type": "application/json"
|
|
85
|
-
},
|
|
86
|
-
body: JSON.stringify(options)
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
if (!response.ok) {
|
|
90
|
-
const errorData = await response.text();
|
|
91
|
-
throw new Error(
|
|
92
|
-
`Failed to create checkout session: ${response.status} - ${errorData}`
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
const result = await response.json();
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// src/payments/config.ts
|
|
101
|
-
var ConfigManager = class {
|
|
102
|
-
constructor(omnibaseClient) {
|
|
103
|
-
this.omnibaseClient = omnibaseClient;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get the current Stripe configuration from the database
|
|
107
|
-
*
|
|
108
|
-
* Retrieves the latest Stripe configuration including products, prices,
|
|
109
|
-
* and UI customization data. This configuration represents the current
|
|
110
|
-
* active pricing structure with all UI elements for pricing table rendering.
|
|
111
|
-
*
|
|
112
|
-
* @returns Promise resolving to the current Stripe configuration
|
|
113
|
-
*
|
|
114
|
-
* @throws {Error} When the API request fails due to network issues
|
|
115
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* Basic usage:
|
|
119
|
-
* ```typescript
|
|
120
|
-
* const config = await getStripeConfig();
|
|
121
|
-
* console.log(`Found ${config.data.config.products.length} products`);
|
|
122
|
-
*
|
|
123
|
-
* // Access product UI configuration
|
|
124
|
-
* config.data.config.products.forEach(product => {
|
|
125
|
-
* console.log(`${product.name}: ${product.ui?.tagline || 'No tagline'}`);
|
|
126
|
-
* });
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
async getStripeConfig() {
|
|
130
|
-
try {
|
|
131
|
-
const response = await this.omnibaseClient.fetch(
|
|
132
|
-
`/api/v1/stripe/config`,
|
|
133
|
-
{
|
|
134
|
-
method: "GET",
|
|
135
|
-
headers: {
|
|
136
|
-
"Content-Type": "application/json"
|
|
137
|
-
},
|
|
138
|
-
credentials: "include"
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
if (!response.ok) {
|
|
142
|
-
const errorData = await response.text();
|
|
143
|
-
throw new Error(
|
|
144
|
-
`Failed to get Stripe config: ${response.status} - ${errorData}`
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
const data = await response.json();
|
|
148
|
-
return data;
|
|
149
|
-
} catch (error) {
|
|
150
|
-
console.error("Error getting Stripe config:", error);
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get available products with UI-ready pricing data
|
|
156
|
-
*
|
|
157
|
-
* Transforms the raw Stripe configuration into UI-ready format for pricing
|
|
158
|
-
* table rendering. Includes formatted pricing, features, limits, and all
|
|
159
|
-
* display customizations needed for marketing pages.
|
|
160
|
-
*
|
|
161
|
-
* @returns Promise resolving to products ready for UI consumption
|
|
162
|
-
*
|
|
163
|
-
* @throws {Error} When the API request fails or configuration is invalid
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* Pricing table rendering:
|
|
167
|
-
* ```typescript
|
|
168
|
-
* const products = await getAvailableProducts();
|
|
169
|
-
*
|
|
170
|
-
* products.forEach(product => {
|
|
171
|
-
* const display = product.pricing_display;
|
|
172
|
-
* console.log(`${display.name} - ${display.tagline}`);
|
|
173
|
-
*
|
|
174
|
-
* display.prices.forEach(price => {
|
|
175
|
-
* console.log(` ${price.display_name}: ${price.formatted_price}`);
|
|
176
|
-
* });
|
|
177
|
-
* });
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
async getAvailableProducts() {
|
|
181
|
-
const configResponse = await this.getStripeConfig();
|
|
182
|
-
if (!configResponse.data?.config) {
|
|
183
|
-
throw new Error("No Stripe configuration found");
|
|
184
|
-
}
|
|
185
|
-
const products = configResponse.data.config.products;
|
|
186
|
-
return products.map(transformProductToUIReady).sort(
|
|
187
|
-
(a, b) => a.pricing_display.sort_order - b.pricing_display.sort_order
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get a specific product by ID
|
|
192
|
-
*
|
|
193
|
-
* Retrieves a single product configuration by its ID from the current
|
|
194
|
-
* Stripe configuration. Useful for product-specific operations.
|
|
195
|
-
*
|
|
196
|
-
* @param productId - The configuration product ID to retrieve
|
|
197
|
-
* @returns Promise resolving to the product or null if not found
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* ```typescript
|
|
201
|
-
* const product = await getProduct('starter_plan');
|
|
202
|
-
* if (product) {
|
|
203
|
-
* console.log(`Found product: ${product.name}`);
|
|
204
|
-
* }
|
|
205
|
-
* ```
|
|
206
|
-
*/
|
|
207
|
-
async getProduct(productId) {
|
|
208
|
-
const configResponse = await this.getStripeConfig();
|
|
209
|
-
if (!configResponse.data?.config) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
const product = configResponse.data.config.products.find(
|
|
213
|
-
(p) => p.id === productId
|
|
214
|
-
);
|
|
215
|
-
return product || null;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
function transformProductToUIReady(product) {
|
|
219
|
-
const ui = product.ui || {};
|
|
220
|
-
return {
|
|
221
|
-
...product,
|
|
222
|
-
pricing_display: {
|
|
223
|
-
name: ui.display_name || product.name,
|
|
224
|
-
tagline: ui.tagline,
|
|
225
|
-
features: ui.features || [],
|
|
226
|
-
badge: ui.badge,
|
|
227
|
-
cta_text: ui.cta_text || "Choose Plan",
|
|
228
|
-
highlighted: ui.highlighted || false,
|
|
229
|
-
sort_order: ui.sort_order || 0,
|
|
230
|
-
prices: product.prices.map((price) => {
|
|
231
|
-
const priceUI = price.ui || {};
|
|
232
|
-
return {
|
|
233
|
-
id: price.id,
|
|
234
|
-
display_name: priceUI.display_name || formatDefaultPriceName(price),
|
|
235
|
-
formatted_price: formatPrice(price, priceUI),
|
|
236
|
-
billing_period: priceUI.billing_period || formatDefaultBillingPeriod(price),
|
|
237
|
-
features: priceUI.features || [],
|
|
238
|
-
limits: priceUI.limits || []
|
|
239
|
-
};
|
|
240
|
-
})
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function formatPrice(price, priceUI) {
|
|
245
|
-
if (priceUI.price_display?.custom_text) {
|
|
246
|
-
return priceUI.price_display.custom_text;
|
|
247
|
-
}
|
|
248
|
-
if (!price.amount || price.amount === 0) {
|
|
249
|
-
return "Free";
|
|
250
|
-
}
|
|
251
|
-
const amount = price.amount / 100;
|
|
252
|
-
const currency = price.currency.toUpperCase();
|
|
253
|
-
let formattedPrice = "";
|
|
254
|
-
if (priceUI.price_display?.show_currency !== false) {
|
|
255
|
-
const currencySymbol = getCurrencySymbol(currency);
|
|
256
|
-
formattedPrice = `${currencySymbol}${amount.toFixed(2)}`;
|
|
257
|
-
} else {
|
|
258
|
-
formattedPrice = amount.toFixed(2);
|
|
259
|
-
}
|
|
260
|
-
if (priceUI.price_display?.suffix) {
|
|
261
|
-
formattedPrice += ` ${priceUI.price_display.suffix}`;
|
|
262
|
-
}
|
|
263
|
-
return formattedPrice;
|
|
264
|
-
}
|
|
265
|
-
function getCurrencySymbol(currency) {
|
|
266
|
-
const symbols = {
|
|
267
|
-
USD: "$",
|
|
268
|
-
EUR: "\u20AC",
|
|
269
|
-
GBP: "\xA3",
|
|
270
|
-
JPY: "\xA5",
|
|
271
|
-
CAD: "C$",
|
|
272
|
-
AUD: "A$"
|
|
273
|
-
};
|
|
274
|
-
return symbols[currency] || currency;
|
|
275
|
-
}
|
|
276
|
-
function formatDefaultPriceName(price) {
|
|
277
|
-
if (price.interval) {
|
|
278
|
-
return price.interval.charAt(0).toUpperCase() + price.interval.slice(1);
|
|
279
|
-
}
|
|
280
|
-
return "One-time";
|
|
281
|
-
}
|
|
282
|
-
function formatDefaultBillingPeriod(price) {
|
|
283
|
-
if (price.interval) {
|
|
284
|
-
const count = price.interval_count || 1;
|
|
285
|
-
const period = count === 1 ? price.interval : `${count} ${price.interval}s`;
|
|
286
|
-
return `per ${period}`;
|
|
287
|
-
}
|
|
288
|
-
return "one-time";
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// src/payments/portal.ts
|
|
292
|
-
var PortalManager = class {
|
|
293
|
-
/**
|
|
294
|
-
* Initialize the portal manager
|
|
295
|
-
*
|
|
296
|
-
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
297
|
-
*
|
|
298
|
-
* @group Portal
|
|
299
|
-
*/
|
|
300
|
-
constructor(omnibaseClient) {
|
|
301
|
-
this.omnibaseClient = omnibaseClient;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Create a new customer portal session
|
|
305
|
-
*
|
|
306
|
-
* Creates a portal session that allows the specified customer to
|
|
307
|
-
* manage their billing information, subscriptions, and payment methods.
|
|
308
|
-
* Returns a URL that the customer should be redirected to.
|
|
309
|
-
*
|
|
310
|
-
* The portal session is temporary and expires after a short period
|
|
311
|
-
* for security. Each access requires creating a new session.
|
|
312
|
-
*
|
|
313
|
-
* @param options - Configuration options for the portal session
|
|
314
|
-
* @param options.return_url - URL to redirect to when exiting the portal
|
|
315
|
-
*
|
|
316
|
-
* @returns Promise resolving to portal session response with access URL
|
|
317
|
-
*
|
|
318
|
-
* @throws {Error} When the API request fails due to network issues
|
|
319
|
-
* @throws {Error} When the server returns an error response
|
|
320
|
-
* @throws {ValidationError} When required parameters are missing or invalid
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```typescript
|
|
324
|
-
* const portal = await portalManager.create({
|
|
325
|
-
* return_url: 'https://myapp.com/account/billing'
|
|
326
|
-
* });
|
|
327
|
-
*
|
|
328
|
-
* // Redirect user to portal
|
|
329
|
-
* if (portal.data?.url) {
|
|
330
|
-
* window.location.href = portal.data.url;
|
|
331
|
-
* }
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* @since 0.6.0
|
|
335
|
-
* @group Portal
|
|
336
|
-
*/
|
|
337
|
-
async create(options) {
|
|
338
|
-
const response = await this.omnibaseClient.fetch(
|
|
339
|
-
"/api/v1/payments/portal",
|
|
340
|
-
{
|
|
341
|
-
method: "POST",
|
|
342
|
-
headers: {
|
|
343
|
-
"Content-Type": "application/json"
|
|
344
|
-
},
|
|
345
|
-
body: JSON.stringify(options)
|
|
346
|
-
}
|
|
347
|
-
);
|
|
348
|
-
if (!response.ok) {
|
|
349
|
-
const errorData = await response.text();
|
|
350
|
-
throw new Error(
|
|
351
|
-
`Failed to create customer portal: ${response.status} - ${errorData}`
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
const result = await response.json();
|
|
355
|
-
return result;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
// src/payments/usage.ts
|
|
360
|
-
var UsageManager = class {
|
|
361
|
-
/**
|
|
362
|
-
* Initialize the usage manager
|
|
363
|
-
*
|
|
364
|
-
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
365
|
-
*
|
|
366
|
-
* @group Usage
|
|
367
|
-
*/
|
|
368
|
-
constructor(omnibaseClient) {
|
|
369
|
-
this.omnibaseClient = omnibaseClient;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Record a usage event for metered billing
|
|
373
|
-
*
|
|
374
|
-
* Records a usage event against a specific meter for billing calculation.
|
|
375
|
-
* The event will be aggregated with other usage events for the billing period
|
|
376
|
-
* to determine the customer's charges for metered products.
|
|
377
|
-
*
|
|
378
|
-
* Usage events should be recorded in real-time or as close to real-time as
|
|
379
|
-
* possible to ensure accurate billing and provide up-to-date usage visibility
|
|
380
|
-
* to customers.
|
|
381
|
-
*
|
|
382
|
-
* @param options - Usage recording options
|
|
383
|
-
* @param options.meter_event_name - Name of the meter to record against
|
|
384
|
-
* @param options.value - Usage quantity as string
|
|
385
|
-
*
|
|
386
|
-
* @returns Promise resolving to API response confirmation
|
|
387
|
-
*
|
|
388
|
-
* @throws {Error} When the API request fails due to network issues
|
|
389
|
-
* @throws {Error} When the server returns an error response (invalid meter name, customer, etc.)
|
|
390
|
-
* @throws {ValidationError} When required parameters are missing or invalid
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* ```typescript
|
|
394
|
-
* // Record each API call
|
|
395
|
-
* await usageManager.recordUsage({
|
|
396
|
-
* meter_event_name: 'api_requests',
|
|
397
|
-
* value: '1'
|
|
398
|
-
* });
|
|
399
|
-
* ```
|
|
400
|
-
*
|
|
401
|
-
* @since 0.6.0
|
|
402
|
-
* @group Usage
|
|
403
|
-
*/
|
|
404
|
-
async recordUsage(options) {
|
|
405
|
-
const response = await this.omnibaseClient.fetch("/api/v1/payments/usage", {
|
|
406
|
-
method: "POST",
|
|
407
|
-
headers: {
|
|
408
|
-
"Content-Type": "application/json"
|
|
409
|
-
},
|
|
410
|
-
body: JSON.stringify(options)
|
|
411
|
-
});
|
|
412
|
-
if (!response.ok) {
|
|
413
|
-
const errorData = await response.text();
|
|
414
|
-
throw new Error(
|
|
415
|
-
`Failed to record usage: ${response.status} - ${errorData}`
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
const result = await response.json();
|
|
419
|
-
return result;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
// src/payments/handler.ts
|
|
424
|
-
var PaymentHandler = class {
|
|
425
|
-
/**
|
|
426
|
-
* Initialize the payment handler with OmnibaseClient
|
|
427
|
-
*
|
|
428
|
-
* Creates a new payment handler instance with access to all payment
|
|
429
|
-
* operations including checkout, configuration, portal, and usage tracking.
|
|
430
|
-
* The handler uses the provided OmnibaseClient for API communication.
|
|
431
|
-
*
|
|
432
|
-
* @param omnibaseClient - OmnibaseClient instance for API communication
|
|
433
|
-
*
|
|
434
|
-
* @example
|
|
435
|
-
* ```typescript
|
|
436
|
-
* const paymentHandler = new PaymentHandler(omnibaseClient);
|
|
437
|
-
* ```
|
|
438
|
-
*
|
|
439
|
-
* @since 0.6.0
|
|
440
|
-
* @group Client
|
|
441
|
-
*/
|
|
442
|
-
constructor(omnibaseClient) {
|
|
443
|
-
this.omnibaseClient = omnibaseClient;
|
|
444
|
-
this.checkout = new CheckoutManager(this.omnibaseClient);
|
|
445
|
-
this.config = new ConfigManager(this.omnibaseClient);
|
|
446
|
-
this.portal = new PortalManager(this.omnibaseClient);
|
|
447
|
-
this.usage = new UsageManager(this.omnibaseClient);
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Checkout session management
|
|
451
|
-
*
|
|
452
|
-
* Provides functionality for creating and managing Stripe checkout sessions
|
|
453
|
-
* for both one-time payments and subscription billing.
|
|
454
|
-
*
|
|
455
|
-
* @example
|
|
456
|
-
* ```typescript
|
|
457
|
-
* const session = await paymentHandler.checkout.createSession({
|
|
458
|
-
* price_id: 'price_monthly_pro',
|
|
459
|
-
* success_url: window.location.origin + '/success',
|
|
460
|
-
* cancel_url: window.location.origin + '/pricing'
|
|
461
|
-
* });
|
|
462
|
-
*
|
|
463
|
-
* if (session.data?.url) {
|
|
464
|
-
* window.location.href = session.data.url;
|
|
465
|
-
* }
|
|
466
|
-
* ```
|
|
467
|
-
*/
|
|
468
|
-
checkout;
|
|
469
|
-
/**
|
|
470
|
-
* Stripe configuration management
|
|
471
|
-
*
|
|
472
|
-
* Handles retrieval and processing of database-backed Stripe configurations,
|
|
473
|
-
* providing UI-ready product and pricing data for rendering pricing tables.
|
|
474
|
-
*
|
|
475
|
-
* @example
|
|
476
|
-
* ```typescript
|
|
477
|
-
* const products = await paymentHandler.config.getAvailableProducts();
|
|
478
|
-
* const config = await paymentHandler.config.getStripeConfig();
|
|
479
|
-
* ```
|
|
480
|
-
*/
|
|
481
|
-
config;
|
|
482
|
-
/**
|
|
483
|
-
* Customer portal management
|
|
484
|
-
*
|
|
485
|
-
* Creates customer portal sessions for subscription management,
|
|
486
|
-
* billing history, and payment method updates.
|
|
487
|
-
*
|
|
488
|
-
* @example
|
|
489
|
-
* ```typescript
|
|
490
|
-
* const portal = await paymentHandler.portal.create({
|
|
491
|
-
* return_url: 'https://app.com/billing'
|
|
492
|
-
* });
|
|
493
|
-
* ```
|
|
494
|
-
*/
|
|
495
|
-
portal;
|
|
496
|
-
/**
|
|
497
|
-
* Usage tracking and metered billing
|
|
498
|
-
*
|
|
499
|
-
* Records usage events for metered billing products and manages
|
|
500
|
-
* usage-based pricing calculations.
|
|
501
|
-
*
|
|
502
|
-
* @example
|
|
503
|
-
* ```typescript
|
|
504
|
-
* await paymentHandler.usage.recordUsage({
|
|
505
|
-
* meter_event_name: 'api_calls',
|
|
506
|
-
* value: '1'
|
|
507
|
-
* });
|
|
508
|
-
* ```
|
|
509
|
-
*/
|
|
510
|
-
usage;
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
// src/permissions/handler.ts
|
|
514
|
-
var import_client = require("@ory/client");
|
|
515
|
-
|
|
516
|
-
// src/permissions/roles.ts
|
|
517
|
-
var RolesHandler = class {
|
|
518
|
-
constructor(client) {
|
|
519
|
-
this.client = client;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Get available namespace definitions for UI
|
|
523
|
-
*
|
|
524
|
-
* Returns all namespaces and their available relations/permissions.
|
|
525
|
-
* Useful for building role configuration UIs.
|
|
526
|
-
*
|
|
527
|
-
* @returns List of namespace definitions
|
|
528
|
-
*
|
|
529
|
-
* @example
|
|
530
|
-
* ```typescript
|
|
531
|
-
* const definitions = await omnibase.permissions.roles.getDefinitions();
|
|
532
|
-
*
|
|
533
|
-
* // Output: [{ namespace: 'Tenant', relations: ['invite_user', 'delete_tenant', ...] }]
|
|
534
|
-
* definitions.forEach(def => {
|
|
535
|
-
* console.log(`${def.namespace} supports: ${def.relations.join(', ')}`);
|
|
536
|
-
* });
|
|
537
|
-
* ```
|
|
538
|
-
*/
|
|
539
|
-
async getDefinitions() {
|
|
540
|
-
const response = await this.client.fetch(
|
|
541
|
-
"/api/v1/permissions/definitions",
|
|
542
|
-
{
|
|
543
|
-
method: "GET"
|
|
544
|
-
}
|
|
545
|
-
);
|
|
546
|
-
const data = await response.json();
|
|
547
|
-
if (!response.ok || data.error) {
|
|
548
|
-
throw new Error(data.error || "Failed to fetch definitions");
|
|
549
|
-
}
|
|
550
|
-
return data.data.definitions;
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* List all roles for the current tenant
|
|
554
|
-
*
|
|
555
|
-
* Returns both system roles (defined in roles.config.json) and
|
|
556
|
-
* custom roles created via the API. System roles have `tenant_id = null`.
|
|
557
|
-
*
|
|
558
|
-
* @returns List of roles
|
|
559
|
-
*
|
|
560
|
-
* @example
|
|
561
|
-
* ```typescript
|
|
562
|
-
* const roles = await omnibase.permissions.roles.list();
|
|
563
|
-
*
|
|
564
|
-
* const systemRoles = roles.filter(r => r.tenant_id === null);
|
|
565
|
-
* const customRoles = roles.filter(r => r.tenant_id !== null);
|
|
566
|
-
*
|
|
567
|
-
* console.log(`System roles: ${systemRoles.map(r => r.role_name).join(', ')}`);
|
|
568
|
-
* console.log(`Custom roles: ${customRoles.map(r => r.role_name).join(', ')}`);
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
async list() {
|
|
572
|
-
const response = await this.client.fetch("/api/v1/permissions/roles", {
|
|
573
|
-
method: "GET"
|
|
574
|
-
});
|
|
575
|
-
const data = await response.json();
|
|
576
|
-
if (!response.ok || data.error) {
|
|
577
|
-
throw new Error(data.error || "Failed to list roles");
|
|
578
|
-
}
|
|
579
|
-
return data.data.roles;
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Create a new custom role
|
|
583
|
-
*
|
|
584
|
-
* Creates a tenant-specific role with the specified permissions.
|
|
585
|
-
* Permissions use the format `namespace#relation` or `namespace:id#relation`.
|
|
586
|
-
*
|
|
587
|
-
* @param request - Role creation request
|
|
588
|
-
* @returns Created role
|
|
589
|
-
*
|
|
590
|
-
* @example
|
|
591
|
-
* ```typescript
|
|
592
|
-
* const role = await omnibase.permissions.roles.create({
|
|
593
|
-
* role_name: 'billing_manager',
|
|
594
|
-
* permissions: [
|
|
595
|
-
* 'tenant#manage_billing',
|
|
596
|
-
* 'tenant#view_invoices',
|
|
597
|
-
* 'tenant#update_payment_methods'
|
|
598
|
-
* ]
|
|
599
|
-
* });
|
|
600
|
-
*
|
|
601
|
-
* console.log(`Created role: ${role.id}`);
|
|
602
|
-
* ```
|
|
603
|
-
*
|
|
604
|
-
* @example
|
|
605
|
-
* Resource-specific permissions:
|
|
606
|
-
* ```typescript
|
|
607
|
-
* const devRole = await omnibase.permissions.roles.create({
|
|
608
|
-
* role_name: 'project_developer',
|
|
609
|
-
* permissions: [
|
|
610
|
-
* 'project:proj_abc123#deploy',
|
|
611
|
-
* 'project:proj_abc123#view_logs',
|
|
612
|
-
* 'tenant#invite_user'
|
|
613
|
-
* ]
|
|
614
|
-
* });
|
|
615
|
-
* ```
|
|
616
|
-
*/
|
|
617
|
-
async create(request) {
|
|
618
|
-
const response = await this.client.fetch("/api/v1/permissions/roles", {
|
|
619
|
-
method: "POST",
|
|
620
|
-
headers: { "Content-Type": "application/json" },
|
|
621
|
-
body: JSON.stringify(request)
|
|
622
|
-
});
|
|
623
|
-
const data = await response.json();
|
|
624
|
-
if (!response.ok || data.error) {
|
|
625
|
-
throw new Error(data.error || "Failed to create role");
|
|
626
|
-
}
|
|
627
|
-
return data.data;
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Update an existing role's permissions
|
|
631
|
-
*
|
|
632
|
-
* Updates the permissions for a role and automatically updates all
|
|
633
|
-
* Keto relationships for users assigned to this role. Old permissions
|
|
634
|
-
* are removed and new ones are created.
|
|
635
|
-
*
|
|
636
|
-
* @param roleId - ID of role to update
|
|
637
|
-
* @param request - Update request with new permissions
|
|
638
|
-
* @returns Updated role
|
|
639
|
-
*
|
|
640
|
-
* @example
|
|
641
|
-
* ```typescript
|
|
642
|
-
* const updatedRole = await omnibase.permissions.roles.update('role_123', {
|
|
643
|
-
* permissions: [
|
|
644
|
-
* 'tenant#manage_billing',
|
|
645
|
-
* 'tenant#view_invoices',
|
|
646
|
-
* 'tenant#manage_users' // Added new permission
|
|
647
|
-
* ]
|
|
648
|
-
* });
|
|
649
|
-
*
|
|
650
|
-
* console.log(`Updated role with ${updatedRole.permissions.length} permissions`);
|
|
651
|
-
* ```
|
|
652
|
-
*/
|
|
653
|
-
async update(roleId, request) {
|
|
654
|
-
const response = await this.client.fetch(
|
|
655
|
-
`/api/v1/permissions/roles/${roleId}`,
|
|
656
|
-
{
|
|
657
|
-
method: "PUT",
|
|
658
|
-
headers: { "Content-Type": "application/json" },
|
|
659
|
-
body: JSON.stringify(request)
|
|
660
|
-
}
|
|
661
|
-
);
|
|
662
|
-
const data = await response.json();
|
|
663
|
-
if (!response.ok || data.error) {
|
|
664
|
-
throw new Error(data.error || "Failed to update role");
|
|
665
|
-
}
|
|
666
|
-
return data.data;
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Delete a role
|
|
670
|
-
*
|
|
671
|
-
* Deletes the role and automatically removes all Keto relationships
|
|
672
|
-
* for users assigned to this role. Cannot delete system roles.
|
|
673
|
-
*
|
|
674
|
-
* @param roleId - ID of role to delete
|
|
675
|
-
*
|
|
676
|
-
* @example
|
|
677
|
-
* ```typescript
|
|
678
|
-
* await omnibase.permissions.roles.delete('role_123');
|
|
679
|
-
* console.log('Role deleted successfully');
|
|
680
|
-
* ```
|
|
681
|
-
*/
|
|
682
|
-
async delete(roleId) {
|
|
683
|
-
const response = await this.client.fetch(
|
|
684
|
-
`/api/v1/permissions/roles/${roleId}`,
|
|
685
|
-
{
|
|
686
|
-
method: "DELETE"
|
|
687
|
-
}
|
|
688
|
-
);
|
|
689
|
-
const data = await response.json();
|
|
690
|
-
if (!response.ok || data.error) {
|
|
691
|
-
throw new Error(data.error || "Failed to delete role");
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Assign a role to a user
|
|
696
|
-
*
|
|
697
|
-
* Assigns a role to a user and automatically creates all necessary
|
|
698
|
-
* Keto relationship tuples based on the role's permissions. The user
|
|
699
|
-
* immediately gains all permissions defined in the role.
|
|
700
|
-
*
|
|
701
|
-
* Supports assignment by either role ID or role name for flexibility.
|
|
702
|
-
*
|
|
703
|
-
* @param userId - ID of user to assign role to
|
|
704
|
-
* @param request - Assignment request with either role_id or role_name
|
|
705
|
-
*
|
|
706
|
-
* @example
|
|
707
|
-
* Assign by role ID:
|
|
708
|
-
* ```typescript
|
|
709
|
-
* await omnibase.permissions.roles.assign('user_123', {
|
|
710
|
-
* role_id: 'role_456'
|
|
711
|
-
* });
|
|
712
|
-
* ```
|
|
713
|
-
*
|
|
714
|
-
* @example
|
|
715
|
-
* Assign by role name (system or custom role):
|
|
716
|
-
* ```typescript
|
|
717
|
-
* // Assign system role
|
|
718
|
-
* await omnibase.permissions.roles.assign('user_123', {
|
|
719
|
-
* role_name: 'owner'
|
|
720
|
-
* });
|
|
721
|
-
*
|
|
722
|
-
* // Assign custom role
|
|
723
|
-
* await omnibase.permissions.roles.assign('user_456', {
|
|
724
|
-
* role_name: 'billing_manager'
|
|
725
|
-
* });
|
|
726
|
-
* ```
|
|
727
|
-
*
|
|
728
|
-
* @example
|
|
729
|
-
* Verify permissions after assignment:
|
|
730
|
-
* ```typescript
|
|
731
|
-
* await omnibase.permissions.roles.assign('user_123', {
|
|
732
|
-
* role_name: 'admin'
|
|
733
|
-
* });
|
|
734
|
-
*
|
|
735
|
-
* // User now has all permissions from the admin role
|
|
736
|
-
* const canManage = await omnibase.permissions.permissions.checkPermission(
|
|
737
|
-
* undefined,
|
|
738
|
-
* {
|
|
739
|
-
* namespace: 'Tenant',
|
|
740
|
-
* object: 'tenant_789',
|
|
741
|
-
* relation: 'manage_billing',
|
|
742
|
-
* subjectId: 'user_123'
|
|
743
|
-
* }
|
|
744
|
-
* );
|
|
745
|
-
* // canManage.data.allowed === true
|
|
746
|
-
* ```
|
|
747
|
-
*/
|
|
748
|
-
async assign(userId, request) {
|
|
749
|
-
const response = await this.client.fetch(
|
|
750
|
-
`/api/v1/permissions/users/${userId}/roles`,
|
|
751
|
-
{
|
|
752
|
-
method: "POST",
|
|
753
|
-
headers: { "Content-Type": "application/json" },
|
|
754
|
-
body: JSON.stringify(request)
|
|
755
|
-
}
|
|
756
|
-
);
|
|
757
|
-
const data = await response.json();
|
|
758
|
-
if (!response.ok || data.error) {
|
|
759
|
-
throw new Error(data.error || "Failed to assign role");
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// src/permissions/handler.ts
|
|
765
|
-
var PermissionsClient = class {
|
|
766
|
-
/**
|
|
767
|
-
* Ory Keto RelationshipApi for managing subject-object relationships
|
|
768
|
-
*
|
|
769
|
-
* Provides methods for creating, updating, and deleting relationships between
|
|
770
|
-
* subjects (users, groups) and objects (tenants, resources). This API handles
|
|
771
|
-
* write operations and is used to establish permission structures.
|
|
772
|
-
*
|
|
773
|
-
* Key methods:
|
|
774
|
-
* - `createRelationship()` - Creates a new relationship tuple
|
|
775
|
-
* - `deleteRelationships()` - Removes existing relationship tuples
|
|
776
|
-
* - `getRelationships()` - Queries existing relationships
|
|
777
|
-
* - `patchRelationships()` - Updates multiple relationships atomically
|
|
778
|
-
*
|
|
779
|
-
* @example
|
|
780
|
-
* ```typescript
|
|
781
|
-
* // Create a relationship
|
|
782
|
-
* await client.relationships.createRelationship(
|
|
783
|
-
* undefined,
|
|
784
|
-
* {
|
|
785
|
-
* namespace: 'Tenant',
|
|
786
|
-
* object: 'tenant_123',
|
|
787
|
-
* relation: 'members',
|
|
788
|
-
* subjectId: 'user_456'
|
|
789
|
-
* }
|
|
790
|
-
* );
|
|
791
|
-
* ```
|
|
792
|
-
*
|
|
793
|
-
* @since 1.0.0
|
|
794
|
-
* @group Relationships
|
|
795
|
-
*/
|
|
796
|
-
relationships;
|
|
797
|
-
/**
|
|
798
|
-
* Ory Keto PermissionApi for checking permissions
|
|
799
|
-
*
|
|
800
|
-
* Provides methods for querying whether a subject has a specific permission
|
|
801
|
-
* on an object. This API handles read operations and is optimized for fast
|
|
802
|
-
* permission checks in your application logic.
|
|
803
|
-
*
|
|
804
|
-
* Key methods:
|
|
805
|
-
* - `checkPermission()` - Checks if a subject has permission on an object
|
|
806
|
-
* - `checkPermissionOrError()` - Same as above but throws error if denied
|
|
807
|
-
* - `expandPermissions()` - Expands relationships to show all granted permissions
|
|
808
|
-
*
|
|
809
|
-
* @example
|
|
810
|
-
* ```typescript
|
|
811
|
-
* // Check permission
|
|
812
|
-
* const result = await client.permissions.checkPermission(
|
|
813
|
-
* undefined,
|
|
814
|
-
* {
|
|
815
|
-
* namespace: 'Tenant',
|
|
816
|
-
* object: 'tenant_123',
|
|
817
|
-
* relation: 'view',
|
|
818
|
-
* subjectId: 'user_456'
|
|
819
|
-
* }
|
|
820
|
-
* );
|
|
821
|
-
*
|
|
822
|
-
* console.log('Has permission:', result.data.allowed);
|
|
823
|
-
* ```
|
|
824
|
-
*
|
|
825
|
-
* @since 1.0.0
|
|
826
|
-
* @group Permissions
|
|
827
|
-
*/
|
|
828
|
-
permissions;
|
|
829
|
-
/**
|
|
830
|
-
* Handler for managing roles and role-based permissions
|
|
831
|
-
*
|
|
832
|
-
* Provides methods for creating custom roles, assigning permissions,
|
|
833
|
-
* and managing role assignments. Works alongside the Keto-based
|
|
834
|
-
* permissions system to provide dynamic RBAC capabilities.
|
|
835
|
-
*
|
|
836
|
-
* @example
|
|
837
|
-
* ```typescript
|
|
838
|
-
* // Create a custom role
|
|
839
|
-
* const role = await omnibase.permissions.roles.create({
|
|
840
|
-
* role_name: 'billing_manager',
|
|
841
|
-
* permissions: ['tenant#manage_billing', 'tenant#view_invoices']
|
|
842
|
-
* });
|
|
843
|
-
*
|
|
844
|
-
* // Assign role to user
|
|
845
|
-
* await omnibase.permissions.roles.assign('user_123', {
|
|
846
|
-
* role_id: role.id
|
|
847
|
-
* });
|
|
848
|
-
* ```
|
|
849
|
-
*
|
|
850
|
-
* @since 0.7.0
|
|
851
|
-
* @group Roles
|
|
852
|
-
*/
|
|
853
|
-
roles;
|
|
854
|
-
/**
|
|
855
|
-
* Creates a new PermissionsClient instance
|
|
856
|
-
*
|
|
857
|
-
* Initializes the client with separate endpoints for read and write operations.
|
|
858
|
-
* The client automatically appends the appropriate Keto API paths to the base URL
|
|
859
|
-
* for optimal performance and security separation.
|
|
860
|
-
*
|
|
861
|
-
* @param apiBaseUrl - The base URL for your Omnibase API instance
|
|
862
|
-
* @param client - The main OmnibaseClient instance (for roles handler)
|
|
863
|
-
*
|
|
864
|
-
* @throws {Error} When the base URL is invalid or cannot be reached
|
|
865
|
-
*
|
|
866
|
-
* @example
|
|
867
|
-
* ```typescript
|
|
868
|
-
* const client = new PermissionsClient('https://api.example.com', omnibaseClient);
|
|
869
|
-
* ```
|
|
870
|
-
*
|
|
871
|
-
* @since 1.0.0
|
|
872
|
-
* @group Client
|
|
873
|
-
*/
|
|
874
|
-
constructor(apiBaseUrl, client) {
|
|
875
|
-
this.relationships = new import_client.RelationshipApi(
|
|
876
|
-
void 0,
|
|
877
|
-
`${apiBaseUrl}/api/v1/permissions/write`
|
|
878
|
-
);
|
|
879
|
-
this.permissions = new import_client.PermissionApi(
|
|
880
|
-
void 0,
|
|
881
|
-
`${apiBaseUrl}/api/v1/permissions/read`
|
|
882
|
-
);
|
|
883
|
-
this.roles = new RolesHandler(client);
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// src/storage/index.ts
|
|
888
|
-
var StorageClient = class {
|
|
889
|
-
constructor(client) {
|
|
890
|
-
this.client = client;
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Upload a file to storage
|
|
894
|
-
*
|
|
895
|
-
* @param path - Full path for the file (e.g., "public/images/avatar.png", "users/123/private/doc.pdf")
|
|
896
|
-
* @param file - File or Blob to upload
|
|
897
|
-
* @param options - Upload options including custom metadata
|
|
898
|
-
*
|
|
899
|
-
* @example
|
|
900
|
-
* ```typescript
|
|
901
|
-
* const result = await storage.upload(
|
|
902
|
-
* 'public/avatars/user-123.png',
|
|
903
|
-
* file,
|
|
904
|
-
* {
|
|
905
|
-
* metadata: {
|
|
906
|
-
* userId: '123',
|
|
907
|
-
* uploadedBy: 'john@example.com',
|
|
908
|
-
* tags: ['profile', 'avatar']
|
|
909
|
-
* }
|
|
910
|
-
* }
|
|
911
|
-
* );
|
|
912
|
-
*
|
|
913
|
-
* // File is automatically uploaded to S3 via the presigned URL
|
|
914
|
-
* console.log('File uploaded to:', result.path);
|
|
915
|
-
* ```
|
|
916
|
-
*/
|
|
917
|
-
async upload(path, file, options) {
|
|
918
|
-
const metadata = {
|
|
919
|
-
// File metadata
|
|
920
|
-
filename: file instanceof File ? file.name : "blob",
|
|
921
|
-
size: file.size,
|
|
922
|
-
mime_type: file.type,
|
|
923
|
-
uploaded_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
924
|
-
// Merge custom metadata
|
|
925
|
-
...options?.metadata || {}
|
|
926
|
-
};
|
|
927
|
-
const response = await this.client.fetch("/api/v1/storage/upload", {
|
|
928
|
-
method: "POST",
|
|
929
|
-
headers: {
|
|
930
|
-
"Content-Type": "application/json"
|
|
931
|
-
},
|
|
932
|
-
body: JSON.stringify({
|
|
933
|
-
path,
|
|
934
|
-
metadata
|
|
935
|
-
})
|
|
936
|
-
});
|
|
937
|
-
if (!response.ok) {
|
|
938
|
-
const error = await response.json().catch(() => ({ error: "Upload failed" }));
|
|
939
|
-
throw new Error(error.error || "Failed to get upload URL");
|
|
940
|
-
}
|
|
941
|
-
const responseData = await response.json();
|
|
942
|
-
const result = responseData.data;
|
|
943
|
-
const uploadResponse = await fetch(result.upload_url, {
|
|
944
|
-
method: "PUT",
|
|
945
|
-
body: file,
|
|
946
|
-
headers: {
|
|
947
|
-
"Content-Type": file.type
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
if (!uploadResponse.ok) {
|
|
951
|
-
throw new Error("Failed to upload file to storage");
|
|
952
|
-
}
|
|
953
|
-
return result;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Download a file from storage
|
|
957
|
-
*
|
|
958
|
-
* @param path - Full path to the file
|
|
959
|
-
*
|
|
960
|
-
* @example
|
|
961
|
-
* ```typescript
|
|
962
|
-
* const { download_url } = await storage.download('public/images/logo.png');
|
|
963
|
-
*
|
|
964
|
-
* // Download the file
|
|
965
|
-
* const response = await fetch(download_url);
|
|
966
|
-
* const blob = await response.blob();
|
|
967
|
-
* ```
|
|
968
|
-
*/
|
|
969
|
-
async download(path) {
|
|
970
|
-
const response = await this.client.fetch("/api/v1/storage/download", {
|
|
971
|
-
method: "POST",
|
|
972
|
-
headers: {
|
|
973
|
-
"Content-Type": "application/json"
|
|
974
|
-
},
|
|
975
|
-
body: JSON.stringify({
|
|
976
|
-
path
|
|
977
|
-
})
|
|
978
|
-
});
|
|
979
|
-
if (!response.ok) {
|
|
980
|
-
const error = await response.json().catch(() => ({ error: "Download failed" }));
|
|
981
|
-
throw new Error(error.error || "Failed to get download URL");
|
|
982
|
-
}
|
|
983
|
-
const responseData = await response.json();
|
|
984
|
-
return responseData.data;
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Delete a file from storage
|
|
988
|
-
*
|
|
989
|
-
* @param path - Full path to the file
|
|
990
|
-
*
|
|
991
|
-
* @example
|
|
992
|
-
* ```typescript
|
|
993
|
-
* await storage.delete('users/123/documents/old-report.pdf');
|
|
994
|
-
* ```
|
|
995
|
-
*/
|
|
996
|
-
async delete(path) {
|
|
997
|
-
const response = await this.client.fetch("/api/v1/storage/object", {
|
|
998
|
-
method: "DELETE",
|
|
999
|
-
headers: {
|
|
1000
|
-
"Content-Type": "application/json"
|
|
1001
|
-
},
|
|
1002
|
-
body: JSON.stringify({
|
|
1003
|
-
path
|
|
1004
|
-
})
|
|
1005
|
-
});
|
|
1006
|
-
if (!response.ok) {
|
|
1007
|
-
const error = await response.json().catch(() => ({ error: "Delete failed" }));
|
|
1008
|
-
throw new Error(error.error || "Failed to delete file");
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
// src/tenants/invites.ts
|
|
1014
|
-
var TenantInviteManager = class {
|
|
1015
|
-
/**
|
|
1016
|
-
* Creates a new TenantInviteManager instance
|
|
1017
|
-
*
|
|
1018
|
-
* Initializes the manager with the provided Omnibase client for making
|
|
1019
|
-
* authenticated API requests to tenant invitation endpoints.
|
|
1020
|
-
*
|
|
1021
|
-
* @param omnibaseClient - Configured Omnibase client instance
|
|
1022
|
-
*
|
|
1023
|
-
* @group Tenant Invitations
|
|
1024
|
-
*/
|
|
1025
|
-
constructor(omnibaseClient) {
|
|
1026
|
-
this.omnibaseClient = omnibaseClient;
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Accepts a tenant invitation using a secure token
|
|
1030
|
-
*
|
|
1031
|
-
* Processes a tenant invitation by validating the provided token and
|
|
1032
|
-
* adding the authenticated user to the specified tenant. The invitation
|
|
1033
|
-
* token is consumed during this process and cannot be used again.
|
|
1034
|
-
*
|
|
1035
|
-
* The function performs several validations:
|
|
1036
|
-
* - Verifies the token exists and is valid
|
|
1037
|
-
* - Checks that the invitation hasn't expired
|
|
1038
|
-
* - Ensures the invitation hasn't already been used
|
|
1039
|
-
* - Confirms the user is authenticated via session cookies
|
|
1040
|
-
*
|
|
1041
|
-
* Upon successful acceptance, the user is granted access to the tenant
|
|
1042
|
-
* with the role specified in the original invitation. The invitation
|
|
1043
|
-
* record is marked as used and cannot be accepted again.
|
|
1044
|
-
*
|
|
1045
|
-
* @param token - The secure invitation token from the email invitation
|
|
1046
|
-
*
|
|
1047
|
-
* @returns Promise resolving to the tenant ID and success confirmation
|
|
1048
|
-
*
|
|
1049
|
-
* @throws {Error} When the token parameter is missing or empty
|
|
1050
|
-
* @throws {Error} When the invitation token is invalid or expired
|
|
1051
|
-
* @throws {Error} When the invitation has already been accepted
|
|
1052
|
-
* @throws {Error} When the user is not authenticated
|
|
1053
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1054
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1055
|
-
*
|
|
1056
|
-
* @example
|
|
1057
|
-
* ```typescript
|
|
1058
|
-
* // Typically called from an invitation link like:
|
|
1059
|
-
* // https://app.com/accept-invite?token=inv_secure_token_abc123
|
|
1060
|
-
*
|
|
1061
|
-
* const urlParams = new URLSearchParams(window.location.search);
|
|
1062
|
-
* const inviteToken = urlParams.get('token');
|
|
1063
|
-
*
|
|
1064
|
-
* if (inviteToken) {
|
|
1065
|
-
* try {
|
|
1066
|
-
* const result = await inviteManager.accept(inviteToken);
|
|
1067
|
-
*
|
|
1068
|
-
* // Success - redirect to tenant dashboard
|
|
1069
|
-
* console.log(`Successfully joined tenant: ${result.data.tenant_id}`);
|
|
1070
|
-
* window.location.href = `/dashboard?tenant=${result.data.tenant_id}`;
|
|
1071
|
-
* } catch (error) {
|
|
1072
|
-
* console.error('Failed to accept invitation:', error.message);
|
|
1073
|
-
* }
|
|
1074
|
-
* }
|
|
1075
|
-
* ```
|
|
1076
|
-
*
|
|
1077
|
-
* @since 0.6.0
|
|
1078
|
-
* @public
|
|
1079
|
-
* @group Tenant Invitations
|
|
1080
|
-
*/
|
|
1081
|
-
async accept(token) {
|
|
1082
|
-
if (!token) {
|
|
1083
|
-
throw new Error("Invite token is required");
|
|
1084
|
-
}
|
|
1085
|
-
const requestBody = {
|
|
1086
|
-
token
|
|
1087
|
-
};
|
|
1088
|
-
try {
|
|
1089
|
-
const response = await this.omnibaseClient.fetch(
|
|
1090
|
-
`/api/v1/tenants/invites/accept`,
|
|
1091
|
-
{
|
|
1092
|
-
method: "PUT",
|
|
1093
|
-
headers: {
|
|
1094
|
-
"Content-Type": "application/json"
|
|
1095
|
-
},
|
|
1096
|
-
body: JSON.stringify(requestBody),
|
|
1097
|
-
credentials: "include"
|
|
1098
|
-
}
|
|
1099
|
-
);
|
|
1100
|
-
if (!response.ok) {
|
|
1101
|
-
const errorData = await response.text();
|
|
1102
|
-
throw new Error(
|
|
1103
|
-
`Failed to accept invite: ${response.status} - ${errorData}`
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1106
|
-
const data = await response.json();
|
|
1107
|
-
return data;
|
|
1108
|
-
} catch (error) {
|
|
1109
|
-
console.error("Error accepting tenant invite:", error);
|
|
1110
|
-
throw error;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* Creates a new user invitation for the active tenant
|
|
1115
|
-
*
|
|
1116
|
-
* Generates a secure invitation that allows a user to join the currently active
|
|
1117
|
-
* tenant with the defined role. The invitation is sent to the provided email address
|
|
1118
|
-
* and includes a time-limited token for security. The invite URL will be automatically
|
|
1119
|
-
* appended with ?token=XYZ when sent to the user.
|
|
1120
|
-
*
|
|
1121
|
-
* The function creates the invitation record in the database and triggers an email
|
|
1122
|
-
* notification to the invited user. The invitation expires after 7 days and can only
|
|
1123
|
-
* be used once.
|
|
1124
|
-
*
|
|
1125
|
-
* Only existing tenant members with appropriate permissions (invite_user permission)
|
|
1126
|
-
* can create invitations. The inviter's authentication and tenant context are validated
|
|
1127
|
-
* via HTTP-only cookies sent with the request.
|
|
1128
|
-
*
|
|
1129
|
-
* @param inviteData - Configuration object for the invitation
|
|
1130
|
-
* @param inviteData.email - Email address of the user to invite
|
|
1131
|
-
* @param inviteData.role - Role the user will have after joining (e.g., 'member', 'admin')
|
|
1132
|
-
* @param inviteData.invite_url - Base URL for the invitation link (will be appended with ?token=XYZ)
|
|
1133
|
-
*
|
|
1134
|
-
* @returns Promise resolving to the created invitation with secure token
|
|
1135
|
-
*
|
|
1136
|
-
* @throws {Error} When required fields (email, role, invite_url) are missing or empty
|
|
1137
|
-
* @throws {Error} When the user doesn't have permission to invite users to the tenant
|
|
1138
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1139
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1140
|
-
*
|
|
1141
|
-
* @example
|
|
1142
|
-
* ```typescript
|
|
1143
|
-
* const invite = await inviteManager.create({
|
|
1144
|
-
* email: 'colleague@company.com',
|
|
1145
|
-
* role: 'member',
|
|
1146
|
-
* invite_url: 'https://yourapp.com/accept-invite'
|
|
1147
|
-
* });
|
|
1148
|
-
*
|
|
1149
|
-
* console.log(`Invite sent to: ${invite.data.invite.email}`);
|
|
1150
|
-
* console.log(`Invite token: ${invite.data.invite.token}`);
|
|
1151
|
-
* ```
|
|
1152
|
-
*
|
|
1153
|
-
* @since 0.6.0
|
|
1154
|
-
* @public
|
|
1155
|
-
* @group Tenant Invitations
|
|
1156
|
-
*/
|
|
1157
|
-
async create(inviteData) {
|
|
1158
|
-
if (!inviteData.email || !inviteData.role || !inviteData.invite_url) {
|
|
1159
|
-
throw new Error(
|
|
1160
|
-
"Missing data in `create` - email, role, and invite_url are required"
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
try {
|
|
1164
|
-
const response = await this.omnibaseClient.fetch(
|
|
1165
|
-
`/api/v1/tenants/invites`,
|
|
1166
|
-
{
|
|
1167
|
-
method: "POST",
|
|
1168
|
-
headers: {
|
|
1169
|
-
"Content-Type": "application/json"
|
|
1170
|
-
},
|
|
1171
|
-
body: JSON.stringify(inviteData),
|
|
1172
|
-
credentials: "include"
|
|
1173
|
-
}
|
|
1174
|
-
);
|
|
1175
|
-
if (!response.ok) {
|
|
1176
|
-
const errorData = await response.text();
|
|
1177
|
-
throw new Error(
|
|
1178
|
-
`Failed to create invite: ${response.status} - ${errorData}`
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
const data = await response.json();
|
|
1182
|
-
return data;
|
|
1183
|
-
} catch (error) {
|
|
1184
|
-
console.error("Error creating tenant user invite:", error);
|
|
1185
|
-
throw error;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
// src/tenants/management.ts
|
|
1191
|
-
var TenantManger = class {
|
|
1192
|
-
/**
|
|
1193
|
-
* Creates a new TenantManger instance
|
|
1194
|
-
*
|
|
1195
|
-
* Initializes the manager with the provided Omnibase client for making
|
|
1196
|
-
* authenticated API requests to tenant management endpoints.
|
|
1197
|
-
*
|
|
1198
|
-
* @param omnibaseClient - Configured Omnibase client instance
|
|
1199
|
-
*
|
|
1200
|
-
* @group Tenant Management
|
|
1201
|
-
*/
|
|
1202
|
-
constructor(omnibaseClient) {
|
|
1203
|
-
this.omnibaseClient = omnibaseClient;
|
|
1204
|
-
}
|
|
1205
|
-
/**
|
|
1206
|
-
* Creates a new tenant in the multi-tenant system
|
|
1207
|
-
*
|
|
1208
|
-
* Establishes a new tenant with integrated Stripe billing setup and assigns
|
|
1209
|
-
* the specified user as the tenant owner. The operation creates the necessary
|
|
1210
|
-
* database records and returns a JWT token that enables Row-Level Security
|
|
1211
|
-
* access to the tenant's isolated data.
|
|
1212
|
-
*
|
|
1213
|
-
* The function automatically handles Stripe customer creation for billing
|
|
1214
|
-
* integration and sets up the initial tenant configuration. The returned
|
|
1215
|
-
* token should be stored securely for subsequent API calls.
|
|
1216
|
-
*
|
|
1217
|
-
* @param tenantData - Configuration object for the new tenant
|
|
1218
|
-
* @param tenantData.name - Display name for the tenant organization
|
|
1219
|
-
* @param tenantData.billing_email - Email address for Stripe billing notifications
|
|
1220
|
-
* @param tenantData.user_id - Unique identifier of the user who will own this tenant
|
|
1221
|
-
*
|
|
1222
|
-
* @returns Promise resolving to the created tenant with authentication token
|
|
1223
|
-
*
|
|
1224
|
-
* @throws {Error} When required fields (name, user_id) are missing or empty
|
|
1225
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1226
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1227
|
-
*
|
|
1228
|
-
* @example
|
|
1229
|
-
* ```typescript
|
|
1230
|
-
* const newTenant = await tenantManager.createTenant({
|
|
1231
|
-
* name: 'Acme Corporation',
|
|
1232
|
-
* billing_email: 'billing@acme.com',
|
|
1233
|
-
* user_id: 'user_123'
|
|
1234
|
-
* });
|
|
1235
|
-
*
|
|
1236
|
-
* console.log(`Tenant created: ${newTenant.data.tenant.id}`);
|
|
1237
|
-
* ```
|
|
1238
|
-
*
|
|
1239
|
-
* @since 0.6.0
|
|
1240
|
-
* @public
|
|
1241
|
-
* @group Tenant Management
|
|
1242
|
-
*/
|
|
1243
|
-
async createTenant(tenantData) {
|
|
1244
|
-
if (!tenantData.name || !tenantData.user_id) {
|
|
1245
|
-
throw new Error("Name and user_id are required");
|
|
1246
|
-
}
|
|
1247
|
-
try {
|
|
1248
|
-
const response = await this.omnibaseClient.fetch(`/api/v1/tenants`, {
|
|
1249
|
-
method: "POST",
|
|
1250
|
-
headers: {
|
|
1251
|
-
"Content-Type": "application/json"
|
|
1252
|
-
},
|
|
1253
|
-
body: JSON.stringify(tenantData),
|
|
1254
|
-
credentials: "include"
|
|
1255
|
-
});
|
|
1256
|
-
if (!response.ok) {
|
|
1257
|
-
const errorData = await response.text();
|
|
1258
|
-
throw new Error(
|
|
1259
|
-
`Failed to create tenant: ${response.status} - ${errorData}`
|
|
1260
|
-
);
|
|
1261
|
-
}
|
|
1262
|
-
const data = await response.json();
|
|
1263
|
-
return data;
|
|
1264
|
-
} catch (error) {
|
|
1265
|
-
console.error("Error creating tenant:", error);
|
|
1266
|
-
throw error;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* Permanently deletes a tenant and all associated data
|
|
1271
|
-
*
|
|
1272
|
-
* ⚠️ **WARNING: This operation is irreversible and will permanently delete:**
|
|
1273
|
-
* - The tenant record and all metadata
|
|
1274
|
-
* - All user memberships and invitations for this tenant
|
|
1275
|
-
* - All tenant-specific data protected by row-level security
|
|
1276
|
-
* - Any tenant-related billing information
|
|
1277
|
-
* - All tenant configuration and settings
|
|
1278
|
-
*
|
|
1279
|
-
* **Access Control:**
|
|
1280
|
-
* Only tenant owners can delete a tenant. This operation requires:
|
|
1281
|
-
* - User must be authenticated
|
|
1282
|
-
* - User must have 'owner' role for the specified tenant
|
|
1283
|
-
* - Tenant must exist and be accessible to the user
|
|
1284
|
-
*
|
|
1285
|
-
* **Security Considerations:**
|
|
1286
|
-
* - All tenant data is immediately and permanently removed
|
|
1287
|
-
* - Other tenant members lose access immediately
|
|
1288
|
-
* - Any active sessions for this tenant are invalidated
|
|
1289
|
-
* - Billing subscriptions are cancelled (if applicable)
|
|
1290
|
-
* - Audit logs for deletion are maintained for compliance
|
|
1291
|
-
*
|
|
1292
|
-
* @returns Promise resolving to a confirmation message
|
|
1293
|
-
*
|
|
1294
|
-
* @throws {Error} When the tenantId parameter is missing or empty
|
|
1295
|
-
* @throws {Error} When the user is not authenticated
|
|
1296
|
-
* @throws {Error} When the user is not an owner of the specified tenant
|
|
1297
|
-
* @throws {Error} When the tenant doesn't exist or is not accessible
|
|
1298
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1299
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1300
|
-
*
|
|
1301
|
-
* @example
|
|
1302
|
-
* ```typescript
|
|
1303
|
-
* // Always confirm before deleting
|
|
1304
|
-
* const userConfirmed = confirm(
|
|
1305
|
-
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
1306
|
-
* );
|
|
1307
|
-
*
|
|
1308
|
-
* if (userConfirmed) {
|
|
1309
|
-
* try {
|
|
1310
|
-
* const result = await tenantManager.deleteTenant();
|
|
1311
|
-
* console.log(result.data.message);
|
|
1312
|
-
*
|
|
1313
|
-
* // Redirect user away from deleted tenant
|
|
1314
|
-
* window.location.href = '/dashboard';
|
|
1315
|
-
* } catch (error) {
|
|
1316
|
-
* console.error('Failed to delete tenant:', error);
|
|
1317
|
-
* }
|
|
1318
|
-
* }
|
|
1319
|
-
* ```
|
|
1320
|
-
*
|
|
1321
|
-
* @since 0.6.0
|
|
1322
|
-
* @public
|
|
1323
|
-
* @group Tenant Management
|
|
1324
|
-
*/
|
|
1325
|
-
async deleteTenant() {
|
|
1326
|
-
try {
|
|
1327
|
-
const response = await this.omnibaseClient.fetch(`/api/v1/tenants`, {
|
|
1328
|
-
method: "DELETE",
|
|
1329
|
-
headers: {
|
|
1330
|
-
"Content-Type": "application/json"
|
|
1331
|
-
},
|
|
1332
|
-
credentials: "include"
|
|
1333
|
-
});
|
|
1334
|
-
if (!response.ok) {
|
|
1335
|
-
const errorData = await response.text();
|
|
1336
|
-
throw new Error(
|
|
1337
|
-
`Failed to delete tenant: ${response.status} - ${errorData}`
|
|
1338
|
-
);
|
|
1339
|
-
}
|
|
1340
|
-
const data = await response.json();
|
|
1341
|
-
return data;
|
|
1342
|
-
} catch (error) {
|
|
1343
|
-
console.error("Error deleting tenant:", error);
|
|
1344
|
-
throw error;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
/**
|
|
1348
|
-
* Switches the user's active tenant context
|
|
1349
|
-
*
|
|
1350
|
-
* Changes the user's active tenant to the specified tenant ID, updating
|
|
1351
|
-
* their authentication context and permissions. This function is essential
|
|
1352
|
-
* for multi-tenant applications where users belong to multiple tenants
|
|
1353
|
-
* and need to switch between them.
|
|
1354
|
-
*
|
|
1355
|
-
* The function performs several operations:
|
|
1356
|
-
* - Validates that the user has access to the specified tenant
|
|
1357
|
-
* - Updates the user's active tenant in their session
|
|
1358
|
-
* - Generates a new JWT token with updated tenant claims
|
|
1359
|
-
* - Updates any cached tenant-specific data
|
|
1360
|
-
*
|
|
1361
|
-
* After switching tenants, all subsequent API calls will be made within
|
|
1362
|
-
* the context of the new active tenant, with row-level security policies
|
|
1363
|
-
* applied accordingly. The new JWT token should be used for all future
|
|
1364
|
-
* authenticated requests.
|
|
1365
|
-
*
|
|
1366
|
-
* @param tenantId - The ID of the tenant to switch to (must be a tenant the user belongs to)
|
|
1367
|
-
*
|
|
1368
|
-
* @returns Promise resolving to a new JWT token and success confirmation
|
|
1369
|
-
*
|
|
1370
|
-
* @throws {Error} When the tenantId parameter is missing or empty
|
|
1371
|
-
* @throws {Error} When the user doesn't have access to the specified tenant
|
|
1372
|
-
* @throws {Error} When the user is not authenticated
|
|
1373
|
-
* @throws {Error} When the specified tenant doesn't exist
|
|
1374
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1375
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx status codes)
|
|
1376
|
-
*
|
|
1377
|
-
* @example
|
|
1378
|
-
* ```typescript
|
|
1379
|
-
* const result = await tenantManager.switchActiveTenant('tenant_xyz789');
|
|
1380
|
-
*
|
|
1381
|
-
* // Store the new token for future requests
|
|
1382
|
-
* console.log(`Switched to tenant. New token: ${result.data.token}`);
|
|
1383
|
-
*
|
|
1384
|
-
* // Now all API calls will be in the context of tenant_xyz789
|
|
1385
|
-
* const tenantData = await getCurrentTenantData();
|
|
1386
|
-
* ```
|
|
1387
|
-
*
|
|
1388
|
-
* @since 0.6.0
|
|
1389
|
-
* @public
|
|
1390
|
-
* @group Tenant Management
|
|
1391
|
-
*/
|
|
1392
|
-
async switchActiveTenant(tenantId) {
|
|
1393
|
-
if (!tenantId) {
|
|
1394
|
-
throw new Error("Tenant ID is required");
|
|
1395
|
-
}
|
|
1396
|
-
const requestBody = {
|
|
1397
|
-
tenant_id: tenantId
|
|
1398
|
-
};
|
|
1399
|
-
try {
|
|
1400
|
-
const response = await this.omnibaseClient.fetch(
|
|
1401
|
-
`/api/v1/tenants/switch-active`,
|
|
1402
|
-
{
|
|
1403
|
-
method: "PUT",
|
|
1404
|
-
headers: {
|
|
1405
|
-
"Content-Type": "application/json"
|
|
1406
|
-
},
|
|
1407
|
-
body: JSON.stringify(requestBody),
|
|
1408
|
-
credentials: "include"
|
|
1409
|
-
}
|
|
1410
|
-
);
|
|
1411
|
-
if (!response.ok) {
|
|
1412
|
-
const errorData = await response.text();
|
|
1413
|
-
throw new Error(
|
|
1414
|
-
`Failed to switch tenant: ${response.status} - ${errorData}`
|
|
1415
|
-
);
|
|
1416
|
-
}
|
|
1417
|
-
const data = await response.json();
|
|
1418
|
-
return data;
|
|
1419
|
-
} catch (error) {
|
|
1420
|
-
console.error("Error switching active tenant:", error);
|
|
1421
|
-
throw error;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
// src/tenants/subscriptions.ts
|
|
1427
|
-
var TenantSubscriptionManager = class {
|
|
1428
|
-
/**
|
|
1429
|
-
* Creates a new TenantSubscriptionManager instance
|
|
1430
|
-
*
|
|
1431
|
-
* @param omnibaseClient - Configured Omnibase client instance
|
|
1432
|
-
*
|
|
1433
|
-
* @group Tenant Subscriptions
|
|
1434
|
-
*/
|
|
1435
|
-
constructor(omnibaseClient) {
|
|
1436
|
-
this.omnibaseClient = omnibaseClient;
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
* Get all active subscriptions for the current tenant
|
|
1440
|
-
*
|
|
1441
|
-
* Retrieves all active Stripe subscriptions associated with the user's
|
|
1442
|
-
* currently active tenant. Returns subscriptions with config-based price IDs
|
|
1443
|
-
* instead of raw Stripe IDs, making it easier to match against your billing
|
|
1444
|
-
* configuration.
|
|
1445
|
-
*
|
|
1446
|
-
* The endpoint automatically:
|
|
1447
|
-
* - Fetches subscriptions from Stripe API
|
|
1448
|
-
* - Maps Stripe price IDs to your config price IDs
|
|
1449
|
-
* - Checks both current and historical price mappings
|
|
1450
|
-
* - Flags legacy prices from old billing configurations
|
|
1451
|
-
* - Filters to only active/trialing/past_due subscriptions
|
|
1452
|
-
*
|
|
1453
|
-
* Returns an empty array if:
|
|
1454
|
-
* - Tenant has no Stripe customer ID configured
|
|
1455
|
-
* - Tenant has no active subscriptions
|
|
1456
|
-
* - User is not authenticated
|
|
1457
|
-
*
|
|
1458
|
-
* @returns Promise resolving to array of active subscriptions
|
|
1459
|
-
*
|
|
1460
|
-
* @throws {Error} When the user is not authenticated
|
|
1461
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1462
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx)
|
|
1463
|
-
*
|
|
1464
|
-
* @example
|
|
1465
|
-
* ```typescript
|
|
1466
|
-
* const response = await subscriptionManager.getActive();
|
|
1467
|
-
*
|
|
1468
|
-
* if (response.data.length === 0) {
|
|
1469
|
-
* console.log('No active subscriptions');
|
|
1470
|
-
* } else {
|
|
1471
|
-
* response.data.forEach(sub => {
|
|
1472
|
-
* console.log(`Plan: ${sub.config_price_id}`);
|
|
1473
|
-
* console.log(`Status: ${sub.status}`);
|
|
1474
|
-
* if (sub.is_legacy_price) {
|
|
1475
|
-
* console.log('⚠️ Using legacy pricing');
|
|
1476
|
-
* }
|
|
1477
|
-
* });
|
|
1478
|
-
* }
|
|
1479
|
-
* ```
|
|
1480
|
-
*
|
|
1481
|
-
* @since 0.6.0
|
|
1482
|
-
* @public
|
|
1483
|
-
* @group Tenant Subscriptions
|
|
1484
|
-
*/
|
|
1485
|
-
async getActive() {
|
|
1486
|
-
try {
|
|
1487
|
-
const response = await this.omnibaseClient.fetch(
|
|
1488
|
-
`/api/v1/tenants/subscriptions`,
|
|
1489
|
-
{
|
|
1490
|
-
method: "GET",
|
|
1491
|
-
credentials: "include"
|
|
1492
|
-
}
|
|
1493
|
-
);
|
|
1494
|
-
if (!response.ok) {
|
|
1495
|
-
const errorData = await response.text();
|
|
1496
|
-
throw new Error(
|
|
1497
|
-
`Failed to fetch subscriptions: ${response.status} - ${errorData}`
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1500
|
-
const data = await response.json();
|
|
1501
|
-
return data;
|
|
1502
|
-
} catch (error) {
|
|
1503
|
-
console.error("Error fetching tenant subscriptions:", error);
|
|
1504
|
-
throw error;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Check if the current tenant has billing information configured
|
|
1509
|
-
*
|
|
1510
|
-
* Verifies whether the tenant has valid payment methods attached to their
|
|
1511
|
-
* Stripe customer account. This is useful for:
|
|
1512
|
-
* - Showing billing setup prompts
|
|
1513
|
-
* - Gating premium features behind payment method requirement
|
|
1514
|
-
* - Displaying billing status indicators in UI
|
|
1515
|
-
* - Determining if customer portal access should be shown
|
|
1516
|
-
*
|
|
1517
|
-
* The check verifies:
|
|
1518
|
-
* - Default payment source (card, bank account, etc.)
|
|
1519
|
-
* - Default payment method in invoice settings
|
|
1520
|
-
* - Whether the payment method is valid and active
|
|
1521
|
-
*
|
|
1522
|
-
* Returns `false` if:
|
|
1523
|
-
* - Tenant has no Stripe customer ID
|
|
1524
|
-
* - No payment methods are configured
|
|
1525
|
-
* - User is not authenticated
|
|
1526
|
-
*
|
|
1527
|
-
* @returns Promise resolving to billing status information
|
|
1528
|
-
*
|
|
1529
|
-
* @throws {Error} When the user is not authenticated
|
|
1530
|
-
* @throws {Error} When the API request fails due to network issues
|
|
1531
|
-
* @throws {Error} When the server returns an error response (4xx, 5xx)
|
|
1532
|
-
*
|
|
1533
|
-
* @example
|
|
1534
|
-
* ```typescript
|
|
1535
|
-
* const response = await subscriptionManager.getBillingStatus();
|
|
1536
|
-
*
|
|
1537
|
-
* if (!response.data.has_billing_info) {
|
|
1538
|
-
* // Show billing setup prompt
|
|
1539
|
-
* showBillingSetupModal();
|
|
1540
|
-
* } else if (!response.data.is_active) {
|
|
1541
|
-
* // Payment method exists but may be expired/invalid
|
|
1542
|
-
* showPaymentMethodUpdatePrompt();
|
|
1543
|
-
* } else {
|
|
1544
|
-
* // All good - show customer portal link
|
|
1545
|
-
* showManageBillingButton();
|
|
1546
|
-
* }
|
|
1547
|
-
* ```
|
|
1548
|
-
*
|
|
1549
|
-
* @since 0.6.0
|
|
1550
|
-
* @public
|
|
1551
|
-
* @group Tenant Subscriptions
|
|
1552
|
-
*/
|
|
1553
|
-
async getBillingStatus() {
|
|
1554
|
-
try {
|
|
1555
|
-
const response = await this.omnibaseClient.fetch(
|
|
1556
|
-
`/api/v1/tenants/billing-status`,
|
|
1557
|
-
{
|
|
1558
|
-
method: "GET",
|
|
1559
|
-
credentials: "include"
|
|
1560
|
-
}
|
|
1561
|
-
);
|
|
1562
|
-
if (!response.ok) {
|
|
1563
|
-
const errorData = await response.text();
|
|
1564
|
-
throw new Error(
|
|
1565
|
-
`Failed to fetch billing status: ${response.status} - ${errorData}`
|
|
1566
|
-
);
|
|
1567
|
-
}
|
|
1568
|
-
const data = await response.json();
|
|
1569
|
-
return data;
|
|
1570
|
-
} catch (error) {
|
|
1571
|
-
console.error("Error fetching billing status:", error);
|
|
1572
|
-
throw error;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
|
|
1577
|
-
// src/tenants/user.ts
|
|
1578
|
-
var TenantUserManager = class {
|
|
1579
|
-
/**
|
|
1580
|
-
* Creates a new tenant user manager
|
|
1581
|
-
*
|
|
1582
|
-
* @param omnibaseClient - Configured OmnibaseClient instance for API communication
|
|
1583
|
-
*
|
|
1584
|
-
* @group Tenant User Management
|
|
1585
|
-
*/
|
|
1586
|
-
constructor(omnibaseClient) {
|
|
1587
|
-
this.omnibaseClient = omnibaseClient;
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Retrieves all users in the active tenant
|
|
1591
|
-
*
|
|
1592
|
-
* This method fetches a list of all users who are members of the current active tenant,
|
|
1593
|
-
* including their basic information (name, email) and assigned role. The operation
|
|
1594
|
-
* requires the requesting user to have appropriate permissions to view tenant users
|
|
1595
|
-
* (typically requires `view_users` permission).
|
|
1596
|
-
*
|
|
1597
|
-
* The returned list includes all tenant members regardless of their role, ordered by
|
|
1598
|
-
* when they joined the tenant (newest first).
|
|
1599
|
-
*
|
|
1600
|
-
* @returns Promise resolving to an array of tenant users with their details
|
|
1601
|
-
*
|
|
1602
|
-
* @throws {Error} When the API request fails (includes status code and error details)
|
|
1603
|
-
* @throws {Error} When the user doesn't have permission to view users
|
|
1604
|
-
* @throws {Error} When the user is not authenticated or no active tenant is set
|
|
1605
|
-
*
|
|
1606
|
-
* @example
|
|
1607
|
-
* ```typescript
|
|
1608
|
-
* // Fetch all users in the active tenant
|
|
1609
|
-
* try {
|
|
1610
|
-
* const result = await userManager.getAll();
|
|
1611
|
-
* console.log(`Found ${result.data.length} users`);
|
|
1612
|
-
*
|
|
1613
|
-
* result.data.forEach(user => {
|
|
1614
|
-
* console.log(`${user.first_name} ${user.last_name} (${user.email}) - ${user.role}`);
|
|
1615
|
-
* });
|
|
1616
|
-
* } catch (error) {
|
|
1617
|
-
* if (error.message.includes('403')) {
|
|
1618
|
-
* console.error('Insufficient permissions to view users');
|
|
1619
|
-
* } else {
|
|
1620
|
-
* console.error('Failed to fetch users:', error);
|
|
1621
|
-
* }
|
|
1622
|
-
* }
|
|
1623
|
-
* ```
|
|
1624
|
-
*
|
|
1625
|
-
* @since 1.0.0
|
|
1626
|
-
* @public
|
|
1627
|
-
* @group Tenant User Management
|
|
1628
|
-
*/
|
|
1629
|
-
async getAll() {
|
|
1630
|
-
const response = await this.omnibaseClient.fetch("/api/v1/tenants/users", {
|
|
1631
|
-
method: "GET"
|
|
1632
|
-
});
|
|
1633
|
-
if (!response.ok) {
|
|
1634
|
-
const errorData = await response.text();
|
|
1635
|
-
throw new Error(
|
|
1636
|
-
`Failed to fetch tenant users: ${response.status} - ${errorData}`
|
|
1637
|
-
);
|
|
1638
|
-
}
|
|
1639
|
-
return await response.json();
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* Removes a user from the active tenant
|
|
1643
|
-
*
|
|
1644
|
-
* This method removes a specified user from the current active tenant. The operation
|
|
1645
|
-
* requires the requesting user to have appropriate permissions (admin or owner role).
|
|
1646
|
-
* The user being removed will lose access to the tenant and all its resources.
|
|
1647
|
-
*
|
|
1648
|
-
* Note: You cannot remove yourself from a tenant using this method. To leave a tenant,
|
|
1649
|
-
* use the appropriate leave or delete tenant operations instead.
|
|
1650
|
-
*
|
|
1651
|
-
* @param data - Request data containing the user ID to remove
|
|
1652
|
-
* @param data.user_id - ID of the user to remove from the tenant
|
|
1653
|
-
*
|
|
1654
|
-
* @returns Promise resolving to an API response confirming the removal
|
|
1655
|
-
*
|
|
1656
|
-
* @throws {Error} When user_id is not provided
|
|
1657
|
-
* @throws {Error} When the API request fails (includes status code and error details)
|
|
1658
|
-
* @throws {Error} When the user doesn't have permission to remove users
|
|
1659
|
-
* @throws {Error} When the specified user is not a member of the tenant
|
|
1660
|
-
*
|
|
1661
|
-
* @example
|
|
1662
|
-
* ```typescript
|
|
1663
|
-
* // Remove a user from the active tenant
|
|
1664
|
-
* try {
|
|
1665
|
-
* await userManager.remove({ user_id: 'user_abc123' });
|
|
1666
|
-
* console.log('User removed successfully');
|
|
1667
|
-
* } catch (error) {
|
|
1668
|
-
* if (error.message.includes('403')) {
|
|
1669
|
-
* console.error('Insufficient permissions to remove user');
|
|
1670
|
-
* } else if (error.message.includes('404')) {
|
|
1671
|
-
* console.error('User not found in tenant');
|
|
1672
|
-
* } else {
|
|
1673
|
-
* console.error('Failed to remove user:', error);
|
|
1674
|
-
* }
|
|
1675
|
-
* }
|
|
1676
|
-
* ```
|
|
1677
|
-
*
|
|
1678
|
-
* @since 0.6.0
|
|
1679
|
-
* @public
|
|
1680
|
-
* @group Tenant User Management
|
|
1681
|
-
*/
|
|
1682
|
-
async remove(data) {
|
|
1683
|
-
if (!data.user_id) {
|
|
1684
|
-
throw new Error("user_id is required");
|
|
1685
|
-
}
|
|
1686
|
-
const response = await this.omnibaseClient.fetch("/api/v1/tenants/users", {
|
|
1687
|
-
method: "DELETE",
|
|
1688
|
-
body: JSON.stringify(data)
|
|
1689
|
-
});
|
|
1690
|
-
if (!response.ok) {
|
|
1691
|
-
const errorData = await response.text();
|
|
1692
|
-
throw new Error(
|
|
1693
|
-
`Failed to delete user from tenant: ${response.status} - ${errorData}`
|
|
1694
|
-
);
|
|
1695
|
-
}
|
|
1696
|
-
return await response.json();
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* Updates a user's role within the active tenant
|
|
1700
|
-
*
|
|
1701
|
-
* This method changes the role of a specified user in the current active tenant. The operation
|
|
1702
|
-
* requires the requesting user to have appropriate permissions (typically admin or owner role).
|
|
1703
|
-
* Role updates take effect immediately and affect the user's permissions and access rights
|
|
1704
|
-
* within the tenant.
|
|
1705
|
-
*
|
|
1706
|
-
* Common roles include 'admin', 'member', and 'viewer', but the exact roles available depend
|
|
1707
|
-
* on your tenant's configuration. Changing a user's role will modify their ability to perform
|
|
1708
|
-
* various operations within the tenant.
|
|
1709
|
-
*
|
|
1710
|
-
* @param data - Request data containing the user ID and new role
|
|
1711
|
-
* @param data.user_id - ID of the user whose role is being updated
|
|
1712
|
-
* @param data.role - New role to assign to the user
|
|
1713
|
-
*
|
|
1714
|
-
* @returns Promise resolving to an API response confirming the role update
|
|
1715
|
-
*
|
|
1716
|
-
* @throws {Error} When user_id or role is not provided
|
|
1717
|
-
* @throws {Error} When the API request fails (includes status code and error details)
|
|
1718
|
-
* @throws {Error} When the user doesn't have permission to update roles
|
|
1719
|
-
* @throws {Error} When the specified user is not a member of the tenant
|
|
1720
|
-
* @throws {Error} When the specified role is invalid or not allowed
|
|
1721
|
-
*
|
|
1722
|
-
* @example
|
|
1723
|
-
* ```typescript
|
|
1724
|
-
* // Update a user's role to admin
|
|
1725
|
-
* try {
|
|
1726
|
-
* const result = await userManager.updateRole({
|
|
1727
|
-
* user_id: 'user_abc123',
|
|
1728
|
-
* role: 'admin'
|
|
1729
|
-
* });
|
|
1730
|
-
* console.log('Role updated successfully:', result.data.message);
|
|
1731
|
-
* } catch (error) {
|
|
1732
|
-
* if (error.message.includes('403')) {
|
|
1733
|
-
* console.error('Insufficient permissions to update roles');
|
|
1734
|
-
* } else if (error.message.includes('404')) {
|
|
1735
|
-
* console.error('User not found in tenant');
|
|
1736
|
-
* } else {
|
|
1737
|
-
* console.error('Failed to update role:', error);
|
|
1738
|
-
* }
|
|
1739
|
-
* }
|
|
1740
|
-
* ```
|
|
1741
|
-
*
|
|
1742
|
-
* @since 0.6.0
|
|
1743
|
-
* @public
|
|
1744
|
-
* @group Tenant User Management
|
|
1745
|
-
*/
|
|
1746
|
-
async updateRole(data) {
|
|
1747
|
-
if (!data.role || !data.user_id)
|
|
1748
|
-
throw new Error("user_id and role is required");
|
|
1749
|
-
const response = await this.omnibaseClient.fetch("/api/v1/tenants/users", {
|
|
1750
|
-
method: "PUT",
|
|
1751
|
-
body: JSON.stringify(data)
|
|
1752
|
-
});
|
|
1753
|
-
if (!response.ok) {
|
|
1754
|
-
const errorData = await response.text();
|
|
1755
|
-
throw new Error(
|
|
1756
|
-
`Failed to update users role: ${response.status} - ${errorData}`
|
|
1757
|
-
);
|
|
1758
|
-
}
|
|
1759
|
-
return await response.json();
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
// src/tenants/handler.ts
|
|
1764
|
-
var TenantHandler = class {
|
|
1765
|
-
/**
|
|
1766
|
-
* Creates a new TenantHandler instance
|
|
1767
|
-
*
|
|
1768
|
-
* Initializes the handler with the provided Omnibase client and sets up
|
|
1769
|
-
* the specialized manager instances for tenant and invitation operations.
|
|
1770
|
-
* The client is used for all underlying HTTP requests and authentication.
|
|
1771
|
-
*
|
|
1772
|
-
* @param omnibaseClient - Configured Omnibase client instance
|
|
1773
|
-
*
|
|
1774
|
-
* @example
|
|
1775
|
-
* ```typescript
|
|
1776
|
-
* const client = new OmnibaseClient({
|
|
1777
|
-
* apiKey: 'your-api-key',
|
|
1778
|
-
* baseURL: 'https://api.yourapp.com'
|
|
1779
|
-
* });
|
|
1780
|
-
* const tenantHandler = new TenantHandler(client);
|
|
1781
|
-
* ```
|
|
1782
|
-
*
|
|
1783
|
-
* @group Tenant Management
|
|
1784
|
-
*/
|
|
1785
|
-
constructor(omnibaseClient) {
|
|
1786
|
-
this.invites = new TenantInviteManager(omnibaseClient);
|
|
1787
|
-
this.manage = new TenantManger(omnibaseClient);
|
|
1788
|
-
this.subscriptions = new TenantSubscriptionManager(omnibaseClient);
|
|
1789
|
-
this.user = new TenantUserManager(omnibaseClient);
|
|
1790
|
-
}
|
|
1791
|
-
/**
|
|
1792
|
-
* Tenant user management operations
|
|
1793
|
-
*
|
|
1794
|
-
* Provides access to operations for managing users within tenants, including
|
|
1795
|
-
* removing users from the active tenant. All operations respect user permissions
|
|
1796
|
-
* and tenant ownership rules.
|
|
1797
|
-
*
|
|
1798
|
-
* @example
|
|
1799
|
-
* ```typescript
|
|
1800
|
-
* // Remove a user from the active tenant
|
|
1801
|
-
* await tenantHandler.user.remove({ user_id: 'user_123' });
|
|
1802
|
-
* ```
|
|
1803
|
-
*
|
|
1804
|
-
* @since 0.6.0
|
|
1805
|
-
* @group Tenant Management
|
|
1806
|
-
*/
|
|
1807
|
-
user;
|
|
1808
|
-
/**
|
|
1809
|
-
* Core tenant management operations
|
|
1810
|
-
*
|
|
1811
|
-
* Provides access to tenant lifecycle operations including creation,
|
|
1812
|
-
* deletion, and active tenant switching. All operations respect user
|
|
1813
|
-
* permissions and tenant ownership rules.
|
|
1814
|
-
*
|
|
1815
|
-
* @example
|
|
1816
|
-
* ```typescript
|
|
1817
|
-
* // Create a new tenant
|
|
1818
|
-
* const tenant = await tenantHandler.manage.createTenant({
|
|
1819
|
-
* name: 'New Company',
|
|
1820
|
-
* billing_email: 'billing@newcompany.com',
|
|
1821
|
-
* user_id: 'user_456'
|
|
1822
|
-
* });
|
|
1823
|
-
*
|
|
1824
|
-
* // Switch to the tenant
|
|
1825
|
-
* await tenantHandler.manage.switchActiveTenant(tenant.data.tenant.id);
|
|
1826
|
-
*
|
|
1827
|
-
* // Delete the tenant (owner only)
|
|
1828
|
-
* await tenantHandler.manage.deleteTenant(tenant.data.tenant.id);
|
|
1829
|
-
* ```
|
|
1830
|
-
*/
|
|
1831
|
-
manage;
|
|
1832
|
-
/**
|
|
1833
|
-
* Tenant invitation management operations
|
|
1834
|
-
*
|
|
1835
|
-
* Provides access to user invitation functionality including creating
|
|
1836
|
-
* invitations for new users and accepting existing invitations.
|
|
1837
|
-
* Supports role-based access control and secure token-based workflows.
|
|
1838
|
-
*
|
|
1839
|
-
* @example
|
|
1840
|
-
* ```typescript
|
|
1841
|
-
* // Create an invitation
|
|
1842
|
-
* const invite = await tenantHandler.invites.create({
|
|
1843
|
-
* email: 'newuser@company.com',
|
|
1844
|
-
* role: 'admin',
|
|
1845
|
-
* invite_url: 'https://yourapp.com/accept-invite'
|
|
1846
|
-
* });
|
|
1847
|
-
*
|
|
1848
|
-
* // Accept an invitation (from the invited user's session)
|
|
1849
|
-
* const result = await tenantHandler.invites.accept('invite_token_xyz');
|
|
1850
|
-
* ```
|
|
1851
|
-
*/
|
|
1852
|
-
invites;
|
|
1853
|
-
/**
|
|
1854
|
-
* Tenant subscription and billing management
|
|
1855
|
-
*
|
|
1856
|
-
* Provides access to subscription data and billing status for the
|
|
1857
|
-
* active tenant, including legacy price detection and payment method
|
|
1858
|
-
* verification. All operations are automatically scoped to the user's
|
|
1859
|
-
* currently active tenant.
|
|
1860
|
-
*
|
|
1861
|
-
* @example
|
|
1862
|
-
* ```typescript
|
|
1863
|
-
* // Get active subscriptions
|
|
1864
|
-
* const subs = await tenantHandler.subscriptions.getActive();
|
|
1865
|
-
*
|
|
1866
|
-
* // Check billing status
|
|
1867
|
-
* const status = await tenantHandler.subscriptions.getBillingStatus();
|
|
1868
|
-
* if (!status.data.has_billing_info) {
|
|
1869
|
-
* console.log('No payment method configured');
|
|
1870
|
-
* }
|
|
1871
|
-
* ```
|
|
1872
|
-
*
|
|
1873
|
-
* @since 0.6.0
|
|
1874
|
-
* @group Tenant Management
|
|
1875
|
-
*/
|
|
1876
|
-
subscriptions;
|
|
1877
|
-
};
|
|
1878
|
-
|
|
1879
|
-
// src/client.ts
|
|
1880
|
-
var OmnibaseClient = class {
|
|
1881
|
-
constructor(config) {
|
|
1882
|
-
this.config = config;
|
|
1883
|
-
this.permissions = new PermissionsClient(this.config.api_url, this);
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Main payment handler for all payment-related operations
|
|
1887
|
-
*
|
|
1888
|
-
* This class serves as the central coordinator for all payment functionality,
|
|
1889
|
-
* providing access to checkout sessions, billing configuration, customer portals,
|
|
1890
|
-
* and usage tracking. It handles the low-level HTTP communication with the
|
|
1891
|
-
* payment API and delegates specific operations to specialized managers.
|
|
1892
|
-
*
|
|
1893
|
-
* The handler automatically manages authentication, request formatting, and
|
|
1894
|
-
* provides a consistent interface across all payment operations.
|
|
1895
|
-
*
|
|
1896
|
-
* @example
|
|
1897
|
-
* ```typescript
|
|
1898
|
-
* // Create a checkout session (mode auto-detected from price)
|
|
1899
|
-
* const checkout = await omnibase.payments.checkout.createSession({
|
|
1900
|
-
* price_id: 'price_123',
|
|
1901
|
-
* success_url: 'https://app.com/success',
|
|
1902
|
-
* cancel_url: 'https://app.com/cancel'
|
|
1903
|
-
* });
|
|
1904
|
-
*
|
|
1905
|
-
* // Get available products
|
|
1906
|
-
* const products = await omnibase.payments.config.getAvailableProducts();
|
|
1907
|
-
* ```
|
|
1908
|
-
*/
|
|
1909
|
-
payments = new PaymentHandler(this);
|
|
1910
|
-
/**
|
|
1911
|
-
* Main tenant management handler
|
|
1912
|
-
*
|
|
1913
|
-
* This is the primary entry point for all tenant-related operations in the
|
|
1914
|
-
* Omnibase SDK. It provides a unified interface to tenant management,
|
|
1915
|
-
* user management, and invitation functionality through dedicated manager instances.
|
|
1916
|
-
*
|
|
1917
|
-
* The handler follows the composition pattern, combining specialized managers
|
|
1918
|
-
* for different aspects of tenant functionality:
|
|
1919
|
-
* - `manage`: Core tenant operations (create, delete, switch)
|
|
1920
|
-
* - `invites`: User invitation management (create, accept)
|
|
1921
|
-
* - `user`: Tenant user operations (remove, update role)
|
|
1922
|
-
*
|
|
1923
|
-
* All operations are performed within the context of the authenticated user
|
|
1924
|
-
* and respect tenant-level permissions and row-level security policies.
|
|
1925
|
-
*
|
|
1926
|
-
* @example
|
|
1927
|
-
* ```typescript
|
|
1928
|
-
* // Create a new tenant
|
|
1929
|
-
* const tenant = await omnibase.tenants.manage.createTenant({
|
|
1930
|
-
* name: 'My Company',
|
|
1931
|
-
* billing_email: 'billing@company.com',
|
|
1932
|
-
* user_id: 'user_123'
|
|
1933
|
-
* });
|
|
1934
|
-
*
|
|
1935
|
-
* // Invite users to the tenant
|
|
1936
|
-
* const invite = await omnibase.tenants.invites.create({
|
|
1937
|
-
* email: 'colleague@company.com',
|
|
1938
|
-
* role: 'member',
|
|
1939
|
-
* invite_url: 'https://yourapp.com/accept-invite'
|
|
1940
|
-
* });
|
|
1941
|
-
*
|
|
1942
|
-
* // Switch to the new tenant
|
|
1943
|
-
* await omnibase.tenants.manage.switchActiveTenant(tenant.data.tenant.id);
|
|
1944
|
-
* ```
|
|
1945
|
-
*
|
|
1946
|
-
* @since 0.6.0
|
|
1947
|
-
* @public
|
|
1948
|
-
* @group Tenant Management
|
|
1949
|
-
*/
|
|
1950
|
-
tenants = new TenantHandler(this);
|
|
1951
|
-
/**
|
|
1952
|
-
* Client for managing permissions and relationships using Ory Keto
|
|
1953
|
-
*
|
|
1954
|
-
* This client provides access to Ory Keto's permission system, allowing you to
|
|
1955
|
-
* create, manage, and check relationships between subjects and objects. It handles
|
|
1956
|
-
* both read operations (permission checks) and write operations (relationship management).
|
|
1957
|
-
*
|
|
1958
|
-
* The client automatically configures separate endpoints for read and write operations
|
|
1959
|
-
* to optimize performance and security by following Ory Keto's recommended architecture.
|
|
1960
|
-
*
|
|
1961
|
-
* @example
|
|
1962
|
-
* ```typescript
|
|
1963
|
-
* // Check if a user can view a tenant
|
|
1964
|
-
* const canView = await omnibase.permissions.permissions.checkPermission(
|
|
1965
|
-
* undefined,
|
|
1966
|
-
* {
|
|
1967
|
-
* namespace: 'Tenant',
|
|
1968
|
-
* object: 'tenant_123',
|
|
1969
|
-
* relation: 'view',
|
|
1970
|
-
* subjectId: 'user_456'
|
|
1971
|
-
* }
|
|
1972
|
-
* );
|
|
1973
|
-
*
|
|
1974
|
-
* if (canView.data.allowed) {
|
|
1975
|
-
* console.log('User can view the tenant');
|
|
1976
|
-
* }
|
|
1977
|
-
*
|
|
1978
|
-
* // Create a relationship making a user an owner of a tenant
|
|
1979
|
-
* await omnibase.permissions.relationships.createRelationship(
|
|
1980
|
-
* undefined,
|
|
1981
|
-
* {
|
|
1982
|
-
* namespace: 'Tenant',
|
|
1983
|
-
* object: 'tenant_123',
|
|
1984
|
-
* relation: 'owners',
|
|
1985
|
-
* subjectId: 'user_456'
|
|
1986
|
-
* }
|
|
1987
|
-
* );
|
|
1988
|
-
* ```
|
|
1989
|
-
*
|
|
1990
|
-
* @since 0.6.0
|
|
1991
|
-
* @public
|
|
1992
|
-
* @group Permissions
|
|
1993
|
-
*/
|
|
1994
|
-
permissions;
|
|
1995
|
-
/**
|
|
1996
|
-
* Storage client for file upload/download operations
|
|
1997
|
-
*
|
|
1998
|
-
* @example
|
|
1999
|
-
* ```typescript
|
|
2000
|
-
* // Upload with metadata
|
|
2001
|
-
* await omnibase.storage.bucket('documents').upload(
|
|
2002
|
-
* 'report.pdf',
|
|
2003
|
-
* file,
|
|
2004
|
-
* { metadata: { department: 'engineering' } }
|
|
2005
|
-
* );
|
|
2006
|
-
* ```
|
|
2007
|
-
*/
|
|
2008
|
-
storage = new StorageClient(this);
|
|
2009
|
-
async fetch(endpoint, options = {}) {
|
|
2010
|
-
if (this.config.fetch)
|
|
2011
|
-
return this.config.fetch(this.config.api_url + endpoint, options);
|
|
2012
|
-
return fetch(this.config.api_url + endpoint, {
|
|
2013
|
-
...options,
|
|
2014
|
-
credentials: "include"
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
};
|
|
2018
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2019
|
-
0 && (module.exports = {
|
|
2020
|
-
OmnibaseClient,
|
|
2021
|
-
PermissionsClient,
|
|
2022
|
-
RolesHandler,
|
|
2023
|
-
StorageClient
|
|
2024
|
-
});
|