diff --git a/package-lock.json b/package-lock.json index f6376ef..0b92f80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@actions/core": "^1.10.1", "@slack/web-api": "^7.3.1", "markdown-it": "^14.1.0", - "openapi-diff-node": "1.1.0" + "openapi-diff-node": "2.0.0" }, "devDependencies": { "@jest/globals": "^29.7.0", @@ -5862,9 +5862,9 @@ } }, "node_modules/openapi-diff-node": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/openapi-diff-node/-/openapi-diff-node-1.1.0.tgz", - "integrity": "sha512-eolLUj8pnJmBhaKFVIOyvuy0p7/kZepRQAQAzSvR/tvUYIxGfYbuJsyhLB1PksY2cuhyDP9zYetLwbHJznA/ig==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/openapi-diff-node/-/openapi-diff-node-2.0.0.tgz", + "integrity": "sha512-afi99lJmxlm22tPQcwpn9AvG9QRoUQ6ncXOW+ROabJTuw9t6jjJaB+ese/p9ekZ5OONmqRuf9rwx3BRMnJQLOA==" }, "node_modules/openapi-types": { "version": "12.1.3", diff --git a/package.json b/package.json index 8c8f2c9..6f37ff5 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@actions/core": "^1.10.1", "@slack/web-api": "^7.3.1", "markdown-it": "^14.1.0", - "openapi-diff-node": "1.1.0" + "openapi-diff-node": "2.0.0" }, "devDependencies": { "@jest/globals": "^29.7.0", diff --git a/src/locale/en-us.ts b/src/locale/en-us.ts index 67ddbee..4946a71 100644 --- a/src/locale/en-us.ts +++ b/src/locale/en-us.ts @@ -26,5 +26,11 @@ export const LOCALE_EN_US: Locale = { description: 'description', required: 'required', - example: 'example' + example: 'example', + + 'changed.before': 'Before', + 'changed.after': 'After', + 'properties.changed': 'Properties changed', + + 'empty.array': 'Not specified' } diff --git a/src/locale/ko-kr.ts b/src/locale/ko-kr.ts index 443f57e..5775d35 100644 --- a/src/locale/ko-kr.ts +++ b/src/locale/ko-kr.ts @@ -26,5 +26,11 @@ export const LOCALE_KO_KR: Locale = { description: '설명', required: '필수여부', - example: '예시' + example: '예시', + + 'changed.before': '변경 전', + 'changed.after': '변경 후', + 'properties.changed': '변경된 속성', + + 'empty.array': '없음' } diff --git a/src/services/slack.ts b/src/services/slack.ts index 3ba56b6..da34297 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -78,6 +78,7 @@ export class Slack { diff: DiffOutputItem ): Promise { const endpoint = `${diff.method.toUpperCase()}: ${diff.path}` + const description = diff.description const changedParameters = this._getUnchangedItems(diff.queryParams) const changedRequestBody = this._getUnchangedItems(diff.requestBody) @@ -150,6 +151,10 @@ export class Slack { type: 'mrkdwn', text: `*${translate('endpoint.singular')}:*\n ${endpoint}` }, + { + type: 'mrkdwn', + text: `*${translate('description')}:*\n ${description}` + }, { type: 'mrkdwn', text: `*${translate('repository')}: *\n 0) { - const changeLogElementList: RichTextElement[] = [] + changeLogElementList.push({ + type: 'rich_text_list', + style: 'bullet', + indent: 0, + border: 1, + elements: [ + { + type: 'rich_text_section', + elements: [ + { + type: 'text', + text: translate('properties.changed') + } + ] + } + ] + }) for (const changeLog of param.changeLogs) { const { field, oldValue, newValue } = changeLog changeLogElementList.push({ - type: 'text', - text: `${field} ${translate( - 'status.modified' - )}: ${oldValue} -> ${newValue}` + type: 'rich_text_list', + style: 'bullet', + indent: 1, + border: 1, + elements: [ + { + type: 'rich_text_section', + elements: [ + { + type: 'text', + text: field + } + ] + } + ] }) - } - descriptionElements.push({ - type: 'rich_text_section', - elements: changeLogElementList - }) + let oldValueText = oldValue + let newValueText = newValue + + if (Array.isArray(oldValue)) { + if (oldValue.length > 0) { + oldValueText = oldValue.join(', ') + } else { + oldValueText = `(${translate('empty.array')})` + } + } + + if (Array.isArray(newValue)) { + if (newValue.length > 0) { + newValueText = newValue.join(', ') + } else { + newValueText = `(${translate('empty.array')})` + } + } + + changeLogElementList.push({ + type: 'rich_text_list', + style: 'bullet', + indent: 2, + border: 1, + elements: [ + { + type: 'rich_text_section', + elements: [ + { + type: 'text', + text: `${translate('changed.before')}: \n${oldValueText}` + } + ] + }, + { + type: 'rich_text_section', + elements: [ + { + type: 'text', + text: `${translate('changed.after')}: \n${newValueText}` + } + ] + } + ] + }) + } } const description: RichTextList = { @@ -349,6 +424,11 @@ export class Slack { elements.push(statusAndEndpoint) elements.push(description) + + if (changeLogElementList.length > 0) { + elements.push(...changeLogElementList) + } + elements.push(newline) } diff --git a/src/types/locale.ts b/src/types/locale.ts index 004bf36..9272e31 100644 --- a/src/types/locale.ts +++ b/src/types/locale.ts @@ -25,4 +25,10 @@ export interface Locale { description: string required: string example: string + + 'changed.before': string + 'changed.after': string + 'properties.changed': string + + 'empty.array': string }