diff --git a/README.md b/README.md index dd983406..1155fb70 100644 --- a/README.md +++ b/README.md @@ -548,7 +548,8 @@ await descopeClient.management.tenant.update( ); // Tenant deletion cannot be undone. Use carefully. -await descopeClient.management.tenant.delete('my-custom-id'); +// Pass true to cascade value, in case you want to delete all users/keys associated only with this tenant +await descopeClient.management.tenant.delete('my-custom-id', true); // Load tenant by id const tenant = await descopeClient.management.tenant.load('my-custom-id'); diff --git a/lib/management/tenant.test.ts b/lib/management/tenant.test.ts index 30d58ebe..a84440f0 100644 --- a/lib/management/tenant.test.ts +++ b/lib/management/tenant.test.ts @@ -145,11 +145,11 @@ describe('Management Tenant', () => { }; mockHttpClient.post.mockResolvedValue(httpResponse); - const resp = await management.tenant.delete('t1'); + const resp = await management.tenant.delete('t1', true); expect(mockHttpClient.post).toHaveBeenCalledWith( apiPaths.tenant.delete, - { id: 't1' }, + { id: 't1', cascade: true }, { token: 'key' }, ); diff --git a/lib/management/tenant.ts b/lib/management/tenant.ts index fa9ef7d4..ae01c23f 100644 --- a/lib/management/tenant.ts +++ b/lib/management/tenant.ts @@ -46,9 +46,9 @@ const withTenant = (sdk: CoreSdk, managementKey?: string) => ({ { token: managementKey }, ), ), - delete: (id: string): Promise> => + delete: (id: string, cascade?: boolean): Promise> => transformResponse( - sdk.httpClient.post(apiPaths.tenant.delete, { id }, { token: managementKey }), + sdk.httpClient.post(apiPaths.tenant.delete, { id, cascade }, { token: managementKey }), ), load: (id: string): Promise> => transformResponse(