From 25e0d36d8bdbe5ef13b0302b054e6a16f1ffba6f Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 7 Oct 2026 15:45:25 +0900 Subject: [PATCH] =?UTF-8?q?261007=5F01=5FENH:=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EC=95=8C=EB=A6=BC=ED=86=A1=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 +- package.json | 2 +- src/noti-hub/index.ts | 3 +- src/noti-hub/kko-template.ts | 34 +++++++++ src/noti-hub/noti-hub-types.ts | 127 ++++++++++++++++++++++++++++++++- 5 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 src/noti-hub/kko-template.ts diff --git a/package-lock.json b/package-lock.json index b5ffe03..9dfe781 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kri/common", - "version": "0.18.5", + "version": "0.19.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@kri/common", - "version": "0.18.5", + "version": "0.19.0", "license": "UNLICENSED", "dependencies": { "clsx": "^2.1.1", diff --git a/package.json b/package.json index 05a46d2..a64c3c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kri/common", - "version": "0.18.5", + "version": "0.19.0", "description": "KRI 프런트엔드 공통 유틸리티", "type": "module", "main": "./dist/index.js", diff --git a/src/noti-hub/index.ts b/src/noti-hub/index.ts index 9a67d48..b855065 100644 --- a/src/noti-hub/index.ts +++ b/src/noti-hub/index.ts @@ -1 +1,2 @@ -export * from './noti-hub-types.js'; \ No newline at end of file +export * from './noti-hub-types.js'; +export * from './kko-template.js'; \ No newline at end of file diff --git a/src/noti-hub/kko-template.ts b/src/noti-hub/kko-template.ts new file mode 100644 index 0000000..84e7c71 --- /dev/null +++ b/src/noti-hub/kko-template.ts @@ -0,0 +1,34 @@ +import type { KkoTemplateDetail } from "./noti-hub-types.js"; + +const isEmptyExtra = (value: unknown): boolean => { + if (value === null || value === undefined) return true; + if (typeof value === "string") return value.trim() === ""; + if (Array.isArray(value)) return value.length === 0; + if (typeof value === "object") return Object.keys(value).length === 0; + return false; +}; + +/** + * 외부 알림톡 템플릿이 내부 저장 가능한 형태인지 미리 판단한다. + * 승인(APR)·정상(A)·block/dormant 명시적 false·기본 텍스트형(BA/NONE)이며 + * 이미지·아이템·대표 링크·버튼·바로연결 등 추가 요소가 없어야 한다. + * 화면 안내용 보조 판단이며 최종 판정은 서버(NotiHub)가 한다. + */ +export const isKkoTemplateSavable = (detail: KkoTemplateDetail): boolean => + detail.inspectionStatus === "APR" && + detail.status === "A" && + detail.block === false && + detail.dormant === false && + detail.templateMessageType === "BA" && + detail.templateEmphasizeType === "NONE" && + [ + detail.templateExtra, + detail.templateImageName, + detail.templateImageUrl, + detail.templateHeader, + detail.templateItemHighlight, + detail.templateItem, + detail.templateRepresentLink, + detail.buttons, + detail.quickReplies, + ].every(isEmptyExtra); diff --git a/src/noti-hub/noti-hub-types.ts b/src/noti-hub/noti-hub-types.ts index 795c18b..f4288d5 100644 --- a/src/noti-hub/noti-hub-types.ts +++ b/src/noti-hub/noti-hub-types.ts @@ -3,12 +3,19 @@ import type { FileResponse, PageRequest, PageResponse } from "../types.js"; export enum MessageType { EMAIL = 11, SMS = 21, - LMS_MMS = 22 + LMS_MMS = 22, + KKO = 31 } export enum ChannelType{ EMAIL = 1, - SMS = 2 + SMS = 2, + KKO = 3 +} + +export enum TemplatePurpose { + NORMAL = 0, + PHONE_VERIFICATION = 1 } export const SMS_TYPE_ARRAY = [MessageType.SMS, MessageType.LMS_MMS] as const; @@ -17,6 +24,7 @@ export type SmsType = typeof SMS_TYPE_ARRAY[number]; export type TemplateSummary = { tmplatIdx: number; tmplatNm: string; + tmplatPurpose?: TemplatePurpose; } export type TemplateBasic = { @@ -29,17 +37,86 @@ export type TemplateBasic = { export type TemplateSms = TemplateBasic & { tmplatTy: SmsType; + tmplatPurpose?: TemplatePurpose; tmplatTitle?: string; sendTel: string; + /** 조회 응답 전용. 파이프(|)로 구분한 첨부파일명 목록 */ + atchFl?: string; } export type TemplateEmail = TemplateBasic & { tmplatTy: MessageType.EMAIL; tmplatTitle: string; sendEml: string; + /** 조회 응답 전용. 파이프(|)로 구분한 첨부파일명 목록 */ + atchFl?: string; } -export type Template = TemplateSms | TemplateEmail; +/** 알림톡 템플릿. 본문은 서버가 외부 템플릿을 조회해 채우므로 요청에서는 tmplatBody, tmplatTitle을 생략한다. */ +export type TemplateKko = { + tmplatIdx?: number; + itrntPrjctCd: string; + tmplatTy: MessageType.KKO; + /** 현재 알림톡은 NORMAL(0)만 지원한다. */ + tmplatPurpose?: TemplatePurpose; + tmplatNm: string; + sendNm: string; + sendTel: string; + kkoTmplatCd: string; + /** 생략하거나 공백이면 서버에서 82를 사용한다. */ + nationCd?: string; + tmplatBody?: string; + tmplatTitle?: string; +}; + +export type Template = TemplateSms | TemplateEmail | TemplateKko; + +export type KkoTemplateListRequest = { + keyword?: string; +}; + +export type KkoTemplateSummary = { + templateCode: string; + templateName: string; + serviceStatus: string | null; + createdAt: string | null; + modifiedAt: string | null; +}; + +export type KkoTemplateListResponse = { + totalCount: number; + totalPage: number; + currentPage: number; + list: KkoTemplateSummary[]; +}; + +export type KkoTemplateDetailRequest = { + templateCode: string; +}; + +export type KkoTemplateDetail = { + templateCode: string; + templateName: string; + templateContent: string; + templatePreviewMessage: string | null; + templateMessageType: string | null; + templateEmphasizeType: string | null; + inspectionStatus: string | null; + status: string | null; + block: boolean | null; + dormant: boolean | null; + templateExtra: string | null; + templateImageName: string | null; + templateImageUrl: string | null; + templateTitle: string | null; + templateSubtitle: string | null; + templateHeader: string | null; + templateItemHighlight: unknown | null; + templateItem: unknown | null; + templateRepresentLink: unknown | null; + buttons: unknown[] | null; + quickReplies: unknown[] | null; +}; export type BulkSendCreateRequest = { reqstCmpn: string; @@ -75,6 +152,23 @@ export type BulkSendResponse = { failCount: number; }; +export type BulkSendFailedChunk = { + chunkIndex: number; + from: number; + to: number; + targetCount: number; + errorMessage: string | null; +}; + +export type BulkSendResult = { + bulkSendKey?: string; + targetCount: number; + requestCount: number; + acceptCount: number; + failCount: number; + failedChunks?: BulkSendFailedChunk[]; +}; + export type SendResultSummaryRequest = { bulkSendKey?: string; itrntPrjctCd?: string; @@ -141,3 +235,30 @@ export type SendInfo = { regUser: string; regDt: string; }; + +export type SendResultInfo = { + cmid: string; + bulkSendKey?: string; + /** MessageType 코드 */ + sendTy: number; + itrntPrjctCd: string; + reqstSvc: string; + prjctCd: string; + sid: string; + resve: boolean; + resultCode: number; + resultLabel?: string; + resultViewLabel?: string; + tmplatIdx?: number; + kkoTmplatCd?: string; + sendEml?: string; + sendTel?: string; + sendNm?: string; + sendDt: string; + destEml?: string; + destNm?: string; + destTel?: string; + regCmpn: string; + regUser: string; + regDt: string; +};