@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.
Files changed (39) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.js +238 -0
  3. package/dist/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.js.map +7 -0
  4. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.js +46 -0
  5. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.js.map +7 -0
  6. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.js +92 -0
  7. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.js.map +7 -0
  8. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.js +61 -0
  9. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.js.map +7 -0
  10. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.js +76 -0
  11. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.js.map +7 -0
  12. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.js +81 -0
  13. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.js.map +7 -0
  14. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.js +69 -0
  15. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.js.map +7 -0
  16. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.js +64 -0
  17. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.js.map +7 -0
  18. package/dist/modules/webhooks/__integration__/helpers/fixtures.js +50 -1
  19. package/dist/modules/webhooks/__integration__/helpers/fixtures.js.map +2 -2
  20. package/dist/modules/webhooks/api/webhooks/[id]/route.js +24 -0
  21. package/dist/modules/webhooks/api/webhooks/[id]/route.js.map +2 -2
  22. package/dist/modules/webhooks/backend/webhooks/[id]/page.js +9 -2
  23. package/dist/modules/webhooks/backend/webhooks/[id]/page.js.map +3 -3
  24. package/dist/modules/webhooks/backend/webhooks/page.js +4 -1
  25. package/dist/modules/webhooks/backend/webhooks/page.js.map +2 -2
  26. package/package.json +6 -6
  27. package/src/modules/webhooks/__integration__/TC-LOCK-OSS-043.spec.ts +352 -0
  28. package/src/modules/webhooks/__integration__/TC-WEBHOOK-004.spec.ts +63 -0
  29. package/src/modules/webhooks/__integration__/TC-WEBHOOK-005.spec.ts +126 -0
  30. package/src/modules/webhooks/__integration__/TC-WEBHOOK-006.spec.ts +82 -0
  31. package/src/modules/webhooks/__integration__/TC-WEBHOOK-007.spec.ts +102 -0
  32. package/src/modules/webhooks/__integration__/TC-WEBHOOK-008.spec.ts +109 -0
  33. package/src/modules/webhooks/__integration__/TC-WEBHOOK-009.spec.ts +95 -0
  34. package/src/modules/webhooks/__integration__/TC-WEBHOOK-010.spec.ts +89 -0
  35. package/src/modules/webhooks/__integration__/helpers/fixtures.ts +101 -1
  36. package/src/modules/webhooks/api/webhooks/[id]/__tests__/optimistic-lock.test.ts +101 -0
  37. package/src/modules/webhooks/api/webhooks/[id]/route.ts +26 -0
  38. package/src/modules/webhooks/backend/webhooks/[id]/page.tsx +9 -2
  39. 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)}`, { fallbackResult: null })
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')