@open-mercato/ui 0.6.6-develop.6317.1.b3be10ab84 → 0.6.6-develop.6331.1.a33b8e99b7

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 (34) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/backend/AppShell.js +13 -2
  3. package/dist/backend/AppShell.js.map +2 -2
  4. package/dist/backend/CrudForm.js +2 -1
  5. package/dist/backend/CrudForm.js.map +2 -2
  6. package/dist/backend/OrganizationScopeBoundary.js +33 -0
  7. package/dist/backend/OrganizationScopeBoundary.js.map +7 -0
  8. package/dist/backend/conflicts/index.js +50 -13
  9. package/dist/backend/conflicts/index.js.map +2 -2
  10. package/dist/backend/detail/AddressesSection.js +9 -5
  11. package/dist/backend/detail/AddressesSection.js.map +2 -2
  12. package/dist/backend/detail/NotesSection.js +11 -6
  13. package/dist/backend/detail/NotesSection.js.map +2 -2
  14. package/dist/backend/injection/recordContext.js +40 -0
  15. package/dist/backend/injection/recordContext.js.map +7 -0
  16. package/dist/backend/notifications/NotificationPanel.js +14 -28
  17. package/dist/backend/notifications/NotificationPanel.js.map +2 -2
  18. package/dist/backend/utils/optimisticLock.js +19 -1
  19. package/dist/backend/utils/optimisticLock.js.map +2 -2
  20. package/package.json +3 -3
  21. package/src/backend/AppShell.tsx +26 -2
  22. package/src/backend/CrudForm.tsx +4 -1
  23. package/src/backend/OrganizationScopeBoundary.tsx +54 -0
  24. package/src/backend/__tests__/CrudForm.custom-fields.test.tsx +59 -0
  25. package/src/backend/__tests__/NotesSection.test.tsx +71 -0
  26. package/src/backend/__tests__/OrganizationScopeBoundary.test.tsx +74 -0
  27. package/src/backend/conflicts/__tests__/recordLockDeferral.test.ts +99 -0
  28. package/src/backend/conflicts/index.ts +96 -19
  29. package/src/backend/detail/AddressesSection.tsx +12 -7
  30. package/src/backend/detail/NotesSection.tsx +19 -8
  31. package/src/backend/injection/recordContext.tsx +101 -0
  32. package/src/backend/notifications/NotificationPanel.tsx +35 -38
  33. package/src/backend/notifications/__tests__/NotificationPanel.test.tsx +124 -0
  34. package/src/backend/utils/optimisticLock.ts +36 -0
@@ -68,3 +68,39 @@ export function extractOptimisticLockConflict(
68
68
  expectedUpdatedAt,
69
69
  }
70
70
  }
71
+
72
+ /**
73
+ * The enterprise `record_locks` 409 conflict code. Kept as a literal here so
74
+ * core/UI stays enterprise-free (no import from `@open-mercato/enterprise`).
75
+ */
76
+ export const RECORD_LOCK_CONFLICT_CODE = 'record_lock_conflict' as const
77
+
78
+ export type RecordLockConflictBody = {
79
+ code: typeof RECORD_LOCK_CONFLICT_CODE
80
+ error?: string
81
+ lock?: unknown
82
+ conflict?: unknown
83
+ }
84
+
85
+ /**
86
+ * Detect whether an error is an enterprise `record_locks` conflict (HTTP 409
87
+ * with `code: 'record_lock_conflict'`). Returns the conflict body when matched
88
+ * so `surfaceRecordConflict` can defer to the merge-dialog widget, or `null`.
89
+ */
90
+ export function extractRecordLockConflict(err: unknown): RecordLockConflictBody | null {
91
+ if (!err || typeof err !== 'object') return null
92
+ const candidate = err as Record<string, unknown>
93
+ if (candidate.status !== 409) return null
94
+ const body = candidate.body && typeof candidate.body === 'object'
95
+ ? candidate.body
96
+ : candidate
97
+ if (!body || typeof body !== 'object') return null
98
+ const bodyRecord = body as Record<string, unknown>
99
+ if (bodyRecord.code !== RECORD_LOCK_CONFLICT_CODE) return null
100
+ return {
101
+ code: RECORD_LOCK_CONFLICT_CODE,
102
+ error: typeof bodyRecord.error === 'string' ? bodyRecord.error : undefined,
103
+ lock: bodyRecord.lock ?? null,
104
+ conflict: bodyRecord.conflict ?? null,
105
+ }
106
+ }