@open-mercato/webhooks 0.6.5-develop.4534.1.b459babe6d → 0.6.5-develop.4559.1.839e136509
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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.js +238 -0
- package/dist/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.js +46 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.js +92 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.js +61 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.js +76 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.js +81 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.js +69 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.js +64 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.js.map +7 -0
- package/dist/modules/webhooks/__integration__/helpers/fixtures.js +50 -1
- package/dist/modules/webhooks/__integration__/helpers/fixtures.js.map +2 -2
- package/dist/modules/webhooks/api/webhooks/[id]/route.js +24 -0
- package/dist/modules/webhooks/api/webhooks/[id]/route.js.map +2 -2
- package/dist/modules/webhooks/backend/webhooks/[id]/page.js +9 -2
- package/dist/modules/webhooks/backend/webhooks/[id]/page.js.map +3 -3
- package/dist/modules/webhooks/backend/webhooks/page.js +4 -1
- package/dist/modules/webhooks/backend/webhooks/page.js.map +2 -2
- package/package.json +6 -6
- package/src/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.ts +352 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.ts +63 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.ts +126 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.ts +82 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.ts +102 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.ts +109 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.ts +95 -0
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.ts +89 -0
- package/src/modules/webhooks/__integration__/helpers/fixtures.ts +101 -1
- package/src/modules/webhooks/api/webhooks/[id]/__tests__/optimistic-lock.test.ts +101 -0
- package/src/modules/webhooks/api/webhooks/[id]/route.ts +26 -0
- package/src/modules/webhooks/backend/webhooks/[id]/page.tsx +9 -2
- package/src/modules/webhooks/backend/webhooks/page.tsx +4 -1
|
@@ -16,6 +16,8 @@ import { FormHeader } from '@open-mercato/ui/backend/forms'
|
|
|
16
16
|
import { RowActions } from '@open-mercato/ui/backend/RowActions'
|
|
17
17
|
import { CrudForm } from '@open-mercato/ui/backend/CrudForm'
|
|
18
18
|
import { deleteCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
19
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
20
|
+
import { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'
|
|
19
21
|
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
20
22
|
import {
|
|
21
23
|
buildWebhookFormContentHeader,
|
|
@@ -362,10 +364,14 @@ export default function WebhookDetailPage() {
|
|
|
362
364
|
const handleDelete = React.useCallback(async () => {
|
|
363
365
|
if (!webhook) return
|
|
364
366
|
try {
|
|
365
|
-
await deleteCrud(`webhooks/${encodeURIComponent(webhook.id)}`, {
|
|
367
|
+
await deleteCrud(`webhooks/${encodeURIComponent(webhook.id)}`, {
|
|
368
|
+
fallbackResult: null,
|
|
369
|
+
headers: buildOptimisticLockHeader(webhook.updatedAt),
|
|
370
|
+
})
|
|
366
371
|
flash(t('webhooks.list.deleteSuccess'), 'success')
|
|
367
372
|
router.push('/backend/webhooks')
|
|
368
|
-
} catch {
|
|
373
|
+
} catch (error) {
|
|
374
|
+
if (surfaceRecordConflict(error, t)) return
|
|
369
375
|
flash(t('webhooks.list.deleteError'), 'error')
|
|
370
376
|
}
|
|
371
377
|
}, [router, t, webhook])
|
|
@@ -497,6 +503,7 @@ export default function WebhookDetailPage() {
|
|
|
497
503
|
fields={fields}
|
|
498
504
|
groups={groups}
|
|
499
505
|
initialValues={createWebhookInitialValues(webhook)}
|
|
506
|
+
optimisticLockUpdatedAt={webhook.updatedAt}
|
|
500
507
|
submitLabel={t('common.save')}
|
|
501
508
|
cancelHref={`/backend/webhooks/${webhook.id}`}
|
|
502
509
|
contentHeader={contentHeader}
|
|
@@ -8,6 +8,8 @@ import type { ColumnDef } from '@tanstack/react-table'
|
|
|
8
8
|
import { Button } from '@open-mercato/ui/primitives/button'
|
|
9
9
|
import { RowActions } from '@open-mercato/ui/backend/RowActions'
|
|
10
10
|
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
11
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
12
|
+
import { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'
|
|
11
13
|
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
12
14
|
import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
|
|
13
15
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
@@ -107,10 +109,11 @@ export default function WebhooksListPage() {
|
|
|
107
109
|
try {
|
|
108
110
|
const call = await apiCall<{ error?: string }>(
|
|
109
111
|
`/api/webhooks/${encodeURIComponent(row.id)}`,
|
|
110
|
-
{ method: 'DELETE' },
|
|
112
|
+
{ method: 'DELETE', headers: buildOptimisticLockHeader(row.updatedAt) },
|
|
111
113
|
{ fallback: null },
|
|
112
114
|
)
|
|
113
115
|
if (!call.ok) {
|
|
116
|
+
if (surfaceRecordConflict({ status: call.status, body: call.result }, t)) return
|
|
114
117
|
const errorPayload = call.result as { error?: string } | undefined
|
|
115
118
|
const message = typeof errorPayload?.error === 'string' ? errorPayload.error : t('webhooks.list.deleteError')
|
|
116
119
|
flash(message, 'error')
|