kcommons 14.18.0 → 14.18.1

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.
@@ -38,9 +38,9 @@ export declare enum TEMPORARY_WORKER_FORM_INCLUDE {
38
38
  last_updated_by_user = "last_updated_by_user"
39
39
  }
40
40
  export declare enum GENDER {
41
- male = "male",
42
- female = "female",
43
- other = "'other"
41
+ Male = "Male",
42
+ Female = "Female",
43
+ Other = "Other"
44
44
  }
45
45
  export interface ITemporaryWorkerFormFilter extends Partial<Pick<ITemporaryWorkerForm, "is_enabled">> {
46
46
  name?: string | null;
@@ -48,3 +48,55 @@ export interface ITemporaryWorkerFormFilter extends Partial<Pick<ITemporaryWorke
48
48
  }
49
49
  export interface ITemporaryWorkerFormFiltersWithPagination extends IPaginationFilters, ITemporaryWorkerFormFilter {
50
50
  }
51
+ export interface IVerifyAadhaarBody {
52
+ udf1: string;
53
+ udf2: string;
54
+ udf3: string;
55
+ }
56
+ export interface IAadhaarRequestUrlResponse {
57
+ txn_id: string;
58
+ api_category: string;
59
+ api_name: string;
60
+ billable: string;
61
+ message: string;
62
+ status: string;
63
+ result: {
64
+ url: string;
65
+ };
66
+ datetime: string;
67
+ }
68
+ export interface IAadhaarDataResponse {
69
+ txn_id: string;
70
+ api_category: string;
71
+ api_name: string;
72
+ billable: boolean;
73
+ message: string;
74
+ status: string;
75
+ result: {
76
+ aadhaar: string;
77
+ };
78
+ datetime: string;
79
+ }
80
+ export interface IAadhaarFetchDataBody {
81
+ txn_id: string;
82
+ }
83
+ export interface AadhaarParsedData {
84
+ first_name: string | null;
85
+ middle_name: string | null;
86
+ last_name: string | null;
87
+ dob: string | null;
88
+ gender: GENDER;
89
+ co: string | null;
90
+ house: string | null;
91
+ lm: string | null;
92
+ loc: string | null;
93
+ vtc: string | null;
94
+ dist: string | null;
95
+ state: string | null;
96
+ pc: string | null;
97
+ country: string | null;
98
+ image: string | null;
99
+ aadhaar: string | null;
100
+ }
101
+ export declare const parseAadhaarXML: (xmlString: string) => AadhaarParsedData | null;
102
+ export declare const calculateAge: (dob: string) => number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GENDER = exports.TEMPORARY_WORKER_FORM_INCLUDE = void 0;
3
+ exports.calculateAge = exports.parseAadhaarXML = exports.GENDER = exports.TEMPORARY_WORKER_FORM_INCLUDE = void 0;
4
4
  var TEMPORARY_WORKER_FORM_INCLUDE;
5
5
  (function (TEMPORARY_WORKER_FORM_INCLUDE) {
6
6
  TEMPORARY_WORKER_FORM_INCLUDE["company"] = "company";
@@ -9,7 +9,72 @@ var TEMPORARY_WORKER_FORM_INCLUDE;
9
9
  })(TEMPORARY_WORKER_FORM_INCLUDE || (exports.TEMPORARY_WORKER_FORM_INCLUDE = TEMPORARY_WORKER_FORM_INCLUDE = {}));
10
10
  var GENDER;
11
11
  (function (GENDER) {
12
- GENDER["male"] = "male";
13
- GENDER["female"] = "female";
14
- GENDER["other"] = "'other";
12
+ GENDER["Male"] = "Male";
13
+ GENDER["Female"] = "Female";
14
+ GENDER["Other"] = "Other";
15
15
  })(GENDER || (exports.GENDER = GENDER = {}));
16
+ const parseAadhaarXML = (xmlString) => {
17
+ const parser = new DOMParser();
18
+ const xml = parser.parseFromString(xmlString, "text/xml");
19
+ const poi = xml.querySelector("Poi");
20
+ const poa = xml.querySelector("Poa");
21
+ const pht = xml.querySelector("Pht");
22
+ const uidData = xml.querySelector("UidData");
23
+ if (!poi || !poa || !pht || !uidData)
24
+ return null;
25
+ const genderCode = poi.getAttribute("gender");
26
+ const full_name = poi.getAttribute("name");
27
+ const parts = full_name ? full_name.trim().split(/\s+/) : "";
28
+ const first_name = parts[0] || "";
29
+ const middle_name = parts.length === 3 ? parts[1] : "";
30
+ const last_name = parts.length >= 2 ? parts[parts.length - 1] : "";
31
+ return {
32
+ // POI
33
+ first_name: first_name,
34
+ middle_name: middle_name,
35
+ last_name: last_name,
36
+ dob: poi.getAttribute("dob"),
37
+ gender: genderCode === "M"
38
+ ? GENDER.Male
39
+ : genderCode === "F"
40
+ ? GENDER.Female
41
+ : GENDER.Other,
42
+ // POA
43
+ co: poa.getAttribute("co"),
44
+ house: poa.getAttribute("house"),
45
+ lm: poa.getAttribute("lm"),
46
+ loc: poa.getAttribute("loc"),
47
+ vtc: poa.getAttribute("vtc"),
48
+ dist: poa.getAttribute("dist"),
49
+ state: poa.getAttribute("state"),
50
+ pc: poa.getAttribute("pc"),
51
+ country: poa.getAttribute("country"),
52
+ // PHT
53
+ image: pht.textContent || null,
54
+ // UID
55
+ aadhaar: uidData.getAttribute("uid"),
56
+ };
57
+ };
58
+ exports.parseAadhaarXML = parseAadhaarXML;
59
+ const calculateAge = (dob) => {
60
+ let birthDate = null;
61
+ // Case 1: ISO format (YYYY-MM-DD) → JS can parse safely
62
+ if (/^\d{4}-\d{2}-\d{2}$/.test(dob)) {
63
+ birthDate = new Date(dob);
64
+ }
65
+ // Case 2: DD-MM-YYYY (manual parse)
66
+ else if (/^\d{2}-\d{2}-\d{4}$/.test(dob)) {
67
+ const [day, month, year] = dob.split("-").map(Number);
68
+ birthDate = new Date(year, month - 1, day);
69
+ }
70
+ if (!birthDate || isNaN(birthDate.getTime()))
71
+ return 0;
72
+ const today = new Date();
73
+ let age = today.getFullYear() - birthDate.getFullYear();
74
+ const m = today.getMonth() - birthDate.getMonth();
75
+ if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
76
+ age--;
77
+ }
78
+ return age;
79
+ };
80
+ exports.calculateAge = calculateAge;
@@ -39,17 +39,17 @@ export interface IUdyamApiResponsev2 {
39
39
  export interface MSMEData {
40
40
  udyam_number: string;
41
41
  dic: string;
42
- 'date_of_commencement_of_production/business': string;
42
+ "date_of_commencement_of_production/business": string;
43
43
  date_of_incorporation: string;
44
44
  date_of_udyam_registration: string;
45
45
  gender: string;
46
- 'msme-dfo': string;
46
+ "msme-dfo": string;
47
47
  major_activity: string;
48
48
  name_of_enterprise: string;
49
49
  organisation_type: string;
50
50
  social_category: string;
51
51
  udyam_registration_number: string;
52
- 'unit/plant_locations_details': UnitPlantLocation[];
52
+ "unit/plant_locations_details": UnitPlantLocation[];
53
53
  enterprise_type: EnterpriseType[];
54
54
  national_industry_classification_code: NationalIndustryClassificationCode[];
55
55
  official_address_of_enterprise: OfficialAddress;
@@ -60,7 +60,7 @@ export interface UnitPlantLocation {
60
60
  unit_name: string;
61
61
  flat: string;
62
62
  building: string;
63
- 'village/town': string;
63
+ "village/town": string;
64
64
  block: string;
65
65
  road: string;
66
66
  city: string;
@@ -69,14 +69,14 @@ export interface UnitPlantLocation {
69
69
  district: string;
70
70
  }
71
71
  export interface EnterpriseType {
72
- 'sno.': string;
72
+ "sno.": string;
73
73
  data_year: string;
74
74
  classification_year: string;
75
75
  enterprise_type: string;
76
76
  classification_date: string;
77
77
  }
78
78
  export interface NationalIndustryClassificationCode {
79
- 'sno.': string;
79
+ "sno.": string;
80
80
  nic_2_digit: string;
81
81
  nic_4_digit: string;
82
82
  nic_5_digit: string;
@@ -84,11 +84,11 @@ export interface NationalIndustryClassificationCode {
84
84
  date: string;
85
85
  }
86
86
  export interface OfficialAddress {
87
- 'flat/door/block_no.': string;
88
- 'name_of_premises/_building': string;
89
- 'village/town': string;
87
+ "flat/door/block_no.": string;
88
+ "name_of_premises/_building": string;
89
+ "village/town": string;
90
90
  block: string;
91
- 'road/street/lane': string;
91
+ "road/street/lane": string;
92
92
  city: string;
93
93
  state: string;
94
94
  district: string;
@@ -96,3 +96,6 @@ export interface OfficialAddress {
96
96
  mobile: string;
97
97
  email: string;
98
98
  }
99
+ export interface IVerifyUdyamReq {
100
+ udyam_no: string;
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kcommons",
3
- "version": "14.18.0",
3
+ "version": "14.18.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",