@abpjs/tenant-management 3.2.0 → 4.0.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/dist/hooks/useTenantManagement.d.ts +10 -8
- package/dist/index.d.ts +12 -1
- package/dist/index.js +50 -153
- package/dist/index.mjs +50 -152
- package/dist/models/index.d.ts +5 -49
- package/dist/proxy/models.d.ts +6 -2
- package/dist/services/index.d.ts +0 -1
- package/dist/services/tenant-management-state.service.d.ts +29 -22
- package/package.json +3 -3
- package/dist/__tests__/tenant-management.service.test.d.ts +0 -1
- package/dist/services/tenant-management.service.d.ts +0 -63
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TenantManagement } from '../models';
|
|
1
|
+
import type { TenantDto, TenantCreateDto, TenantUpdateDto, GetTenantsInput } from '../proxy/models';
|
|
3
2
|
/**
|
|
4
3
|
* Result from tenant management operations
|
|
5
4
|
*/
|
|
@@ -19,14 +18,15 @@ export type SortOrder = 'asc' | 'desc' | '';
|
|
|
19
18
|
export type ModalContentType = 'saveConnStr' | 'saveTenant';
|
|
20
19
|
/**
|
|
21
20
|
* Return type for useTenantManagement hook
|
|
21
|
+
* @since 4.0.0 - Uses TenantDto, TenantCreateDto, TenantUpdateDto instead of legacy types
|
|
22
22
|
*/
|
|
23
23
|
export interface UseTenantManagementReturn {
|
|
24
24
|
/** List of tenants */
|
|
25
|
-
tenants:
|
|
25
|
+
tenants: TenantDto[];
|
|
26
26
|
/** Total count of tenants */
|
|
27
27
|
totalCount: number;
|
|
28
28
|
/** Currently selected tenant */
|
|
29
|
-
selectedTenant:
|
|
29
|
+
selectedTenant: TenantDto | null;
|
|
30
30
|
/** Loading state */
|
|
31
31
|
isLoading: boolean;
|
|
32
32
|
/** Error message if any */
|
|
@@ -42,13 +42,13 @@ export interface UseTenantManagementReturn {
|
|
|
42
42
|
/** Whether the save button should be disabled @since 1.1.0 */
|
|
43
43
|
isDisabledSaveButton: boolean;
|
|
44
44
|
/** Fetch all tenants (with optional params) */
|
|
45
|
-
fetchTenants: (
|
|
45
|
+
fetchTenants: (input?: Partial<GetTenantsInput>) => Promise<TenantManagementResult>;
|
|
46
46
|
/** Fetch a tenant by ID */
|
|
47
47
|
fetchTenantById: (id: string) => Promise<TenantManagementResult>;
|
|
48
48
|
/** Create a new tenant */
|
|
49
|
-
createTenant: (data:
|
|
49
|
+
createTenant: (data: TenantCreateDto) => Promise<TenantManagementResult>;
|
|
50
50
|
/** Update an existing tenant */
|
|
51
|
-
updateTenant: (data:
|
|
51
|
+
updateTenant: (id: string, data: TenantUpdateDto) => Promise<TenantManagementResult>;
|
|
52
52
|
/** Delete a tenant */
|
|
53
53
|
deleteTenant: (id: string) => Promise<TenantManagementResult>;
|
|
54
54
|
/** Fetch connection string for a tenant */
|
|
@@ -58,7 +58,7 @@ export interface UseTenantManagementReturn {
|
|
|
58
58
|
/** Delete connection string (use shared database) */
|
|
59
59
|
deleteConnectionString: (id: string) => Promise<TenantManagementResult>;
|
|
60
60
|
/** Set selected tenant */
|
|
61
|
-
setSelectedTenant: (tenant:
|
|
61
|
+
setSelectedTenant: (tenant: TenantDto | null) => void;
|
|
62
62
|
/** Set use shared database flag */
|
|
63
63
|
setUseSharedDatabase: (value: boolean) => void;
|
|
64
64
|
/** Set default connection string */
|
|
@@ -87,6 +87,8 @@ export interface UseTenantManagementReturn {
|
|
|
87
87
|
* management modal. It handles fetching, creating, updating, and deleting tenants,
|
|
88
88
|
* as well as managing connection strings.
|
|
89
89
|
*
|
|
90
|
+
* @since 4.0.0 - Uses TenantService (proxy) instead of TenantManagementService
|
|
91
|
+
*
|
|
90
92
|
* @example
|
|
91
93
|
* ```tsx
|
|
92
94
|
* function TenantModal() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @abpjs/tenant-management
|
|
3
3
|
* ABP Framework Tenant Management module for React
|
|
4
|
-
* Translated from @abp/ng.tenant-management
|
|
4
|
+
* Translated from @abp/ng.tenant-management v4.0.0
|
|
5
|
+
*
|
|
6
|
+
* Changes in v4.0.0:
|
|
7
|
+
* - BREAKING: Removed TenantManagementService (use TenantService from proxy instead)
|
|
8
|
+
* - BREAKING: Removed deprecated types: TenantManagement.Response, Item, AddRequest, UpdateRequest, DefaultConnectionStringRequest
|
|
9
|
+
* - BREAKING: useTenantManagement hook now uses TenantService (proxy) internally
|
|
10
|
+
* - BREAKING: updateTenant signature changed from (data: {id, name}) to (id: string, data: TenantUpdateDto)
|
|
11
|
+
* - BREAKING: createTenant now takes TenantCreateDto instead of TenantManagement.AddRequest
|
|
12
|
+
* - BREAKING: fetchTenants now takes Partial<GetTenantsInput> instead of ABP.PageQueryParams
|
|
13
|
+
* - Updated TenantManagementStateService to use TenantService instead of TenantManagementService
|
|
14
|
+
* - Updated TenantManagementStateService dispatch methods to use proxy DTOs
|
|
15
|
+
* - Updated TenantsComponentInputs to use TenantDto instead of legacy Item type
|
|
5
16
|
*
|
|
6
17
|
* Changes in v3.2.0:
|
|
7
18
|
* - Added proxy submodule with typed DTOs and TenantService
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(index_exports, {
|
|
|
24
24
|
TENANT_MANAGEMENT_ROUTE_PATHS: () => TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
25
25
|
TENANT_MANAGEMENT_ROUTE_PROVIDERS: () => TENANT_MANAGEMENT_ROUTE_PROVIDERS,
|
|
26
26
|
TenantManagementModal: () => TenantManagementModal,
|
|
27
|
-
TenantManagementService: () => TenantManagementService,
|
|
28
27
|
TenantManagementStateService: () => TenantManagementStateService,
|
|
29
28
|
TenantService: () => TenantService,
|
|
30
29
|
configureRoutes: () => configureRoutes,
|
|
@@ -212,117 +211,11 @@ var TenantService = class {
|
|
|
212
211
|
}
|
|
213
212
|
};
|
|
214
213
|
|
|
215
|
-
// src/services/tenant-management.service.ts
|
|
216
|
-
var TenantManagementService = class {
|
|
217
|
-
constructor(rest) {
|
|
218
|
-
/**
|
|
219
|
-
* The API name used for REST requests.
|
|
220
|
-
* @since 2.4.0
|
|
221
|
-
*/
|
|
222
|
-
this.apiName = "default";
|
|
223
|
-
this.rest = rest;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Get all tenants (paginated)
|
|
227
|
-
* @param params Optional pagination and filter parameters
|
|
228
|
-
* @returns Promise with paginated tenant response
|
|
229
|
-
*/
|
|
230
|
-
getAll(params = {}) {
|
|
231
|
-
return this.rest.request({
|
|
232
|
-
method: "GET",
|
|
233
|
-
url: "/api/multi-tenancy/tenants",
|
|
234
|
-
params
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Get a tenant by ID
|
|
239
|
-
* @param id Tenant ID
|
|
240
|
-
* @returns Promise with tenant item
|
|
241
|
-
*/
|
|
242
|
-
getById(id) {
|
|
243
|
-
return this.rest.request({
|
|
244
|
-
method: "GET",
|
|
245
|
-
url: `/api/multi-tenancy/tenants/${id}`
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Create a new tenant
|
|
250
|
-
* @param body Tenant creation request
|
|
251
|
-
* @returns Promise with created tenant item
|
|
252
|
-
*/
|
|
253
|
-
create(body) {
|
|
254
|
-
return this.rest.request({
|
|
255
|
-
method: "POST",
|
|
256
|
-
url: "/api/multi-tenancy/tenants",
|
|
257
|
-
body
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Update an existing tenant
|
|
262
|
-
* @param body Tenant update request (includes id)
|
|
263
|
-
* @returns Promise with updated tenant item
|
|
264
|
-
*/
|
|
265
|
-
update(body) {
|
|
266
|
-
const { id, ...data } = body;
|
|
267
|
-
return this.rest.request({
|
|
268
|
-
method: "PUT",
|
|
269
|
-
url: `/api/multi-tenancy/tenants/${id}`,
|
|
270
|
-
body: data
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Delete a tenant
|
|
275
|
-
* @param id Tenant ID
|
|
276
|
-
* @returns Promise that resolves when deletion completes
|
|
277
|
-
*/
|
|
278
|
-
delete(id) {
|
|
279
|
-
return this.rest.request({
|
|
280
|
-
method: "DELETE",
|
|
281
|
-
url: `/api/multi-tenancy/tenants/${id}`
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Get default connection string for a tenant
|
|
286
|
-
* @param id Tenant ID
|
|
287
|
-
* @returns Promise with connection string (empty string if using shared database)
|
|
288
|
-
*/
|
|
289
|
-
getDefaultConnectionString(id) {
|
|
290
|
-
return this.rest.request({
|
|
291
|
-
method: "GET",
|
|
292
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Update default connection string for a tenant
|
|
297
|
-
* @param payload Request with tenant ID and connection string
|
|
298
|
-
* @returns Promise that resolves when update completes
|
|
299
|
-
*/
|
|
300
|
-
updateDefaultConnectionString(payload) {
|
|
301
|
-
const { id, defaultConnectionString } = payload;
|
|
302
|
-
return this.rest.request({
|
|
303
|
-
method: "PUT",
|
|
304
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`,
|
|
305
|
-
params: { defaultConnectionString }
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Delete default connection string for a tenant (use shared database)
|
|
310
|
-
* @param id Tenant ID
|
|
311
|
-
* @returns Promise that resolves when deletion completes
|
|
312
|
-
*/
|
|
313
|
-
deleteDefaultConnectionString(id) {
|
|
314
|
-
return this.rest.request({
|
|
315
|
-
method: "DELETE",
|
|
316
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
214
|
// src/services/tenant-management-state.service.ts
|
|
322
215
|
var TenantManagementStateService = class {
|
|
323
216
|
/**
|
|
324
217
|
* Constructor
|
|
325
|
-
* @param tenantService Optional
|
|
218
|
+
* @param tenantService Optional TenantService for dispatch methods (v4.0.0: uses TenantService instead of TenantManagementService)
|
|
326
219
|
*/
|
|
327
220
|
constructor(tenantService) {
|
|
328
221
|
this._tenants = [];
|
|
@@ -360,15 +253,6 @@ var TenantManagementStateService = class {
|
|
|
360
253
|
this._totalCount = count;
|
|
361
254
|
this.notifySubscribers();
|
|
362
255
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Update state from a response
|
|
365
|
-
* @internal
|
|
366
|
-
*/
|
|
367
|
-
updateFromResponse(response) {
|
|
368
|
-
this._tenants = [...response.items];
|
|
369
|
-
this._totalCount = response.totalCount;
|
|
370
|
-
this.notifySubscribers();
|
|
371
|
-
}
|
|
372
256
|
/**
|
|
373
257
|
* Reset the state to initial values
|
|
374
258
|
*/
|
|
@@ -392,67 +276,79 @@ var TenantManagementStateService = class {
|
|
|
392
276
|
this._subscribers.forEach((callback) => callback());
|
|
393
277
|
}
|
|
394
278
|
// ========================
|
|
395
|
-
// Dispatch Methods (v2.0.0)
|
|
279
|
+
// Dispatch Methods (v2.0.0, updated v4.0.0)
|
|
396
280
|
// ========================
|
|
397
281
|
/**
|
|
398
282
|
* Dispatch GetTenants action - fetches tenants from API and updates state
|
|
399
|
-
* @param
|
|
400
|
-
* @returns Promise with the tenant
|
|
283
|
+
* @param input Query parameters for tenant list
|
|
284
|
+
* @returns Promise with the paged tenant result
|
|
401
285
|
* @since 2.0.0
|
|
286
|
+
* @since 4.0.0 - Uses TenantService.getList with GetTenantsInput
|
|
402
287
|
*/
|
|
403
|
-
async dispatchGetTenants(
|
|
288
|
+
async dispatchGetTenants(input) {
|
|
404
289
|
if (!this._tenantService) {
|
|
405
290
|
throw new Error(
|
|
406
|
-
"
|
|
291
|
+
"TenantService is required for dispatchGetTenants. Pass it to the constructor."
|
|
407
292
|
);
|
|
408
293
|
}
|
|
409
|
-
const response = await this._tenantService.
|
|
410
|
-
|
|
294
|
+
const response = await this._tenantService.getList({
|
|
295
|
+
filter: "",
|
|
296
|
+
maxResultCount: 10,
|
|
297
|
+
skipCount: 0,
|
|
298
|
+
...input
|
|
299
|
+
});
|
|
300
|
+
this._tenants = [...response.items ?? []];
|
|
301
|
+
this._totalCount = response.totalCount ?? 0;
|
|
302
|
+
this.notifySubscribers();
|
|
411
303
|
return response;
|
|
412
304
|
}
|
|
413
305
|
/**
|
|
414
306
|
* Dispatch GetTenantById action - fetches a single tenant by ID
|
|
415
307
|
* @param id Tenant ID
|
|
416
|
-
* @returns Promise with the tenant
|
|
308
|
+
* @returns Promise with the tenant DTO
|
|
417
309
|
* @since 2.0.0
|
|
310
|
+
* @since 4.0.0 - Returns TenantDto instead of TenantManagement.Item
|
|
418
311
|
*/
|
|
419
312
|
async dispatchGetTenantById(id) {
|
|
420
313
|
if (!this._tenantService) {
|
|
421
314
|
throw new Error(
|
|
422
|
-
"
|
|
315
|
+
"TenantService is required for dispatchGetTenantById. Pass it to the constructor."
|
|
423
316
|
);
|
|
424
317
|
}
|
|
425
|
-
return this._tenantService.
|
|
318
|
+
return this._tenantService.get(id);
|
|
426
319
|
}
|
|
427
320
|
/**
|
|
428
321
|
* Dispatch CreateTenant action - creates a new tenant and refreshes the list
|
|
429
|
-
* @param
|
|
322
|
+
* @param input Tenant creation data
|
|
430
323
|
* @returns Promise with the created tenant
|
|
431
324
|
* @since 2.0.0
|
|
325
|
+
* @since 4.0.0 - Uses TenantCreateDto instead of TenantManagement.AddRequest
|
|
432
326
|
*/
|
|
433
|
-
async dispatchCreateTenant(
|
|
327
|
+
async dispatchCreateTenant(input) {
|
|
434
328
|
if (!this._tenantService) {
|
|
435
329
|
throw new Error(
|
|
436
|
-
"
|
|
330
|
+
"TenantService is required for dispatchCreateTenant. Pass it to the constructor."
|
|
437
331
|
);
|
|
438
332
|
}
|
|
439
|
-
const result = await this._tenantService.create(
|
|
333
|
+
const result = await this._tenantService.create(input);
|
|
440
334
|
await this.dispatchGetTenants();
|
|
441
335
|
return result;
|
|
442
336
|
}
|
|
443
337
|
/**
|
|
444
338
|
* Dispatch UpdateTenant action - updates an existing tenant and refreshes the list
|
|
445
|
-
* @param
|
|
339
|
+
* @param id Tenant ID
|
|
340
|
+
* @param input Tenant update data
|
|
446
341
|
* @returns Promise with the updated tenant
|
|
447
342
|
* @since 2.0.0
|
|
343
|
+
* @since 4.0.0 - Uses TenantUpdateDto instead of TenantManagement.UpdateRequest, takes id separately
|
|
448
344
|
*/
|
|
449
|
-
async dispatchUpdateTenant(
|
|
345
|
+
async dispatchUpdateTenant(id, input) {
|
|
450
346
|
if (!this._tenantService) {
|
|
451
347
|
throw new Error(
|
|
452
|
-
"
|
|
348
|
+
"TenantService is required for dispatchUpdateTenant. Pass it to the constructor."
|
|
453
349
|
);
|
|
454
350
|
}
|
|
455
|
-
const result = await this._tenantService.update(
|
|
351
|
+
const result = await this._tenantService.update(id, input);
|
|
456
352
|
await this.dispatchGetTenants();
|
|
457
353
|
return result;
|
|
458
354
|
}
|
|
@@ -465,7 +361,7 @@ var TenantManagementStateService = class {
|
|
|
465
361
|
async dispatchDeleteTenant(id) {
|
|
466
362
|
if (!this._tenantService) {
|
|
467
363
|
throw new Error(
|
|
468
|
-
"
|
|
364
|
+
"TenantService is required for dispatchDeleteTenant. Pass it to the constructor."
|
|
469
365
|
);
|
|
470
366
|
}
|
|
471
367
|
await this._tenantService.delete(id);
|
|
@@ -485,7 +381,7 @@ var import_react = require("react");
|
|
|
485
381
|
var import_core2 = require("@abpjs/core");
|
|
486
382
|
function useTenantManagement() {
|
|
487
383
|
const restService = (0, import_core2.useRestService)();
|
|
488
|
-
const service = (0, import_react.useMemo)(() => new
|
|
384
|
+
const service = (0, import_react.useMemo)(() => new TenantService(restService), [restService]);
|
|
489
385
|
const [tenants, setTenants] = (0, import_react.useState)([]);
|
|
490
386
|
const [totalCount, setTotalCount] = (0, import_react.useState)(0);
|
|
491
387
|
const [selectedTenant, setSelectedTenant] = (0, import_react.useState)(null);
|
|
@@ -497,13 +393,18 @@ function useTenantManagement() {
|
|
|
497
393
|
const [sortOrder, setSortOrder] = (0, import_react.useState)("");
|
|
498
394
|
const [visibleFeatures, setVisibleFeatures] = (0, import_react.useState)(false);
|
|
499
395
|
const [featuresProviderKey, setFeaturesProviderKey] = (0, import_react.useState)("");
|
|
500
|
-
const fetchTenants = (0, import_react.useCallback)(async (
|
|
396
|
+
const fetchTenants = (0, import_react.useCallback)(async (input) => {
|
|
501
397
|
setIsLoading(true);
|
|
502
398
|
setError(null);
|
|
503
399
|
try {
|
|
504
|
-
const response = await service.
|
|
505
|
-
|
|
506
|
-
|
|
400
|
+
const response = await service.getList({
|
|
401
|
+
filter: "",
|
|
402
|
+
maxResultCount: 10,
|
|
403
|
+
skipCount: 0,
|
|
404
|
+
...input
|
|
405
|
+
});
|
|
406
|
+
setTenants(response.items ?? []);
|
|
407
|
+
setTotalCount(response.totalCount ?? 0);
|
|
507
408
|
setIsLoading(false);
|
|
508
409
|
return { success: true };
|
|
509
410
|
} catch (err) {
|
|
@@ -518,7 +419,7 @@ function useTenantManagement() {
|
|
|
518
419
|
setIsLoading(true);
|
|
519
420
|
setError(null);
|
|
520
421
|
try {
|
|
521
|
-
const tenant = await service.
|
|
422
|
+
const tenant = await service.get(id);
|
|
522
423
|
setSelectedTenant(tenant);
|
|
523
424
|
setIsLoading(false);
|
|
524
425
|
return { success: true };
|
|
@@ -537,7 +438,7 @@ function useTenantManagement() {
|
|
|
537
438
|
setError(null);
|
|
538
439
|
try {
|
|
539
440
|
await service.create(data);
|
|
540
|
-
await service.
|
|
441
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
541
442
|
setIsLoading(false);
|
|
542
443
|
return { success: true };
|
|
543
444
|
} catch (err) {
|
|
@@ -550,12 +451,12 @@ function useTenantManagement() {
|
|
|
550
451
|
[service]
|
|
551
452
|
);
|
|
552
453
|
const updateTenant = (0, import_react.useCallback)(
|
|
553
|
-
async (data) => {
|
|
454
|
+
async (id, data) => {
|
|
554
455
|
setIsLoading(true);
|
|
555
456
|
setError(null);
|
|
556
457
|
try {
|
|
557
|
-
await service.update(data);
|
|
558
|
-
await service.
|
|
458
|
+
await service.update(id, data);
|
|
459
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
559
460
|
setIsLoading(false);
|
|
560
461
|
return { success: true };
|
|
561
462
|
} catch (err) {
|
|
@@ -573,7 +474,7 @@ function useTenantManagement() {
|
|
|
573
474
|
setError(null);
|
|
574
475
|
try {
|
|
575
476
|
await service.delete(id);
|
|
576
|
-
await service.
|
|
477
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
577
478
|
setIsLoading(false);
|
|
578
479
|
return { success: true };
|
|
579
480
|
} catch (err) {
|
|
@@ -609,10 +510,7 @@ function useTenantManagement() {
|
|
|
609
510
|
setIsLoading(true);
|
|
610
511
|
setError(null);
|
|
611
512
|
try {
|
|
612
|
-
await service.updateDefaultConnectionString(
|
|
613
|
-
id,
|
|
614
|
-
defaultConnectionString: connectionString
|
|
615
|
-
});
|
|
513
|
+
await service.updateDefaultConnectionString(id, connectionString);
|
|
616
514
|
setDefaultConnectionString(connectionString);
|
|
617
515
|
setUseSharedDatabase(false);
|
|
618
516
|
setIsLoading(false);
|
|
@@ -866,7 +764,7 @@ function TenantManagementModal({
|
|
|
866
764
|
}
|
|
867
765
|
let result;
|
|
868
766
|
if (isEditing && tenantId) {
|
|
869
|
-
result = await updateTenant(
|
|
767
|
+
result = await updateTenant(tenantId, { name: tenantName.trim() });
|
|
870
768
|
} else {
|
|
871
769
|
const emailValid = validateAdminEmail(adminEmail);
|
|
872
770
|
const passwordValid = validateAdminPassword(adminPassword);
|
|
@@ -1091,7 +989,6 @@ TenantManagementModal.componentKey = eTenantManagementComponents.Tenants;
|
|
|
1091
989
|
TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
1092
990
|
TENANT_MANAGEMENT_ROUTE_PROVIDERS,
|
|
1093
991
|
TenantManagementModal,
|
|
1094
|
-
TenantManagementService,
|
|
1095
992
|
TenantManagementStateService,
|
|
1096
993
|
TenantService,
|
|
1097
994
|
configureRoutes,
|
package/dist/index.mjs
CHANGED
|
@@ -173,117 +173,11 @@ var TenantService = class {
|
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
// src/services/tenant-management.service.ts
|
|
177
|
-
var TenantManagementService = class {
|
|
178
|
-
constructor(rest) {
|
|
179
|
-
/**
|
|
180
|
-
* The API name used for REST requests.
|
|
181
|
-
* @since 2.4.0
|
|
182
|
-
*/
|
|
183
|
-
this.apiName = "default";
|
|
184
|
-
this.rest = rest;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Get all tenants (paginated)
|
|
188
|
-
* @param params Optional pagination and filter parameters
|
|
189
|
-
* @returns Promise with paginated tenant response
|
|
190
|
-
*/
|
|
191
|
-
getAll(params = {}) {
|
|
192
|
-
return this.rest.request({
|
|
193
|
-
method: "GET",
|
|
194
|
-
url: "/api/multi-tenancy/tenants",
|
|
195
|
-
params
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get a tenant by ID
|
|
200
|
-
* @param id Tenant ID
|
|
201
|
-
* @returns Promise with tenant item
|
|
202
|
-
*/
|
|
203
|
-
getById(id) {
|
|
204
|
-
return this.rest.request({
|
|
205
|
-
method: "GET",
|
|
206
|
-
url: `/api/multi-tenancy/tenants/${id}`
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Create a new tenant
|
|
211
|
-
* @param body Tenant creation request
|
|
212
|
-
* @returns Promise with created tenant item
|
|
213
|
-
*/
|
|
214
|
-
create(body) {
|
|
215
|
-
return this.rest.request({
|
|
216
|
-
method: "POST",
|
|
217
|
-
url: "/api/multi-tenancy/tenants",
|
|
218
|
-
body
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Update an existing tenant
|
|
223
|
-
* @param body Tenant update request (includes id)
|
|
224
|
-
* @returns Promise with updated tenant item
|
|
225
|
-
*/
|
|
226
|
-
update(body) {
|
|
227
|
-
const { id, ...data } = body;
|
|
228
|
-
return this.rest.request({
|
|
229
|
-
method: "PUT",
|
|
230
|
-
url: `/api/multi-tenancy/tenants/${id}`,
|
|
231
|
-
body: data
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Delete a tenant
|
|
236
|
-
* @param id Tenant ID
|
|
237
|
-
* @returns Promise that resolves when deletion completes
|
|
238
|
-
*/
|
|
239
|
-
delete(id) {
|
|
240
|
-
return this.rest.request({
|
|
241
|
-
method: "DELETE",
|
|
242
|
-
url: `/api/multi-tenancy/tenants/${id}`
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get default connection string for a tenant
|
|
247
|
-
* @param id Tenant ID
|
|
248
|
-
* @returns Promise with connection string (empty string if using shared database)
|
|
249
|
-
*/
|
|
250
|
-
getDefaultConnectionString(id) {
|
|
251
|
-
return this.rest.request({
|
|
252
|
-
method: "GET",
|
|
253
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Update default connection string for a tenant
|
|
258
|
-
* @param payload Request with tenant ID and connection string
|
|
259
|
-
* @returns Promise that resolves when update completes
|
|
260
|
-
*/
|
|
261
|
-
updateDefaultConnectionString(payload) {
|
|
262
|
-
const { id, defaultConnectionString } = payload;
|
|
263
|
-
return this.rest.request({
|
|
264
|
-
method: "PUT",
|
|
265
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`,
|
|
266
|
-
params: { defaultConnectionString }
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Delete default connection string for a tenant (use shared database)
|
|
271
|
-
* @param id Tenant ID
|
|
272
|
-
* @returns Promise that resolves when deletion completes
|
|
273
|
-
*/
|
|
274
|
-
deleteDefaultConnectionString(id) {
|
|
275
|
-
return this.rest.request({
|
|
276
|
-
method: "DELETE",
|
|
277
|
-
url: `/api/multi-tenancy/tenants/${id}/default-connection-string`
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
|
|
282
176
|
// src/services/tenant-management-state.service.ts
|
|
283
177
|
var TenantManagementStateService = class {
|
|
284
178
|
/**
|
|
285
179
|
* Constructor
|
|
286
|
-
* @param tenantService Optional
|
|
180
|
+
* @param tenantService Optional TenantService for dispatch methods (v4.0.0: uses TenantService instead of TenantManagementService)
|
|
287
181
|
*/
|
|
288
182
|
constructor(tenantService) {
|
|
289
183
|
this._tenants = [];
|
|
@@ -321,15 +215,6 @@ var TenantManagementStateService = class {
|
|
|
321
215
|
this._totalCount = count;
|
|
322
216
|
this.notifySubscribers();
|
|
323
217
|
}
|
|
324
|
-
/**
|
|
325
|
-
* Update state from a response
|
|
326
|
-
* @internal
|
|
327
|
-
*/
|
|
328
|
-
updateFromResponse(response) {
|
|
329
|
-
this._tenants = [...response.items];
|
|
330
|
-
this._totalCount = response.totalCount;
|
|
331
|
-
this.notifySubscribers();
|
|
332
|
-
}
|
|
333
218
|
/**
|
|
334
219
|
* Reset the state to initial values
|
|
335
220
|
*/
|
|
@@ -353,67 +238,79 @@ var TenantManagementStateService = class {
|
|
|
353
238
|
this._subscribers.forEach((callback) => callback());
|
|
354
239
|
}
|
|
355
240
|
// ========================
|
|
356
|
-
// Dispatch Methods (v2.0.0)
|
|
241
|
+
// Dispatch Methods (v2.0.0, updated v4.0.0)
|
|
357
242
|
// ========================
|
|
358
243
|
/**
|
|
359
244
|
* Dispatch GetTenants action - fetches tenants from API and updates state
|
|
360
|
-
* @param
|
|
361
|
-
* @returns Promise with the tenant
|
|
245
|
+
* @param input Query parameters for tenant list
|
|
246
|
+
* @returns Promise with the paged tenant result
|
|
362
247
|
* @since 2.0.0
|
|
248
|
+
* @since 4.0.0 - Uses TenantService.getList with GetTenantsInput
|
|
363
249
|
*/
|
|
364
|
-
async dispatchGetTenants(
|
|
250
|
+
async dispatchGetTenants(input) {
|
|
365
251
|
if (!this._tenantService) {
|
|
366
252
|
throw new Error(
|
|
367
|
-
"
|
|
253
|
+
"TenantService is required for dispatchGetTenants. Pass it to the constructor."
|
|
368
254
|
);
|
|
369
255
|
}
|
|
370
|
-
const response = await this._tenantService.
|
|
371
|
-
|
|
256
|
+
const response = await this._tenantService.getList({
|
|
257
|
+
filter: "",
|
|
258
|
+
maxResultCount: 10,
|
|
259
|
+
skipCount: 0,
|
|
260
|
+
...input
|
|
261
|
+
});
|
|
262
|
+
this._tenants = [...response.items ?? []];
|
|
263
|
+
this._totalCount = response.totalCount ?? 0;
|
|
264
|
+
this.notifySubscribers();
|
|
372
265
|
return response;
|
|
373
266
|
}
|
|
374
267
|
/**
|
|
375
268
|
* Dispatch GetTenantById action - fetches a single tenant by ID
|
|
376
269
|
* @param id Tenant ID
|
|
377
|
-
* @returns Promise with the tenant
|
|
270
|
+
* @returns Promise with the tenant DTO
|
|
378
271
|
* @since 2.0.0
|
|
272
|
+
* @since 4.0.0 - Returns TenantDto instead of TenantManagement.Item
|
|
379
273
|
*/
|
|
380
274
|
async dispatchGetTenantById(id) {
|
|
381
275
|
if (!this._tenantService) {
|
|
382
276
|
throw new Error(
|
|
383
|
-
"
|
|
277
|
+
"TenantService is required for dispatchGetTenantById. Pass it to the constructor."
|
|
384
278
|
);
|
|
385
279
|
}
|
|
386
|
-
return this._tenantService.
|
|
280
|
+
return this._tenantService.get(id);
|
|
387
281
|
}
|
|
388
282
|
/**
|
|
389
283
|
* Dispatch CreateTenant action - creates a new tenant and refreshes the list
|
|
390
|
-
* @param
|
|
284
|
+
* @param input Tenant creation data
|
|
391
285
|
* @returns Promise with the created tenant
|
|
392
286
|
* @since 2.0.0
|
|
287
|
+
* @since 4.0.0 - Uses TenantCreateDto instead of TenantManagement.AddRequest
|
|
393
288
|
*/
|
|
394
|
-
async dispatchCreateTenant(
|
|
289
|
+
async dispatchCreateTenant(input) {
|
|
395
290
|
if (!this._tenantService) {
|
|
396
291
|
throw new Error(
|
|
397
|
-
"
|
|
292
|
+
"TenantService is required for dispatchCreateTenant. Pass it to the constructor."
|
|
398
293
|
);
|
|
399
294
|
}
|
|
400
|
-
const result = await this._tenantService.create(
|
|
295
|
+
const result = await this._tenantService.create(input);
|
|
401
296
|
await this.dispatchGetTenants();
|
|
402
297
|
return result;
|
|
403
298
|
}
|
|
404
299
|
/**
|
|
405
300
|
* Dispatch UpdateTenant action - updates an existing tenant and refreshes the list
|
|
406
|
-
* @param
|
|
301
|
+
* @param id Tenant ID
|
|
302
|
+
* @param input Tenant update data
|
|
407
303
|
* @returns Promise with the updated tenant
|
|
408
304
|
* @since 2.0.0
|
|
305
|
+
* @since 4.0.0 - Uses TenantUpdateDto instead of TenantManagement.UpdateRequest, takes id separately
|
|
409
306
|
*/
|
|
410
|
-
async dispatchUpdateTenant(
|
|
307
|
+
async dispatchUpdateTenant(id, input) {
|
|
411
308
|
if (!this._tenantService) {
|
|
412
309
|
throw new Error(
|
|
413
|
-
"
|
|
310
|
+
"TenantService is required for dispatchUpdateTenant. Pass it to the constructor."
|
|
414
311
|
);
|
|
415
312
|
}
|
|
416
|
-
const result = await this._tenantService.update(
|
|
313
|
+
const result = await this._tenantService.update(id, input);
|
|
417
314
|
await this.dispatchGetTenants();
|
|
418
315
|
return result;
|
|
419
316
|
}
|
|
@@ -426,7 +323,7 @@ var TenantManagementStateService = class {
|
|
|
426
323
|
async dispatchDeleteTenant(id) {
|
|
427
324
|
if (!this._tenantService) {
|
|
428
325
|
throw new Error(
|
|
429
|
-
"
|
|
326
|
+
"TenantService is required for dispatchDeleteTenant. Pass it to the constructor."
|
|
430
327
|
);
|
|
431
328
|
}
|
|
432
329
|
await this._tenantService.delete(id);
|
|
@@ -446,7 +343,7 @@ import { useState, useCallback, useMemo } from "react";
|
|
|
446
343
|
import { useRestService } from "@abpjs/core";
|
|
447
344
|
function useTenantManagement() {
|
|
448
345
|
const restService = useRestService();
|
|
449
|
-
const service = useMemo(() => new
|
|
346
|
+
const service = useMemo(() => new TenantService(restService), [restService]);
|
|
450
347
|
const [tenants, setTenants] = useState([]);
|
|
451
348
|
const [totalCount, setTotalCount] = useState(0);
|
|
452
349
|
const [selectedTenant, setSelectedTenant] = useState(null);
|
|
@@ -458,13 +355,18 @@ function useTenantManagement() {
|
|
|
458
355
|
const [sortOrder, setSortOrder] = useState("");
|
|
459
356
|
const [visibleFeatures, setVisibleFeatures] = useState(false);
|
|
460
357
|
const [featuresProviderKey, setFeaturesProviderKey] = useState("");
|
|
461
|
-
const fetchTenants = useCallback(async (
|
|
358
|
+
const fetchTenants = useCallback(async (input) => {
|
|
462
359
|
setIsLoading(true);
|
|
463
360
|
setError(null);
|
|
464
361
|
try {
|
|
465
|
-
const response = await service.
|
|
466
|
-
|
|
467
|
-
|
|
362
|
+
const response = await service.getList({
|
|
363
|
+
filter: "",
|
|
364
|
+
maxResultCount: 10,
|
|
365
|
+
skipCount: 0,
|
|
366
|
+
...input
|
|
367
|
+
});
|
|
368
|
+
setTenants(response.items ?? []);
|
|
369
|
+
setTotalCount(response.totalCount ?? 0);
|
|
468
370
|
setIsLoading(false);
|
|
469
371
|
return { success: true };
|
|
470
372
|
} catch (err) {
|
|
@@ -479,7 +381,7 @@ function useTenantManagement() {
|
|
|
479
381
|
setIsLoading(true);
|
|
480
382
|
setError(null);
|
|
481
383
|
try {
|
|
482
|
-
const tenant = await service.
|
|
384
|
+
const tenant = await service.get(id);
|
|
483
385
|
setSelectedTenant(tenant);
|
|
484
386
|
setIsLoading(false);
|
|
485
387
|
return { success: true };
|
|
@@ -498,7 +400,7 @@ function useTenantManagement() {
|
|
|
498
400
|
setError(null);
|
|
499
401
|
try {
|
|
500
402
|
await service.create(data);
|
|
501
|
-
await service.
|
|
403
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
502
404
|
setIsLoading(false);
|
|
503
405
|
return { success: true };
|
|
504
406
|
} catch (err) {
|
|
@@ -511,12 +413,12 @@ function useTenantManagement() {
|
|
|
511
413
|
[service]
|
|
512
414
|
);
|
|
513
415
|
const updateTenant = useCallback(
|
|
514
|
-
async (data) => {
|
|
416
|
+
async (id, data) => {
|
|
515
417
|
setIsLoading(true);
|
|
516
418
|
setError(null);
|
|
517
419
|
try {
|
|
518
|
-
await service.update(data);
|
|
519
|
-
await service.
|
|
420
|
+
await service.update(id, data);
|
|
421
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
520
422
|
setIsLoading(false);
|
|
521
423
|
return { success: true };
|
|
522
424
|
} catch (err) {
|
|
@@ -534,7 +436,7 @@ function useTenantManagement() {
|
|
|
534
436
|
setError(null);
|
|
535
437
|
try {
|
|
536
438
|
await service.delete(id);
|
|
537
|
-
await service.
|
|
439
|
+
await service.getList({ filter: "", maxResultCount: 10, skipCount: 0 }).then((response) => setTenants(response.items ?? []));
|
|
538
440
|
setIsLoading(false);
|
|
539
441
|
return { success: true };
|
|
540
442
|
} catch (err) {
|
|
@@ -570,10 +472,7 @@ function useTenantManagement() {
|
|
|
570
472
|
setIsLoading(true);
|
|
571
473
|
setError(null);
|
|
572
474
|
try {
|
|
573
|
-
await service.updateDefaultConnectionString(
|
|
574
|
-
id,
|
|
575
|
-
defaultConnectionString: connectionString
|
|
576
|
-
});
|
|
475
|
+
await service.updateDefaultConnectionString(id, connectionString);
|
|
577
476
|
setDefaultConnectionString(connectionString);
|
|
578
477
|
setUseSharedDatabase(false);
|
|
579
478
|
setIsLoading(false);
|
|
@@ -833,7 +732,7 @@ function TenantManagementModal({
|
|
|
833
732
|
}
|
|
834
733
|
let result;
|
|
835
734
|
if (isEditing && tenantId) {
|
|
836
|
-
result = await updateTenant(
|
|
735
|
+
result = await updateTenant(tenantId, { name: tenantName.trim() });
|
|
837
736
|
} else {
|
|
838
737
|
const emailValid = validateAdminEmail(adminEmail);
|
|
839
738
|
const passwordValid = validateAdminPassword(adminPassword);
|
|
@@ -1057,7 +956,6 @@ export {
|
|
|
1057
956
|
TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
1058
957
|
TENANT_MANAGEMENT_ROUTE_PROVIDERS,
|
|
1059
958
|
TenantManagementModal,
|
|
1060
|
-
TenantManagementService,
|
|
1061
959
|
TenantManagementStateService,
|
|
1062
960
|
TenantService,
|
|
1063
961
|
configureRoutes,
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tenant Management module type definitions
|
|
3
|
-
* Translated from @abp/ng.tenant-management
|
|
3
|
+
* Translated from @abp/ng.tenant-management v4.0.0
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { PagedResultDto } from '@abpjs/core';
|
|
6
6
|
import type { TenantDto } from '../proxy/models';
|
|
7
7
|
/**
|
|
8
8
|
* TenantManagement namespace containing all tenant-related types
|
|
@@ -16,60 +16,16 @@ export declare namespace TenantManagement {
|
|
|
16
16
|
result: PagedResultDto<TenantDto>;
|
|
17
17
|
selectedItem: TenantDto;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* API response for tenant list (paginated)
|
|
21
|
-
* @deprecated To be deleted in v4.0. Use PagedResultDto<TenantDto> from @abpjs/core instead.
|
|
22
|
-
*/
|
|
23
|
-
type Response = ABP.PagedResponse<Item>;
|
|
24
|
-
/**
|
|
25
|
-
* Single tenant item
|
|
26
|
-
* @deprecated To be deleted in v4.0. Use TenantDto from '@abpjs/tenant-management/proxy' instead.
|
|
27
|
-
*/
|
|
28
|
-
interface Item {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Request payload for creating a new tenant
|
|
34
|
-
* @since 2.4.0 Added adminEmailAddress and adminPassword fields
|
|
35
|
-
* @deprecated To be deleted in v4.0. Use TenantCreateDto from '@abpjs/tenant-management/proxy' instead.
|
|
36
|
-
*/
|
|
37
|
-
interface AddRequest {
|
|
38
|
-
/** Admin email address for the new tenant */
|
|
39
|
-
adminEmailAddress: string;
|
|
40
|
-
/** Admin password for the new tenant */
|
|
41
|
-
adminPassword: string;
|
|
42
|
-
/** Tenant name */
|
|
43
|
-
name: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Request payload for updating an existing tenant
|
|
47
|
-
* @since 2.4.0 No longer extends AddRequest (only id and name needed for update)
|
|
48
|
-
* @deprecated To be deleted in v4.0. Use TenantUpdateDto from '@abpjs/tenant-management/proxy' instead.
|
|
49
|
-
*/
|
|
50
|
-
interface UpdateRequest {
|
|
51
|
-
/** Tenant ID */
|
|
52
|
-
id: string;
|
|
53
|
-
/** Tenant name */
|
|
54
|
-
name: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Request payload for updating tenant's default connection string
|
|
58
|
-
* @deprecated To be deleted in v4.0. Use TenantService.updateDefaultConnectionString instead.
|
|
59
|
-
*/
|
|
60
|
-
interface DefaultConnectionStringRequest {
|
|
61
|
-
id: string;
|
|
62
|
-
defaultConnectionString: string;
|
|
63
|
-
}
|
|
64
19
|
/**
|
|
65
20
|
* Input props for TenantsComponent
|
|
66
21
|
* @since 2.0.0
|
|
22
|
+
* @since 4.0.0 - Uses TenantDto instead of legacy Item type
|
|
67
23
|
*/
|
|
68
24
|
interface TenantsComponentInputs {
|
|
69
25
|
/** Callback when tenant is created */
|
|
70
|
-
readonly onTenantCreated?: (tenant:
|
|
26
|
+
readonly onTenantCreated?: (tenant: TenantDto) => void;
|
|
71
27
|
/** Callback when tenant is updated */
|
|
72
|
-
readonly onTenantUpdated?: (tenant:
|
|
28
|
+
readonly onTenantUpdated?: (tenant: TenantDto) => void;
|
|
73
29
|
/** Callback when tenant is deleted */
|
|
74
30
|
readonly onTenantDeleted?: (id: string) => void;
|
|
75
31
|
}
|
package/dist/proxy/models.d.ts
CHANGED
|
@@ -20,9 +20,11 @@ export interface GetTenantsInput extends PagedAndSortedResultRequestDto {
|
|
|
20
20
|
* Extends ExtensibleObject for extra properties support.
|
|
21
21
|
* @since 3.2.0
|
|
22
22
|
*/
|
|
23
|
-
export interface TenantCreateOrUpdateDtoBase extends ExtensibleObject {
|
|
23
|
+
export interface TenantCreateOrUpdateDtoBase extends Omit<ExtensibleObject, 'extraProperties'> {
|
|
24
24
|
/** The name of the tenant */
|
|
25
25
|
name: string;
|
|
26
|
+
/** Extra properties (optional, defaults to empty object) */
|
|
27
|
+
extraProperties?: Record<string, any>;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* DTO for creating a new tenant.
|
|
@@ -47,7 +49,9 @@ export interface TenantUpdateDto extends TenantCreateOrUpdateDtoBase {
|
|
|
47
49
|
* Extends ExtensibleEntityDto with string ID.
|
|
48
50
|
* @since 3.2.0
|
|
49
51
|
*/
|
|
50
|
-
export interface TenantDto extends ExtensibleEntityDto<string> {
|
|
52
|
+
export interface TenantDto extends Omit<ExtensibleEntityDto<string>, 'extraProperties'> {
|
|
51
53
|
/** The name of the tenant */
|
|
52
54
|
name: string;
|
|
55
|
+
/** Extra properties (optional, defaults to empty object) */
|
|
56
|
+
extraProperties?: Record<string, any>;
|
|
53
57
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tenant Management State Service
|
|
3
|
-
* Translated from @abp/ng.tenant-management
|
|
3
|
+
* Translated from @abp/ng.tenant-management v4.0.0
|
|
4
4
|
*
|
|
5
5
|
* This service provides state management for tenant management,
|
|
6
6
|
* equivalent to the Angular NGXS TenantManagementState selectors.
|
|
7
7
|
*
|
|
8
|
+
* Changes in v4.0.0:
|
|
9
|
+
* - Now uses TenantService (proxy) instead of TenantManagementService
|
|
10
|
+
* - Uses TenantDto instead of ABP.BasicItem for tenant state
|
|
11
|
+
* - Uses proxy DTOs (TenantCreateDto, TenantUpdateDto) for dispatch methods
|
|
12
|
+
* - Removed updateFromResponse (used deprecated TenantManagement.Response)
|
|
13
|
+
*
|
|
8
14
|
* Changes in v2.0.0:
|
|
9
15
|
* - Added dispatchGetTenants() method
|
|
10
16
|
* - Added dispatchGetTenantById() method
|
|
@@ -12,14 +18,15 @@
|
|
|
12
18
|
* - Added dispatchUpdateTenant() method
|
|
13
19
|
* - Added dispatchDeleteTenant() method
|
|
14
20
|
*/
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import {
|
|
21
|
+
import type { PagedResultDto } from '@abpjs/core';
|
|
22
|
+
import type { TenantDto, TenantCreateDto, TenantUpdateDto, GetTenantsInput } from '../proxy/models';
|
|
23
|
+
import { TenantService } from '../proxy/tenant.service';
|
|
18
24
|
/**
|
|
19
25
|
* State service for managing tenant management state.
|
|
20
26
|
* Provides methods equivalent to Angular's NGXS state selectors and dispatch methods.
|
|
21
27
|
*
|
|
22
28
|
* @since 1.1.0
|
|
29
|
+
* @since 4.0.0 - Uses TenantService (proxy) instead of TenantManagementService
|
|
23
30
|
*/
|
|
24
31
|
export declare class TenantManagementStateService {
|
|
25
32
|
private _tenants;
|
|
@@ -28,14 +35,14 @@ export declare class TenantManagementStateService {
|
|
|
28
35
|
private _tenantService?;
|
|
29
36
|
/**
|
|
30
37
|
* Constructor
|
|
31
|
-
* @param tenantService Optional
|
|
38
|
+
* @param tenantService Optional TenantService for dispatch methods (v4.0.0: uses TenantService instead of TenantManagementService)
|
|
32
39
|
*/
|
|
33
|
-
constructor(tenantService?:
|
|
40
|
+
constructor(tenantService?: TenantService);
|
|
34
41
|
/**
|
|
35
42
|
* Get all tenants
|
|
36
43
|
* Equivalent to Angular's TenantManagementState selector
|
|
37
44
|
*/
|
|
38
|
-
get():
|
|
45
|
+
get(): TenantDto[];
|
|
39
46
|
/**
|
|
40
47
|
* Get the total count of tenants
|
|
41
48
|
* @since 1.1.0
|
|
@@ -45,17 +52,12 @@ export declare class TenantManagementStateService {
|
|
|
45
52
|
* Set tenants data (called internally by the hook)
|
|
46
53
|
* @internal
|
|
47
54
|
*/
|
|
48
|
-
setTenants(tenants:
|
|
55
|
+
setTenants(tenants: TenantDto[]): void;
|
|
49
56
|
/**
|
|
50
57
|
* Set total count (called internally by the hook)
|
|
51
58
|
* @internal
|
|
52
59
|
*/
|
|
53
60
|
setTotalCount(count: number): void;
|
|
54
|
-
/**
|
|
55
|
-
* Update state from a response
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
updateFromResponse(response: TenantManagement.Response): void;
|
|
59
61
|
/**
|
|
60
62
|
* Reset the state to initial values
|
|
61
63
|
*/
|
|
@@ -69,32 +71,37 @@ export declare class TenantManagementStateService {
|
|
|
69
71
|
private notifySubscribers;
|
|
70
72
|
/**
|
|
71
73
|
* Dispatch GetTenants action - fetches tenants from API and updates state
|
|
72
|
-
* @param
|
|
73
|
-
* @returns Promise with the tenant
|
|
74
|
+
* @param input Query parameters for tenant list
|
|
75
|
+
* @returns Promise with the paged tenant result
|
|
74
76
|
* @since 2.0.0
|
|
77
|
+
* @since 4.0.0 - Uses TenantService.getList with GetTenantsInput
|
|
75
78
|
*/
|
|
76
|
-
dispatchGetTenants(
|
|
79
|
+
dispatchGetTenants(input?: Partial<GetTenantsInput>): Promise<PagedResultDto<TenantDto>>;
|
|
77
80
|
/**
|
|
78
81
|
* Dispatch GetTenantById action - fetches a single tenant by ID
|
|
79
82
|
* @param id Tenant ID
|
|
80
|
-
* @returns Promise with the tenant
|
|
83
|
+
* @returns Promise with the tenant DTO
|
|
81
84
|
* @since 2.0.0
|
|
85
|
+
* @since 4.0.0 - Returns TenantDto instead of TenantManagement.Item
|
|
82
86
|
*/
|
|
83
|
-
dispatchGetTenantById(id: string): Promise<
|
|
87
|
+
dispatchGetTenantById(id: string): Promise<TenantDto>;
|
|
84
88
|
/**
|
|
85
89
|
* Dispatch CreateTenant action - creates a new tenant and refreshes the list
|
|
86
|
-
* @param
|
|
90
|
+
* @param input Tenant creation data
|
|
87
91
|
* @returns Promise with the created tenant
|
|
88
92
|
* @since 2.0.0
|
|
93
|
+
* @since 4.0.0 - Uses TenantCreateDto instead of TenantManagement.AddRequest
|
|
89
94
|
*/
|
|
90
|
-
dispatchCreateTenant(
|
|
95
|
+
dispatchCreateTenant(input: TenantCreateDto): Promise<TenantDto>;
|
|
91
96
|
/**
|
|
92
97
|
* Dispatch UpdateTenant action - updates an existing tenant and refreshes the list
|
|
93
|
-
* @param
|
|
98
|
+
* @param id Tenant ID
|
|
99
|
+
* @param input Tenant update data
|
|
94
100
|
* @returns Promise with the updated tenant
|
|
95
101
|
* @since 2.0.0
|
|
102
|
+
* @since 4.0.0 - Uses TenantUpdateDto instead of TenantManagement.UpdateRequest, takes id separately
|
|
96
103
|
*/
|
|
97
|
-
dispatchUpdateTenant(
|
|
104
|
+
dispatchUpdateTenant(id: string, input: TenantUpdateDto): Promise<TenantDto>;
|
|
98
105
|
/**
|
|
99
106
|
* Dispatch DeleteTenant action - deletes a tenant and refreshes the list
|
|
100
107
|
* @param id Tenant ID to delete
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/tenant-management",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "ABP Framework tenant-management components for React - translated from @abp/ng.tenant-management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@chakra-ui/react": "^3.2.0",
|
|
25
25
|
"@emotion/react": "^11.11.0",
|
|
26
|
-
"@abpjs/core": "
|
|
27
|
-
"@abpjs/theme-shared": "
|
|
26
|
+
"@abpjs/core": "4.0.0",
|
|
27
|
+
"@abpjs/theme-shared": "4.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@abp/ng.tenant-management": "3.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { RestService, ABP } from '@abpjs/core';
|
|
2
|
-
import { TenantManagement } from '../models';
|
|
3
|
-
/**
|
|
4
|
-
* Service for tenant management API calls
|
|
5
|
-
* Translated from @abp/ng.tenant-management v2.4.0
|
|
6
|
-
*/
|
|
7
|
-
export declare class TenantManagementService {
|
|
8
|
-
private rest;
|
|
9
|
-
/**
|
|
10
|
-
* The API name used for REST requests.
|
|
11
|
-
* @since 2.4.0
|
|
12
|
-
*/
|
|
13
|
-
apiName: string;
|
|
14
|
-
constructor(rest: RestService);
|
|
15
|
-
/**
|
|
16
|
-
* Get all tenants (paginated)
|
|
17
|
-
* @param params Optional pagination and filter parameters
|
|
18
|
-
* @returns Promise with paginated tenant response
|
|
19
|
-
*/
|
|
20
|
-
getAll(params?: ABP.PageQueryParams): Promise<TenantManagement.Response>;
|
|
21
|
-
/**
|
|
22
|
-
* Get a tenant by ID
|
|
23
|
-
* @param id Tenant ID
|
|
24
|
-
* @returns Promise with tenant item
|
|
25
|
-
*/
|
|
26
|
-
getById(id: string): Promise<TenantManagement.Item>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a new tenant
|
|
29
|
-
* @param body Tenant creation request
|
|
30
|
-
* @returns Promise with created tenant item
|
|
31
|
-
*/
|
|
32
|
-
create(body: TenantManagement.AddRequest): Promise<TenantManagement.Item>;
|
|
33
|
-
/**
|
|
34
|
-
* Update an existing tenant
|
|
35
|
-
* @param body Tenant update request (includes id)
|
|
36
|
-
* @returns Promise with updated tenant item
|
|
37
|
-
*/
|
|
38
|
-
update(body: TenantManagement.UpdateRequest): Promise<TenantManagement.Item>;
|
|
39
|
-
/**
|
|
40
|
-
* Delete a tenant
|
|
41
|
-
* @param id Tenant ID
|
|
42
|
-
* @returns Promise that resolves when deletion completes
|
|
43
|
-
*/
|
|
44
|
-
delete(id: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Get default connection string for a tenant
|
|
47
|
-
* @param id Tenant ID
|
|
48
|
-
* @returns Promise with connection string (empty string if using shared database)
|
|
49
|
-
*/
|
|
50
|
-
getDefaultConnectionString(id: string): Promise<string>;
|
|
51
|
-
/**
|
|
52
|
-
* Update default connection string for a tenant
|
|
53
|
-
* @param payload Request with tenant ID and connection string
|
|
54
|
-
* @returns Promise that resolves when update completes
|
|
55
|
-
*/
|
|
56
|
-
updateDefaultConnectionString(payload: TenantManagement.DefaultConnectionStringRequest): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Delete default connection string for a tenant (use shared database)
|
|
59
|
-
* @param id Tenant ID
|
|
60
|
-
* @returns Promise that resolves when deletion completes
|
|
61
|
-
*/
|
|
62
|
-
deleteDefaultConnectionString(id: string): Promise<void>;
|
|
63
|
-
}
|