@abpjs/tenant-management 0.8.0 → 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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type RenderOptions, type RenderResult } from '@testing-library/react';
3
+ import { vi } from 'vitest';
4
+ /**
5
+ * Mock RestService for testing service calls
6
+ */
7
+ export interface MockRestService {
8
+ request: ReturnType<typeof vi.fn>;
9
+ }
10
+ export declare function createMockRestService(): MockRestService;
11
+ /**
12
+ * Mock for @abpjs/core's useRestService hook
13
+ */
14
+ export declare const mockRestService: MockRestService;
15
+ /**
16
+ * Mock for @abpjs/core's useLocalization hook
17
+ */
18
+ export declare const mockUseLocalization: import("vitest").Mock<[], {
19
+ t: (key: string, ...params: string[]) => string;
20
+ instant: (key: string) => string;
21
+ languages: {
22
+ cultureName: string;
23
+ displayName: string;
24
+ }[];
25
+ localization: {};
26
+ }>;
27
+ /**
28
+ * Custom render function that wraps components with test providers
29
+ */
30
+ declare function customRender(ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>): RenderResult;
31
+ /**
32
+ * Reset all mocks between tests
33
+ */
34
+ export declare function resetMocks(): void;
35
+ export * from '@testing-library/react';
36
+ export { customRender as render };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { TENANT_MANAGEMENT_ROUTES, TENANT_MANAGEMENT_ROUTE_PATHS, TENANT_MANAGEMENT_POLICIES, } from './routes';
@@ -0,0 +1,40 @@
1
+ import { ABP } from '@abpjs/core';
2
+ /**
3
+ * Tenant Management module routes configuration (v0.9.0 format).
4
+ * Translated from @abp/ng.tenant-management TENANT_MANAGEMENT_ROUTES.
5
+ *
6
+ * These routes define the navigation structure for the tenant management module
7
+ * within the ABP Framework application.
8
+ *
9
+ * In v0.9.0, the format changed from `ABP.FullRoute[]` to `{ routes: ABP.FullRoute[] }`
10
+ */
11
+ export declare const TENANT_MANAGEMENT_ROUTES: {
12
+ routes: ABP.FullRoute[];
13
+ };
14
+ /**
15
+ * Route paths for the tenant management module.
16
+ * Use these constants for programmatic navigation.
17
+ */
18
+ export declare const TENANT_MANAGEMENT_ROUTE_PATHS: {
19
+ /** Base path for tenant management module */
20
+ readonly BASE: "/tenant-management";
21
+ /** Tenants management path */
22
+ readonly TENANTS: "/tenant-management/tenants";
23
+ };
24
+ /**
25
+ * Required policies for tenant management module routes.
26
+ */
27
+ export declare const TENANT_MANAGEMENT_POLICIES: {
28
+ /** Policy for tenants management */
29
+ readonly TENANTS: "AbpTenantManagement.Tenants";
30
+ /** Policy for creating tenants */
31
+ readonly TENANTS_CREATE: "AbpTenantManagement.Tenants.Create";
32
+ /** Policy for updating tenants */
33
+ readonly TENANTS_UPDATE: "AbpTenantManagement.Tenants.Update";
34
+ /** Policy for deleting tenants */
35
+ readonly TENANTS_DELETE: "AbpTenantManagement.Tenants.Delete";
36
+ /** Policy for managing connection strings */
37
+ readonly TENANTS_MANAGE_CONNECTION_STRINGS: "AbpTenantManagement.Tenants.ManageConnectionStrings";
38
+ /** Policy for managing features */
39
+ readonly TENANTS_MANAGE_FEATURES: "AbpTenantManagement.Tenants.ManageFeatures";
40
+ };
@@ -1,3 +1,4 @@
1
+ import { ABP } from '@abpjs/core';
1
2
  import { TenantManagement } from '../models';
2
3
  /**
3
4
  * Result from tenant management operations
@@ -12,6 +13,8 @@ export interface TenantManagementResult {
12
13
  export interface UseTenantManagementReturn {
13
14
  /** List of tenants */
14
15
  tenants: TenantManagement.Item[];
16
+ /** Total count of tenants */
17
+ totalCount: number;
15
18
  /** Currently selected tenant */
16
19
  selectedTenant: TenantManagement.Item | null;
17
20
  /** Loading state */
@@ -22,8 +25,8 @@ export interface UseTenantManagementReturn {
22
25
  defaultConnectionString: string;
23
26
  /** Whether the selected tenant uses shared database */
24
27
  useSharedDatabase: boolean;
25
- /** Fetch all tenants */
26
- fetchTenants: () => Promise<TenantManagementResult>;
28
+ /** Fetch all tenants (with optional params in v0.9.0) */
29
+ fetchTenants: (params?: ABP.PageQueryParams) => Promise<TenantManagementResult>;
27
30
  /** Fetch a tenant by ID */
28
31
  fetchTenantById: (id: string) => Promise<TenantManagementResult>;
29
32
  /** Create a new tenant */
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @abpjs/tenant-management
3
3
  * ABP Framework Tenant Management module for React
4
- * Translated from @abp/ng.tenant-management v0.8.0
4
+ * Translated from @abp/ng.tenant-management v0.9.0
5
5
  */
6
6
  export * from './models';
7
7
  export * from './services';
8
8
  export * from './hooks';
9
+ export * from './constants';
9
10
  export * from './components';
package/dist/index.js CHANGED
@@ -20,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ TENANT_MANAGEMENT_POLICIES: () => TENANT_MANAGEMENT_POLICIES,
24
+ TENANT_MANAGEMENT_ROUTES: () => TENANT_MANAGEMENT_ROUTES,
25
+ TENANT_MANAGEMENT_ROUTE_PATHS: () => TENANT_MANAGEMENT_ROUTE_PATHS,
23
26
  TenantManagementModal: () => TenantManagementModal,
24
27
  TenantManagementService: () => TenantManagementService,
25
28
  useTenantManagement: () => useTenantManagement
@@ -33,12 +36,14 @@ var TenantManagementService = class {
33
36
  }
34
37
  /**
35
38
  * Get all tenants (paginated)
39
+ * @param params Optional pagination and filter parameters
36
40
  * @returns Promise with paginated tenant response
37
41
  */
38
- getAll() {
42
+ getAll(params = {}) {
39
43
  return this.rest.request({
40
44
  method: "GET",
41
- url: "/api/multi-tenancy/tenants"
45
+ url: "/api/multi-tenancy/tenants",
46
+ params
42
47
  });
43
48
  }
44
49
  /**
@@ -132,17 +137,19 @@ function useTenantManagement() {
132
137
  const restService = (0, import_core.useRestService)();
133
138
  const service = (0, import_react.useMemo)(() => new TenantManagementService(restService), [restService]);
134
139
  const [tenants, setTenants] = (0, import_react.useState)([]);
140
+ const [totalCount, setTotalCount] = (0, import_react.useState)(0);
135
141
  const [selectedTenant, setSelectedTenant] = (0, import_react.useState)(null);
136
142
  const [isLoading, setIsLoading] = (0, import_react.useState)(false);
137
143
  const [error, setError] = (0, import_react.useState)(null);
138
144
  const [defaultConnectionString, setDefaultConnectionString] = (0, import_react.useState)("");
139
145
  const [useSharedDatabase, setUseSharedDatabase] = (0, import_react.useState)(true);
140
- const fetchTenants = (0, import_react.useCallback)(async () => {
146
+ const fetchTenants = (0, import_react.useCallback)(async (params) => {
141
147
  setIsLoading(true);
142
148
  setError(null);
143
149
  try {
144
- const response = await service.getAll();
150
+ const response = await service.getAll(params);
145
151
  setTenants(response.items);
152
+ setTotalCount(response.totalCount);
146
153
  setIsLoading(false);
147
154
  return { success: true };
148
155
  } catch (err) {
@@ -286,6 +293,7 @@ function useTenantManagement() {
286
293
  );
287
294
  const reset = (0, import_react.useCallback)(() => {
288
295
  setTenants([]);
296
+ setTotalCount(0);
289
297
  setSelectedTenant(null);
290
298
  setIsLoading(false);
291
299
  setError(null);
@@ -294,6 +302,7 @@ function useTenantManagement() {
294
302
  }, []);
295
303
  return {
296
304
  tenants,
305
+ totalCount,
297
306
  selectedTenant,
298
307
  isLoading,
299
308
  error,
@@ -314,9 +323,58 @@ function useTenantManagement() {
314
323
  };
315
324
  }
316
325
 
326
+ // src/constants/routes.ts
327
+ var import_core2 = require("@abpjs/core");
328
+ var TENANT_MANAGEMENT_ROUTES = {
329
+ routes: [
330
+ {
331
+ name: "AbpUiNavigation::Menu:Administration",
332
+ path: "",
333
+ order: 1,
334
+ wrapper: true
335
+ },
336
+ {
337
+ name: "AbpTenantManagement::Menu:TenantManagement",
338
+ path: "tenant-management",
339
+ order: 2,
340
+ parentName: "AbpUiNavigation::Menu:Administration",
341
+ layout: import_core2.eLayoutType.application,
342
+ requiredPolicy: "AbpTenantManagement.Tenants",
343
+ children: [
344
+ {
345
+ path: "tenants",
346
+ name: "AbpTenantManagement::Tenants",
347
+ order: 1,
348
+ requiredPolicy: "AbpTenantManagement.Tenants"
349
+ }
350
+ ]
351
+ }
352
+ ]
353
+ };
354
+ var TENANT_MANAGEMENT_ROUTE_PATHS = {
355
+ /** Base path for tenant management module */
356
+ BASE: "/tenant-management",
357
+ /** Tenants management path */
358
+ TENANTS: "/tenant-management/tenants"
359
+ };
360
+ var TENANT_MANAGEMENT_POLICIES = {
361
+ /** Policy for tenants management */
362
+ TENANTS: "AbpTenantManagement.Tenants",
363
+ /** Policy for creating tenants */
364
+ TENANTS_CREATE: "AbpTenantManagement.Tenants.Create",
365
+ /** Policy for updating tenants */
366
+ TENANTS_UPDATE: "AbpTenantManagement.Tenants.Update",
367
+ /** Policy for deleting tenants */
368
+ TENANTS_DELETE: "AbpTenantManagement.Tenants.Delete",
369
+ /** Policy for managing connection strings */
370
+ TENANTS_MANAGE_CONNECTION_STRINGS: "AbpTenantManagement.Tenants.ManageConnectionStrings",
371
+ /** Policy for managing features */
372
+ TENANTS_MANAGE_FEATURES: "AbpTenantManagement.Tenants.ManageFeatures"
373
+ };
374
+
317
375
  // src/components/TenantManagementModal/TenantManagementModal.tsx
318
376
  var import_react2 = require("react");
319
- var import_core2 = require("@abpjs/core");
377
+ var import_core3 = require("@abpjs/core");
320
378
  var import_theme_shared = require("@abpjs/theme-shared");
321
379
  var import_react3 = require("@chakra-ui/react");
322
380
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -327,7 +385,7 @@ function TenantManagementModal({
327
385
  initialView = "tenant",
328
386
  onSave
329
387
  }) {
330
- const { t } = (0, import_core2.useLocalization)();
388
+ const { t } = (0, import_core3.useLocalization)();
331
389
  const {
332
390
  selectedTenant,
333
391
  isLoading,
@@ -547,6 +605,9 @@ function TenantManagementModal({
547
605
  }
548
606
  // Annotate the CommonJS export names for ESM import in node:
549
607
  0 && (module.exports = {
608
+ TENANT_MANAGEMENT_POLICIES,
609
+ TENANT_MANAGEMENT_ROUTES,
610
+ TENANT_MANAGEMENT_ROUTE_PATHS,
550
611
  TenantManagementModal,
551
612
  TenantManagementService,
552
613
  useTenantManagement
package/dist/index.mjs CHANGED
@@ -5,12 +5,14 @@ var TenantManagementService = class {
5
5
  }
6
6
  /**
7
7
  * Get all tenants (paginated)
8
+ * @param params Optional pagination and filter parameters
8
9
  * @returns Promise with paginated tenant response
9
10
  */
10
- getAll() {
11
+ getAll(params = {}) {
11
12
  return this.rest.request({
12
13
  method: "GET",
13
- url: "/api/multi-tenancy/tenants"
14
+ url: "/api/multi-tenancy/tenants",
15
+ params
14
16
  });
15
17
  }
16
18
  /**
@@ -104,17 +106,19 @@ function useTenantManagement() {
104
106
  const restService = useRestService();
105
107
  const service = useMemo(() => new TenantManagementService(restService), [restService]);
106
108
  const [tenants, setTenants] = useState([]);
109
+ const [totalCount, setTotalCount] = useState(0);
107
110
  const [selectedTenant, setSelectedTenant] = useState(null);
108
111
  const [isLoading, setIsLoading] = useState(false);
109
112
  const [error, setError] = useState(null);
110
113
  const [defaultConnectionString, setDefaultConnectionString] = useState("");
111
114
  const [useSharedDatabase, setUseSharedDatabase] = useState(true);
112
- const fetchTenants = useCallback(async () => {
115
+ const fetchTenants = useCallback(async (params) => {
113
116
  setIsLoading(true);
114
117
  setError(null);
115
118
  try {
116
- const response = await service.getAll();
119
+ const response = await service.getAll(params);
117
120
  setTenants(response.items);
121
+ setTotalCount(response.totalCount);
118
122
  setIsLoading(false);
119
123
  return { success: true };
120
124
  } catch (err) {
@@ -258,6 +262,7 @@ function useTenantManagement() {
258
262
  );
259
263
  const reset = useCallback(() => {
260
264
  setTenants([]);
265
+ setTotalCount(0);
261
266
  setSelectedTenant(null);
262
267
  setIsLoading(false);
263
268
  setError(null);
@@ -266,6 +271,7 @@ function useTenantManagement() {
266
271
  }, []);
267
272
  return {
268
273
  tenants,
274
+ totalCount,
269
275
  selectedTenant,
270
276
  isLoading,
271
277
  error,
@@ -286,6 +292,55 @@ function useTenantManagement() {
286
292
  };
287
293
  }
288
294
 
295
+ // src/constants/routes.ts
296
+ import { eLayoutType } from "@abpjs/core";
297
+ var TENANT_MANAGEMENT_ROUTES = {
298
+ routes: [
299
+ {
300
+ name: "AbpUiNavigation::Menu:Administration",
301
+ path: "",
302
+ order: 1,
303
+ wrapper: true
304
+ },
305
+ {
306
+ name: "AbpTenantManagement::Menu:TenantManagement",
307
+ path: "tenant-management",
308
+ order: 2,
309
+ parentName: "AbpUiNavigation::Menu:Administration",
310
+ layout: eLayoutType.application,
311
+ requiredPolicy: "AbpTenantManagement.Tenants",
312
+ children: [
313
+ {
314
+ path: "tenants",
315
+ name: "AbpTenantManagement::Tenants",
316
+ order: 1,
317
+ requiredPolicy: "AbpTenantManagement.Tenants"
318
+ }
319
+ ]
320
+ }
321
+ ]
322
+ };
323
+ var TENANT_MANAGEMENT_ROUTE_PATHS = {
324
+ /** Base path for tenant management module */
325
+ BASE: "/tenant-management",
326
+ /** Tenants management path */
327
+ TENANTS: "/tenant-management/tenants"
328
+ };
329
+ var TENANT_MANAGEMENT_POLICIES = {
330
+ /** Policy for tenants management */
331
+ TENANTS: "AbpTenantManagement.Tenants",
332
+ /** Policy for creating tenants */
333
+ TENANTS_CREATE: "AbpTenantManagement.Tenants.Create",
334
+ /** Policy for updating tenants */
335
+ TENANTS_UPDATE: "AbpTenantManagement.Tenants.Update",
336
+ /** Policy for deleting tenants */
337
+ TENANTS_DELETE: "AbpTenantManagement.Tenants.Delete",
338
+ /** Policy for managing connection strings */
339
+ TENANTS_MANAGE_CONNECTION_STRINGS: "AbpTenantManagement.Tenants.ManageConnectionStrings",
340
+ /** Policy for managing features */
341
+ TENANTS_MANAGE_FEATURES: "AbpTenantManagement.Tenants.ManageFeatures"
342
+ };
343
+
289
344
  // src/components/TenantManagementModal/TenantManagementModal.tsx
290
345
  import { useEffect, useCallback as useCallback2, useState as useState2 } from "react";
291
346
  import { useLocalization } from "@abpjs/core";
@@ -524,6 +579,9 @@ function TenantManagementModal({
524
579
  );
525
580
  }
526
581
  export {
582
+ TENANT_MANAGEMENT_POLICIES,
583
+ TENANT_MANAGEMENT_ROUTES,
584
+ TENANT_MANAGEMENT_ROUTE_PATHS,
527
585
  TenantManagementModal,
528
586
  TenantManagementService,
529
587
  useTenantManagement
@@ -1,17 +1,18 @@
1
- import { RestService } from '@abpjs/core';
1
+ import { RestService, ABP } from '@abpjs/core';
2
2
  import { TenantManagement } from '../models';
3
3
  /**
4
4
  * Service for tenant management API calls
5
- * Translated from @abp/ng.tenant-management v0.8.0
5
+ * Translated from @abp/ng.tenant-management v0.9.0
6
6
  */
7
7
  export declare class TenantManagementService {
8
8
  private rest;
9
9
  constructor(rest: RestService);
10
10
  /**
11
11
  * Get all tenants (paginated)
12
+ * @param params Optional pagination and filter parameters
12
13
  * @returns Promise with paginated tenant response
13
14
  */
14
- getAll(): Promise<TenantManagement.Response>;
15
+ getAll(params?: ABP.PageQueryParams): Promise<TenantManagement.Response>;
15
16
  /**
16
17
  * Get a tenant by ID
17
18
  * @param id Tenant ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/tenant-management",
3
- "version": "0.8.0",
3
+ "version": "0.9.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,14 +23,23 @@
23
23
  "dependencies": {
24
24
  "@chakra-ui/react": "^3.2.0",
25
25
  "@emotion/react": "^11.11.0",
26
- "@abpjs/core": "0.8.0",
27
- "@abpjs/theme-shared": "0.8.0"
26
+ "@abpjs/core": "0.9.0",
27
+ "@abpjs/theme-shared": "0.9.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@abp/ng.tenant-management": "0.8.0",
30
+ "@abp/ng.tenant-management": "0.9.0",
31
+ "@testing-library/jest-dom": "^6.4.0",
32
+ "@testing-library/react": "^14.2.0",
33
+ "@types/react": "^18.2.0",
34
+ "@types/react-dom": "^18.2.0",
35
+ "@vitest/coverage-v8": "^1.2.0",
31
36
  "autoprefixer": "^10.4.16",
37
+ "jsdom": "^24.0.0",
32
38
  "postcss": "^8.4.32",
33
- "tailwindcss": "^3.4.0"
39
+ "react": "^18.2.0",
40
+ "react-dom": "^18.2.0",
41
+ "tailwindcss": "^3.4.0",
42
+ "vitest": "^1.2.0"
34
43
  },
35
44
  "author": "tekthar.com",
36
45
  "license": "LGPL-3.0",