diff --git a/package.json b/package.json index 26c7228..a328787 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "eslint": "^9.7.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jsdoc": "^48.7.0", + "hotscript": "^1.0.13", "prettier": "^3.3.3", "tsup": "^8.2.3", "typescript": "^5.5.3", diff --git a/src/bill/getBillList.spec.ts b/src/bill/getBillList.spec.ts index 240efb7..9974eff 100644 --- a/src/bill/getBillList.spec.ts +++ b/src/bill/getBillList.spec.ts @@ -1,7 +1,31 @@ import { describe, it, expect, vi } from 'vitest'; import { getBillList } from './getBillList'; import { callOpenApi } from '../functional'; -import { translatedVariableDictionary } from '../constant'; +import { + 대, + 대표발의자, + 대표발의자코드, + 법사위상정일, + 법사위처리결과, + 법사위처리일, + 법사위회부일, + 본회의심의결과, + 소관위, + 소관위상정일, + 소관위처리결과, + 소관위처리일, + 소관위코드, + 소관위회부일, + 위원회심사_처리일, + 의결일, + 의안ID, + 의안명, + 의안번호, + 의안상세정보_URL, + 제안일, + 제안자, + 제안자구분, +} from '../constant'; vi.mock('../functional', () => ({ callOpenApi: vi.fn(), @@ -50,30 +74,29 @@ describe('getBillList', () => { expect(bills).toHaveLength(1); expect(bills[0]).toEqual({ - [translatedVariableDictionary['의안ID']]: 'PRC_K2S4R0S4Q3P0L0K9J0J9I5Q7P2Q4O6', - [translatedVariableDictionary['의안번호']]: '2126707', - [translatedVariableDictionary['대']]: '21', - [translatedVariableDictionary['의안명']]: '문화다양성의 보호와 증진에 관한 법률 일부개정법률안', - [translatedVariableDictionary['제안자']]: '이자스민의원 등 10인', - [translatedVariableDictionary['제안자구분']]: '의원', - [translatedVariableDictionary['제안일']]: '2024-05-29', - [translatedVariableDictionary['소관위코드']]: '9700513', - [translatedVariableDictionary['소관위']]: '문화체육관광위원회', - [translatedVariableDictionary['소관위회부일']]: '2024-05-29', - [translatedVariableDictionary['위원회심사_처리일']]: null, - [translatedVariableDictionary['의안상세정보_URL']]: - 'https://likms.assembly.go.kr/bill/billDetail.do?billId=PRC_K2S4R0S4Q3P0L0K9J0J9I5Q7P2Q4O6', - [translatedVariableDictionary['대표발의자']]: '이자스민', - [translatedVariableDictionary['법사위처리결과']]: null, - [translatedVariableDictionary['법사위처리일']]: null, - [translatedVariableDictionary['법사위상정일']]: null, - [translatedVariableDictionary['법사위회부일']]: null, - [translatedVariableDictionary['소관위처리결과']]: null, - [translatedVariableDictionary['소관위처리일']]: null, - [translatedVariableDictionary['소관위상정일']]: null, - [translatedVariableDictionary['대표발의자코드']]: 'SZ51175J', - [translatedVariableDictionary['본회의심의결과']]: '임기만료폐기', - [translatedVariableDictionary['의결일']]: '2024-05-29', + [의안ID]: 'PRC_K2S4R0S4Q3P0L0K9J0J9I5Q7P2Q4O6', + [의안번호]: '2126707', + [대]: '21', + [의안명]: '문화다양성의 보호와 증진에 관한 법률 일부개정법률안', + [제안자]: '이자스민의원 등 10인', + [제안자구분]: '의원', + [제안일]: '2024-05-29', + [소관위코드]: '9700513', + [소관위]: '문화체육관광위원회', + [소관위회부일]: '2024-05-29', + [위원회심사_처리일]: null, + [의안상세정보_URL]: 'https://likms.assembly.go.kr/bill/billDetail.do?billId=PRC_K2S4R0S4Q3P0L0K9J0J9I5Q7P2Q4O6', + [대표발의자]: '이자스민', + [법사위처리결과]: null, + [법사위처리일]: null, + [법사위상정일]: null, + [법사위회부일]: null, + [소관위처리결과]: null, + [소관위처리일]: null, + [소관위상정일]: null, + [대표발의자코드]: 'SZ51175J', + [본회의심의결과]: '임기만료폐기', + [의결일]: '2024-05-29', }); }); diff --git a/src/bill/getBillList.ts b/src/bill/getBillList.ts index 9d36dbd..9d9904b 100644 --- a/src/bill/getBillList.ts +++ b/src/bill/getBillList.ts @@ -1,6 +1,30 @@ import { callOpenApi } from '../functional'; import { PaginationType } from '../types/callOpenApi'; -import { translatedVariableDictionary } from '../constant'; +import { + 대, + 대표발의자, + 대표발의자코드, + 법사위상정일, + 법사위처리결과, + 법사위처리일, + 법사위회부일, + 본회의심의결과, + 소관위, + 소관위상정일, + 소관위처리결과, + 소관위처리일, + 소관위코드, + 소관위회부일, + 위원회심사_처리일, + 의결일, + 의안ID, + 의안명, + 의안번호, + 의안상세정보_URL, + 제안일, + 제안자, + 제안자구분, +} from '../constant'; // https://open.assembly.go.kr/portal/data/service/selectAPIServicePage.do/O4K6HM0012064I15889 // 법률안 심사 및 처리(의안검색) 구현 @@ -51,29 +75,29 @@ type Argument = { const command = 'TVBPMBILL11'; const transform = (v: Row) => ({ - [translatedVariableDictionary['의안ID']]: v.BILL_ID, - [translatedVariableDictionary['의안번호']]: v.BILL_NO, - [translatedVariableDictionary['대']]: v.AGE, - [translatedVariableDictionary['의안명']]: v.BILL_NAME, - [translatedVariableDictionary['제안자']]: v.PROPOSER, - [translatedVariableDictionary['제안자구분']]: v.PROPOSER_KIND, - [translatedVariableDictionary['제안일']]: v.PROPOSE_DT, - [translatedVariableDictionary['소관위코드']]: v.CURR_COMMITTEE_ID, - [translatedVariableDictionary['소관위']]: v.CURR_COMMITTEE, - [translatedVariableDictionary['소관위회부일']]: v.COMMITTEE_DT, - [translatedVariableDictionary['위원회심사_처리일']]: v.COMMITTEE_PROC_DT, - [translatedVariableDictionary['의안상세정보_URL']]: v.LINK_URL, - [translatedVariableDictionary['대표발의자']]: v.RST_PROPOSER, - [translatedVariableDictionary['법사위처리결과']]: v.LAW_PROC_RESULT_CD, - [translatedVariableDictionary['법사위처리일']]: v.LAW_PROC_DT, - [translatedVariableDictionary['법사위상정일']]: v.LAW_PRESENT_DT, - [translatedVariableDictionary['법사위회부일']]: v.LAW_SUBMIT_DT, - [translatedVariableDictionary['소관위처리결과']]: v.CMT_PROC_RESULT_CD, - [translatedVariableDictionary['소관위처리일']]: v.CMT_PROC_DT, - [translatedVariableDictionary['소관위상정일']]: v.CMT_PRESENT_DT, - [translatedVariableDictionary['대표발의자코드']]: v.RST_MONA_CD, - [translatedVariableDictionary['본회의심의결과']]: v.PROC_RESULT_CD, - [translatedVariableDictionary['의결일']]: v.PROC_DT, + [의안ID]: v.BILL_ID, + [의안번호]: v.BILL_NO, + [대]: v.AGE, + [의안명]: v.BILL_NAME, + [제안자]: v.PROPOSER, + [제안자구분]: v.PROPOSER_KIND, + [제안일]: v.PROPOSE_DT, + [소관위코드]: v.CURR_COMMITTEE_ID, + [소관위]: v.CURR_COMMITTEE, + [소관위회부일]: v.COMMITTEE_DT, + [위원회심사_처리일]: v.COMMITTEE_PROC_DT, + [의안상세정보_URL]: v.LINK_URL, + [대표발의자]: v.RST_PROPOSER, + [법사위처리결과]: v.LAW_PROC_RESULT_CD, + [법사위처리일]: v.LAW_PROC_DT, + [법사위상정일]: v.LAW_PRESENT_DT, + [법사위회부일]: v.LAW_SUBMIT_DT, + [소관위처리결과]: v.CMT_PROC_RESULT_CD, + [소관위처리일]: v.CMT_PROC_DT, + [소관위상정일]: v.CMT_PRESENT_DT, + [대표발의자코드]: v.RST_MONA_CD, + [본회의심의결과]: v.PROC_RESULT_CD, + [의결일]: v.PROC_DT, }); /** @@ -96,5 +120,5 @@ export const getBillList = async ({ page, take, ...rest }: Argument) => { PROC_DT: rest.resolutionDate, } ); - return res.TVBPMBILL11[1].row.map(transform); + return res[command][1].row.map(transform); }; diff --git a/src/bill/index.spec.ts b/src/bill/index.spec.ts deleted file mode 100644 index 46c7995..0000000 --- a/src/bill/index.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -// src/bill/index.spec.ts -import { describe, it, expect } from 'vitest'; -import { getBillList } from './index'; - -describe('bill index.ts', () => { - it('should export getBillList', () => { - expect(getBillList).toBeDefined(); - }); -}); diff --git a/src/constant/index.ts b/src/constant/index.ts index 4e85c48..e6ce9b0 100644 --- a/src/constant/index.ts +++ b/src/constant/index.ts @@ -1,71 +1 @@ -/** - * @description if you modify this properties, you should upgrade the minor version because it will be a break changes - * @ignore `~명`과 같은 이름을 지칭하는 변수의 경우 `Name`으로 끝나야함, 예외적으로 구분명은 `Division`으로 끝남 - * @ignore `~코드`와 같은 이름을 지칭하는 변수의 경우 `Code`로 끝나야함 - * @ignore `~일자`와 같은 이름을 지칭하는 변수의 경우 `Date`로 끝나야함 - * @ignore `~구분`과 같은 이름을 지칭하는 변수의 경우 `Division`으로 끝나야함, 만약 `구분명`이라면 `Division`을 사용 - * @ignore `~처리`과 같은 이름을 지칭하는 변수의 경우 `Process`으로 끝나야함 - * @ignore `~상정`과 같은 이름을 지칭하는 변수의 경우 `Present`으로 끝나야함 - * @ignore `~회부`과 같은 이름을 지칭하는 변수의 경우 `Submit`으로 끝나야함 - * @ignore `~의결`과 같은 이름을 지칭하는 변수의 경우 `Resolution`으로 끝나야함 - */ -export const translatedVariableDictionary = { - 국회의원코드: 'lawmakerCode', - 국회의원명: 'lawmakerName', - 국회의원한자명: 'lawmakerChineseName', - 국회의원영문명: 'lawmakerEnglishName', - 생일구분코드: 'birthdayDivisionCode', - 생일일자: 'birthday', - 직책명: 'dutyName', - 정당명: 'politicalPartyName', - 선거구명: 'electoralDistrictName', - 선거구구분명: 'electoralDistrictDivisionName', - 위원회명: 'committeeName', - 소속위원회명: 'belongingCommitteeName', - 재선구분명: 'reElectionClassificationDivision', - 당선대수: 'electionCongress', - 성별: 'gender', - 전화번호: 'phoneNumber', - 국회의원이메일주소: 'email', - 국회의원홈페이지URL: 'homepage', - 보좌관: 'aide', - 비서관: 'seniorSecretary', - 비서: 'secretary', - 약력: 'profile', - 사무실호실: 'officeRoom', - 사진: 'picture', - - // 의안 관련 추가 - 의안ID: 'billID', - 의안번호: 'billNumber', - 대: 'age', - 의안명: 'billName', - 제안자: 'proposer', - 제안자구분: 'proposerDivision', - 제안일: 'proposeDate', - 소관위코드: 'jurisdictionCommitteeCode', - 소관위: 'jurisdictionCommittee', - 소관위회부일: 'jurisdictionCommitteeSubmitDate', - 위원회심사_처리일: 'committeeReviewProcessDate', - 의안상세정보_URL: 'billDetailUrl', - 대표발의자: 'leadProposer', - 법사위처리결과: 'legislationAndJudiciaryCommitteeProcessResult', - 법사위처리일: 'legislationAndJudiciaryCommitteeProcessDate', - 법사위상정일: 'legislationAndJudiciaryCommitteePresentDate', - 법사위회부일: 'legislationAndJudiciaryCommitteeSubmitDate', - 소관위처리결과: 'jurisdictionCommitteeProcessResult', - 소관위처리일: 'jurisdictionCommitteeProcessDate', - 소관위상정일: 'jurisdictionCommitteePresentDate', - 대표발의자코드: 'leadProposerCode', - 본회의심의결과: 'plenarySessionReviewResult', - 의결일: 'resolutionDate', - 일정_종류: 'scheduleType', - 일정_내용: 'scheduleContent', - 일정_일자: 'scheduleDate', - 일정_시간: 'scheduleTime', - 회의_구분: 'conferenceDivision', - 회의_회기: 'conferenceSession', - 회의_차수: 'conferenceDegree', - 행사_주체자: 'eventInstitution', - 행사_장소: 'eventPlace', -} as const; +export * from './translatedVariableDictionary'; diff --git a/src/constant/translatedVariableDictionary/index.ts b/src/constant/translatedVariableDictionary/index.ts new file mode 100644 index 0000000..399a6a2 --- /dev/null +++ b/src/constant/translatedVariableDictionary/index.ts @@ -0,0 +1,95 @@ +/** + * @description if you modify this properties, you should upgrade the minor version because it will be a break changes + */ + +import { variable } from './variable'; + +const 국회의원 = 'lawmaker'; +const 코드 = 'code'; +const 명 = 'name'; +const 한자명 = variable(`chinese`, 명); +const 영문명 = variable(`english`, 명); +const 구분 = 'division'; +const 구분명 = `${구분}`; +const 생일 = 'birthday'; +const 직책 = 'duty'; +const 정당 = 'politicalParty'; +const 선거구 = 'electoralDistrict'; +const 위원회 = 'committee'; +const 소속위원회 = 'belongingCommittee'; +const 선거 = 'election'; +const 재선 = variable(`re`, 선거); +const 의안 = `bill`; +const 번호 = 'number'; +const 소관위원회 = variable(`jurisdiction`, 위원회); +const 법제사법위원회 = variable(`legislationAndJudiciary`, 위원회); +const 처리 = 'process'; +const 일자 = `date`; +const 처리결과 = variable(처리, `result`); +const 처리일 = variable(처리, 일자); +const 회부일 = variable(`submit`, 일자); +const 상정일 = variable(`present`, 일자); + +const 일정 = 'schedule'; +const 시간 = 'time'; +const 회의 = 'conference'; +const 행사 = 'event'; + +export const 국회의원코드 = variable(국회의원, 코드); +export const 국회의원명 = variable(국회의원, 명); +export const 국회의원한자명 = variable(국회의원, 한자명); +export const 국회의원영문명 = variable(국회의원, 영문명); +export const 생일구분코드 = variable(생일, 구분, 코드); +export const 생일일자 = variable(생일); +export const 직책명 = variable(직책, 명); +export const 정당명 = variable(정당, 명); +export const 선거구명 = variable(선거구, 명); +export const 선거구구분명 = variable(선거구, 구분명); +export const 위원회명 = variable(위원회, 명); +export const 소속위원회명 = variable(소속위원회, 명); +export const 재선구분명 = variable(재선, 구분명); +export const 당선대수 = variable(선거, 'congress'); +export const 성별 = 'gender'; +export const 전화번호 = 'phoneNumber'; +export const 국회의원이메일주소 = 'email'; +export const 국회의원홈페이지URL = 'homepage'; +export const 보좌관 = 'aide'; +export const 비서관 = 'seniorSecretary'; +export const 비서 = 'secretary'; +export const 약력 = 'profile'; +export const 사무실호실 = 'officeRoom'; +export const 사진 = 'picture'; + +export const 의안ID = variable(의안, 'ID'); +export const 의안번호 = variable(의안, 번호); +export const 대 = 'age'; +export const 의안명 = variable(의안, 명); +export const 제안자 = variable('proposer'); +export const 대표발의자 = variable(`lead`, 제안자); +export const 제안자구분 = variable(제안자, 구분); +export const 제안일 = 'proposeDate'; +export const 소관위코드 = variable(소관위원회, 코드); +export const 소관위 = variable(소관위원회); +export const 소관위회부일 = variable(소관위원회, 회부일); +export const 위원회심사_처리일 = variable(위원회, 'review', 처리일); +export const 의안상세정보_URL = variable(의안, 'detailUrl'); +export const 법사위처리결과 = variable(법제사법위원회, 처리결과); +export const 법사위처리일 = variable(법제사법위원회, 처리일); +export const 법사위상정일 = variable(법제사법위원회, 상정일); +export const 법사위회부일 = variable(법제사법위원회, 회부일); +export const 소관위처리결과 = variable(소관위원회, 처리결과); +export const 소관위처리일 = variable(소관위원회, 처리일); +export const 소관위상정일 = variable(소관위원회, 상정일); +export const 대표발의자코드 = variable(대표발의자, 코드); +export const 본회의심의결과 = 'plenarySessionReviewResult'; +export const 의결일 = 'resolutionDate'; + +export const 일정_종류 = variable(일정, 'type'); +export const 일정_내용 = variable(일정, 'content'); +export const 일정_일자 = variable(일정, 일자); +export const 일정_시간 = variable(일정, 시간); +export const 회의_구분 = variable(회의, 구분); +export const 회의_회기 = variable(회의, 'session'); +export const 회의_차수 = variable(회의, 'degree'); +export const 행사_주체자 = variable(행사, 'institution'); +export const 행사_장소 = variable(행사, 'place'); diff --git a/src/constant/translatedVariableDictionary/translatedVariableDictionary.spec.ts b/src/constant/translatedVariableDictionary/translatedVariableDictionary.spec.ts new file mode 100644 index 0000000..2f5517a --- /dev/null +++ b/src/constant/translatedVariableDictionary/translatedVariableDictionary.spec.ts @@ -0,0 +1,69 @@ +import { describe, it, expectTypeOf, expect } from 'vitest'; +import * as H from 'hotscript'; + +import { + 국회의원명, + 국회의원영문명, + 국회의원코드, + 국회의원한자명, + 당선대수, + 생일구분코드, + 위원회심사_처리일, +} from './index'; +import { variable } from './variable'; + +describe('variable function', () => { + it('should return correct variable name for single argument', () => { + const result = variable('test'); + expect(result).toBe('test'); + }); + + it('should return correct variable name for multiple arguments', () => { + const result = variable('foo', 'bar', 'baz'); + expect(result).toBe('fooBarBaz'); + }); + + it('should handle string arguments correctly', () => { + const result = variable('Hello', 'World'); + expect(result).toBe('helloWorld'); + }); + + it('should return correct type for single argument', () => { + const result: H.Call = variable('test'); + expect(typeof result).toBe('string'); + }); + + it('should return correct type for multiple arguments', () => { + const result: H.Pipe< + ['foo', 'bar', 'baz'], + [H.Tuples.Map, H.Tuples.Join<''>, H.Strings.Uncapitalize] + > = variable('foo', 'bar', 'baz'); + expect(typeof result).toBe('string'); + }); +}); + +describe('translatedVariableDictionary', () => { + it('should have correct types', () => { + // Test the types of individual properties + expectTypeOf(국회의원코드).toEqualTypeOf<'lawmakerCode'>(); + expect(국회의원코드).toBe('lawmakerCode'); + + expectTypeOf(국회의원명).toEqualTypeOf<'lawmakerName'>(); + expect(국회의원명).toBe('lawmakerName'); + + expectTypeOf(국회의원한자명).toEqualTypeOf<'lawmakerChineseName'>(); + expect(국회의원한자명).toBe('lawmakerChineseName'); + + expectTypeOf(국회의원영문명).toEqualTypeOf<'lawmakerEnglishName'>(); + expect(국회의원영문명).toBe('lawmakerEnglishName'); + + expectTypeOf(생일구분코드).toEqualTypeOf<'birthdayDivisionCode'>(); + expect(생일구분코드).toBe('birthdayDivisionCode'); + + expectTypeOf(당선대수).toEqualTypeOf<'electionCongress'>(); + expect(당선대수).toBe('electionCongress'); + + expectTypeOf(위원회심사_처리일).toEqualTypeOf<'committeeReviewProcessDate'>(); + expect(위원회심사_처리일).toBe('committeeReviewProcessDate'); + }); +}); diff --git a/src/constant/translatedVariableDictionary/variable.ts b/src/constant/translatedVariableDictionary/variable.ts new file mode 100644 index 0000000..4a9e253 --- /dev/null +++ b/src/constant/translatedVariableDictionary/variable.ts @@ -0,0 +1,10 @@ +import * as H from 'hotscript'; + +export const variable = >(...args: Args) => + args.reduce( + (prev, cur, idx) => + idx === 0 + ? `${cur.charAt(0).toLowerCase()}${cur.slice(1)}` + : `${prev}${cur.charAt(0).toUpperCase()}${cur.slice(1)}`, + '' + ) as H.Pipe, H.Tuples.Join<''>, H.Strings.Uncapitalize]>; diff --git a/src/lawmaker/getLawmakerList.spec.ts b/src/lawmaker/getLawmakerList.spec.ts index 1f5aeb1..79d10de 100644 --- a/src/lawmaker/getLawmakerList.spec.ts +++ b/src/lawmaker/getLawmakerList.spec.ts @@ -1,7 +1,31 @@ import { describe, it, expect, vi } from 'vitest'; import { getLawmakerList } from './getLawmakerList'; import { callOpenApi } from '../functional'; -import { translatedVariableDictionary } from '../constant'; +import { + 국회의원명, + 국회의원영문명, + 국회의원이메일주소, + 국회의원코드, + 국회의원한자명, + 국회의원홈페이지URL, + 보좌관, + 비서, + 비서관, + 사무실호실, + 사진, + 생일구분코드, + 생일일자, + 선거구구분명, + 선거구명, + 성별, + 소속위원회명, + 약력, + 위원회명, + 재선구분명, + 전화번호, + 정당명, + 직책명, +} from '../constant'; vi.mock('../functional', () => ({ callOpenApi: vi.fn(), @@ -50,29 +74,29 @@ describe('getLawmakerList', () => { expect(lawmakers).toHaveLength(1); expect(lawmakers[0]).toEqual({ - [translatedVariableDictionary['국회의원코드']]: '1234', - [translatedVariableDictionary['국회의원명']]: 'John Doe', - [translatedVariableDictionary['국회의원한자명']]: '张三', - [translatedVariableDictionary['국회의원영문명']]: 'John Doe', - [translatedVariableDictionary['생일구분코드']]: '1', - [translatedVariableDictionary['생일일자']]: '1990-01-01', - [translatedVariableDictionary['직책명']]: 'Lawmaker', - [translatedVariableDictionary['정당명']]: 'Democratic Party', - [translatedVariableDictionary['선거구명']]: 'District A', - [translatedVariableDictionary['선거구구분명']]: 'District', - [translatedVariableDictionary['위원회명']]: 'Committee A', - [translatedVariableDictionary['소속위원회명']]: 'Committee A', - [translatedVariableDictionary['재선구분명']]: 'First-term', - [translatedVariableDictionary['성별']]: 'Male', - [translatedVariableDictionary['전화번호']]: '123-456-7890', - [translatedVariableDictionary['국회의원이메일주소']]: 'john.doe@example.com', - [translatedVariableDictionary['국회의원홈페이지URL']]: 'https://example.com/john-doe', - [translatedVariableDictionary['보좌관']]: 'Jane Smith', - [translatedVariableDictionary['비서관']]: 'Bob Johnson', - [translatedVariableDictionary['비서']]: 'Alice Williams', - [translatedVariableDictionary['약력']]: 'John Doe is a lawmaker.', - [translatedVariableDictionary['사무실호실']]: '123', - [translatedVariableDictionary['사진']]: 'https://example.com/john-doe.jpg', + [국회의원코드]: '1234', + [국회의원명]: 'John Doe', + [국회의원한자명]: '张三', + [국회의원영문명]: 'John Doe', + [생일구분코드]: '1', + [생일일자]: '1990-01-01', + [직책명]: 'Lawmaker', + [정당명]: 'Democratic Party', + [선거구명]: 'District A', + [선거구구분명]: 'District', + [위원회명]: 'Committee A', + [소속위원회명]: 'Committee A', + [재선구분명]: 'First-term', + [성별]: 'Male', + [전화번호]: '123-456-7890', + [국회의원이메일주소]: 'john.doe@example.com', + [국회의원홈페이지URL]: 'https://example.com/john-doe', + [보좌관]: 'Jane Smith', + [비서관]: 'Bob Johnson', + [비서]: 'Alice Williams', + [약력]: 'John Doe is a lawmaker.', + [사무실호실]: '123', + [사진]: 'https://example.com/john-doe.jpg', }); }); it('should return an empty list when no lawmakers are found', async () => { diff --git a/src/lawmaker/getLawmakerList.ts b/src/lawmaker/getLawmakerList.ts index f4c1e4e..a6831ce 100644 --- a/src/lawmaker/getLawmakerList.ts +++ b/src/lawmaker/getLawmakerList.ts @@ -1,6 +1,31 @@ import { callOpenApi } from '../functional'; import { PaginationType } from '../types/callOpenApi'; -import { translatedVariableDictionary } from '../constant/index'; +import { + 국회의원명, + 국회의원영문명, + 국회의원이메일주소, + 국회의원코드, + 국회의원한자명, + 국회의원홈페이지URL, + 당선대수, + 보좌관, + 비서, + 비서관, + 사무실호실, + 사진, + 생일구분코드, + 생일일자, + 선거구구분명, + 선거구명, + 성별, + 소속위원회명, + 약력, + 위원회명, + 재선구분명, + 전화번호, + 정당명, + 직책명, +} from '../constant'; interface Lawmaker { NAAS_CD: string; // 국회의원코드 @@ -43,30 +68,30 @@ type Argument = { const command = 'ALLNAMEMBER'; const transform = (v: Row) => ({ - [translatedVariableDictionary['국회의원코드']]: v.NAAS_CD, - [translatedVariableDictionary['국회의원명']]: v.NAAS_NM, - [translatedVariableDictionary['국회의원한자명']]: v.NAAS_CH_NM, - [translatedVariableDictionary['국회의원영문명']]: v.NAAS_EN_NM, - [translatedVariableDictionary['생일구분코드']]: v.BIRDY_DIV_CD, - [translatedVariableDictionary['생일일자']]: v.BIRDY_DT, - [translatedVariableDictionary['직책명']]: v.DTY_NM, - [translatedVariableDictionary['정당명']]: v.PLPT_NM, - [translatedVariableDictionary['선거구명']]: v.ELECD_NM, - [translatedVariableDictionary['선거구구분명']]: v.ELECD_DIV_NM, - [translatedVariableDictionary['위원회명']]: v.CMIT_NM, - [translatedVariableDictionary['소속위원회명']]: v.BLNG_CMIT_NM, - [translatedVariableDictionary['재선구분명']]: v.RLCT_DIV_NM, - [translatedVariableDictionary['당선대수']]: v.GTELT_ERACO, // 당선대수 - [translatedVariableDictionary['성별']]: v.NTR_DIV, - [translatedVariableDictionary['전화번호']]: v.NAAS_TEL_NO, - [translatedVariableDictionary['국회의원이메일주소']]: v.NAAS_EMAIL_ADDR, - [translatedVariableDictionary['국회의원홈페이지URL']]: v.NAAS_HP_URL, - [translatedVariableDictionary['보좌관']]: v.AIDE_NM, - [translatedVariableDictionary['비서관']]: v.CHF_SCRT_NM, - [translatedVariableDictionary['비서']]: v.SCRT_NM, - [translatedVariableDictionary['약력']]: v.BRF_HST, - [translatedVariableDictionary['사무실호실']]: v.OFFM_RNUM_NO, - [translatedVariableDictionary['사진']]: v.NAAS_PIC, + [국회의원코드]: v.NAAS_CD, + [국회의원명]: v.NAAS_NM, + [국회의원한자명]: v.NAAS_CH_NM, + [국회의원영문명]: v.NAAS_EN_NM, + [생일구분코드]: v.BIRDY_DIV_CD, + [생일일자]: v.BIRDY_DT, + [직책명]: v.DTY_NM, + [정당명]: v.PLPT_NM, + [선거구명]: v.ELECD_NM, + [선거구구분명]: v.ELECD_DIV_NM, + [위원회명]: v.CMIT_NM, + [소속위원회명]: v.BLNG_CMIT_NM, + [재선구분명]: v.RLCT_DIV_NM, + [당선대수]: v.GTELT_ERACO, // 당선대수 + [성별]: v.NTR_DIV, + [전화번호]: v.NAAS_TEL_NO, + [국회의원이메일주소]: v.NAAS_EMAIL_ADDR, + [국회의원홈페이지URL]: v.NAAS_HP_URL, + [보좌관]: v.AIDE_NM, + [비서관]: v.CHF_SCRT_NM, + [비서]: v.SCRT_NM, + [약력]: v.BRF_HST, + [사무실호실]: v.OFFM_RNUM_NO, + [사진]: v.NAAS_PIC, }); /** diff --git a/src/national-assembly/getNationalAssemblySchedule.spec.ts b/src/national-assembly/getNationalAssemblySchedule.spec.ts index f7865a8..fbe6656 100644 --- a/src/national-assembly/getNationalAssemblySchedule.spec.ts +++ b/src/national-assembly/getNationalAssemblySchedule.spec.ts @@ -1,7 +1,18 @@ import { describe, it, expect, vi } from 'vitest'; import { getNationalAssemblySchedule } from './getNationalAssemblySchedule'; import { callOpenApi } from '../functional'; -import { translatedVariableDictionary } from '../constant'; +import { + 위원회명, + 일정_내용, + 일정_시간, + 일정_일자, + 일정_종류, + 행사_장소, + 행사_주체자, + 회의_구분, + 회의_차수, + 회의_회기, +} from '../constant'; vi.mock('../functional', () => ({ callOpenApi: vi.fn(), @@ -37,16 +48,16 @@ describe('getNationalAssemblySchedule', () => { expect(schedules).toHaveLength(1); expect(schedules[0]).toEqual({ - [translatedVariableDictionary['일정_종류']]: 'Meeting', - [translatedVariableDictionary['일정_내용']]: 'Committee Meeting', - [translatedVariableDictionary['일정_일자']]: '2023-05-01', - [translatedVariableDictionary['일정_시간']]: '09:00', - [translatedVariableDictionary['회의_구분']]: 'Regular', - [translatedVariableDictionary['위원회명']]: 'Committee A', - [translatedVariableDictionary['회의_회기']]: '1', - [translatedVariableDictionary['회의_차수']]: '1', - [translatedVariableDictionary['행사_주체자']]: 'National Assembly', - [translatedVariableDictionary['행사_장소']]: 'Room 123', + [일정_종류]: 'Meeting', + [일정_내용]: 'Committee Meeting', + [일정_일자]: '2023-05-01', + [일정_시간]: '09:00', + [회의_구분]: 'Regular', + [위원회명]: 'Committee A', + [회의_회기]: '1', + [회의_차수]: '1', + [행사_주체자]: 'National Assembly', + [행사_장소]: 'Room 123', }); }); diff --git a/src/national-assembly/getNationalAssemblySchedule.ts b/src/national-assembly/getNationalAssemblySchedule.ts index 4fd6ee1..e2e19d9 100644 --- a/src/national-assembly/getNationalAssemblySchedule.ts +++ b/src/national-assembly/getNationalAssemblySchedule.ts @@ -1,4 +1,15 @@ -import { translatedVariableDictionary } from '../constant'; +import { + 위원회명, + 일정_내용, + 일정_시간, + 일정_일자, + 일정_종류, + 행사_장소, + 행사_주체자, + 회의_구분, + 회의_차수, + 회의_회기, +} from '../constant'; import { callOpenApi } from '../functional'; import { PaginationType } from '../types/callOpenApi'; @@ -27,16 +38,16 @@ type Argument = { const command = 'ALLSCHEDULE'; const transform = (v: Row) => ({ - [translatedVariableDictionary['일정_종류']]: v.SCH_KIND, - [translatedVariableDictionary['일정_내용']]: v.SCH_CN, - [translatedVariableDictionary['일정_일자']]: v.SCH_DT, - [translatedVariableDictionary['일정_시간']]: v.SCH_TM, - [translatedVariableDictionary['회의_구분']]: v.CONF_DIV, - [translatedVariableDictionary['위원회명']]: v.CMIT_NM, - [translatedVariableDictionary['회의_회기']]: v.CONF_SESS, - [translatedVariableDictionary['회의_차수']]: v.CONF_DGR, - [translatedVariableDictionary['행사_주체자']]: v.EV_INST_NM, - [translatedVariableDictionary['행사_장소']]: v.EV_PLC, + [일정_종류]: v.SCH_KIND, + [일정_내용]: v.SCH_CN, + [일정_일자]: v.SCH_DT, + [일정_시간]: v.SCH_TM, + [회의_구분]: v.CONF_DIV, + [위원회명]: v.CMIT_NM, + [회의_회기]: v.CONF_SESS, + [회의_차수]: v.CONF_DGR, + [행사_주체자]: v.EV_INST_NM, + [행사_장소]: v.EV_PLC, }); /** * @description call https://open.assembly.go.kr/portal/data/service/selectAPIServicePage.do/OOWY4R001216HX11437 diff --git a/yarn.lock b/yarn.lock index fb9543b..bcfb01f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1218,6 +1218,7 @@ __metadata: eslint: "npm:^9.7.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-jsdoc: "npm:^48.7.0" + hotscript: "npm:^1.0.13" prettier: "npm:^3.3.3" tsup: "npm:^8.2.3" typescript: "npm:^5.5.3" @@ -2215,6 +2216,13 @@ __metadata: languageName: node linkType: hard +"hotscript@npm:^1.0.13": + version: 1.0.13 + resolution: "hotscript@npm:1.0.13" + checksum: 10c0/423ea2aa437befeeffc32ea5a364b0d833f442fecdd7531c6fe8dc3df092c58d31145f757ad505ec7629ce4bb0eb8ff58889c8a58fe36312f975ff682f5cd422 + languageName: node + linkType: hard + "html-escaper@npm:^2.0.0": version: 2.0.2 resolution: "html-escaper@npm:2.0.2"