@open-mercato/webhooks 0.6.7 → 0.6.8-develop.6875.1.871a4afc94

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.
Files changed (71) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js +15 -0
  3. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js.map +2 -2
  4. package/dist/modules/webhooks/api/inbound/[endpointId]/route.js +152 -7
  5. package/dist/modules/webhooks/api/inbound/[endpointId]/route.js.map +3 -3
  6. package/dist/modules/webhooks/backend/webhooks/[id]/page.js +5 -4
  7. package/dist/modules/webhooks/backend/webhooks/[id]/page.js.map +2 -2
  8. package/dist/modules/webhooks/backend/webhooks/page.js +3 -2
  9. package/dist/modules/webhooks/backend/webhooks/page.js.map +2 -2
  10. package/dist/modules/webhooks/components/WebhookSecretPanel.js +3 -3
  11. package/dist/modules/webhooks/components/WebhookSecretPanel.js.map +2 -2
  12. package/dist/modules/webhooks/components/webhook-form-config.js +6 -6
  13. package/dist/modules/webhooks/components/webhook-form-config.js.map +2 -2
  14. package/dist/modules/webhooks/data/entities.js +101 -1
  15. package/dist/modules/webhooks/data/entities.js.map +2 -2
  16. package/dist/modules/webhooks/encryption.js +7 -0
  17. package/dist/modules/webhooks/encryption.js.map +2 -2
  18. package/dist/modules/webhooks/events.js +2 -0
  19. package/dist/modules/webhooks/events.js.map +2 -2
  20. package/dist/modules/webhooks/extension-points.js +15 -0
  21. package/dist/modules/webhooks/extension-points.js.map +7 -0
  22. package/dist/modules/webhooks/generators.js +57 -0
  23. package/dist/modules/webhooks/generators.js.map +7 -0
  24. package/dist/modules/webhooks/lib/inbound-dispatch.js +105 -0
  25. package/dist/modules/webhooks/lib/inbound-dispatch.js.map +7 -0
  26. package/dist/modules/webhooks/lib/inbound-registry.js +76 -0
  27. package/dist/modules/webhooks/lib/inbound-registry.js.map +7 -0
  28. package/dist/modules/webhooks/lib/module-webhook-registry.js +12 -0
  29. package/dist/modules/webhooks/lib/module-webhook-registry.js.map +7 -0
  30. package/dist/modules/webhooks/lib/queue.js +47 -0
  31. package/dist/modules/webhooks/lib/queue.js.map +2 -2
  32. package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js +16 -0
  33. package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js.map +7 -0
  34. package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js +2 -1
  35. package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js.map +2 -2
  36. package/dist/modules/webhooks/workers/inbound-dispatch.js +29 -0
  37. package/dist/modules/webhooks/workers/inbound-dispatch.js.map +7 -0
  38. package/generated/entities/inbound_endpoint_config_entity/index.ts +8 -0
  39. package/generated/entities/webhook_ingestion_entity/index.ts +16 -0
  40. package/generated/entities.ids.generated.ts +3 -1
  41. package/generated/entity-fields-registry.ts +28 -0
  42. package/package.json +12 -11
  43. package/src/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.ts +16 -0
  44. package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.test.ts +99 -1
  45. package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.unify.test.ts +149 -0
  46. package/src/modules/webhooks/api/inbound/[endpointId]/route.ts +178 -7
  47. package/src/modules/webhooks/backend/webhooks/[id]/page.tsx +5 -4
  48. package/src/modules/webhooks/backend/webhooks/page.tsx +3 -2
  49. package/src/modules/webhooks/components/WebhookSecretPanel.tsx +3 -3
  50. package/src/modules/webhooks/components/webhook-form-config.tsx +6 -6
  51. package/src/modules/webhooks/data/entities.ts +84 -0
  52. package/src/modules/webhooks/encryption.ts +7 -0
  53. package/src/modules/webhooks/events.ts +2 -0
  54. package/src/modules/webhooks/extension-points.ts +12 -0
  55. package/src/modules/webhooks/generators.ts +57 -0
  56. package/src/modules/webhooks/i18n/de.json +1 -1
  57. package/src/modules/webhooks/i18n/en.json +1 -1
  58. package/src/modules/webhooks/i18n/es.json +1 -1
  59. package/src/modules/webhooks/i18n/ko.json +161 -0
  60. package/src/modules/webhooks/i18n/pl.json +1 -1
  61. package/src/modules/webhooks/lib/__tests__/inbound-dispatch.test.ts +186 -0
  62. package/src/modules/webhooks/lib/__tests__/inbound-registry.test.ts +102 -0
  63. package/src/modules/webhooks/lib/__tests__/module-webhook-registry.test.ts +53 -0
  64. package/src/modules/webhooks/lib/inbound-dispatch.ts +147 -0
  65. package/src/modules/webhooks/lib/inbound-registry.ts +92 -0
  66. package/src/modules/webhooks/lib/module-webhook-registry.ts +33 -0
  67. package/src/modules/webhooks/lib/queue.ts +60 -0
  68. package/src/modules/webhooks/migrations/.snapshot-open-mercato.json +907 -338
  69. package/src/modules/webhooks/migrations/Migration20260617141327_webhooks.ts +16 -0
  70. package/src/modules/webhooks/widgets/injection/integration-deliveries/widget.client.tsx +2 -1
  71. package/src/modules/webhooks/workers/inbound-dispatch.ts +31 -0
@@ -0,0 +1,57 @@
1
+ import type { GeneratorPlugin } from '@open-mercato/shared/modules/generators'
2
+
3
+ function buildSourcesOutput({ importSection, entriesLiteral }: { importSection: string; entriesLiteral: string }): string {
4
+ return `// AUTO-GENERATED by mercato generate registry
5
+ import type { WebhookSourceConfig } from '@open-mercato/shared/lib/webhooks'
6
+ ${importSection ? `${importSection}\n` : ''}type WebhookSourceModuleEntry = { moduleId: string; sources: WebhookSourceConfig[] }
7
+
8
+ export const webhookSourceEntries: WebhookSourceModuleEntry[] = [
9
+ ${entriesLiteral ? ` ${entriesLiteral}\n` : ''}]
10
+ `
11
+ }
12
+
13
+ function buildHandlersOutput({ importSection, entriesLiteral }: { importSection: string; entriesLiteral: string }): string {
14
+ return `// AUTO-GENERATED by mercato generate registry
15
+ import type { WebhookHandlerRegistryEntry } from '@open-mercato/shared/lib/webhooks'
16
+ ${importSection ? `${importSection}\n` : ''}type WebhookHandlerModuleEntry = { moduleId: string; handlers: WebhookHandlerRegistryEntry[] }
17
+
18
+ export const webhookHandlerEntries: WebhookHandlerModuleEntry[] = [
19
+ ${entriesLiteral ? ` ${entriesLiteral}\n` : ''}]
20
+ `
21
+ }
22
+
23
+ const sourcesPlugin: GeneratorPlugin = {
24
+ id: 'webhooks.sources',
25
+ conventionFile: 'webhook-sources.ts',
26
+ importPrefix: 'WEBHOOK_SOURCES',
27
+ configExpr: (importName: string, moduleId: string) =>
28
+ `{ moduleId: '${moduleId}', sources: ((${importName}.default ?? ${importName}.webhookSources ?? []) as WebhookSourceConfig[]) }`,
29
+ outputFileName: 'webhook-sources.generated.ts',
30
+ buildOutput: buildSourcesOutput,
31
+ bootstrapRegistration: {
32
+ entriesExportName: 'webhookSourceEntries',
33
+ registrationImports: [
34
+ `import { registerWebhookSourceEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`,
35
+ ],
36
+ buildCall: (name: string) => `registerWebhookSourceEntries(${name})`,
37
+ },
38
+ }
39
+
40
+ const handlersPlugin: GeneratorPlugin = {
41
+ id: 'webhooks.handlers',
42
+ conventionFile: 'webhook-handlers.ts',
43
+ importPrefix: 'WEBHOOK_HANDLERS',
44
+ configExpr: (importName: string, moduleId: string) =>
45
+ `{ moduleId: '${moduleId}', handlers: ((${importName}.default ?? ${importName}.webhookHandlers ?? []) as WebhookHandlerRegistryEntry[]) }`,
46
+ outputFileName: 'webhook-handlers.generated.ts',
47
+ buildOutput: buildHandlersOutput,
48
+ bootstrapRegistration: {
49
+ entriesExportName: 'webhookHandlerEntries',
50
+ registrationImports: [
51
+ `import { registerWebhookHandlerEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`,
52
+ ],
53
+ buildCall: (name: string) => `registerWebhookHandlerEntries(${name})`,
54
+ },
55
+ }
56
+
57
+ export const generatorPlugins: GeneratorPlugin[] = [sourcesPlugin, handlersPlugin]
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maximale Anzahl von Zustellungen pro Minute für diesen Endpunkt (0 bedeutet unbegrenzt). Der Wert wird gespeichert, aber vom Zustellungs-Worker noch nicht durchgesetzt.",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited). Stored for future use — the delivery worker does not enforce it yet.",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Máximo de entregas por minuto para este endpoint (0 significa sin límite). El valor se guarda, pero el worker de entrega aún no lo aplica.",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -0,0 +1,161 @@
1
+ {
2
+ "webhooks.deliveries.actions.retry": "재시도",
3
+ "webhooks.deliveries.actions.viewDetails": "상세 정보 보기",
4
+ "webhooks.deliveries.autoRefreshHint": "이 페이지가 열려 있는 동안 전달 로그가 자동으로 새로고침됩니다.",
5
+ "webhooks.deliveries.columns.attempts": "시도 횟수",
6
+ "webhooks.deliveries.columns.createdAt": "시간",
7
+ "webhooks.deliveries.columns.duration": "소요 시간",
8
+ "webhooks.deliveries.columns.enqueuedAt": "대기열 등록 시각",
9
+ "webhooks.deliveries.columns.event": "이벤트",
10
+ "webhooks.deliveries.columns.responseStatus": "HTTP 상태",
11
+ "webhooks.deliveries.columns.status": "상태",
12
+ "webhooks.deliveries.detailTitle": "전달 상세 정보",
13
+ "webhooks.deliveries.empty": "아직 전달 시도가 없습니다.",
14
+ "webhooks.deliveries.loadError": "전달 상세 정보를 불러오지 못했습니다.",
15
+ "webhooks.deliveries.refresh": "새로고침",
16
+ "webhooks.deliveries.refreshing": "새로고침 중...",
17
+ "webhooks.deliveries.requestBody": "요청 본문",
18
+ "webhooks.deliveries.responseBody": "응답 본문",
19
+ "webhooks.deliveries.responseHeaders": "응답 헤더",
20
+ "webhooks.deliveries.retryError": "전달 재시도에 실패했습니다.",
21
+ "webhooks.deliveries.retrySuccess": "전달이 성공적으로 다시 대기열에 등록되었습니다.",
22
+ "webhooks.deliveries.status.delivered": "전달됨",
23
+ "webhooks.deliveries.status.expired": "만료됨",
24
+ "webhooks.deliveries.status.failed": "실패",
25
+ "webhooks.deliveries.status.pending": "대기 중",
26
+ "webhooks.deliveries.status.sending": "전송 중",
27
+ "webhooks.deliveries.title": "전달 로그",
28
+ "webhooks.detail.actions.activate": "활성화",
29
+ "webhooks.detail.actions.deactivate": "비활성화",
30
+ "webhooks.detail.actions.rotateSecret": "시크릿 교체",
31
+ "webhooks.detail.actions.test": "테스트 전송",
32
+ "webhooks.detail.backToList": "웹훅으로 돌아가기",
33
+ "webhooks.detail.consecutiveFailures": "연속 실패 횟수",
34
+ "webhooks.detail.deliveryTip": "광범위한 이벤트 패턴을 활성화하기 전에 테스트 전달부터 시작하세요. 아래 전달 로그에 소비자가 정확히 어떤 응답을 반환했는지 표시됩니다.",
35
+ "webhooks.detail.loadError": "웹훅을 불러오지 못했습니다.",
36
+ "webhooks.detail.loading": "웹훅 상세 정보를 불러오는 중...",
37
+ "webhooks.detail.previousSecretSetAt": "이전 시크릿 활성 시작 시각",
38
+ "webhooks.detail.readOnlyTip": "현재 읽기 전용 접근 권한이 있습니다. 이 엔드포인트를 변경해야 하면 관리자에게 관리, 테스트 또는 시크릿 교체 권한을 요청하세요.",
39
+ "webhooks.detail.rotateError": "웹훅 시크릿 교체에 실패했습니다.",
40
+ "webhooks.detail.rotateSuccess": "웹훅 시크릿이 교체되었습니다",
41
+ "webhooks.detail.signatureTip": "소비자는 Standard Webhooks 헤더(webhook-id, webhook-timestamp, webhook-signature)를 검증해야 합니다.",
42
+ "webhooks.detail.testError": "테스트 전달 전송에 실패했습니다.",
43
+ "webhooks.detail.testQueued": "테스트 전달이 실패 상태로 완료되었습니다.",
44
+ "webhooks.detail.testResult": "최근 테스트 결과",
45
+ "webhooks.detail.testSuccess": "테스트 전달에 성공했습니다.",
46
+ "webhooks.detail.title": "웹훅 상세 정보",
47
+ "webhooks.errors.forbidden": "이 작업을 수행할 권한이 없습니다.",
48
+ "webhooks.errors.notFound": "웹훅을 찾을 수 없습니다.",
49
+ "webhooks.errors.orgRequired": "조직 컨텍스트가 필요합니다.",
50
+ "webhooks.errors.tenantRequired": "테넌트 컨텍스트가 필요합니다.",
51
+ "webhooks.form.advancedStrategyTip": "현재 HTTP 전달이 활성화되어 있습니다. 라우팅 힌트에는 커스텀 헤더를 사용하고, 시크릿은 요청 헤더에 넣지 마세요.",
52
+ "webhooks.form.autoDisableThreshold": "자동 비활성화 임계값",
53
+ "webhooks.form.autoDisableThresholdHint": "이 횟수만큼 연속 실패하면 웹훅을 비활성화합니다 (0은 자동 비활성화를 사용하지 않음).",
54
+ "webhooks.form.createError": "웹훅 생성에 실패했습니다.",
55
+ "webhooks.form.createSuccess": "웹훅이 성공적으로 생성되었습니다.",
56
+ "webhooks.form.customHeaders": "커스텀 헤더",
57
+ "webhooks.form.customHeadersHint": "각 웹훅 요청과 함께 전송할 추가 헤더의 선택적 JSON 객체입니다.",
58
+ "webhooks.form.customHeadersInvalid": "커스텀 헤더는 문자열 값을 가진 유효한 JSON 객체여야 합니다.",
59
+ "webhooks.form.customHeadersTip": "환경이나 소스 식별자와 같은 정적 메타데이터에 헤더를 사용하세요. 여기에 액세스 토큰이나 시크릿을 넣지 마세요.",
60
+ "webhooks.form.deliveryDefaultsTip": "기본값은 대부분의 소비자에게 안전한 시작점입니다. 수신자가 느린 것으로 알려진 경우에만 재시도 횟수나 시간 제한을 늘리세요.",
61
+ "webhooks.form.description": "설명",
62
+ "webhooks.form.descriptionPlaceholder": "이 웹훅에 대한 선택적 설명",
63
+ "webhooks.form.events": "구독된 이벤트",
64
+ "webhooks.form.eventsHint": "이 웹훅을 트리거할 이벤트를 선택하세요.",
65
+ "webhooks.form.eventsPatternTip": "팁: 목록에서 정확한 이벤트를 선택하거나 customers.*나 *와 같은 와일드카드 패턴을 입력하여 폭넓게 구독할 수 있습니다.",
66
+ "webhooks.form.eventsPlaceholder": "이벤트 선택...",
67
+ "webhooks.form.eventsRequired": "이벤트를 하나 이상 선택하세요.",
68
+ "webhooks.form.group.advanced": "고급",
69
+ "webhooks.form.group.delivery": "전달 설정",
70
+ "webhooks.form.group.events": "이벤트 구독",
71
+ "webhooks.form.group.general": "일반",
72
+ "webhooks.form.guidanceBody": "이벤트가 전달될 위치를 구성하고, 필요한 이벤트 패턴을 선택한 다음, 프로덕션에 적용하기 전에 테스트 전송으로 소비자를 검증하세요.",
73
+ "webhooks.form.guidanceSecurityBody": "서명 시크릿은 자동으로 생성됩니다. 생성 또는 교체 후에만 전체 값을 볼 수 있으므로 페이지를 닫기 전에 수신자 측에 저장하세요.",
74
+ "webhooks.form.guidanceSecurityTitle": "보안 체크리스트",
75
+ "webhooks.form.guidanceTitle": "설정 가이드",
76
+ "webhooks.form.httpMethod": "HTTP 메서드",
77
+ "webhooks.form.isActive": "활성",
78
+ "webhooks.form.maxRetries": "최대 재시도 횟수",
79
+ "webhooks.form.maxRetriesHint": "최대 전달 재시도 횟수 (0~30).",
80
+ "webhooks.form.name": "이름",
81
+ "webhooks.form.namePlaceholder": "내 웹훅",
82
+ "webhooks.form.rateLimitPerMinute": "분당 속도 제한",
83
+ "webhooks.form.rateLimitPerMinuteHint": "이 엔드포인트의 분당 최대 전달 수 (0은 무제한).",
84
+ "webhooks.form.secret": "서명 시크릿",
85
+ "webhooks.form.secretCopied": "시크릿이 클립보드에 복사되었습니다.",
86
+ "webhooks.form.secretCopy": "시크릿 복사",
87
+ "webhooks.form.secretHint": "이 시크릿은 웹훅 페이로드에 서명하는 데 사용됩니다. 안전하게 보관하세요.",
88
+ "webhooks.form.secretMissing": "웹훅이 생성되었지만 시크릿이 반환되지 않았습니다.",
89
+ "webhooks.form.secretRotationTip": "전환 기간 동안 소비자가 기존 시크릿과 새 시크릿으로 생성된 서명을 모두 허용한 후에만 시크릿을 교체하세요.",
90
+ "webhooks.form.secretUsageTip": "지금 이 시크릿을 수신 서비스에 저장하세요. 이후 조회에는 마스킹된 값만 표시됩니다.",
91
+ "webhooks.form.secretVerificationTip": "webhook-id 및 webhook-timestamp와 함께 이 값을 사용하여 webhook-signature 헤더를 검증하세요.",
92
+ "webhooks.form.secretVisibleOnce": "이 시크릿을 볼 수 있는 마지막 기회입니다. 지금 안전하게 보관하세요.",
93
+ "webhooks.form.subscribedEvents": "구독된 이벤트",
94
+ "webhooks.form.timeoutMs": "시간 제한 (ms)",
95
+ "webhooks.form.timeoutMsHint": "요청 시간 제한 (밀리초, 1000~60000).",
96
+ "webhooks.form.title.create": "웹훅 생성",
97
+ "webhooks.form.title.edit": "웹훅 편집",
98
+ "webhooks.form.updateError": "웹훅 수정에 실패했습니다.",
99
+ "webhooks.form.updateSuccess": "웹훅이 성공적으로 수정되었습니다.",
100
+ "webhooks.form.url": "엔드포인트 URL",
101
+ "webhooks.form.urlHint": "HTTP POST를 통해 웹훅 페이로드를 수신할 URL입니다.",
102
+ "webhooks.form.urlPlaceholder": "https://example.com/webhook",
103
+ "webhooks.integrationDeliveries.actions.openWebhook": "웹훅 열기",
104
+ "webhooks.integrationDeliveries.columns.webhook": "웹훅",
105
+ "webhooks.integrationDeliveries.errorMessage": "오류 메시지",
106
+ "webhooks.integrationDeliveries.filters.allStatuses": "모든 상태",
107
+ "webhooks.integrationDeliveries.loadError": "웹훅 전달을 불러오지 못했습니다.",
108
+ "webhooks.integrationDeliveries.summary": "구성된 모든 웹훅 엔드포인트의 전달 시도를 검토하세요. 행을 열어 요청 및 응답 페이로드를 확인하세요.",
109
+ "webhooks.integrationSetup.actions.create": "웹훅 생성",
110
+ "webhooks.integrationSetup.actions.edit": "웹훅 편집",
111
+ "webhooks.integrationSetup.actions.openList": "웹훅 목록 열기",
112
+ "webhooks.integrationSetup.configuredTitle": "구성된 웹훅",
113
+ "webhooks.integrationSetup.disabledBody": "통합 스위치가 꺼져 있어 다시 활성화할 때까지 웹훅 전송, 재시도, 테스트 전달, 수신이 차단됩니다.",
114
+ "webhooks.integrationSetup.disabledTitle": "전달 처리가 비활성화되어 있습니다",
115
+ "webhooks.integrationSetup.empty": "아직 구성된 웹훅이 없습니다. 이벤트 전송이나 수신을 시작하려면 하나를 생성하세요.",
116
+ "webhooks.integrationSetup.enabledBody": "저장된 웹훅이 트래픽을 송수신할 수 있습니다. 아래 링크를 사용하여 엔드포인트를 검토하고 각 웹훅 상세 페이지에서 전달 로그를 여세요.",
117
+ "webhooks.integrationSetup.enabledTitle": "전달 처리가 활성화되어 있습니다",
118
+ "webhooks.integrationSetup.eventCount": "이벤트 패턴 {count}개",
119
+ "webhooks.integrationSetup.loadError": "구성된 웹훅을 불러오지 못했습니다.",
120
+ "webhooks.integrationSetup.loading": "구성된 웹훅을 불러오는 중...",
121
+ "webhooks.integrationSetup.more": "{total}개 중 {shown}개 표시 중.",
122
+ "webhooks.integrationSetup.notificationsBody": "재시도가 모두 소진된 후 웹훅 전달이 최종적으로 실패하면 관리자 사용자에게 알립니다.",
123
+ "webhooks.integrationSetup.notificationsDisabled": "비활성화됨",
124
+ "webhooks.integrationSetup.notificationsEnabled": "활성화됨",
125
+ "webhooks.integrationSetup.notificationsTitle": "전달 실패 알림",
126
+ "webhooks.integrationSetup.settingsLoadError": "웹훅 통합 설정을 불러오지 못했습니다.",
127
+ "webhooks.integrationSetup.settingsSaveError": "웹훅 통합 설정 저장에 실패했습니다.",
128
+ "webhooks.integrationSetup.settingsSaveSuccess": "웹훅 통합 설정이 저장되었습니다.",
129
+ "webhooks.integrationSetup.summary": "전용 웹훅 화면에서 커스텀 웹훅을 관리하세요. 이 통합을 끄면 아웃바운드 전달, 테스트 전송, 재시도, 인바운드 웹훅 수신이 차단됩니다.",
130
+ "webhooks.integrationSetup.title": "웹훅 구성",
131
+ "webhooks.integrationTabs.settings": "설정",
132
+ "webhooks.list.actions.delete": "삭제",
133
+ "webhooks.list.actions.edit": "편집",
134
+ "webhooks.list.actions.test": "테스트",
135
+ "webhooks.list.actions.viewDeliveries": "전달 내역 보기",
136
+ "webhooks.list.columns.createdAt": "생성됨",
137
+ "webhooks.list.columns.events": "이벤트",
138
+ "webhooks.list.columns.lastDelivery": "마지막 전달",
139
+ "webhooks.list.columns.lastTriggered": "마지막 트리거",
140
+ "webhooks.list.columns.name": "이름",
141
+ "webhooks.list.columns.status": "상태",
142
+ "webhooks.list.columns.successRate": "상태",
143
+ "webhooks.list.columns.url": "URL",
144
+ "webhooks.list.confirmDelete": "이 웹훅을 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.",
145
+ "webhooks.list.createFirst": "첫 웹훅을 생성하여 이벤트 알림 수신을 시작하세요.",
146
+ "webhooks.list.deleteError": "웹훅 삭제에 실패했습니다.",
147
+ "webhooks.list.deleteSuccess": "웹훅이 성공적으로 삭제되었습니다.",
148
+ "webhooks.list.description": "플랫폼 이벤트를 수신할 웹훅 엔드포인트를 관리합니다.",
149
+ "webhooks.list.empty": "아직 구성된 웹훅이 없습니다.",
150
+ "webhooks.list.filters.status": "상태",
151
+ "webhooks.list.loadError": "웹훅을 불러오지 못했습니다.",
152
+ "webhooks.list.operatorTip": "좁은 범위의 자동화에는 정확한 이벤트를, 하나의 소비자가 전체 도메인을 처리할 때는 와일드카드 패턴을 사용하세요. 각 배포 후 전달 로그를 확인하세요.",
153
+ "webhooks.list.status.active": "활성",
154
+ "webhooks.list.status.inactive": "비활성",
155
+ "webhooks.list.title": "웹훅",
156
+ "webhooks.nav.create": "웹훅 생성",
157
+ "webhooks.nav.group": "통합",
158
+ "webhooks.nav.title": "웹훅",
159
+ "webhooks.notifications.delivery.failed.body": "웹훅 {webhookName}이(가) 이벤트 {eventType}을(를) 전달하지 못했습니다. {errorMessage}",
160
+ "webhooks.notifications.delivery.failed.title": "{webhookName}의 웹훅 전달 실패"
161
+ }
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Nazwa",
81
81
  "webhooks.form.namePlaceholder": "Mój webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Limit na minutę",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maksymalna liczba dostaw na minutę dla tego endpointu (0 oznacza brak limitu).",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maksymalna liczba dostaw na minutę dla tego endpointu (0 oznacza brak limitu). Wartość jest zapisywana, ale nie jest jeszcze wymuszana przy dostarczaniu.",
84
84
  "webhooks.form.secret": "Sekret podpisujący",
85
85
  "webhooks.form.secretCopied": "Skopiowano sekret do schowka.",
86
86
  "webhooks.form.secretCopy": "Kopiuj sekret",
@@ -0,0 +1,186 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql'
2
+ import type { WebhookHandlerContext, WebhookHandlerPayload } from '@open-mercato/shared/lib/webhooks'
3
+
4
+ const findOneWithDecryption = jest.fn()
5
+ const emitWebhooksEvent = jest.fn(async () => undefined)
6
+
7
+ jest.mock('@open-mercato/shared/lib/encryption/find', () => ({
8
+ findOneWithDecryption: (...args: unknown[]) => findOneWithDecryption(...args),
9
+ }))
10
+ jest.mock('../../events', () => ({
11
+ emitWebhooksEvent: (...args: unknown[]) => emitWebhooksEvent(...args),
12
+ }))
13
+
14
+ import { processInboundDispatchJob, type InboundDispatchJob } from '../inbound-dispatch'
15
+ import {
16
+ clearWebhookHandlers,
17
+ registerWebhookHandler,
18
+ } from '../inbound-registry'
19
+
20
+ type IngestionRow = {
21
+ id: string
22
+ status: string
23
+ payload: Record<string, unknown>
24
+ headers: Record<string, string> | null
25
+ handlerCount: number
26
+ handlerResults: unknown
27
+ processedAt: Date | null
28
+ durationMs: number | null
29
+ errorMessage: string | null
30
+ tenantId: string
31
+ organizationId: string
32
+ }
33
+
34
+ function makeIngestion(overrides: Partial<IngestionRow> = {}): IngestionRow {
35
+ return {
36
+ id: 'ing-1',
37
+ status: 'received',
38
+ payload: { id: 'evt_1', type: 'payment_intent.succeeded' },
39
+ headers: { 'stripe-signature': 'sig' },
40
+ handlerCount: 0,
41
+ handlerResults: null,
42
+ processedAt: null,
43
+ durationMs: null,
44
+ errorMessage: null,
45
+ tenantId: 't1',
46
+ organizationId: 'o1',
47
+ ...overrides,
48
+ }
49
+ }
50
+
51
+ const job: InboundDispatchJob = {
52
+ ingestionId: 'ing-1',
53
+ sourceKey: 'stripe',
54
+ eventType: 'payment_intent.succeeded',
55
+ tenantId: 't1',
56
+ organizationId: 'o1',
57
+ }
58
+
59
+ const em = { flush: jest.fn(async () => undefined) } as unknown as EntityManager
60
+ const ctx: WebhookHandlerContext = { resolve: <T,>() => undefined as T }
61
+
62
+ beforeEach(() => {
63
+ clearWebhookHandlers()
64
+ findOneWithDecryption.mockReset()
65
+ emitWebhooksEvent.mockClear()
66
+ ;(em.flush as jest.Mock).mockClear()
67
+ })
68
+
69
+ it('runs all matching handlers and marks the ingestion processed', async () => {
70
+ const ingestion = makeIngestion()
71
+ findOneWithDecryption.mockResolvedValue(ingestion)
72
+ const calls: string[] = []
73
+ registerWebhookHandler({
74
+ meta: { source: 'stripe', event: 'payment_intent.*', id: 'payments:a' },
75
+ handler: async () => ({ default: async () => { calls.push('a') } }),
76
+ })
77
+ registerWebhookHandler({
78
+ meta: { source: 'stripe', event: '*', id: 'audit:b' },
79
+ handler: async () => ({ default: async () => { calls.push('b') } }),
80
+ })
81
+
82
+ await processInboundDispatchJob(em, job, ctx)
83
+
84
+ expect(calls.sort()).toEqual(['a', 'b'])
85
+ expect(ingestion.status).toBe('processed')
86
+ expect(ingestion.handlerCount).toBe(2)
87
+ expect(emitWebhooksEvent).toHaveBeenCalledWith(
88
+ 'webhooks.inbound.processed',
89
+ expect.objectContaining({ ingestionId: 'ing-1', handlerCount: 2, failedCount: 0 }),
90
+ )
91
+ })
92
+
93
+ it('isolates a failing handler, marks failed, and still runs the others', async () => {
94
+ const ingestion = makeIngestion()
95
+ findOneWithDecryption.mockResolvedValue(ingestion)
96
+ const calls: string[] = []
97
+ registerWebhookHandler({
98
+ meta: { source: 'stripe', event: 'payment_intent.succeeded', id: 'payments:boom' },
99
+ handler: async () => ({ default: async () => { throw new Error('handler exploded') } }),
100
+ })
101
+ registerWebhookHandler({
102
+ meta: { source: 'stripe', event: '*', id: 'audit:ok' },
103
+ handler: async () => ({ default: async () => { calls.push('ok') } }),
104
+ })
105
+
106
+ await processInboundDispatchJob(em, job, ctx)
107
+
108
+ expect(calls).toEqual(['ok'])
109
+ expect(ingestion.status).toBe('failed')
110
+ expect(ingestion.errorMessage).toBe('1/2 handlers failed')
111
+ expect(emitWebhooksEvent).toHaveBeenCalledWith(
112
+ 'webhooks.inbound.handler_failed',
113
+ expect.objectContaining({ handlerId: 'payments:boom', errorMessage: 'handler exploded' }),
114
+ )
115
+ })
116
+
117
+ it('is idempotent when the ingestion is already processed', async () => {
118
+ findOneWithDecryption.mockResolvedValue(makeIngestion({ status: 'processed' }))
119
+ const handler = jest.fn(async () => ({ default: async () => undefined }))
120
+ registerWebhookHandler({ meta: { source: 'stripe', event: '*', id: 'x' }, handler })
121
+
122
+ await processInboundDispatchJob(em, job, ctx)
123
+
124
+ expect(handler).not.toHaveBeenCalled()
125
+ expect(em.flush).not.toHaveBeenCalled()
126
+ expect(emitWebhooksEvent).not.toHaveBeenCalled()
127
+ })
128
+
129
+ it('returns early when the ingestion is missing', async () => {
130
+ findOneWithDecryption.mockResolvedValue(null)
131
+ await processInboundDispatchJob(em, job, ctx)
132
+ expect(em.flush).not.toHaveBeenCalled()
133
+ })
134
+
135
+ it('passes the handler the payload and headers from the ingestion, not from the job', async () => {
136
+ const ingestion = makeIngestion({
137
+ payload: { id: 'evt_from_row', type: 'payment_intent.succeeded' },
138
+ headers: { 'stripe-signature': 'sig_from_row' },
139
+ })
140
+ findOneWithDecryption.mockResolvedValue(ingestion)
141
+ const seen: WebhookHandlerPayload[] = []
142
+ registerWebhookHandler({
143
+ meta: { source: 'stripe', event: '*', id: 'audit:capture' },
144
+ handler: async () => ({ default: async (payload: WebhookHandlerPayload) => { seen.push(payload) } }),
145
+ })
146
+
147
+ await processInboundDispatchJob(em, job, ctx)
148
+
149
+ expect(seen).toHaveLength(1)
150
+ expect(seen[0].data).toEqual({ id: 'evt_from_row', type: 'payment_intent.succeeded' })
151
+ expect(seen[0].headers).toEqual({ 'stripe-signature': 'sig_from_row' })
152
+ })
153
+
154
+ it('re-runs only the handlers that did not already succeed when retried after a partial failure', async () => {
155
+ const ingestion = makeIngestion({
156
+ status: 'failed',
157
+ handlerCount: 2,
158
+ errorMessage: '1/2 handlers failed',
159
+ handlerResults: [
160
+ { handlerId: 'audit:ok', module: 'audit', status: 'success', durationMs: 3, startedAt: '2026-06-17T00:00:00.000Z' },
161
+ { handlerId: 'payments:boom', module: 'payments', status: 'failed', errorMessage: 'handler exploded', durationMs: 1, startedAt: '2026-06-17T00:00:00.000Z' },
162
+ ],
163
+ })
164
+ findOneWithDecryption.mockResolvedValue(ingestion)
165
+ const calls: string[] = []
166
+ registerWebhookHandler({
167
+ meta: { source: 'stripe', event: '*', id: 'audit:ok' },
168
+ handler: async () => ({ default: async () => { calls.push('audit:ok') } }),
169
+ })
170
+ registerWebhookHandler({
171
+ meta: { source: 'stripe', event: 'payment_intent.succeeded', id: 'payments:boom' },
172
+ handler: async () => ({ default: async () => { calls.push('payments:boom') } }),
173
+ })
174
+
175
+ await processInboundDispatchJob(em, job, ctx)
176
+
177
+ expect(calls).toEqual(['payments:boom'])
178
+ expect(ingestion.status).toBe('processed')
179
+ expect(ingestion.errorMessage).toBeNull()
180
+ expect(ingestion.handlerResults).toEqual(
181
+ expect.arrayContaining([
182
+ expect.objectContaining({ handlerId: 'audit:ok', status: 'success' }),
183
+ expect.objectContaining({ handlerId: 'payments:boom', status: 'success' }),
184
+ ]),
185
+ )
186
+ })
@@ -0,0 +1,102 @@
1
+ import type {
2
+ WebhookHandler,
3
+ WebhookHandlerRegistryEntry,
4
+ WebhookSourceConfig,
5
+ } from '@open-mercato/shared/lib/webhooks'
6
+ import {
7
+ clearWebhookHandlers,
8
+ clearWebhookSources,
9
+ getWebhookSource,
10
+ listWebhookHandlers,
11
+ listWebhookSources,
12
+ registerWebhookHandler,
13
+ registerWebhookSource,
14
+ resolveWebhookHandlers,
15
+ setWebhookHandlers,
16
+ setWebhookSources,
17
+ } from '../inbound-registry'
18
+
19
+ const noopHandler: WebhookHandler = async () => undefined
20
+
21
+ function makeSource(key: string): WebhookSourceConfig {
22
+ return {
23
+ key,
24
+ label: key,
25
+ verifier: async () => true,
26
+ eventTypeExtractor: (body) => String((body as { type?: string }).type ?? ''),
27
+ }
28
+ }
29
+
30
+ function makeEntry(source: string, event: string, id: string): WebhookHandlerRegistryEntry {
31
+ return {
32
+ meta: { source, event, id },
33
+ handler: async () => ({ default: noopHandler }),
34
+ }
35
+ }
36
+
37
+ beforeEach(() => {
38
+ clearWebhookSources()
39
+ clearWebhookHandlers()
40
+ })
41
+
42
+ describe('webhook source registry', () => {
43
+ it('registers and resolves a source by key', () => {
44
+ registerWebhookSource(makeSource('stripe'))
45
+ expect(getWebhookSource('stripe')?.key).toBe('stripe')
46
+ expect(getWebhookSource('missing')).toBeUndefined()
47
+ expect(listWebhookSources()).toHaveLength(1)
48
+ })
49
+
50
+ it('unregister removes only the matching source instance', () => {
51
+ const unregister = registerWebhookSource(makeSource('stripe'))
52
+ registerWebhookSource(makeSource('resend'))
53
+ unregister()
54
+ expect(getWebhookSource('stripe')).toBeUndefined()
55
+ expect(getWebhookSource('resend')?.key).toBe('resend')
56
+ })
57
+
58
+ it('setWebhookSources replaces the whole registry', () => {
59
+ registerWebhookSource(makeSource('old'))
60
+ setWebhookSources([makeSource('stripe'), makeSource('resend')])
61
+ expect(getWebhookSource('old')).toBeUndefined()
62
+ expect(listWebhookSources().map((s) => s.key).sort()).toEqual(['resend', 'stripe'])
63
+ })
64
+ })
65
+
66
+ describe('resolveWebhookHandlers', () => {
67
+ it('matches handlers by source key', () => {
68
+ registerWebhookHandler(makeEntry('stripe', '*', 'a'))
69
+ registerWebhookHandler(makeEntry('resend', '*', 'b'))
70
+ const matched = resolveWebhookHandlers('stripe', 'payment_intent.succeeded')
71
+ expect(matched.map((m) => m.meta.id)).toEqual(['a'])
72
+ })
73
+
74
+ it('supports exact, wildcard, and prefix-wildcard event patterns', () => {
75
+ registerWebhookHandler(makeEntry('stripe', 'payment_intent.succeeded', 'exact'))
76
+ registerWebhookHandler(makeEntry('stripe', 'payment_intent.*', 'prefix'))
77
+ registerWebhookHandler(makeEntry('stripe', '*', 'all'))
78
+ registerWebhookHandler(makeEntry('stripe', 'charge.refunded', 'other'))
79
+
80
+ const matched = resolveWebhookHandlers('stripe', 'payment_intent.succeeded')
81
+ expect(matched.map((m) => m.meta.id).sort()).toEqual(['all', 'exact', 'prefix'])
82
+ })
83
+
84
+ it('returns multiple handlers for the same source + event', () => {
85
+ registerWebhookHandler(makeEntry('stripe', 'payment_intent.succeeded', 'h1'))
86
+ registerWebhookHandler(makeEntry('stripe', 'payment_intent.succeeded', 'h2'))
87
+ expect(resolveWebhookHandlers('stripe', 'payment_intent.succeeded')).toHaveLength(2)
88
+ })
89
+
90
+ it('returns no handlers when nothing matches', () => {
91
+ registerWebhookHandler(makeEntry('stripe', 'charge.refunded', 'x'))
92
+ expect(resolveWebhookHandlers('stripe', 'payment_intent.succeeded')).toEqual([])
93
+ expect(resolveWebhookHandlers('paypal', 'charge.refunded')).toEqual([])
94
+ })
95
+
96
+ it('setWebhookHandlers replaces the whole handler registry', () => {
97
+ registerWebhookHandler(makeEntry('stripe', '*', 'old'))
98
+ setWebhookHandlers([makeEntry('resend', 'email.received', 'new')])
99
+ expect(listWebhookHandlers().map((e) => e.meta.id)).toEqual(['new'])
100
+ expect(resolveWebhookHandlers('resend', 'email.received').map((e) => e.meta.id)).toEqual(['new'])
101
+ })
102
+ })
@@ -0,0 +1,53 @@
1
+ import type { WebhookHandler } from '@open-mercato/shared/lib/webhooks'
2
+ import {
3
+ registerWebhookHandlerEntries,
4
+ registerWebhookSourceEntries,
5
+ } from '../module-webhook-registry'
6
+ import {
7
+ clearWebhookHandlers,
8
+ clearWebhookSources,
9
+ listWebhookHandlers,
10
+ listWebhookSources,
11
+ } from '../inbound-registry'
12
+
13
+ const noopHandler: WebhookHandler = async () => undefined
14
+
15
+ beforeEach(() => {
16
+ clearWebhookSources()
17
+ clearWebhookHandlers()
18
+ })
19
+
20
+ it('flattens module source entries into the source registry', () => {
21
+ registerWebhookSourceEntries([
22
+ {
23
+ moduleId: 'gateway_stripe',
24
+ sources: [
25
+ { key: 'stripe', label: 'Stripe', verifier: async () => true, eventTypeExtractor: () => '' },
26
+ ],
27
+ },
28
+ { moduleId: 'inbox_ops', sources: [
29
+ { key: 'resend', label: 'Resend', verifier: async () => true, eventTypeExtractor: () => '' },
30
+ ] },
31
+ ])
32
+ expect(listWebhookSources().map((s) => s.key).sort()).toEqual(['resend', 'stripe'])
33
+ })
34
+
35
+ it('flattens module handler entries into the handler registry', () => {
36
+ registerWebhookHandlerEntries([
37
+ {
38
+ moduleId: 'gateway_stripe',
39
+ handlers: [
40
+ { meta: { source: 'stripe', event: 'payment_intent.succeeded', id: 'a' }, handler: async () => ({ default: noopHandler }) },
41
+ { meta: { source: 'stripe', event: 'charge.refunded', id: 'b' }, handler: async () => ({ default: noopHandler }) },
42
+ ],
43
+ },
44
+ ])
45
+ expect(listWebhookHandlers().map((e) => e.meta.id).sort()).toEqual(['a', 'b'])
46
+ })
47
+
48
+ it('tolerates entries with no sources/handlers', () => {
49
+ registerWebhookSourceEntries([{ moduleId: 'empty', sources: [] }])
50
+ registerWebhookHandlerEntries([{ moduleId: 'empty', handlers: [] }])
51
+ expect(listWebhookSources()).toEqual([])
52
+ expect(listWebhookHandlers()).toEqual([])
53
+ })