@abpjs/tenant-management 2.2.0 → 2.4.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/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * @abpjs/tenant-management
3
3
  * ABP Framework Tenant Management module for React
4
- * Translated from @abp/ng.tenant-management v2.2.0
4
+ * Translated from @abp/ng.tenant-management v2.4.0
5
+ *
6
+ * Changes in v2.4.0:
7
+ * - Added apiName property to TenantManagementService (defaults to 'default')
8
+ * - Added adminEmailAddress and adminPassword fields to AddRequest interface
9
+ * - UpdateRequest no longer extends AddRequest (now only has id and name)
5
10
  *
6
11
  * Changes in v2.2.0:
7
12
  * - Added openFeaturesModal(providerKey: string) to useTenantManagement hook
package/dist/index.js CHANGED
@@ -33,6 +33,11 @@ module.exports = __toCommonJS(index_exports);
33
33
  // src/services/tenant-management.service.ts
34
34
  var TenantManagementService = class {
35
35
  constructor(rest) {
36
+ /**
37
+ * The API name used for REST requests.
38
+ * @since 2.4.0
39
+ */
40
+ this.apiName = "default";
36
41
  this.rest = rest;
37
42
  }
38
43
  /**
@@ -575,6 +580,10 @@ function TenantManagementModal({
575
580
  const [currentView, setCurrentView] = (0, import_react2.useState)(initialView);
576
581
  const [tenantName, setTenantName] = (0, import_react2.useState)("");
577
582
  const [tenantNameError, setTenantNameError] = (0, import_react2.useState)(null);
583
+ const [adminEmail, setAdminEmail] = (0, import_react2.useState)("");
584
+ const [adminEmailError, setAdminEmailError] = (0, import_react2.useState)(null);
585
+ const [adminPassword, setAdminPassword] = (0, import_react2.useState)("");
586
+ const [adminPasswordError, setAdminPasswordError] = (0, import_react2.useState)(null);
578
587
  const [localConnectionString, setLocalConnectionString] = (0, import_react2.useState)("");
579
588
  const [localUseSharedDatabase, setLocalUseSharedDatabase] = (0, import_react2.useState)(true);
580
589
  const isEditing = !!tenantId;
@@ -598,6 +607,10 @@ function TenantManagementModal({
598
607
  reset();
599
608
  setTenantName("");
600
609
  setTenantNameError(null);
610
+ setAdminEmail("");
611
+ setAdminEmailError(null);
612
+ setAdminPassword("");
613
+ setAdminPasswordError(null);
601
614
  setLocalConnectionString("");
602
615
  setLocalUseSharedDatabase(true);
603
616
  }
@@ -628,6 +641,39 @@ function TenantManagementModal({
628
641
  },
629
642
  [t]
630
643
  );
644
+ const validateAdminEmail = (0, import_react2.useCallback)(
645
+ (email) => {
646
+ if (!email || email.trim().length === 0) {
647
+ setAdminEmailError(t("AbpValidation::ThisFieldIsRequired"));
648
+ return false;
649
+ }
650
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
651
+ if (!emailRegex.test(email)) {
652
+ setAdminEmailError(t("AbpValidation::ThisFieldIsNotAValidEmailAddress"));
653
+ return false;
654
+ }
655
+ setAdminEmailError(null);
656
+ return true;
657
+ },
658
+ [t]
659
+ );
660
+ const validateAdminPassword = (0, import_react2.useCallback)(
661
+ (password) => {
662
+ if (!password || password.length === 0) {
663
+ setAdminPasswordError(t("AbpValidation::ThisFieldIsRequired"));
664
+ return false;
665
+ }
666
+ if (password.length < 6) {
667
+ setAdminPasswordError(
668
+ t("AbpValidation::ThisFieldMustBeAStringWithAMinimumLengthOf{0}", "6")
669
+ );
670
+ return false;
671
+ }
672
+ setAdminPasswordError(null);
673
+ return true;
674
+ },
675
+ [t]
676
+ );
631
677
  const handleTenantSubmit = (0, import_react2.useCallback)(async () => {
632
678
  if (!validateTenantName(tenantName)) {
633
679
  return;
@@ -636,7 +682,16 @@ function TenantManagementModal({
636
682
  if (isEditing && tenantId) {
637
683
  result = await updateTenant({ id: tenantId, name: tenantName.trim() });
638
684
  } else {
639
- result = await createTenant({ name: tenantName.trim() });
685
+ const emailValid = validateAdminEmail(adminEmail);
686
+ const passwordValid = validateAdminPassword(adminPassword);
687
+ if (!emailValid || !passwordValid) {
688
+ return;
689
+ }
690
+ result = await createTenant({
691
+ name: tenantName.trim(),
692
+ adminEmailAddress: adminEmail.trim(),
693
+ adminPassword
694
+ });
640
695
  }
641
696
  if (result.success) {
642
697
  onSave?.();
@@ -644,9 +699,13 @@ function TenantManagementModal({
644
699
  }
645
700
  }, [
646
701
  tenantName,
702
+ adminEmail,
703
+ adminPassword,
647
704
  isEditing,
648
705
  tenantId,
649
706
  validateTenantName,
707
+ validateAdminEmail,
708
+ validateAdminPassword,
650
709
  createTenant,
651
710
  updateTenant,
652
711
  onSave,
@@ -686,6 +745,26 @@ function TenantManagementModal({
686
745
  },
687
746
  [tenantNameError, validateTenantName]
688
747
  );
748
+ const handleAdminEmailChange = (0, import_react2.useCallback)(
749
+ (e) => {
750
+ const value = e.target.value;
751
+ setAdminEmail(value);
752
+ if (adminEmailError) {
753
+ validateAdminEmail(value);
754
+ }
755
+ },
756
+ [adminEmailError, validateAdminEmail]
757
+ );
758
+ const handleAdminPasswordChange = (0, import_react2.useCallback)(
759
+ (e) => {
760
+ const value = e.target.value;
761
+ setAdminPassword(value);
762
+ if (adminPasswordError) {
763
+ validateAdminPassword(value);
764
+ }
765
+ },
766
+ [adminPasswordError, validateAdminPassword]
767
+ );
689
768
  const handleUseSharedDatabaseChange = (0, import_react2.useCallback)(() => {
690
769
  setLocalUseSharedDatabase((prev) => {
691
770
  const newValue = !prev;
@@ -698,26 +777,70 @@ function TenantManagementModal({
698
777
  const handleConnectionStringChange = (0, import_react2.useCallback)((e) => {
699
778
  setLocalConnectionString(e.target.value);
700
779
  }, []);
701
- const renderTenantForm = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.VStack, { gap: 4, align: "stretch", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
702
- import_theme_shared.FormField,
703
- {
704
- label: t("AbpTenantManagement::TenantName"),
705
- htmlFor: "tenant-name",
706
- invalid: !!tenantNameError,
707
- errorText: tenantNameError || void 0,
708
- required: true,
709
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
710
- import_react3.Input,
780
+ const renderTenantForm = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react3.VStack, { gap: 4, align: "stretch", children: [
781
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
782
+ import_theme_shared.FormField,
783
+ {
784
+ label: t("AbpTenantManagement::TenantName"),
785
+ htmlFor: "tenant-name",
786
+ invalid: !!tenantNameError,
787
+ errorText: tenantNameError || void 0,
788
+ required: true,
789
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
790
+ import_react3.Input,
791
+ {
792
+ id: "tenant-name",
793
+ value: tenantName,
794
+ onChange: handleTenantNameChange,
795
+ placeholder: t("AbpTenantManagement::TenantName"),
796
+ maxLength: 256
797
+ }
798
+ )
799
+ }
800
+ ),
801
+ !isEditing && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
802
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
803
+ import_theme_shared.FormField,
804
+ {
805
+ label: t("AbpTenantManagement::DisplayName:AdminEmailAddress"),
806
+ htmlFor: "admin-email",
807
+ invalid: !!adminEmailError,
808
+ errorText: adminEmailError || void 0,
809
+ required: true,
810
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
811
+ import_react3.Input,
812
+ {
813
+ id: "admin-email",
814
+ type: "email",
815
+ value: adminEmail,
816
+ onChange: handleAdminEmailChange,
817
+ placeholder: t("AbpTenantManagement::DisplayName:AdminEmailAddress")
818
+ }
819
+ )
820
+ }
821
+ ),
822
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
823
+ import_theme_shared.FormField,
711
824
  {
712
- id: "tenant-name",
713
- value: tenantName,
714
- onChange: handleTenantNameChange,
715
- placeholder: t("AbpTenantManagement::TenantName"),
716
- maxLength: 256
825
+ label: t("AbpTenantManagement::DisplayName:AdminPassword"),
826
+ htmlFor: "admin-password",
827
+ invalid: !!adminPasswordError,
828
+ errorText: adminPasswordError || void 0,
829
+ required: true,
830
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
831
+ import_react3.Input,
832
+ {
833
+ id: "admin-password",
834
+ type: "password",
835
+ value: adminPassword,
836
+ onChange: handleAdminPasswordChange,
837
+ placeholder: t("AbpTenantManagement::DisplayName:AdminPassword")
838
+ }
839
+ )
717
840
  }
718
841
  )
719
- }
720
- ) });
842
+ ] })
843
+ ] });
721
844
  const renderConnectionStringForm = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react3.VStack, { gap: 4, align: "stretch", children: [
722
845
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
723
846
  import_theme_shared.Checkbox,
package/dist/index.mjs CHANGED
@@ -1,6 +1,11 @@
1
1
  // src/services/tenant-management.service.ts
2
2
  var TenantManagementService = class {
3
3
  constructor(rest) {
4
+ /**
5
+ * The API name used for REST requests.
6
+ * @since 2.4.0
7
+ */
8
+ this.apiName = "default";
4
9
  this.rest = rest;
5
10
  }
6
11
  /**
@@ -549,6 +554,10 @@ function TenantManagementModal({
549
554
  const [currentView, setCurrentView] = useState2(initialView);
550
555
  const [tenantName, setTenantName] = useState2("");
551
556
  const [tenantNameError, setTenantNameError] = useState2(null);
557
+ const [adminEmail, setAdminEmail] = useState2("");
558
+ const [adminEmailError, setAdminEmailError] = useState2(null);
559
+ const [adminPassword, setAdminPassword] = useState2("");
560
+ const [adminPasswordError, setAdminPasswordError] = useState2(null);
552
561
  const [localConnectionString, setLocalConnectionString] = useState2("");
553
562
  const [localUseSharedDatabase, setLocalUseSharedDatabase] = useState2(true);
554
563
  const isEditing = !!tenantId;
@@ -572,6 +581,10 @@ function TenantManagementModal({
572
581
  reset();
573
582
  setTenantName("");
574
583
  setTenantNameError(null);
584
+ setAdminEmail("");
585
+ setAdminEmailError(null);
586
+ setAdminPassword("");
587
+ setAdminPasswordError(null);
575
588
  setLocalConnectionString("");
576
589
  setLocalUseSharedDatabase(true);
577
590
  }
@@ -602,6 +615,39 @@ function TenantManagementModal({
602
615
  },
603
616
  [t]
604
617
  );
618
+ const validateAdminEmail = useCallback2(
619
+ (email) => {
620
+ if (!email || email.trim().length === 0) {
621
+ setAdminEmailError(t("AbpValidation::ThisFieldIsRequired"));
622
+ return false;
623
+ }
624
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
625
+ if (!emailRegex.test(email)) {
626
+ setAdminEmailError(t("AbpValidation::ThisFieldIsNotAValidEmailAddress"));
627
+ return false;
628
+ }
629
+ setAdminEmailError(null);
630
+ return true;
631
+ },
632
+ [t]
633
+ );
634
+ const validateAdminPassword = useCallback2(
635
+ (password) => {
636
+ if (!password || password.length === 0) {
637
+ setAdminPasswordError(t("AbpValidation::ThisFieldIsRequired"));
638
+ return false;
639
+ }
640
+ if (password.length < 6) {
641
+ setAdminPasswordError(
642
+ t("AbpValidation::ThisFieldMustBeAStringWithAMinimumLengthOf{0}", "6")
643
+ );
644
+ return false;
645
+ }
646
+ setAdminPasswordError(null);
647
+ return true;
648
+ },
649
+ [t]
650
+ );
605
651
  const handleTenantSubmit = useCallback2(async () => {
606
652
  if (!validateTenantName(tenantName)) {
607
653
  return;
@@ -610,7 +656,16 @@ function TenantManagementModal({
610
656
  if (isEditing && tenantId) {
611
657
  result = await updateTenant({ id: tenantId, name: tenantName.trim() });
612
658
  } else {
613
- result = await createTenant({ name: tenantName.trim() });
659
+ const emailValid = validateAdminEmail(adminEmail);
660
+ const passwordValid = validateAdminPassword(adminPassword);
661
+ if (!emailValid || !passwordValid) {
662
+ return;
663
+ }
664
+ result = await createTenant({
665
+ name: tenantName.trim(),
666
+ adminEmailAddress: adminEmail.trim(),
667
+ adminPassword
668
+ });
614
669
  }
615
670
  if (result.success) {
616
671
  onSave?.();
@@ -618,9 +673,13 @@ function TenantManagementModal({
618
673
  }
619
674
  }, [
620
675
  tenantName,
676
+ adminEmail,
677
+ adminPassword,
621
678
  isEditing,
622
679
  tenantId,
623
680
  validateTenantName,
681
+ validateAdminEmail,
682
+ validateAdminPassword,
624
683
  createTenant,
625
684
  updateTenant,
626
685
  onSave,
@@ -660,6 +719,26 @@ function TenantManagementModal({
660
719
  },
661
720
  [tenantNameError, validateTenantName]
662
721
  );
722
+ const handleAdminEmailChange = useCallback2(
723
+ (e) => {
724
+ const value = e.target.value;
725
+ setAdminEmail(value);
726
+ if (adminEmailError) {
727
+ validateAdminEmail(value);
728
+ }
729
+ },
730
+ [adminEmailError, validateAdminEmail]
731
+ );
732
+ const handleAdminPasswordChange = useCallback2(
733
+ (e) => {
734
+ const value = e.target.value;
735
+ setAdminPassword(value);
736
+ if (adminPasswordError) {
737
+ validateAdminPassword(value);
738
+ }
739
+ },
740
+ [adminPasswordError, validateAdminPassword]
741
+ );
663
742
  const handleUseSharedDatabaseChange = useCallback2(() => {
664
743
  setLocalUseSharedDatabase((prev) => {
665
744
  const newValue = !prev;
@@ -672,26 +751,70 @@ function TenantManagementModal({
672
751
  const handleConnectionStringChange = useCallback2((e) => {
673
752
  setLocalConnectionString(e.target.value);
674
753
  }, []);
675
- const renderTenantForm = () => /* @__PURE__ */ jsx(VStack, { gap: 4, align: "stretch", children: /* @__PURE__ */ jsx(
676
- FormField,
677
- {
678
- label: t("AbpTenantManagement::TenantName"),
679
- htmlFor: "tenant-name",
680
- invalid: !!tenantNameError,
681
- errorText: tenantNameError || void 0,
682
- required: true,
683
- children: /* @__PURE__ */ jsx(
684
- Input,
754
+ const renderTenantForm = () => /* @__PURE__ */ jsxs(VStack, { gap: 4, align: "stretch", children: [
755
+ /* @__PURE__ */ jsx(
756
+ FormField,
757
+ {
758
+ label: t("AbpTenantManagement::TenantName"),
759
+ htmlFor: "tenant-name",
760
+ invalid: !!tenantNameError,
761
+ errorText: tenantNameError || void 0,
762
+ required: true,
763
+ children: /* @__PURE__ */ jsx(
764
+ Input,
765
+ {
766
+ id: "tenant-name",
767
+ value: tenantName,
768
+ onChange: handleTenantNameChange,
769
+ placeholder: t("AbpTenantManagement::TenantName"),
770
+ maxLength: 256
771
+ }
772
+ )
773
+ }
774
+ ),
775
+ !isEditing && /* @__PURE__ */ jsxs(Fragment, { children: [
776
+ /* @__PURE__ */ jsx(
777
+ FormField,
778
+ {
779
+ label: t("AbpTenantManagement::DisplayName:AdminEmailAddress"),
780
+ htmlFor: "admin-email",
781
+ invalid: !!adminEmailError,
782
+ errorText: adminEmailError || void 0,
783
+ required: true,
784
+ children: /* @__PURE__ */ jsx(
785
+ Input,
786
+ {
787
+ id: "admin-email",
788
+ type: "email",
789
+ value: adminEmail,
790
+ onChange: handleAdminEmailChange,
791
+ placeholder: t("AbpTenantManagement::DisplayName:AdminEmailAddress")
792
+ }
793
+ )
794
+ }
795
+ ),
796
+ /* @__PURE__ */ jsx(
797
+ FormField,
685
798
  {
686
- id: "tenant-name",
687
- value: tenantName,
688
- onChange: handleTenantNameChange,
689
- placeholder: t("AbpTenantManagement::TenantName"),
690
- maxLength: 256
799
+ label: t("AbpTenantManagement::DisplayName:AdminPassword"),
800
+ htmlFor: "admin-password",
801
+ invalid: !!adminPasswordError,
802
+ errorText: adminPasswordError || void 0,
803
+ required: true,
804
+ children: /* @__PURE__ */ jsx(
805
+ Input,
806
+ {
807
+ id: "admin-password",
808
+ type: "password",
809
+ value: adminPassword,
810
+ onChange: handleAdminPasswordChange,
811
+ placeholder: t("AbpTenantManagement::DisplayName:AdminPassword")
812
+ }
813
+ )
691
814
  }
692
815
  )
693
- }
694
- ) });
816
+ ] })
817
+ ] });
695
818
  const renderConnectionStringForm = () => /* @__PURE__ */ jsxs(VStack, { gap: 4, align: "stretch", children: [
696
819
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
697
820
  Checkbox,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Tenant Management module type definitions
3
- * Translated from @abp/ng.tenant-management v2.0.0
3
+ * Translated from @abp/ng.tenant-management v2.4.0
4
4
  */
5
5
  import type { ABP } from '@abpjs/core';
6
6
  /**
@@ -27,15 +27,25 @@ export declare namespace TenantManagement {
27
27
  }
28
28
  /**
29
29
  * Request payload for creating a new tenant
30
+ * @since 2.4.0 Added adminEmailAddress and adminPassword fields
30
31
  */
31
32
  interface AddRequest {
33
+ /** Admin email address for the new tenant */
34
+ adminEmailAddress: string;
35
+ /** Admin password for the new tenant */
36
+ adminPassword: string;
37
+ /** Tenant name */
32
38
  name: string;
33
39
  }
34
40
  /**
35
41
  * Request payload for updating an existing tenant
42
+ * @since 2.4.0 No longer extends AddRequest (only id and name needed for update)
36
43
  */
37
- interface UpdateRequest extends AddRequest {
44
+ interface UpdateRequest {
45
+ /** Tenant ID */
38
46
  id: string;
47
+ /** Tenant name */
48
+ name: string;
39
49
  }
40
50
  /**
41
51
  * Request payload for updating tenant's default connection string
@@ -2,10 +2,15 @@ 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 v1.0.0
5
+ * Translated from @abp/ng.tenant-management v2.4.0
6
6
  */
7
7
  export declare class TenantManagementService {
8
8
  private rest;
9
+ /**
10
+ * The API name used for REST requests.
11
+ * @since 2.4.0
12
+ */
13
+ apiName: string;
9
14
  constructor(rest: RestService);
10
15
  /**
11
16
  * Get all tenants (paginated)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/tenant-management",
3
- "version": "2.2.0",
3
+ "version": "2.4.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,11 +23,11 @@
23
23
  "dependencies": {
24
24
  "@chakra-ui/react": "^3.2.0",
25
25
  "@emotion/react": "^11.11.0",
26
- "@abpjs/theme-shared": "2.2.0",
27
- "@abpjs/core": "2.2.0"
26
+ "@abpjs/core": "2.4.0",
27
+ "@abpjs/theme-shared": "2.4.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@abp/ng.tenant-management": "2.2.0",
30
+ "@abp/ng.tenant-management": "2.4.0",
31
31
  "@testing-library/jest-dom": "^6.4.0",
32
32
  "@testing-library/react": "^14.2.0",
33
33
  "@types/react": "^18.2.0",