@open-mercato/enterprise 0.6.6-develop.6465.1.019f0fb26f → 0.6.6-develop.6472.1.1673e7e66b
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/dist/modules/record_locks/subscribers/conflict-detected-notification.js +3 -1
- package/dist/modules/record_locks/subscribers/conflict-detected-notification.js.map +2 -2
- package/dist/modules/record_locks/subscribers/conflict-resolved-notification.js +3 -1
- package/dist/modules/record_locks/subscribers/conflict-resolved-notification.js.map +2 -2
- package/dist/modules/record_locks/subscribers/lock-contended-notification.js +3 -1
- package/dist/modules/record_locks/subscribers/lock-contended-notification.js.map +2 -2
- package/dist/modules/record_locks/subscribers/lock-force-released-notification.js +3 -1
- package/dist/modules/record_locks/subscribers/lock-force-released-notification.js.map +2 -2
- package/dist/modules/record_locks/widgets/injection/record-locking/widget.client.js +4 -2
- package/dist/modules/record_locks/widgets/injection/record-locking/widget.client.js.map +2 -2
- package/dist/modules/security/api/enforcement/_shared.js +3 -1
- package/dist/modules/security/api/enforcement/_shared.js.map +2 -2
- package/dist/modules/security/api/mfa/_shared.js +3 -1
- package/dist/modules/security/api/mfa/_shared.js.map +2 -2
- package/dist/modules/security/api/profile/password/route.js +3 -1
- package/dist/modules/security/api/profile/password/route.js.map +2 -2
- package/dist/modules/security/api/sudo/_shared.js +3 -1
- package/dist/modules/security/api/sudo/_shared.js.map +2 -2
- package/dist/modules/security/api/users/_shared.js +3 -1
- package/dist/modules/security/api/users/_shared.js.map +2 -2
- package/dist/modules/sso/api/callback/oidc/route.js +5 -3
- package/dist/modules/sso/api/callback/oidc/route.js.map +2 -2
- package/dist/modules/sso/api/error-handler.js +4 -2
- package/dist/modules/sso/api/error-handler.js.map +2 -2
- package/dist/modules/sso/api/hrd/route.js +3 -1
- package/dist/modules/sso/api/hrd/route.js.map +2 -2
- package/dist/modules/sso/api/initiate/route.js +4 -2
- package/dist/modules/sso/api/initiate/route.js.map +2 -2
- package/dist/modules/sso/backend/sso/config/[id]/page.js +2 -2
- package/dist/modules/sso/backend/sso/config/[id]/page.js.map +2 -2
- package/dist/modules/sso/i18n/de.json +2 -2
- package/dist/modules/sso/i18n/en.json +2 -2
- package/dist/modules/sso/i18n/es.json +2 -2
- package/dist/modules/sso/i18n/pl.json +2 -2
- package/dist/modules/sso/services/accountLinkingService.js +9 -46
- package/dist/modules/sso/services/accountLinkingService.js.map +2 -2
- package/dist/modules/sso/services/ssoConfigService.js +9 -7
- package/dist/modules/sso/services/ssoConfigService.js.map +2 -2
- package/dist/modules/sso/services/ssoService.js +4 -2
- package/dist/modules/sso/services/ssoService.js.map +2 -2
- package/dist/modules/system_status_overlays/subscribers/application-bootstrap-enterprise-warning.js +4 -2
- package/dist/modules/system_status_overlays/subscribers/application-bootstrap-enterprise-warning.js.map +2 -2
- package/package.json +5 -5
- package/src/modules/record_locks/subscribers/conflict-detected-notification.ts +4 -1
- package/src/modules/record_locks/subscribers/conflict-resolved-notification.ts +4 -1
- package/src/modules/record_locks/subscribers/lock-contended-notification.ts +4 -1
- package/src/modules/record_locks/subscribers/lock-force-released-notification.ts +4 -1
- package/src/modules/record_locks/widgets/injection/record-locking/widget.client.tsx +5 -2
- package/src/modules/security/api/enforcement/_shared.ts +4 -1
- package/src/modules/security/api/mfa/_shared.ts +4 -1
- package/src/modules/security/api/profile/password/route.ts +4 -1
- package/src/modules/security/api/sudo/_shared.ts +4 -1
- package/src/modules/security/api/users/_shared.ts +4 -1
- package/src/modules/sso/api/callback/oidc/route.ts +6 -3
- package/src/modules/sso/api/error-handler.ts +5 -2
- package/src/modules/sso/api/hrd/route.ts +4 -1
- package/src/modules/sso/api/initiate/route.ts +5 -2
- package/src/modules/sso/backend/sso/config/[id]/page.tsx +2 -2
- package/src/modules/sso/i18n/de.json +2 -2
- package/src/modules/sso/i18n/en.json +2 -2
- package/src/modules/sso/i18n/es.json +2 -2
- package/src/modules/sso/i18n/pl.json +2 -2
- package/src/modules/sso/services/accountLinkingService.ts +10 -52
- package/src/modules/sso/services/ssoConfigService.ts +10 -7
- package/src/modules/sso/services/ssoService.ts +5 -2
- package/src/modules/system_status_overlays/subscribers/application-bootstrap-enterprise-warning.ts +6 -2
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
resolveRecordLockNotificationType,
|
|
9
9
|
resolveRecordResourceLink
|
|
10
10
|
} from "../lib/notificationHelpers.js";
|
|
11
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
12
|
+
const logger = createLogger("record_locks").child({ subscriber: "conflict-detected-notification" });
|
|
11
13
|
const metadata = {
|
|
12
14
|
event: "record_locks.conflict.detected",
|
|
13
15
|
persistent: true,
|
|
@@ -67,7 +69,7 @@ async function handle(payload, ctx) {
|
|
|
67
69
|
organizationId: payload.organizationId ?? null
|
|
68
70
|
});
|
|
69
71
|
} catch (error) {
|
|
70
|
-
|
|
72
|
+
logger.error("Failed to create notification", { err: error });
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/record_locks/subscribers/conflict-detected-notification.ts"],
|
|
4
|
-
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { ActionLog } from '@open-mercato/core/modules/audit_logs/data/entities'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { parseDecryptedFieldValue } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport {\n isConflictNotificationEnabled,\n resolveRecordLockNotificationType,\n resolveRecordResourceLink,\n} from '../lib/notificationHelpers'\n\nexport const metadata = {\n event: 'record_locks.conflict.detected',\n persistent: true,\n id: 'record_locks:conflict-detected-notification',\n}\n\ntype Payload = {\n conflictId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n conflictActorUserId: string\n incomingActorUserId?: string | null\n baseActionLogId?: string | null\n incomingActionLogId?: string | null\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nfunction formatChangedFieldLabel(rawField: string): string {\n const trimmedField = rawField.trim()\n const withoutNamespace = trimmedField.includes('::') ? (trimmedField.split('::').pop() ?? trimmedField) : trimmedField\n const withoutPrefix = withoutNamespace.includes('.') ? (withoutNamespace.split('.').pop() ?? withoutNamespace) : withoutNamespace\n const words = withoutPrefix\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[._-]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean)\n\n if (!words.length) return trimmedField\n return words\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ')\n}\n\nfunction readActionLogChanges(log: ActionLog | null): Record<string, unknown> | null {\n const rawChanges = log?.changesJson as unknown\n if (rawChanges && typeof rawChanges === 'object' && !Array.isArray(rawChanges)) {\n return rawChanges as Record<string, unknown>\n }\n if (typeof rawChanges !== 'string') return null\n\n const parsed = parseDecryptedFieldValue(rawChanges)\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : null\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.conflictActorUserId) return\n\n const notificationsEnabled = await isConflictNotificationEnabled(ctx, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n if (!notificationsEnabled) return\n\n try {\n const em = (ctx.resolve('em') as EntityManager).fork()\n const incomingLog = payload.incomingActionLogId\n ? await findOneWithDecryption(\n em,\n ActionLog,\n { id: payload.incomingActionLogId, deletedAt: null },\n undefined,\n { tenantId: payload.tenantId, organizationId: payload.organizationId ?? null },\n )\n : null\n const changesJson = readActionLogChanges(incomingLog)\n const changedFields = changesJson\n ? Object.keys(changesJson).slice(0, 12).map(formatChangedFieldLabel).join(', ')\n : ''\n\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.conflict.detected')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.conflictActorUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n changedFields: changedFields || '-',\n },\n sourceEntityType: 'record_locks:conflict',\n sourceEntityId: payload.conflictId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.conflict.detected:${payload.conflictId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAE3C,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;
|
|
4
|
+
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { ActionLog } from '@open-mercato/core/modules/audit_logs/data/entities'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { parseDecryptedFieldValue } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport {\n isConflictNotificationEnabled,\n resolveRecordLockNotificationType,\n resolveRecordResourceLink,\n} from '../lib/notificationHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('record_locks').child({ subscriber: 'conflict-detected-notification' })\n\nexport const metadata = {\n event: 'record_locks.conflict.detected',\n persistent: true,\n id: 'record_locks:conflict-detected-notification',\n}\n\ntype Payload = {\n conflictId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n conflictActorUserId: string\n incomingActorUserId?: string | null\n baseActionLogId?: string | null\n incomingActionLogId?: string | null\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nfunction formatChangedFieldLabel(rawField: string): string {\n const trimmedField = rawField.trim()\n const withoutNamespace = trimmedField.includes('::') ? (trimmedField.split('::').pop() ?? trimmedField) : trimmedField\n const withoutPrefix = withoutNamespace.includes('.') ? (withoutNamespace.split('.').pop() ?? withoutNamespace) : withoutNamespace\n const words = withoutPrefix\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[._-]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean)\n\n if (!words.length) return trimmedField\n return words\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ')\n}\n\nfunction readActionLogChanges(log: ActionLog | null): Record<string, unknown> | null {\n const rawChanges = log?.changesJson as unknown\n if (rawChanges && typeof rawChanges === 'object' && !Array.isArray(rawChanges)) {\n return rawChanges as Record<string, unknown>\n }\n if (typeof rawChanges !== 'string') return null\n\n const parsed = parseDecryptedFieldValue(rawChanges)\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : null\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.conflictActorUserId) return\n\n const notificationsEnabled = await isConflictNotificationEnabled(ctx, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n if (!notificationsEnabled) return\n\n try {\n const em = (ctx.resolve('em') as EntityManager).fork()\n const incomingLog = payload.incomingActionLogId\n ? await findOneWithDecryption(\n em,\n ActionLog,\n { id: payload.incomingActionLogId, deletedAt: null },\n undefined,\n { tenantId: payload.tenantId, organizationId: payload.organizationId ?? null },\n )\n : null\n const changesJson = readActionLogChanges(incomingLog)\n const changedFields = changesJson\n ? Object.keys(changesJson).slice(0, 12).map(formatChangedFieldLabel).join(', ')\n : ''\n\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.conflict.detected')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.conflictActorUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n changedFields: changedFields || '-',\n },\n sourceEntityType: 'record_locks:conflict',\n sourceEntityId: payload.conflictId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.conflict.detected:${payload.conflictId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n logger.error('Failed to create notification', { err: error })\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
resolveRecordLockNotificationType,
|
|
6
6
|
resolveRecordResourceLink
|
|
7
7
|
} from "../lib/notificationHelpers.js";
|
|
8
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
9
|
+
const logger = createLogger("record_locks").child({ subscriber: "conflict-resolved-notification" });
|
|
8
10
|
const metadata = {
|
|
9
11
|
event: "record_locks.conflict.resolved",
|
|
10
12
|
persistent: true,
|
|
@@ -37,7 +39,7 @@ async function handle(payload, ctx) {
|
|
|
37
39
|
organizationId: payload.organizationId ?? null
|
|
38
40
|
});
|
|
39
41
|
} catch (error) {
|
|
40
|
-
|
|
42
|
+
logger.error("Failed to create notification", { err: error });
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/record_locks/subscribers/conflict-resolved-notification.ts"],
|
|
4
|
-
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport {\n isConflictNotificationEnabled,\n resolveRecordLockNotificationType,\n resolveRecordResourceLink,\n} from '../lib/notificationHelpers'\n\nexport const metadata = {\n event: 'record_locks.conflict.resolved',\n persistent: true,\n id: 'record_locks:conflict-resolved-notification',\n}\n\ntype Payload = {\n conflictId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n conflictActorUserId: string\n incomingActorUserId?: string | null\n resolution?: 'accept_incoming' | 'accept_mine' | 'merged' | null\n resolvedByUserId: string\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.incomingActorUserId || payload.incomingActorUserId === payload.resolvedByUserId) return\n\n const notificationsEnabled = await isConflictNotificationEnabled(ctx, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n if (!notificationsEnabled) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.conflict.resolved')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.incomingActorUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n resolution: payload.resolution ?? 'accept_mine',\n },\n sourceEntityType: 'record_locks:conflict',\n sourceEntityId: payload.conflictId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.conflict.resolved:${payload.conflictId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;
|
|
4
|
+
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport {\n isConflictNotificationEnabled,\n resolveRecordLockNotificationType,\n resolveRecordResourceLink,\n} from '../lib/notificationHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('record_locks').child({ subscriber: 'conflict-resolved-notification' })\n\nexport const metadata = {\n event: 'record_locks.conflict.resolved',\n persistent: true,\n id: 'record_locks:conflict-resolved-notification',\n}\n\ntype Payload = {\n conflictId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n conflictActorUserId: string\n incomingActorUserId?: string | null\n resolution?: 'accept_incoming' | 'accept_mine' | 'merged' | null\n resolvedByUserId: string\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.incomingActorUserId || payload.incomingActorUserId === payload.resolvedByUserId) return\n\n const notificationsEnabled = await isConflictNotificationEnabled(ctx, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n if (!notificationsEnabled) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.conflict.resolved')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.incomingActorUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n resolution: payload.resolution ?? 'accept_mine',\n },\n sourceEntityType: 'record_locks:conflict',\n sourceEntityId: payload.conflictId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.conflict.resolved:${payload.conflictId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n logger.error('Failed to create notification', { err: error })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,cAAc,EAAE,MAAM,EAAE,YAAY,iCAAiC,CAAC;AAE3F,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,IAAI;AACN;AAkBA,eAAO,OAA8B,SAAkB,KAAsB;AAC3E,MAAI,CAAC,QAAQ,uBAAuB,QAAQ,wBAAwB,QAAQ,iBAAkB;AAE9F,QAAM,uBAAuB,MAAM,8BAA8B,KAAK;AAAA,IACpE,UAAU,QAAQ;AAAA,IAClB,gBAAgB,QAAQ,kBAAkB;AAAA,EAC5C,CAAC;AACD,MAAI,CAAC,qBAAsB;AAE3B,MAAI;AACF,UAAM,sBAAsB,2BAA2B,GAAG;AAC1D,UAAM,UAAU,kCAAkC,gCAAgC;AAClF,QAAI,CAAC,QAAS;AAEd,UAAM,oBAAoB,0BAA0B,SAAS;AAAA,MAC3D,iBAAiB,QAAQ;AAAA,MACzB,eAAe;AAAA,QACb,cAAc,QAAQ;AAAA,QACtB,YAAY,QAAQ,cAAc;AAAA,MACpC;AAAA,MACA,kBAAkB;AAAA,MAClB,gBAAgB,QAAQ;AAAA,MACxB,UAAU,0BAA0B,QAAQ,cAAc,QAAQ,UAAU;AAAA,MAC5E,UAAU,kCAAkC,QAAQ,UAAU;AAAA,IAChE,CAAC;AAED,UAAM,oBAAoB,OAAO,mBAAmB;AAAA,MAClD,UAAU,QAAQ;AAAA,MAClB,gBAAgB,QAAQ,kBAAkB;AAAA,IAC5C,CAAC;AAAA,EACH,SAAS,OAAO;AACd,WAAO,MAAM,iCAAiC,EAAE,KAAK,MAAM,CAAC;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { buildNotificationFromType } from "@open-mercato/core/modules/notifications/lib/notificationBuilder";
|
|
2
2
|
import { resolveNotificationService } from "@open-mercato/core/modules/notifications/lib/notificationService";
|
|
3
3
|
import { resolveRecordLockNotificationType, resolveRecordResourceLink } from "../lib/notificationHelpers.js";
|
|
4
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
5
|
+
const logger = createLogger("record_locks").child({ subscriber: "lock-contended-notification" });
|
|
4
6
|
const metadata = {
|
|
5
7
|
event: "record_locks.lock.contended",
|
|
6
8
|
persistent: true,
|
|
@@ -28,7 +30,7 @@ async function handle(payload, ctx) {
|
|
|
28
30
|
organizationId: payload.organizationId ?? null
|
|
29
31
|
});
|
|
30
32
|
} catch (error) {
|
|
31
|
-
|
|
33
|
+
logger.error("Failed to create notification", { err: error });
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/record_locks/subscribers/lock-contended-notification.ts"],
|
|
4
|
-
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport { resolveRecordLockNotificationType, resolveRecordResourceLink } from '../lib/notificationHelpers'\n\nexport const metadata = {\n event: 'record_locks.lock.contended',\n persistent: true,\n id: 'record_locks:lock-contended-notification',\n}\n\ntype Payload = {\n lockId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n lockedByUserId: string\n attemptedByUserId: string\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.lockedByUserId || !payload.attemptedByUserId) return\n if (payload.lockedByUserId === payload.attemptedByUserId) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.lock.contended')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.lockedByUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n },\n sourceEntityType: 'record_locks:lock',\n sourceEntityId: payload.lockId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.lock.contended:${payload.lockId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport { resolveRecordLockNotificationType, resolveRecordResourceLink } from '../lib/notificationHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('record_locks').child({ subscriber: 'lock-contended-notification' })\n\nexport const metadata = {\n event: 'record_locks.lock.contended',\n persistent: true,\n id: 'record_locks:lock-contended-notification',\n}\n\ntype Payload = {\n lockId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n lockedByUserId: string\n attemptedByUserId: string\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.lockedByUserId || !payload.attemptedByUserId) return\n if (payload.lockedByUserId === payload.attemptedByUserId) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.lock.contended')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.lockedByUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n },\n sourceEntityType: 'record_locks:lock',\n sourceEntityId: payload.lockId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n groupKey: `record_locks.lock.contended:${payload.lockId}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n logger.error('Failed to create notification', { err: error })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC,iCAAiC;AAC7E,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,cAAc,EAAE,MAAM,EAAE,YAAY,8BAA8B,CAAC;AAExF,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,IAAI;AACN;AAgBA,eAAO,OAA8B,SAAkB,KAAsB;AAC3E,MAAI,CAAC,QAAQ,kBAAkB,CAAC,QAAQ,kBAAmB;AAC3D,MAAI,QAAQ,mBAAmB,QAAQ,kBAAmB;AAE1D,MAAI;AACF,UAAM,sBAAsB,2BAA2B,GAAG;AAC1D,UAAM,UAAU,kCAAkC,6BAA6B;AAC/E,QAAI,CAAC,QAAS;AAEd,UAAM,oBAAoB,0BAA0B,SAAS;AAAA,MAC3D,iBAAiB,QAAQ;AAAA,MACzB,eAAe;AAAA,QACb,cAAc,QAAQ;AAAA,MACxB;AAAA,MACA,kBAAkB;AAAA,MAClB,gBAAgB,QAAQ;AAAA,MACxB,UAAU,0BAA0B,QAAQ,cAAc,QAAQ,UAAU;AAAA,MAC5E,UAAU,+BAA+B,QAAQ,MAAM;AAAA,IACzD,CAAC;AAED,UAAM,oBAAoB,OAAO,mBAAmB;AAAA,MAClD,UAAU,QAAQ;AAAA,MAClB,gBAAgB,QAAQ,kBAAkB;AAAA,IAC5C,CAAC;AAAA,EACH,SAAS,OAAO;AACd,WAAO,MAAM,iCAAiC,EAAE,KAAK,MAAM,CAAC;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { buildNotificationFromType } from "@open-mercato/core/modules/notifications/lib/notificationBuilder";
|
|
2
2
|
import { resolveNotificationService } from "@open-mercato/core/modules/notifications/lib/notificationService";
|
|
3
3
|
import { resolveRecordLockNotificationType, resolveRecordResourceLink } from "../lib/notificationHelpers.js";
|
|
4
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
5
|
+
const logger = createLogger("record_locks").child({ subscriber: "lock-force-released-notification" });
|
|
4
6
|
const metadata = {
|
|
5
7
|
event: "record_locks.lock.force_released",
|
|
6
8
|
persistent: true,
|
|
@@ -26,7 +28,7 @@ async function handle(payload, ctx) {
|
|
|
26
28
|
organizationId: payload.organizationId ?? null
|
|
27
29
|
});
|
|
28
30
|
} catch (error) {
|
|
29
|
-
|
|
31
|
+
logger.error("Failed to create notification", { err: error });
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/record_locks/subscribers/lock-force-released-notification.ts"],
|
|
4
|
-
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport { resolveRecordLockNotificationType, resolveRecordResourceLink } from '../lib/notificationHelpers'\n\nexport const metadata = {\n event: 'record_locks.lock.force_released',\n persistent: true,\n id: 'record_locks:lock-force-released-notification',\n}\n\ntype Payload = {\n lockId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n lockedByUserId: string\n releasedByUserId: string\n reason?: string | null\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.lockedByUserId || payload.lockedByUserId === payload.releasedByUserId) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.lock.force_released')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.lockedByUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n },\n sourceEntityType: 'record_locks:lock',\n sourceEntityId: payload.lockId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'\nimport { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'\nimport { resolveRecordLockNotificationType, resolveRecordResourceLink } from '../lib/notificationHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('record_locks').child({ subscriber: 'lock-force-released-notification' })\n\nexport const metadata = {\n event: 'record_locks.lock.force_released',\n persistent: true,\n id: 'record_locks:lock-force-released-notification',\n}\n\ntype Payload = {\n lockId: string\n resourceKind: string\n resourceId: string\n tenantId: string\n organizationId?: string | null\n lockedByUserId: string\n releasedByUserId: string\n reason?: string | null\n}\n\ntype ResolverContext = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport default async function handle(payload: Payload, ctx: ResolverContext) {\n if (!payload.lockedByUserId || payload.lockedByUserId === payload.releasedByUserId) return\n\n try {\n const notificationService = resolveNotificationService(ctx)\n const typeDef = resolveRecordLockNotificationType('record_locks.lock.force_released')\n if (!typeDef) return\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: payload.lockedByUserId,\n bodyVariables: {\n resourceKind: payload.resourceKind,\n },\n sourceEntityType: 'record_locks:lock',\n sourceEntityId: payload.lockId,\n linkHref: resolveRecordResourceLink(payload.resourceKind, payload.resourceId),\n })\n\n await notificationService.create(notificationInput, {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId ?? null,\n })\n } catch (error) {\n logger.error('Failed to create notification', { err: error })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC,iCAAiC;AAC7E,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,cAAc,EAAE,MAAM,EAAE,YAAY,mCAAmC,CAAC;AAE7F,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,IAAI;AACN;AAiBA,eAAO,OAA8B,SAAkB,KAAsB;AAC3E,MAAI,CAAC,QAAQ,kBAAkB,QAAQ,mBAAmB,QAAQ,iBAAkB;AAEpF,MAAI;AACF,UAAM,sBAAsB,2BAA2B,GAAG;AAC1D,UAAM,UAAU,kCAAkC,kCAAkC;AACpF,QAAI,CAAC,QAAS;AAEd,UAAM,oBAAoB,0BAA0B,SAAS;AAAA,MAC3D,iBAAiB,QAAQ;AAAA,MACzB,eAAe;AAAA,QACb,cAAc,QAAQ;AAAA,MACxB;AAAA,MACA,kBAAkB;AAAA,MAClB,gBAAgB,QAAQ;AAAA,MACxB,UAAU,0BAA0B,QAAQ,cAAc,QAAQ,UAAU;AAAA,IAC9E,CAAC;AAED,UAAM,oBAAoB,OAAO,mBAAmB;AAAA,MAClD,UAAU,QAAQ;AAAA,MAClB,gBAAgB,QAAQ,kBAAkB;AAAA,IAC5C,CAAC;AAAA,EACH,SAAS,OAAO;AACd,WAAO,MAAM,iCAAiC,EAAE,KAAK,MAAM,CAAC;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
} from "@open-mercato/enterprise/modules/record_locks/lib/clientLockStore";
|
|
30
30
|
import { isUuid, resolveConflictId, runAcceptIncoming } from "./conflictResolution.js";
|
|
31
31
|
import { isOptimisticLockFloorConflict } from "@open-mercato/enterprise/modules/record_locks/lib/optimisticLockFloor";
|
|
32
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
33
|
+
const logger = createLogger("record_locks").child({ component: "record-locking-widget" });
|
|
32
34
|
const GLOBAL_RECORD_LOCK_OWNERS_KEY = "__openMercatoRecordLockWidgetOwners__";
|
|
33
35
|
function getRecordLockOwnerMap() {
|
|
34
36
|
const store = globalThis;
|
|
@@ -327,7 +329,7 @@ function releaseLockWithKeepalive(state) {
|
|
|
327
329
|
keepalive: true,
|
|
328
330
|
credentials: "include"
|
|
329
331
|
}).catch((error) => {
|
|
330
|
-
|
|
332
|
+
logger.warn("Failed to release lock with keepalive fallback", { err: error });
|
|
331
333
|
});
|
|
332
334
|
}
|
|
333
335
|
function RecordLockingWidget({
|
|
@@ -420,7 +422,7 @@ function RecordLockingWidget({
|
|
|
420
422
|
token: current.lock.token,
|
|
421
423
|
reason: "cancelled"
|
|
422
424
|
}).catch((error) => {
|
|
423
|
-
|
|
425
|
+
logger.warn("Failed to release lock while demoting owner", { err: error });
|
|
424
426
|
});
|
|
425
427
|
clearRecordLockFormState(formId);
|
|
426
428
|
}, [formId, isPrimaryInstance]);
|