Skip to content

Commit

Permalink
Suppost cascade delete of tenants (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviadl authored Jun 9, 2024
1 parent 730ebf3 commit 3d867f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/management/tenant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
);

Expand Down
4 changes: 2 additions & 2 deletions lib/management/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const withTenant = (sdk: CoreSdk, managementKey?: string) => ({
{ token: managementKey },
),
),
delete: (id: string): Promise<SdkResponse<never>> =>
delete: (id: string, cascade?: boolean): Promise<SdkResponse<never>> =>
transformResponse(
sdk.httpClient.post(apiPaths.tenant.delete, { id }, { token: managementKey }),
sdk.httpClient.post(apiPaths.tenant.delete, { id, cascade }, { token: managementKey }),
),
load: (id: string): Promise<SdkResponse<Tenant>> =>
transformResponse<Tenant, Tenant>(
Expand Down

0 comments on commit 3d867f7

Please sign in to comment.