@abpjs/tenant-management 0.8.0 → 1.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.
@@ -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
@@ -6,12 +7,19 @@ export interface TenantManagementResult {
6
7
  success: boolean;
7
8
  error?: string;
8
9
  }
10
+ /**
11
+ * Sort order type
12
+ * @since 1.0.0
13
+ */
14
+ export type SortOrder = 'asc' | 'desc' | '';
9
15
  /**
10
16
  * Return type for useTenantManagement hook
11
17
  */
12
18
  export interface UseTenantManagementReturn {
13
19
  /** List of tenants */
14
20
  tenants: TenantManagement.Item[];
21
+ /** Total count of tenants */
22
+ totalCount: number;
15
23
  /** Currently selected tenant */
16
24
  selectedTenant: TenantManagement.Item | null;
17
25
  /** Loading state */
@@ -22,8 +30,12 @@ export interface UseTenantManagementReturn {
22
30
  defaultConnectionString: string;
23
31
  /** Whether the selected tenant uses shared database */
24
32
  useSharedDatabase: boolean;
25
- /** Fetch all tenants */
26
- fetchTenants: () => Promise<TenantManagementResult>;
33
+ /** Current sort key @since 1.0.0 */
34
+ sortKey: string;
35
+ /** Current sort order @since 1.0.0 */
36
+ sortOrder: SortOrder;
37
+ /** Fetch all tenants (with optional params) */
38
+ fetchTenants: (params?: ABP.PageQueryParams) => Promise<TenantManagementResult>;
27
39
  /** Fetch a tenant by ID */
28
40
  fetchTenantById: (id: string) => Promise<TenantManagementResult>;
29
41
  /** Create a new tenant */
@@ -44,6 +56,10 @@ export interface UseTenantManagementReturn {
44
56
  setUseSharedDatabase: (value: boolean) => void;
45
57
  /** Set default connection string */
46
58
  setDefaultConnectionString: (value: string) => void;
59
+ /** Set sort key @since 1.0.0 */
60
+ setSortKey: (key: string) => void;
61
+ /** Set sort order @since 1.0.0 */
62
+ setSortOrder: (order: SortOrder) => void;
47
63
  /** Reset all state */
48
64
  reset: () => void;
49
65
  }
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 v1.0.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,21 @@ 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 [sortKey, setSortKey] = (0, import_react.useState)("name");
147
+ const [sortOrder, setSortOrder] = (0, import_react.useState)("");
148
+ const fetchTenants = (0, import_react.useCallback)(async (params) => {
141
149
  setIsLoading(true);
142
150
  setError(null);
143
151
  try {
144
- const response = await service.getAll();
152
+ const response = await service.getAll(params);
145
153
  setTenants(response.items);
154
+ setTotalCount(response.totalCount);
146
155
  setIsLoading(false);
147
156
  return { success: true };
148
157
  } catch (err) {
@@ -286,6 +295,7 @@ function useTenantManagement() {
286
295
  );
287
296
  const reset = (0, import_react.useCallback)(() => {
288
297
  setTenants([]);
298
+ setTotalCount(0);
289
299
  setSelectedTenant(null);
290
300
  setIsLoading(false);
291
301
  setError(null);
@@ -294,11 +304,14 @@ function useTenantManagement() {
294
304
  }, []);
295
305
  return {
296
306
  tenants,
307
+ totalCount,
297
308
  selectedTenant,
298
309
  isLoading,
299
310
  error,
300
311
  defaultConnectionString,
301
312
  useSharedDatabase,
313
+ sortKey,
314
+ sortOrder,
302
315
  fetchTenants,
303
316
  fetchTenantById,
304
317
  createTenant,
@@ -310,13 +323,64 @@ function useTenantManagement() {
310
323
  setSelectedTenant,
311
324
  setUseSharedDatabase,
312
325
  setDefaultConnectionString,
326
+ setSortKey,
327
+ setSortOrder,
313
328
  reset
314
329
  };
315
330
  }
316
331
 
332
+ // src/constants/routes.ts
333
+ var import_core2 = require("@abpjs/core");
334
+ var TENANT_MANAGEMENT_ROUTES = {
335
+ routes: [
336
+ {
337
+ name: "AbpUiNavigation::Menu:Administration",
338
+ path: "",
339
+ order: 1,
340
+ wrapper: true
341
+ },
342
+ {
343
+ name: "AbpTenantManagement::Menu:TenantManagement",
344
+ path: "tenant-management",
345
+ order: 2,
346
+ parentName: "AbpUiNavigation::Menu:Administration",
347
+ layout: import_core2.eLayoutType.application,
348
+ requiredPolicy: "AbpTenantManagement.Tenants",
349
+ children: [
350
+ {
351
+ path: "tenants",
352
+ name: "AbpTenantManagement::Tenants",
353
+ order: 1,
354
+ requiredPolicy: "AbpTenantManagement.Tenants"
355
+ }
356
+ ]
357
+ }
358
+ ]
359
+ };
360
+ var TENANT_MANAGEMENT_ROUTE_PATHS = {
361
+ /** Base path for tenant management module */
362
+ BASE: "/tenant-management",
363
+ /** Tenants management path */
364
+ TENANTS: "/tenant-management/tenants"
365
+ };
366
+ var TENANT_MANAGEMENT_POLICIES = {
367
+ /** Policy for tenants management */
368
+ TENANTS: "AbpTenantManagement.Tenants",
369
+ /** Policy for creating tenants */
370
+ TENANTS_CREATE: "AbpTenantManagement.Tenants.Create",
371
+ /** Policy for updating tenants */
372
+ TENANTS_UPDATE: "AbpTenantManagement.Tenants.Update",
373
+ /** Policy for deleting tenants */
374
+ TENANTS_DELETE: "AbpTenantManagement.Tenants.Delete",
375
+ /** Policy for managing connection strings */
376
+ TENANTS_MANAGE_CONNECTION_STRINGS: "AbpTenantManagement.Tenants.ManageConnectionStrings",
377
+ /** Policy for managing features */
378
+ TENANTS_MANAGE_FEATURES: "AbpTenantManagement.Tenants.ManageFeatures"
379
+ };
380
+
317
381
  // src/components/TenantManagementModal/TenantManagementModal.tsx
318
382
  var import_react2 = require("react");
319
- var import_core2 = require("@abpjs/core");
383
+ var import_core3 = require("@abpjs/core");
320
384
  var import_theme_shared = require("@abpjs/theme-shared");
321
385
  var import_react3 = require("@chakra-ui/react");
322
386
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -327,7 +391,7 @@ function TenantManagementModal({
327
391
  initialView = "tenant",
328
392
  onSave
329
393
  }) {
330
- const { t } = (0, import_core2.useLocalization)();
394
+ const { t } = (0, import_core3.useLocalization)();
331
395
  const {
332
396
  selectedTenant,
333
397
  isLoading,
@@ -547,6 +611,9 @@ function TenantManagementModal({
547
611
  }
548
612
  // Annotate the CommonJS export names for ESM import in node:
549
613
  0 && (module.exports = {
614
+ TENANT_MANAGEMENT_POLICIES,
615
+ TENANT_MANAGEMENT_ROUTES,
616
+ TENANT_MANAGEMENT_ROUTE_PATHS,
550
617
  TenantManagementModal,
551
618
  TenantManagementService,
552
619
  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,21 @@ 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 [sortKey, setSortKey] = useState("name");
116
+ const [sortOrder, setSortOrder] = useState("");
117
+ const fetchTenants = useCallback(async (params) => {
113
118
  setIsLoading(true);
114
119
  setError(null);
115
120
  try {
116
- const response = await service.getAll();
121
+ const response = await service.getAll(params);
117
122
  setTenants(response.items);
123
+ setTotalCount(response.totalCount);
118
124
  setIsLoading(false);
119
125
  return { success: true };
120
126
  } catch (err) {
@@ -258,6 +264,7 @@ function useTenantManagement() {
258
264
  );
259
265
  const reset = useCallback(() => {
260
266
  setTenants([]);
267
+ setTotalCount(0);
261
268
  setSelectedTenant(null);
262
269
  setIsLoading(false);
263
270
  setError(null);
@@ -266,11 +273,14 @@ function useTenantManagement() {
266
273
  }, []);
267
274
  return {
268
275
  tenants,
276
+ totalCount,
269
277
  selectedTenant,
270
278
  isLoading,
271
279
  error,
272
280
  defaultConnectionString,
273
281
  useSharedDatabase,
282
+ sortKey,
283
+ sortOrder,
274
284
  fetchTenants,
275
285
  fetchTenantById,
276
286
  createTenant,
@@ -282,10 +292,61 @@ function useTenantManagement() {
282
292
  setSelectedTenant,
283
293
  setUseSharedDatabase,
284
294
  setDefaultConnectionString,
295
+ setSortKey,
296
+ setSortOrder,
285
297
  reset
286
298
  };
287
299
  }
288
300
 
301
+ // src/constants/routes.ts
302
+ import { eLayoutType } from "@abpjs/core";
303
+ var TENANT_MANAGEMENT_ROUTES = {
304
+ routes: [
305
+ {
306
+ name: "AbpUiNavigation::Menu:Administration",
307
+ path: "",
308
+ order: 1,
309
+ wrapper: true
310
+ },
311
+ {
312
+ name: "AbpTenantManagement::Menu:TenantManagement",
313
+ path: "tenant-management",
314
+ order: 2,
315
+ parentName: "AbpUiNavigation::Menu:Administration",
316
+ layout: eLayoutType.application,
317
+ requiredPolicy: "AbpTenantManagement.Tenants",
318
+ children: [
319
+ {
320
+ path: "tenants",
321
+ name: "AbpTenantManagement::Tenants",
322
+ order: 1,
323
+ requiredPolicy: "AbpTenantManagement.Tenants"
324
+ }
325
+ ]
326
+ }
327
+ ]
328
+ };
329
+ var TENANT_MANAGEMENT_ROUTE_PATHS = {
330
+ /** Base path for tenant management module */
331
+ BASE: "/tenant-management",
332
+ /** Tenants management path */
333
+ TENANTS: "/tenant-management/tenants"
334
+ };
335
+ var TENANT_MANAGEMENT_POLICIES = {
336
+ /** Policy for tenants management */
337
+ TENANTS: "AbpTenantManagement.Tenants",
338
+ /** Policy for creating tenants */
339
+ TENANTS_CREATE: "AbpTenantManagement.Tenants.Create",
340
+ /** Policy for updating tenants */
341
+ TENANTS_UPDATE: "AbpTenantManagement.Tenants.Update",
342
+ /** Policy for deleting tenants */
343
+ TENANTS_DELETE: "AbpTenantManagement.Tenants.Delete",
344
+ /** Policy for managing connection strings */
345
+ TENANTS_MANAGE_CONNECTION_STRINGS: "AbpTenantManagement.Tenants.ManageConnectionStrings",
346
+ /** Policy for managing features */
347
+ TENANTS_MANAGE_FEATURES: "AbpTenantManagement.Tenants.ManageFeatures"
348
+ };
349
+
289
350
  // src/components/TenantManagementModal/TenantManagementModal.tsx
290
351
  import { useEffect, useCallback as useCallback2, useState as useState2 } from "react";
291
352
  import { useLocalization } from "@abpjs/core";
@@ -524,6 +585,9 @@ function TenantManagementModal({
524
585
  );
525
586
  }
526
587
  export {
588
+ TENANT_MANAGEMENT_POLICIES,
589
+ TENANT_MANAGEMENT_ROUTES,
590
+ TENANT_MANAGEMENT_ROUTE_PATHS,
527
591
  TenantManagementModal,
528
592
  TenantManagementService,
529
593
  useTenantManagement
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Tenant Management module type definitions
3
- * Translated from @abp/ng.tenant-management v0.7.6
3
+ * Translated from @abp/ng.tenant-management v1.0.0
4
4
  */
5
5
  import type { ABP } from '@abpjs/core';
6
6
  /**
@@ -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 v1.0.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": "1.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,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/theme-shared": "1.0.0",
27
+ "@abpjs/core": "1.0.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@abp/ng.tenant-management": "0.8.0",
30
+ "@abp/ng.tenant-management": "1.0.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",
@@ -53,6 +62,7 @@
53
62
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
54
63
  "format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
55
64
  "type-check": "tsc --noEmit",
56
- "test": "vitest"
65
+ "test": "vitest run",
66
+ "test:watch": "vitest"
57
67
  }
58
68
  }