@open-mercato/core 0.6.8-develop.7068.1.c55b52e1a1 → 0.6.8-develop.7072.1.19c2a8bbe0

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 (51) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js +5 -1
  3. package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js.map +2 -2
  4. package/dist/modules/auth/backend/users/[id]/edit/page.meta.js +5 -1
  5. package/dist/modules/auth/backend/users/[id]/edit/page.meta.js.map +2 -2
  6. package/dist/modules/auth/components/AclEditor.js +39 -30
  7. package/dist/modules/auth/components/AclEditor.js.map +2 -2
  8. package/dist/modules/customers/api/companies/[id]/people/route.js +1 -1
  9. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  10. package/dist/modules/customers/api/companies/[id]/route.js +8 -9
  11. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  12. package/dist/modules/customers/api/deals/[id]/companies/route.js +1 -1
  13. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  14. package/dist/modules/customers/api/deals/[id]/people/route.js +1 -1
  15. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  16. package/dist/modules/customers/api/deals/[id]/route.js +8 -25
  17. package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
  18. package/dist/modules/customers/api/deals/[id]/stats/route.js +3 -22
  19. package/dist/modules/customers/api/deals/[id]/stats/route.js.map +2 -2
  20. package/dist/modules/customers/api/entity-roles-factory.js +4 -4
  21. package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
  22. package/dist/modules/customers/api/people/[id]/companies/context.js +1 -1
  23. package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
  24. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +1 -1
  25. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
  26. package/dist/modules/customers/api/people/[id]/route.js +11 -10
  27. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  28. package/dist/modules/customers/lib/detailReadAccess.js +12 -0
  29. package/dist/modules/customers/lib/detailReadAccess.js.map +7 -0
  30. package/package.json +7 -7
  31. package/src/modules/auth/backend/roles/[id]/edit/page.meta.ts +5 -2
  32. package/src/modules/auth/backend/users/[id]/edit/page.meta.ts +5 -2
  33. package/src/modules/auth/components/AclEditor.tsx +63 -33
  34. package/src/modules/auth/i18n/de.json +380 -0
  35. package/src/modules/auth/i18n/en.json +380 -0
  36. package/src/modules/auth/i18n/es.json +380 -0
  37. package/src/modules/auth/i18n/ko.json +380 -0
  38. package/src/modules/auth/i18n/pl.json +382 -2
  39. package/src/modules/customers/api/companies/[id]/people/route.ts +4 -1
  40. package/src/modules/customers/api/companies/[id]/route.ts +13 -10
  41. package/src/modules/customers/api/deals/[id]/companies/route.ts +4 -1
  42. package/src/modules/customers/api/deals/[id]/people/route.ts +4 -1
  43. package/src/modules/customers/api/deals/[id]/route.ts +17 -28
  44. package/src/modules/customers/api/deals/[id]/stats/route.ts +10 -25
  45. package/src/modules/customers/api/entity-roles-factory.ts +8 -4
  46. package/src/modules/customers/api/people/[id]/companies/context.ts +4 -1
  47. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +4 -1
  48. package/src/modules/customers/api/people/[id]/route.ts +16 -11
  49. package/src/modules/customers/lib/detailReadAccess.ts +35 -0
  50. package/src/modules/dashboards/i18n/es.json +4 -4
  51. package/src/modules/dashboards/i18n/pl.json +7 -7
@@ -1,4 +1,4 @@
1
- [build:core] found 4335 entry points
1
+ [build:core] found 4337 entry points
2
2
  [build:core] built successfully
3
3
  [build:core:generated] found 218 entry points
4
4
  [build:core:generated] built successfully
@@ -2,7 +2,11 @@ const metadata = {
2
2
  requireAuth: true,
3
3
  requireFeatures: ["auth.roles.manage"],
4
4
  pageTitle: "Edit Role",
5
- breadcrumb: [{ label: "Roles", href: "/backend/roles" }, { label: "Edit" }]
5
+ pageTitleKey: "auth.roles.form.title.edit",
6
+ breadcrumb: [
7
+ { label: "Roles", labelKey: "auth.nav.roles", href: "/backend/roles" },
8
+ { label: "Edit", labelKey: "common.edit" }
9
+ ]
6
10
  };
7
11
  export {
8
12
  metadata
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/auth/backend/roles/%5Bid%5D/edit/page.meta.ts"],
4
- "sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['auth.roles.manage'],\n pageTitle: 'Edit Role',\n breadcrumb: [ { label: 'Roles', href: '/backend/roles' }, { label: 'Edit' } ],\n}\n\n\n"],
5
- "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,mBAAmB;AAAA,EACrC,WAAW;AAAA,EACX,YAAY,CAAE,EAAE,OAAO,SAAS,MAAM,iBAAiB,GAAG,EAAE,OAAO,OAAO,CAAE;AAC9E;",
4
+ "sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['auth.roles.manage'],\n pageTitle: 'Edit Role',\n pageTitleKey: 'auth.roles.form.title.edit',\n breadcrumb: [\n { label: 'Roles', labelKey: 'auth.nav.roles', href: '/backend/roles' },\n { label: 'Edit', labelKey: 'common.edit' },\n ],\n}\n\n"],
5
+ "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,mBAAmB;AAAA,EACrC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,IACV,EAAE,OAAO,SAAS,UAAU,kBAAkB,MAAM,iBAAiB;AAAA,IACrE,EAAE,OAAO,QAAQ,UAAU,cAAc;AAAA,EAC3C;AACF;",
6
6
  "names": []
7
7
  }
@@ -2,7 +2,11 @@ const metadata = {
2
2
  requireAuth: true,
3
3
  requireFeatures: ["auth.users.edit"],
4
4
  pageTitle: "Edit User",
5
- breadcrumb: [{ label: "Users", href: "/backend/users" }, { label: "Edit" }]
5
+ pageTitleKey: "auth.users.form.title.edit",
6
+ breadcrumb: [
7
+ { label: "Users", labelKey: "auth.nav.users", href: "/backend/users" },
8
+ { label: "Edit", labelKey: "common.edit" }
9
+ ]
6
10
  };
7
11
  export {
8
12
  metadata
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/auth/backend/users/%5Bid%5D/edit/page.meta.ts"],
4
- "sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['auth.users.edit'],\n pageTitle: 'Edit User',\n breadcrumb: [ { label: 'Users', href: '/backend/users' }, { label: 'Edit' } ],\n}\n\n\n"],
5
- "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,iBAAiB;AAAA,EACnC,WAAW;AAAA,EACX,YAAY,CAAE,EAAE,OAAO,SAAS,MAAM,iBAAiB,GAAG,EAAE,OAAO,OAAO,CAAE;AAC9E;",
4
+ "sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['auth.users.edit'],\n pageTitle: 'Edit User',\n pageTitleKey: 'auth.users.form.title.edit',\n breadcrumb: [\n { label: 'Users', labelKey: 'auth.nav.users', href: '/backend/users' },\n { label: 'Edit', labelKey: 'common.edit' },\n ],\n}\n\n"],
5
+ "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,iBAAiB;AAAA,EACnC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,IACV,EAAE,OAAO,SAAS,UAAU,kBAAkB,MAAM,iBAAiB;AAAA,IACrE,EAAE,OAAO,QAAQ,UAAU,cAAc;AAAA,EAC3C;AACF;",
6
6
  "names": []
7
7
  }
@@ -7,9 +7,6 @@ import Link from "next/link";
7
7
  import { hasFeature, matchFeature } from "@open-mercato/shared/security/features";
8
8
  import { useT } from "@open-mercato/shared/lib/i18n/context";
9
9
  import { AclDependencyDiagnosticsPanel } from "./AclDependencyDiagnosticsPanel.js";
10
- function toTitleCase(value) {
11
- return value.replace(/[-_.]/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
12
- }
13
10
  function normalizeFeatureArray(input) {
14
11
  if (!Array.isArray(input)) return [];
15
12
  const dedup = /* @__PURE__ */ new Set();
@@ -26,12 +23,13 @@ function isTenantRestrictedFeature(feature) {
26
23
  if (feature.startsWith("directory.tenants")) return true;
27
24
  return false;
28
25
  }
29
- function formatWildcardLabel(moduleId, wildcard) {
26
+ function formatWildcardLabel(t, moduleId, wildcard) {
30
27
  if (!wildcard.endsWith(".*")) return wildcard;
31
28
  const prefix = `${moduleId}.`;
32
29
  const suffix = wildcard.startsWith(prefix) ? wildcard.slice(prefix.length, -2) : wildcard.slice(0, -2);
33
- if (!suffix) return "All features";
34
- return `All ${suffix.split(".").map(toTitleCase).join(" / ")}`;
30
+ if (!suffix) return t("auth.acl.wildcards.allFeatures", "All features");
31
+ const group = suffix.split(".").map((segment) => segment.replace(/[-_]/g, " ").replace(/\b\w/g, (char) => char.toUpperCase())).join(" / ");
32
+ return t("auth.acl.wildcards.allGroup", "All permissions in {group}", { group });
35
33
  }
36
34
  function buildRoleSummaries(items, allowedNames) {
37
35
  const summaries = [];
@@ -209,19 +207,27 @@ function AclEditor({
209
207
  const grouped = React.useMemo(() => {
210
208
  const moduleMap = /* @__PURE__ */ new Map();
211
209
  for (const m of modules) {
212
- moduleMap.set(m.id, m.title);
210
+ moduleMap.set(m.id, t(`auth.acl.modules.${m.id}`, m.title));
213
211
  }
214
212
  const map = /* @__PURE__ */ new Map();
215
213
  for (const f of features) {
216
214
  const moduleId = f.module;
217
215
  const moduleTitle = moduleMap.get(moduleId) || moduleId;
216
+ const localizedFeature = {
217
+ ...f,
218
+ title: t(`auth.acl.features.${f.id}`, f.title)
219
+ };
218
220
  if (!map.has(moduleId)) {
219
221
  map.set(moduleId, { moduleId, moduleTitle, features: [] });
220
222
  }
221
- map.get(moduleId).features.push(f);
223
+ map.get(moduleId).features.push(localizedFeature);
222
224
  }
223
225
  return Array.from(map.values()).sort((a, b) => a.moduleTitle.localeCompare(b.moduleTitle));
224
- }, [features, modules]);
226
+ }, [features, modules, t]);
227
+ const localizedFeatures = React.useMemo(
228
+ () => grouped.flatMap((group) => group.features),
229
+ [grouped]
230
+ );
225
231
  const hasGlobalWildcard = granted.includes("*");
226
232
  const hasOrganizationRestriction = Array.isArray(organizations) && organizations.length > 0;
227
233
  const showOrganizationWarning = (kind === "role" || overrideEnabled) && canEditOrganizations && !isSuperAdmin && hasOrganizationRestriction && granted.length === 0;
@@ -243,16 +249,18 @@ function AclEditor({
243
249
  };
244
250
  const isFeatureCoveredByWildcard = (featureId) => granted.some((feature) => (feature === "*" || feature.endsWith(".*")) && matchFeature(featureId, feature));
245
251
  const isFeatureChecked = (featureId) => hasFeature(granted, featureId);
246
- if (loading) return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading ACL\u2026" });
252
+ if (loading) {
253
+ return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: t("auth.acl.loading", "Loading access control\u2026") });
254
+ }
247
255
  const showRoleBanner = kind === "user" && !hasCustomAcl && !overrideEnabled;
248
256
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
249
- showRoleBanner && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4", children: [
250
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-blue-900 mb-2", children: "Permissions inherited from roles" }),
251
- /* @__PURE__ */ jsxs("div", { className: "text-sm text-blue-700 mb-3", children: [
252
- "This user currently inherits permissions from their assigned roles.",
257
+ showRoleBanner && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-status-info-border bg-status-info-bg p-4", children: [
258
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-status-info-text mb-2", children: t("auth.acl.inherited.title", "Permissions inherited from roles") }),
259
+ /* @__PURE__ */ jsxs("div", { className: "text-sm text-status-info-text mb-3", children: [
260
+ t("auth.acl.inherited.description", "This user currently inherits permissions from their assigned roles."),
253
261
  roleDetails.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
254
262
  " ",
255
- "Assigned roles:",
263
+ t("auth.acl.inherited.assignedRoles", "Assigned roles:"),
256
264
  " ",
257
265
  roleDetails.map((role, idx) => {
258
266
  const roleId = typeof role?.id === "string" && role.id.length > 0 ? role.id : `role-${idx}`;
@@ -263,7 +271,7 @@ function AclEditor({
263
271
  Link,
264
272
  {
265
273
  href: `/backend/roles/${roleId}/edit`,
266
- className: "font-semibold text-blue-900 underline hover:text-blue-950 transition-colors",
274
+ className: "font-semibold text-status-info-text underline",
267
275
  children: roleName
268
276
  }
269
277
  )
@@ -282,7 +290,7 @@ function AclEditor({
282
290
  onChange: (e) => setOverrideEnabled(e.target.checked)
283
291
  }
284
292
  ),
285
- /* @__PURE__ */ jsx("label", { htmlFor: "overrideAcl", className: "text-sm text-blue-900 font-medium", children: "Override permissions for this user only" })
293
+ /* @__PURE__ */ jsx("label", { htmlFor: "overrideAcl", className: "text-sm text-status-info-text font-medium", children: t("auth.acl.inherited.override", "Override permissions for this user only") })
286
294
  ] })
287
295
  ] }),
288
296
  (kind === "role" || overrideEnabled) && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -298,13 +306,13 @@ function AclEditor({
298
306
  onChange: (e) => setIsSuperAdmin(!!e.target.checked)
299
307
  }
300
308
  ),
301
- /* @__PURE__ */ jsx("label", { htmlFor: "isSuperAdmin", className: "text-sm", children: "Super Admin (all features)" })
309
+ /* @__PURE__ */ jsx("label", { htmlFor: "isSuperAdmin", className: "text-sm", children: t("auth.acl.superAdmin.label", "Super Admin (all features)") })
302
310
  ] }),
303
- !actorIsSuperAdmin && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Only super administrators can change this option." }),
311
+ !actorIsSuperAdmin && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("auth.acl.superAdmin.hint", "Only super administrators can change this option.") }),
304
312
  !isSuperAdmin && /* @__PURE__ */ jsxs(Fragment, { children: [
305
- hasGlobalWildcard && /* @__PURE__ */ jsxs("div", { className: "rounded border border-blue-200 bg-blue-50 p-3", children: [
306
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-blue-900", children: "Global wildcard (*) enabled" }),
307
- /* @__PURE__ */ jsx("div", { className: "text-xs text-blue-700 mt-1", children: "This grants access to all features in the system." }),
313
+ hasGlobalWildcard && /* @__PURE__ */ jsxs("div", { className: "rounded border border-status-info-border bg-status-info-bg p-3", children: [
314
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-status-info-text", children: t("auth.acl.globalWildcard.title", "Global wildcard (*) enabled") }),
315
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-status-info-text mt-1", children: t("auth.acl.globalWildcard.description", "This grants access to all features in the system.") }),
308
316
  /* @__PURE__ */ jsx(
309
317
  Button,
310
318
  {
@@ -312,7 +320,7 @@ function AclEditor({
312
320
  size: "sm",
313
321
  className: "mt-2",
314
322
  onClick: () => updateGranted((prev) => prev.filter((x) => x !== "*")),
315
- children: "Remove global wildcard"
323
+ children: t("auth.acl.globalWildcard.remove", "Remove global wildcard")
316
324
  }
317
325
  )
318
326
  ] }),
@@ -320,7 +328,7 @@ function AclEditor({
320
328
  AclDependencyDiagnosticsPanel,
321
329
  {
322
330
  granted,
323
- catalog: features,
331
+ catalog: localizedFeatures,
324
332
  onGrantedChange: updateGranted,
325
333
  hideUnknownReferences: process.env.NODE_ENV === "production"
326
334
  }
@@ -360,13 +368,14 @@ function AclEditor({
360
368
  }
361
369
  ),
362
370
  /* @__PURE__ */ jsxs("label", { htmlFor: `module-${group.moduleId}`, className: "text-sm text-muted-foreground", children: [
363
- "All ",
364
- moduleWildcard && !hasGlobalWildcard ? /* @__PURE__ */ jsxs("span", { className: "font-medium text-blue-600", children: [
371
+ t("auth.acl.allModuleFeatures", "All"),
372
+ " ",
373
+ moduleWildcard && !hasGlobalWildcard ? /* @__PURE__ */ jsxs("span", { className: "font-medium text-status-info-text", children: [
365
374
  "(",
366
375
  group.moduleId,
367
376
  ".*)"
368
377
  ] }) : "",
369
- moduleRestricted ? /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs font-medium text-muted-foreground", children: "(manage via super admin)" }) : null
378
+ moduleRestricted ? /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs font-medium text-muted-foreground", children: t("auth.acl.manageViaSuperAdmin", "(manage via super admin)") }) : null
370
379
  ] })
371
380
  ] })
372
381
  ] }),
@@ -393,7 +402,7 @@ function AclEditor({
393
402
  htmlFor: `wildcard-${wildcard}`,
394
403
  className: `text-sm ${disabled ? "text-muted-foreground" : ""}`,
395
404
  children: [
396
- formatWildcardLabel(group.moduleId, wildcard),
405
+ formatWildcardLabel(t, group.moduleId, wildcard),
397
406
  " ",
398
407
  /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-xs font-mono", children: [
399
408
  "(",
@@ -467,7 +476,7 @@ function AclEditor({
467
476
  ] }),
468
477
  canEditOrganizations && /* @__PURE__ */ jsxs("div", { className: "rounded border p-3", children: [
469
478
  /* @__PURE__ */ jsx("div", { className: "text-sm font-medium mb-2", children: t("auth.acl.organizationsScope", "Organizations scope") }),
470
- /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground mb-2", children: "Empty = all organizations. Select one or more to restrict." }),
479
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground mb-2", children: t("auth.acl.organizationsScopeHint", "Empty means all organizations. Select one or more to restrict access.") }),
471
480
  /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-2", children: orgOptions.map((o) => {
472
481
  const checked = organizations == null ? false : (organizations || []).includes(o.id);
473
482
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
@@ -482,7 +491,7 @@ function AclEditor({
482
491
  ] }, o.id);
483
492
  }) }),
484
493
  /* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => setOrganizations(null), children: t("auth.acl.allowAllOrganizations", "Allow all organizations") }) }),
485
- showOrganizationWarning && /* @__PURE__ */ jsx("div", { className: "mt-3 rounded border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900", children: t("auth.acl.organizationWarning", "Organization restrictions are saved only when at least one feature override is selected. Add a feature or enable a module wildcard before saving.") })
494
+ showOrganizationWarning && /* @__PURE__ */ jsx("div", { className: "mt-3 rounded border border-status-warning-border bg-status-warning-bg px-3 py-2 text-sm text-status-warning-text", children: t("auth.acl.organizationWarning", "Organization restrictions are saved only when at least one feature override is selected. Add a feature or enable a module wildcard before saving.") })
486
495
  ] })
487
496
  ] })
488
497
  ] });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/auth/components/AclEditor.tsx"],
4
- "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport Link from 'next/link'\nimport { hasFeature, matchFeature } from '@open-mercato/shared/security/features'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FeatureDescriptor } from '@open-mercato/shared/security/aclDependencies'\nimport { AclDependencyDiagnosticsPanel } from './AclDependencyDiagnosticsPanel'\n\nfunction toTitleCase(value: string): string {\n return value.replace(/[-_.]/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\nfunction normalizeFeatureArray(input: unknown): string[] {\n if (!Array.isArray(input)) return []\n const dedup = new Set<string>()\n for (const value of input) {\n if (typeof value !== 'string') continue\n const trimmed = value.trim()\n if (!trimmed) continue\n dedup.add(trimmed)\n }\n return Array.from(dedup)\n}\n\nfunction isTenantRestrictedFeature(feature: string): boolean {\n if (feature === '*' || feature === 'directory.*') return true\n if (feature.startsWith('directory.tenants')) return true\n return false\n}\n\nfunction formatWildcardLabel(moduleId: string, wildcard: string): string {\n if (!wildcard.endsWith('.*')) return wildcard\n const prefix = `${moduleId}.`\n const suffix = wildcard.startsWith(prefix) ? wildcard.slice(prefix.length, -2) : wildcard.slice(0, -2)\n if (!suffix) return 'All features'\n return `All ${suffix.split('.').map(toTitleCase).join(' / ')}`\n}\n\ntype Feature = { id: string; title: string; module: string; dependsOn?: string[] }\ntype ModuleInfo = { id: string; title: string }\ntype RoleListItem = { id?: string | null; name?: string | null }\ntype RoleListResponse = { items?: RoleListItem[] }\ntype RoleSummary = { id: string; name: string }\n\nfunction buildRoleSummaries(items: RoleListItem[], allowedNames: string[]): RoleSummary[] {\n const summaries: RoleSummary[] = []\n for (const role of items) {\n const name = typeof role?.name === 'string' ? role.name : ''\n if (!name || !allowedNames.includes(name)) continue\n const hasValidId = typeof role?.id === 'string' && role.id.length > 0\n const id = hasValidId ? (role!.id as string) : name\n summaries.push({ id, name })\n }\n return summaries\n}\n\nexport type AclData = {\n isSuperAdmin: boolean\n features: string[]\n organizations: string[] | null\n}\n\ntype FeatureListResponse = { items?: Feature[]; modules?: ModuleInfo[] }\ntype AclPayload = {\n hasCustomAcl?: boolean\n isSuperAdmin?: boolean\n features?: unknown\n organizations?: unknown\n updatedAt?: string | null\n}\ntype OrganizationListResponse = { items?: Array<{ id?: string; name?: string }> }\n\nfunction normalizeOrganizationOptions(items: OrganizationListResponse['items']): Array<{ id: string; name: string }> {\n if (!Array.isArray(items)) return []\n return items.reduce<Array<{ id: string; name: string }>>((acc, org) => {\n if (!org) return acc\n const id = typeof org.id === 'string' && org.id.trim().length > 0 ? org.id : null\n if (!id) return acc\n const name = typeof org.name === 'string' && org.name.trim().length > 0 ? org.name : id\n acc.push({ id, name })\n return acc\n }, [])\n}\n\nasync function readJsonOr<T>(\n url: string,\n init: RequestInit | undefined,\n fallback: T,\n): Promise<T> {\n const call = await apiCall<T>(url, init, { fallback })\n if (!call.ok) return fallback\n return call.result ?? fallback\n}\n\nexport function AclEditor({\n kind,\n targetId,\n canEditOrganizations,\n value,\n onChange,\n onVersionChange,\n userRoles,\n currentUserIsSuperAdmin,\n tenantId,\n preserveOnTenantChange = false,\n}: {\n kind: 'user' | 'role'\n targetId: string\n canEditOrganizations: boolean\n value?: AclData\n onChange?: (data: AclData) => void\n /**\n * Reports the loaded ACL row's `updatedAt` (or null when none exists) so the\n * parent can send the optimistic-lock header on save and reject stale ACL\n * overwrites (#2055).\n */\n onVersionChange?: (updatedAt: string | null) => void\n userRoles?: string[]\n currentUserIsSuperAdmin?: boolean\n tenantId?: string | null\n preserveOnTenantChange?: boolean\n}) {\n const actorIsSuperAdmin = !!currentUserIsSuperAdmin\n const [loading, setLoading] = React.useState(true)\n const [features, setFeatures] = React.useState<Feature[]>([])\n const t = useT()\n const [modules, setModules] = React.useState<ModuleInfo[]>([])\n const [granted, setGranted] = React.useState<string[]>(() => {\n const normalized = normalizeFeatureArray(value?.features)\n return actorIsSuperAdmin ? normalized : normalized.filter((feature) => !isTenantRestrictedFeature(feature))\n })\n const [isSuperAdmin, setIsSuperAdmin] = React.useState(value?.isSuperAdmin || false)\n const [organizations, setOrganizations] = React.useState<string[] | null>(value?.organizations ?? null)\n const [orgOptions, setOrgOptions] = React.useState<{ id: string; name: string }[]>([])\n const [hasCustomAcl, setHasCustomAcl] = React.useState(true)\n const [overrideEnabled, setOverrideEnabled] = React.useState(false)\n const [roleDetails, setRoleDetails] = React.useState<RoleSummary[]>([])\n\n const actorSanitizeFeatures = React.useCallback(\n (list: unknown): string[] => {\n const normalized = normalizeFeatureArray(list)\n if (actorIsSuperAdmin) return normalized\n return normalized.filter((feature) => !isTenantRestrictedFeature(feature))\n },\n [actorIsSuperAdmin],\n )\n\n const updateGranted = React.useCallback(\n (updater: (prev: string[]) => string[]) => {\n setGranted((prev) => actorSanitizeFeatures(updater(prev)))\n },\n [actorSanitizeFeatures],\n )\n\n const tenantIdRef = React.useRef(tenantId)\n React.useEffect(() => { tenantIdRef.current = tenantId }, [tenantId])\n const hasMountedRef = React.useRef(false)\n\n const fetchAclState = React.useCallback(async (forTenantId: string | null | undefined, cancelledRef: { current: boolean }) => {\n try {\n const aclQuery = new URLSearchParams()\n aclQuery.set(kind === 'user' ? 'userId' : 'roleId', targetId)\n if (forTenantId) aclQuery.set('tenantId', forTenantId)\n const aclQueryString = aclQuery.toString()\n const aclJson = await readJsonOr<AclPayload>(\n `/api/auth/${kind === 'user' ? 'users' : 'roles'}/acl${aclQueryString ? `?${aclQueryString}` : ''}`,\n undefined,\n { hasCustomAcl: true, isSuperAdmin: false, features: [], organizations: null },\n )\n if (cancelledRef.current) return\n const customAclExists = aclJson.hasCustomAcl !== false\n setHasCustomAcl(customAclExists)\n setOverrideEnabled(customAclExists)\n setIsSuperAdmin(!!aclJson.isSuperAdmin)\n setGranted(actorSanitizeFeatures(aclJson.features))\n setOrganizations(aclJson.organizations == null ? null : Array.isArray(aclJson.organizations) ? aclJson.organizations : [])\n onVersionChange?.(typeof aclJson.updatedAt === 'string' ? aclJson.updatedAt : null)\n } catch {}\n }, [kind, targetId, actorSanitizeFeatures, onVersionChange])\n\n React.useEffect(() => {\n const cancelled = { current: false }\n async function load() {\n setLoading(true)\n try {\n const fJson = await readJsonOr<FeatureListResponse>(\n '/api/auth/features',\n undefined,\n { items: [], modules: [] },\n )\n if (!cancelled.current) {\n setFeatures(fJson.items || [])\n setModules(fJson.modules || [])\n }\n } catch {}\n await fetchAclState(tenantIdRef.current, cancelled)\n hasMountedRef.current = true\n if (!cancelled.current) setLoading(false)\n }\n load()\n return () => { cancelled.current = true }\n }, [kind, targetId, fetchAclState])\n\n React.useEffect(() => {\n if (!hasMountedRef.current) return\n if (preserveOnTenantChange) return\n const cancelled = { current: false }\n fetchAclState(tenantId, cancelled)\n return () => { cancelled.current = true }\n }, [tenantId, preserveOnTenantChange, fetchAclState])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadTenantScoped() {\n if (canEditOrganizations) {\n try {\n const orgQuery = new URLSearchParams()\n if (tenantId) orgQuery.set('tenantId', tenantId)\n const orgQueryString = orgQuery.toString()\n const oJson = await readJsonOr<OrganizationListResponse>(\n `/api/directory/organizations${orgQueryString ? `?${orgQueryString}` : ''}`,\n undefined,\n { items: [] },\n )\n if (!cancelled) setOrgOptions(normalizeOrganizationOptions(oJson.items))\n } catch {}\n }\n if (kind === 'user' && userRoles && userRoles.length > 0) {\n try {\n const roleQuery = new URLSearchParams({ pageSize: '100' })\n if (tenantId) roleQuery.set('tenantId', tenantId)\n const roleQueryString = roleQuery.toString()\n const rolesJson = await readJsonOr<RoleListResponse>(\n `/api/auth/roles${roleQueryString ? `?${roleQueryString}` : ''}`,\n undefined,\n { items: [] },\n )\n if (!cancelled) {\n const allRoles = Array.isArray(rolesJson.items) ? rolesJson.items : []\n const userRoleDetails: RoleSummary[] = buildRoleSummaries(allRoles, userRoles)\n setRoleDetails(userRoleDetails)\n }\n } catch {}\n }\n }\n loadTenantScoped()\n return () => { cancelled = true }\n }, [kind, canEditOrganizations, userRoles, tenantId])\n\n // Notify parent of changes\n React.useEffect(() => {\n onChange?.({ isSuperAdmin, features: granted, organizations })\n }, [isSuperAdmin, granted, organizations, onChange])\n\n const grouped = React.useMemo(() => {\n const moduleMap = new Map<string, string>()\n for (const m of modules) {\n moduleMap.set(m.id, m.title)\n }\n const map = new Map<string, { moduleId: string; moduleTitle: string; features: Feature[] }>()\n for (const f of features) {\n const moduleId = f.module\n const moduleTitle = moduleMap.get(moduleId) || moduleId\n if (!map.has(moduleId)) {\n map.set(moduleId, { moduleId, moduleTitle, features: [] })\n }\n map.get(moduleId)!.features.push(f)\n }\n return Array.from(map.values()).sort((a, b) => a.moduleTitle.localeCompare(b.moduleTitle))\n }, [features, modules])\n\n const hasGlobalWildcard = granted.includes('*')\n const hasOrganizationRestriction = Array.isArray(organizations) && organizations.length > 0\n const showOrganizationWarning =\n (kind === 'role' || overrideEnabled) &&\n canEditOrganizations &&\n !isSuperAdmin &&\n hasOrganizationRestriction &&\n granted.length === 0\n\n \n const toggleWildcard = React.useCallback((wildcard: string, enable: boolean) => {\n if (!actorIsSuperAdmin && enable && isTenantRestrictedFeature(wildcard)) return\n updateGranted((prev) => {\n if (enable) {\n if (prev.includes(wildcard)) return prev\n return [...prev, wildcard]\n }\n return prev.filter((feature) => feature !== wildcard)\n })\n }, [actorIsSuperAdmin, updateGranted])\n\n const toggleModuleWildcard = React.useCallback((moduleId: string, enable: boolean) => {\n toggleWildcard(`${moduleId}.*`, enable)\n }, [toggleWildcard])\n\n const isModuleWildcardEnabled = (moduleId: string) => {\n return granted.includes(`${moduleId}.*`)\n }\n\n const isFeatureCoveredByWildcard = (featureId: string) =>\n granted.some((feature) => (feature === '*' || feature.endsWith('.*')) && matchFeature(featureId, feature))\n\n const isFeatureChecked = (featureId: string) => hasFeature(granted, featureId)\n\n if (loading) return <div className=\"text-sm text-muted-foreground\">Loading ACL\u2026</div>\n\n const showRoleBanner = kind === 'user' && !hasCustomAcl && !overrideEnabled\n\n return (\n <div className=\"space-y-4\">\n {showRoleBanner && (\n <div className=\"rounded-lg border border-blue-200 bg-blue-50 p-4\">\n <div className=\"text-sm font-medium text-blue-900 mb-2\">\n Permissions inherited from roles\n </div>\n <div className=\"text-sm text-blue-700 mb-3\">\n This user currently inherits permissions from their assigned roles.\n {roleDetails.length > 0 && (\n <span>\n {' '}Assigned roles:{' '}\n {roleDetails.map((role, idx) => {\n const roleId = typeof role?.id === 'string' && role.id.length > 0 ? role.id : `role-${idx}`\n const roleName = typeof role?.name === 'string' && role.name.length > 0 ? role.name : roleId\n return (\n <React.Fragment key={roleId}>\n {idx > 0 && ', '}\n <Link \n href={`/backend/roles/${roleId}/edit`}\n className=\"font-semibold text-blue-900 underline hover:text-blue-950 transition-colors\"\n >\n {roleName}\n </Link>\n </React.Fragment>\n )\n })}\n </span>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <input \n id=\"overrideAcl\" \n type=\"checkbox\" \n className=\"h-4 w-4\" \n checked={overrideEnabled} \n onChange={(e) => setOverrideEnabled(e.target.checked)} \n />\n <label htmlFor=\"overrideAcl\" className=\"text-sm text-blue-900 font-medium\">\n Override permissions for this user only\n </label>\n </div>\n </div>\n )}\n {(kind === 'role' || overrideEnabled) && (\n <>\n <div className=\"flex items-center gap-2\">\n <input\n id=\"isSuperAdmin\"\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={isSuperAdmin}\n disabled={!actorIsSuperAdmin}\n onChange={(e) => setIsSuperAdmin(!!e.target.checked)}\n />\n <label htmlFor=\"isSuperAdmin\" className=\"text-sm\">Super Admin (all features)</label>\n </div>\n {!actorIsSuperAdmin && (\n <p className=\"text-xs text-muted-foreground\">Only super administrators can change this option.</p>\n )}\n {!isSuperAdmin && (\n <>\n {hasGlobalWildcard && (\n <div className=\"rounded border border-blue-200 bg-blue-50 p-3\">\n <div className=\"text-sm font-medium text-blue-900\">Global wildcard (*) enabled</div>\n <div className=\"text-xs text-blue-700 mt-1\">This grants access to all features in the system.</div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-2\"\n onClick={() => updateGranted((prev) => prev.filter((x) => x !== '*'))}\n >\n Remove global wildcard\n </Button>\n </div>\n )}\n {!hasGlobalWildcard && (\n <AclDependencyDiagnosticsPanel\n granted={granted}\n catalog={features as readonly FeatureDescriptor[]}\n onGrantedChange={updateGranted}\n hideUnknownReferences={process.env.NODE_ENV === 'production'}\n />\n )}\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n {grouped.map((group) => {\n const moduleWildcard = isModuleWildcardEnabled(group.moduleId)\n const nestedWildcards = Array.from(\n new Set(\n granted.filter(\n (feature) =>\n feature !== '*' &&\n feature.endsWith('.*') &&\n feature.startsWith(`${group.moduleId}.`) &&\n feature !== `${group.moduleId}.*`,\n ),\n ),\n )\n .map((wildcard) => {\n const prefix = wildcard.slice(0, -1)\n const relatedFeatures = group.features.filter((feature) => feature.id.startsWith(prefix))\n return { wildcard, features: relatedFeatures }\n })\n .sort((a, b) => a.wildcard.localeCompare(b.wildcard))\n const nestedCoveredIds = new Set<string>()\n for (const entry of nestedWildcards) {\n for (const feature of entry.features) nestedCoveredIds.add(feature.id)\n }\n const moduleRestricted = !actorIsSuperAdmin && isTenantRestrictedFeature(`${group.moduleId}.*`)\n const moduleCheckboxDisabled = hasGlobalWildcard || moduleRestricted\n return (\n <div key={group.moduleId} className=\"rounded border p-3\">\n <div className=\"flex items-center justify-between mb-3 pb-2 border-b\">\n <div className=\"text-sm font-medium\">{group.moduleTitle}</div>\n <div className=\"flex items-center gap-2\">\n <input \n id={`module-${group.moduleId}`} \n type=\"checkbox\" \n className=\"h-4 w-4\" \n checked={moduleWildcard || hasGlobalWildcard} \n disabled={moduleCheckboxDisabled}\n onChange={(e) => toggleModuleWildcard(group.moduleId, e.target.checked)} \n />\n <label htmlFor={`module-${group.moduleId}`} className=\"text-sm text-muted-foreground\">\n All {moduleWildcard && !hasGlobalWildcard ? <span className=\"font-medium text-blue-600\">({group.moduleId}.*)</span> : ''}\n {moduleRestricted ? <span className=\"ml-2 text-xs font-medium text-muted-foreground\">(manage via super admin)</span> : null}\n </label>\n </div>\n </div>\n {nestedWildcards.length > 0 && (\n <div className=\"space-y-3 mb-3\">\n {nestedWildcards.map(({ wildcard, features: wildcardFeatures }) => {\n const checked = granted.includes(wildcard) || hasGlobalWildcard || moduleWildcard\n const wildcardRestricted = !actorIsSuperAdmin && isTenantRestrictedFeature(wildcard)\n const disabled = hasGlobalWildcard || moduleWildcard || wildcardRestricted\n return (\n <div key={wildcard} className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <input\n id={`wildcard-${wildcard}`}\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={checked}\n disabled={disabled}\n onChange={(e) => toggleWildcard(wildcard, !!e.target.checked)}\n />\n <label\n htmlFor={`wildcard-${wildcard}`}\n className={`text-sm ${disabled ? 'text-muted-foreground' : ''}`}\n >\n {formatWildcardLabel(group.moduleId, wildcard)}{' '}\n <span className=\"text-muted-foreground text-xs font-mono\">({wildcard})</span>\n {wildcardRestricted ? (\n <span className=\"ml-2 text-xs font-medium text-muted-foreground\">\n {t('auth.acl.restricted', 'Restricted')}\n </span>\n ) : null}\n </label>\n </div>\n {wildcardFeatures.length > 0 && (\n <div className=\"relative ml-6 pl-4 text-sm text-muted-foreground space-y-1\">\n <div className=\"absolute left-0 top-1 bottom-1 w-px bg-border\" aria-hidden />\n {wildcardFeatures.map((wf) => (\n <div key={`${wildcard}-${wf.id}`} className=\"pl-2\">\n <span>\n {wf.title}{' '}\n <span className=\"text-xs font-mono text-muted-foreground\">({wf.id})</span>\n </span>\n </div>\n ))}\n </div>\n )}\n </div>\n )\n })}\n </div>\n )}\n <div className=\"space-y-2\">\n {group.features.map((f) => {\n if (nestedCoveredIds.has(f.id)) return null\n const checked = isFeatureChecked(f.id)\n const isWildcardCovered = isFeatureCoveredByWildcard(f.id)\n const restricted = !actorIsSuperAdmin && isTenantRestrictedFeature(f.id)\n const disabled = isWildcardCovered || restricted\n return (\n <div key={f.id} className=\"flex items-center gap-2\">\n <input\n id={`f-${f.id}`}\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={checked}\n disabled={disabled}\n onChange={(e) => {\n const on = !!e.target.checked\n updateGranted((prev) => {\n if (on) return [...prev, f.id]\n return prev.filter((x) => x !== f.id)\n })\n }}\n />\n <label\n htmlFor={`f-${f.id}`}\n className={`text-sm ${disabled ? 'text-muted-foreground' : ''}`}\n >\n {f.title} <span className=\"text-muted-foreground text-xs\">({f.id})</span>\n {restricted ? (\n <span className=\"ml-2 text-xs font-medium text-muted-foreground\">\n {t('auth.acl.restricted', 'Restricted')}\n </span>\n ) : null}\n </label>\n </div>\n )\n })}\n </div>\n </div>\n )\n })}\n </div>\n </>\n )}\n {canEditOrganizations && (\n <div className=\"rounded border p-3\">\n <div className=\"text-sm font-medium mb-2\">\n {t('auth.acl.organizationsScope', 'Organizations scope')}\n </div>\n <div className=\"text-xs text-muted-foreground mb-2\">Empty = all organizations. Select one or more to restrict.</div>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-2\">\n {orgOptions.map((o) => {\n const checked = organizations == null ? false : (organizations || []).includes(o.id)\n return (\n <div key={o.id} className=\"flex items-center gap-2\">\n <input id={`org-${o.id}`} type=\"checkbox\" className=\"h-4 w-4\" checked={checked} onChange={(e) => {\n const on = !!e.target.checked\n setOrganizations((prev) => {\n if (prev == null) return on ? [o.id] : []\n return on ? Array.from(new Set([...(prev || []), o.id])) : (prev || []).filter((x) => x !== o.id)\n })\n }} />\n <label htmlFor={`org-${o.id}`} className=\"text-sm\">{o.name}</label>\n </div>\n )\n })}\n </div>\n <div className=\"mt-2\">\n <Button variant=\"outline\" onClick={() => setOrganizations(null)}>{t('auth.acl.allowAllOrganizations', 'Allow all organizations')}</Button>\n </div>\n {showOrganizationWarning && (\n <div className=\"mt-3 rounded border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900\">\n {t('auth.acl.organizationWarning', 'Organization restrictions are saved only when at least one feature override is selected. Add a feature or enable a module wildcard before saving.')}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </div>\n )\n}\n"],
5
- "mappings": ";AAmTsB,SAiEd,UAjEc,KAoBF,YApBE;AAlTtB,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAErB,SAAS,qCAAqC;AAE9C,SAAS,YAAY,OAAuB;AAC1C,SAAO,MAAM,QAAQ,UAAU,GAAG,EAAE,QAAQ,SAAS,CAAC,SAAS,KAAK,YAAY,CAAC;AACnF;AAEA,SAAS,sBAAsB,OAA0B;AACvD,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,SAAS,OAAO;AACzB,QAAI,OAAO,UAAU,SAAU;AAC/B,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,CAAC,QAAS;AACd,UAAM,IAAI,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4BACZ,YAAE,+BAA+B,qBAAqB,GACzD;AAAA,QACA,oBAAC,SAAI,WAAU,sCAAqC,wEAA0D;AAAA,QAC9G,oBAAC,SAAI,WAAU,yCACZ,qBAAW,IAAI,CAAC,MAAM;AACrB,gBAAM,UAAU,iBAAiB,OAAO,SAAS,iBAAiB,CAAC,GAAG,SAAS,EAAE,EAAE;AACnF,iBACE,qBAAC,SAAe,WAAU,2BACxB;AAAA,gCAAC,WAAM,IAAI,OAAO,EAAE,EAAE,IAAI,MAAK,YAAW,WAAU,WAAU,SAAkB,UAAU,CAAC,MAAM;AAC/F,oBAAM,KAAK,CAAC,CAAC,EAAE,OAAO;AACtB,+BAAiB,CAAC,SAAS;AACzB,oBAAI,QAAQ,KAAM,QAAO,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC;AACxC,uBAAO,KAAK,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAI,QAAQ,CAAC,GAAI,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,MAAM,EAAE,EAAE;AAAA,cAClG,CAAC;AAAA,YACH,GAAG;AAAA,YACH,oBAAC,WAAM,SAAS,OAAO,EAAE,EAAE,IAAI,WAAU,WAAW,YAAE,MAAK;AAAA,eARnD,EAAE,EASZ;AAAA,QAEJ,CAAC,GACH;AAAA,QACA,oBAAC,SAAI,WAAU,QACb,8BAAC,UAAO,SAAQ,WAAU,SAAS,MAAM,iBAAiB,IAAI,GAAI,YAAE,kCAAkC,yBAAyB,GAAE,GACnI;AAAA,QACC,2BACC,oBAAC,SAAI,WAAU,qFACZ,YAAE,gCAAgC,mJAAmJ,GACxL;AAAA,SAEJ;AAAA,OAEJ;AAAA,KAEJ;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport Link from 'next/link'\nimport { hasFeature, matchFeature } from '@open-mercato/shared/security/features'\nimport { useT, type TranslateFn } from '@open-mercato/shared/lib/i18n/context'\nimport type { FeatureDescriptor } from '@open-mercato/shared/security/aclDependencies'\nimport { AclDependencyDiagnosticsPanel } from './AclDependencyDiagnosticsPanel'\n\nfunction normalizeFeatureArray(input: unknown): string[] {\n if (!Array.isArray(input)) return []\n const dedup = new Set<string>()\n for (const value of input) {\n if (typeof value !== 'string') continue\n const trimmed = value.trim()\n if (!trimmed) continue\n dedup.add(trimmed)\n }\n return Array.from(dedup)\n}\n\nfunction isTenantRestrictedFeature(feature: string): boolean {\n if (feature === '*' || feature === 'directory.*') return true\n if (feature.startsWith('directory.tenants')) return true\n return false\n}\n\nfunction formatWildcardLabel(t: TranslateFn, moduleId: string, wildcard: string): string {\n if (!wildcard.endsWith('.*')) return wildcard\n const prefix = `${moduleId}.`\n const suffix = wildcard.startsWith(prefix) ? wildcard.slice(prefix.length, -2) : wildcard.slice(0, -2)\n if (!suffix) return t('auth.acl.wildcards.allFeatures', 'All features')\n const group = suffix\n .split('.')\n .map((segment) => segment.replace(/[-_]/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase()))\n .join(' / ')\n return t('auth.acl.wildcards.allGroup', 'All permissions in {group}', { group })\n}\n\ntype Feature = { id: string; title: string; module: string; dependsOn?: string[] }\ntype ModuleInfo = { id: string; title: string }\ntype RoleListItem = { id?: string | null; name?: string | null }\ntype RoleListResponse = { items?: RoleListItem[] }\ntype RoleSummary = { id: string; name: string }\n\nfunction buildRoleSummaries(items: RoleListItem[], allowedNames: string[]): RoleSummary[] {\n const summaries: RoleSummary[] = []\n for (const role of items) {\n const name = typeof role?.name === 'string' ? role.name : ''\n if (!name || !allowedNames.includes(name)) continue\n const hasValidId = typeof role?.id === 'string' && role.id.length > 0\n const id = hasValidId ? (role!.id as string) : name\n summaries.push({ id, name })\n }\n return summaries\n}\n\nexport type AclData = {\n isSuperAdmin: boolean\n features: string[]\n organizations: string[] | null\n}\n\ntype FeatureListResponse = { items?: Feature[]; modules?: ModuleInfo[] }\ntype AclPayload = {\n hasCustomAcl?: boolean\n isSuperAdmin?: boolean\n features?: unknown\n organizations?: unknown\n updatedAt?: string | null\n}\ntype OrganizationListResponse = { items?: Array<{ id?: string; name?: string }> }\n\nfunction normalizeOrganizationOptions(items: OrganizationListResponse['items']): Array<{ id: string; name: string }> {\n if (!Array.isArray(items)) return []\n return items.reduce<Array<{ id: string; name: string }>>((acc, org) => {\n if (!org) return acc\n const id = typeof org.id === 'string' && org.id.trim().length > 0 ? org.id : null\n if (!id) return acc\n const name = typeof org.name === 'string' && org.name.trim().length > 0 ? org.name : id\n acc.push({ id, name })\n return acc\n }, [])\n}\n\nasync function readJsonOr<T>(\n url: string,\n init: RequestInit | undefined,\n fallback: T,\n): Promise<T> {\n const call = await apiCall<T>(url, init, { fallback })\n if (!call.ok) return fallback\n return call.result ?? fallback\n}\n\nexport function AclEditor({\n kind,\n targetId,\n canEditOrganizations,\n value,\n onChange,\n onVersionChange,\n userRoles,\n currentUserIsSuperAdmin,\n tenantId,\n preserveOnTenantChange = false,\n}: {\n kind: 'user' | 'role'\n targetId: string\n canEditOrganizations: boolean\n value?: AclData\n onChange?: (data: AclData) => void\n /**\n * Reports the loaded ACL row's `updatedAt` (or null when none exists) so the\n * parent can send the optimistic-lock header on save and reject stale ACL\n * overwrites (#2055).\n */\n onVersionChange?: (updatedAt: string | null) => void\n userRoles?: string[]\n currentUserIsSuperAdmin?: boolean\n tenantId?: string | null\n preserveOnTenantChange?: boolean\n}) {\n const actorIsSuperAdmin = !!currentUserIsSuperAdmin\n const [loading, setLoading] = React.useState(true)\n const [features, setFeatures] = React.useState<Feature[]>([])\n const t = useT()\n const [modules, setModules] = React.useState<ModuleInfo[]>([])\n const [granted, setGranted] = React.useState<string[]>(() => {\n const normalized = normalizeFeatureArray(value?.features)\n return actorIsSuperAdmin ? normalized : normalized.filter((feature) => !isTenantRestrictedFeature(feature))\n })\n const [isSuperAdmin, setIsSuperAdmin] = React.useState(value?.isSuperAdmin || false)\n const [organizations, setOrganizations] = React.useState<string[] | null>(value?.organizations ?? null)\n const [orgOptions, setOrgOptions] = React.useState<{ id: string; name: string }[]>([])\n const [hasCustomAcl, setHasCustomAcl] = React.useState(true)\n const [overrideEnabled, setOverrideEnabled] = React.useState(false)\n const [roleDetails, setRoleDetails] = React.useState<RoleSummary[]>([])\n\n const actorSanitizeFeatures = React.useCallback(\n (list: unknown): string[] => {\n const normalized = normalizeFeatureArray(list)\n if (actorIsSuperAdmin) return normalized\n return normalized.filter((feature) => !isTenantRestrictedFeature(feature))\n },\n [actorIsSuperAdmin],\n )\n\n const updateGranted = React.useCallback(\n (updater: (prev: string[]) => string[]) => {\n setGranted((prev) => actorSanitizeFeatures(updater(prev)))\n },\n [actorSanitizeFeatures],\n )\n\n const tenantIdRef = React.useRef(tenantId)\n React.useEffect(() => { tenantIdRef.current = tenantId }, [tenantId])\n const hasMountedRef = React.useRef(false)\n\n const fetchAclState = React.useCallback(async (forTenantId: string | null | undefined, cancelledRef: { current: boolean }) => {\n try {\n const aclQuery = new URLSearchParams()\n aclQuery.set(kind === 'user' ? 'userId' : 'roleId', targetId)\n if (forTenantId) aclQuery.set('tenantId', forTenantId)\n const aclQueryString = aclQuery.toString()\n const aclJson = await readJsonOr<AclPayload>(\n `/api/auth/${kind === 'user' ? 'users' : 'roles'}/acl${aclQueryString ? `?${aclQueryString}` : ''}`,\n undefined,\n { hasCustomAcl: true, isSuperAdmin: false, features: [], organizations: null },\n )\n if (cancelledRef.current) return\n const customAclExists = aclJson.hasCustomAcl !== false\n setHasCustomAcl(customAclExists)\n setOverrideEnabled(customAclExists)\n setIsSuperAdmin(!!aclJson.isSuperAdmin)\n setGranted(actorSanitizeFeatures(aclJson.features))\n setOrganizations(aclJson.organizations == null ? null : Array.isArray(aclJson.organizations) ? aclJson.organizations : [])\n onVersionChange?.(typeof aclJson.updatedAt === 'string' ? aclJson.updatedAt : null)\n } catch {}\n }, [kind, targetId, actorSanitizeFeatures, onVersionChange])\n\n React.useEffect(() => {\n const cancelled = { current: false }\n async function load() {\n setLoading(true)\n try {\n const fJson = await readJsonOr<FeatureListResponse>(\n '/api/auth/features',\n undefined,\n { items: [], modules: [] },\n )\n if (!cancelled.current) {\n setFeatures(fJson.items || [])\n setModules(fJson.modules || [])\n }\n } catch {}\n await fetchAclState(tenantIdRef.current, cancelled)\n hasMountedRef.current = true\n if (!cancelled.current) setLoading(false)\n }\n load()\n return () => { cancelled.current = true }\n }, [kind, targetId, fetchAclState])\n\n React.useEffect(() => {\n if (!hasMountedRef.current) return\n if (preserveOnTenantChange) return\n const cancelled = { current: false }\n fetchAclState(tenantId, cancelled)\n return () => { cancelled.current = true }\n }, [tenantId, preserveOnTenantChange, fetchAclState])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadTenantScoped() {\n if (canEditOrganizations) {\n try {\n const orgQuery = new URLSearchParams()\n if (tenantId) orgQuery.set('tenantId', tenantId)\n const orgQueryString = orgQuery.toString()\n const oJson = await readJsonOr<OrganizationListResponse>(\n `/api/directory/organizations${orgQueryString ? `?${orgQueryString}` : ''}`,\n undefined,\n { items: [] },\n )\n if (!cancelled) setOrgOptions(normalizeOrganizationOptions(oJson.items))\n } catch {}\n }\n if (kind === 'user' && userRoles && userRoles.length > 0) {\n try {\n const roleQuery = new URLSearchParams({ pageSize: '100' })\n if (tenantId) roleQuery.set('tenantId', tenantId)\n const roleQueryString = roleQuery.toString()\n const rolesJson = await readJsonOr<RoleListResponse>(\n `/api/auth/roles${roleQueryString ? `?${roleQueryString}` : ''}`,\n undefined,\n { items: [] },\n )\n if (!cancelled) {\n const allRoles = Array.isArray(rolesJson.items) ? rolesJson.items : []\n const userRoleDetails: RoleSummary[] = buildRoleSummaries(allRoles, userRoles)\n setRoleDetails(userRoleDetails)\n }\n } catch {}\n }\n }\n loadTenantScoped()\n return () => { cancelled = true }\n }, [kind, canEditOrganizations, userRoles, tenantId])\n\n // Notify parent of changes\n React.useEffect(() => {\n onChange?.({ isSuperAdmin, features: granted, organizations })\n }, [isSuperAdmin, granted, organizations, onChange])\n\n const grouped = React.useMemo(() => {\n const moduleMap = new Map<string, string>()\n for (const m of modules) {\n moduleMap.set(m.id, t(`auth.acl.modules.${m.id}`, m.title))\n }\n const map = new Map<string, { moduleId: string; moduleTitle: string; features: Feature[] }>()\n for (const f of features) {\n const moduleId = f.module\n const moduleTitle = moduleMap.get(moduleId) || moduleId\n const localizedFeature = {\n ...f,\n title: t(`auth.acl.features.${f.id}`, f.title),\n }\n if (!map.has(moduleId)) {\n map.set(moduleId, { moduleId, moduleTitle, features: [] })\n }\n map.get(moduleId)!.features.push(localizedFeature)\n }\n return Array.from(map.values()).sort((a, b) => a.moduleTitle.localeCompare(b.moduleTitle))\n }, [features, modules, t])\n\n const localizedFeatures = React.useMemo(\n () => grouped.flatMap((group) => group.features),\n [grouped],\n )\n\n const hasGlobalWildcard = granted.includes('*')\n const hasOrganizationRestriction = Array.isArray(organizations) && organizations.length > 0\n const showOrganizationWarning =\n (kind === 'role' || overrideEnabled) &&\n canEditOrganizations &&\n !isSuperAdmin &&\n hasOrganizationRestriction &&\n granted.length === 0\n\n \n const toggleWildcard = React.useCallback((wildcard: string, enable: boolean) => {\n if (!actorIsSuperAdmin && enable && isTenantRestrictedFeature(wildcard)) return\n updateGranted((prev) => {\n if (enable) {\n if (prev.includes(wildcard)) return prev\n return [...prev, wildcard]\n }\n return prev.filter((feature) => feature !== wildcard)\n })\n }, [actorIsSuperAdmin, updateGranted])\n\n const toggleModuleWildcard = React.useCallback((moduleId: string, enable: boolean) => {\n toggleWildcard(`${moduleId}.*`, enable)\n }, [toggleWildcard])\n\n const isModuleWildcardEnabled = (moduleId: string) => {\n return granted.includes(`${moduleId}.*`)\n }\n\n const isFeatureCoveredByWildcard = (featureId: string) =>\n granted.some((feature) => (feature === '*' || feature.endsWith('.*')) && matchFeature(featureId, feature))\n\n const isFeatureChecked = (featureId: string) => hasFeature(granted, featureId)\n\n if (loading) {\n return (\n <div className=\"text-sm text-muted-foreground\">\n {t('auth.acl.loading', 'Loading access control\u2026')}\n </div>\n )\n }\n\n const showRoleBanner = kind === 'user' && !hasCustomAcl && !overrideEnabled\n\n return (\n <div className=\"space-y-4\">\n {showRoleBanner && (\n <div className=\"rounded-lg border border-status-info-border bg-status-info-bg p-4\">\n <div className=\"text-sm font-medium text-status-info-text mb-2\">\n {t('auth.acl.inherited.title', 'Permissions inherited from roles')}\n </div>\n <div className=\"text-sm text-status-info-text mb-3\">\n {t('auth.acl.inherited.description', 'This user currently inherits permissions from their assigned roles.')}\n {roleDetails.length > 0 && (\n <span>\n {' '}{t('auth.acl.inherited.assignedRoles', 'Assigned roles:')}{' '}\n {roleDetails.map((role, idx) => {\n const roleId = typeof role?.id === 'string' && role.id.length > 0 ? role.id : `role-${idx}`\n const roleName = typeof role?.name === 'string' && role.name.length > 0 ? role.name : roleId\n return (\n <React.Fragment key={roleId}>\n {idx > 0 && ', '}\n <Link \n href={`/backend/roles/${roleId}/edit`}\n className=\"font-semibold text-status-info-text underline\"\n >\n {roleName}\n </Link>\n </React.Fragment>\n )\n })}\n </span>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <input \n id=\"overrideAcl\" \n type=\"checkbox\" \n className=\"h-4 w-4\" \n checked={overrideEnabled} \n onChange={(e) => setOverrideEnabled(e.target.checked)} \n />\n <label htmlFor=\"overrideAcl\" className=\"text-sm text-status-info-text font-medium\">\n {t('auth.acl.inherited.override', 'Override permissions for this user only')}\n </label>\n </div>\n </div>\n )}\n {(kind === 'role' || overrideEnabled) && (\n <>\n <div className=\"flex items-center gap-2\">\n <input\n id=\"isSuperAdmin\"\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={isSuperAdmin}\n disabled={!actorIsSuperAdmin}\n onChange={(e) => setIsSuperAdmin(!!e.target.checked)}\n />\n <label htmlFor=\"isSuperAdmin\" className=\"text-sm\">\n {t('auth.acl.superAdmin.label', 'Super Admin (all features)')}\n </label>\n </div>\n {!actorIsSuperAdmin && (\n <p className=\"text-xs text-muted-foreground\">\n {t('auth.acl.superAdmin.hint', 'Only super administrators can change this option.')}\n </p>\n )}\n {!isSuperAdmin && (\n <>\n {hasGlobalWildcard && (\n <div className=\"rounded border border-status-info-border bg-status-info-bg p-3\">\n <div className=\"text-sm font-medium text-status-info-text\">\n {t('auth.acl.globalWildcard.title', 'Global wildcard (*) enabled')}\n </div>\n <div className=\"text-xs text-status-info-text mt-1\">\n {t('auth.acl.globalWildcard.description', 'This grants access to all features in the system.')}\n </div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-2\"\n onClick={() => updateGranted((prev) => prev.filter((x) => x !== '*'))}\n >\n {t('auth.acl.globalWildcard.remove', 'Remove global wildcard')}\n </Button>\n </div>\n )}\n {!hasGlobalWildcard && (\n <AclDependencyDiagnosticsPanel\n granted={granted}\n catalog={localizedFeatures as readonly FeatureDescriptor[]}\n onGrantedChange={updateGranted}\n hideUnknownReferences={process.env.NODE_ENV === 'production'}\n />\n )}\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n {grouped.map((group) => {\n const moduleWildcard = isModuleWildcardEnabled(group.moduleId)\n const nestedWildcards = Array.from(\n new Set(\n granted.filter(\n (feature) =>\n feature !== '*' &&\n feature.endsWith('.*') &&\n feature.startsWith(`${group.moduleId}.`) &&\n feature !== `${group.moduleId}.*`,\n ),\n ),\n )\n .map((wildcard) => {\n const prefix = wildcard.slice(0, -1)\n const relatedFeatures = group.features.filter((feature) => feature.id.startsWith(prefix))\n return { wildcard, features: relatedFeatures }\n })\n .sort((a, b) => a.wildcard.localeCompare(b.wildcard))\n const nestedCoveredIds = new Set<string>()\n for (const entry of nestedWildcards) {\n for (const feature of entry.features) nestedCoveredIds.add(feature.id)\n }\n const moduleRestricted = !actorIsSuperAdmin && isTenantRestrictedFeature(`${group.moduleId}.*`)\n const moduleCheckboxDisabled = hasGlobalWildcard || moduleRestricted\n return (\n <div key={group.moduleId} className=\"rounded border p-3\">\n <div className=\"flex items-center justify-between mb-3 pb-2 border-b\">\n <div className=\"text-sm font-medium\">{group.moduleTitle}</div>\n <div className=\"flex items-center gap-2\">\n <input \n id={`module-${group.moduleId}`} \n type=\"checkbox\" \n className=\"h-4 w-4\" \n checked={moduleWildcard || hasGlobalWildcard} \n disabled={moduleCheckboxDisabled}\n onChange={(e) => toggleModuleWildcard(group.moduleId, e.target.checked)} \n />\n <label htmlFor={`module-${group.moduleId}`} className=\"text-sm text-muted-foreground\">\n {t('auth.acl.allModuleFeatures', 'All')}{' '}\n {moduleWildcard && !hasGlobalWildcard ? <span className=\"font-medium text-status-info-text\">({group.moduleId}.*)</span> : ''}\n {moduleRestricted ? (\n <span className=\"ml-2 text-xs font-medium text-muted-foreground\">\n {t('auth.acl.manageViaSuperAdmin', '(manage via super admin)')}\n </span>\n ) : null}\n </label>\n </div>\n </div>\n {nestedWildcards.length > 0 && (\n <div className=\"space-y-3 mb-3\">\n {nestedWildcards.map(({ wildcard, features: wildcardFeatures }) => {\n const checked = granted.includes(wildcard) || hasGlobalWildcard || moduleWildcard\n const wildcardRestricted = !actorIsSuperAdmin && isTenantRestrictedFeature(wildcard)\n const disabled = hasGlobalWildcard || moduleWildcard || wildcardRestricted\n return (\n <div key={wildcard} className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <input\n id={`wildcard-${wildcard}`}\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={checked}\n disabled={disabled}\n onChange={(e) => toggleWildcard(wildcard, !!e.target.checked)}\n />\n <label\n htmlFor={`wildcard-${wildcard}`}\n className={`text-sm ${disabled ? 'text-muted-foreground' : ''}`}\n >\n {formatWildcardLabel(t, group.moduleId, wildcard)}{' '}\n <span className=\"text-muted-foreground text-xs font-mono\">({wildcard})</span>\n {wildcardRestricted ? (\n <span className=\"ml-2 text-xs font-medium text-muted-foreground\">\n {t('auth.acl.restricted', 'Restricted')}\n </span>\n ) : null}\n </label>\n </div>\n {wildcardFeatures.length > 0 && (\n <div className=\"relative ml-6 pl-4 text-sm text-muted-foreground space-y-1\">\n <div className=\"absolute left-0 top-1 bottom-1 w-px bg-border\" aria-hidden />\n {wildcardFeatures.map((wf) => (\n <div key={`${wildcard}-${wf.id}`} className=\"pl-2\">\n <span>\n {wf.title}{' '}\n <span className=\"text-xs font-mono text-muted-foreground\">({wf.id})</span>\n </span>\n </div>\n ))}\n </div>\n )}\n </div>\n )\n })}\n </div>\n )}\n <div className=\"space-y-2\">\n {group.features.map((f) => {\n if (nestedCoveredIds.has(f.id)) return null\n const checked = isFeatureChecked(f.id)\n const isWildcardCovered = isFeatureCoveredByWildcard(f.id)\n const restricted = !actorIsSuperAdmin && isTenantRestrictedFeature(f.id)\n const disabled = isWildcardCovered || restricted\n return (\n <div key={f.id} className=\"flex items-center gap-2\">\n <input\n id={`f-${f.id}`}\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={checked}\n disabled={disabled}\n onChange={(e) => {\n const on = !!e.target.checked\n updateGranted((prev) => {\n if (on) return [...prev, f.id]\n return prev.filter((x) => x !== f.id)\n })\n }}\n />\n <label\n htmlFor={`f-${f.id}`}\n className={`text-sm ${disabled ? 'text-muted-foreground' : ''}`}\n >\n {f.title} <span className=\"text-muted-foreground text-xs\">({f.id})</span>\n {restricted ? (\n <span className=\"ml-2 text-xs font-medium text-muted-foreground\">\n {t('auth.acl.restricted', 'Restricted')}\n </span>\n ) : null}\n </label>\n </div>\n )\n })}\n </div>\n </div>\n )\n })}\n </div>\n </>\n )}\n {canEditOrganizations && (\n <div className=\"rounded border p-3\">\n <div className=\"text-sm font-medium mb-2\">\n {t('auth.acl.organizationsScope', 'Organizations scope')}\n </div>\n <div className=\"text-xs text-muted-foreground mb-2\">\n {t('auth.acl.organizationsScopeHint', 'Empty means all organizations. Select one or more to restrict access.')}\n </div>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-2\">\n {orgOptions.map((o) => {\n const checked = organizations == null ? false : (organizations || []).includes(o.id)\n return (\n <div key={o.id} className=\"flex items-center gap-2\">\n <input id={`org-${o.id}`} type=\"checkbox\" className=\"h-4 w-4\" checked={checked} onChange={(e) => {\n const on = !!e.target.checked\n setOrganizations((prev) => {\n if (prev == null) return on ? [o.id] : []\n return on ? Array.from(new Set([...(prev || []), o.id])) : (prev || []).filter((x) => x !== o.id)\n })\n }} />\n <label htmlFor={`org-${o.id}`} className=\"text-sm\">{o.name}</label>\n </div>\n )\n })}\n </div>\n <div className=\"mt-2\">\n <Button variant=\"outline\" onClick={() => setOrganizations(null)}>{t('auth.acl.allowAllOrganizations', 'Allow all organizations')}</Button>\n </div>\n {showOrganizationWarning && (\n <div className=\"mt-3 rounded border border-status-warning-border bg-status-warning-bg px-3 py-2 text-sm text-status-warning-text\">\n {t('auth.acl.organizationWarning', 'Organization restrictions are saved only when at least one feature override is selected. Add a feature or enable a module wildcard before saving.')}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": ";AA8TM,SAyEE,UAzEF,KAwBc,YAxBd;AA7TN,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAA8B;AAEvC,SAAS,qCAAqC;AAE9C,SAAS,sBAAsB,OAA0B;AACvD,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,SAAS,OAAO;AACzB,QAAI,OAAO,UAAU,SAAU;AAC/B,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,CAAC,QAAS;AACd,UAAM,IAAI,OAAO;AAAA,EACnB;AACA,SAAO,MAAM,KAAK,KAAK;AACzB;AAEA,SAAS,0BAA0B,SAA0B;AAC3D,MAAI,YAAY,OAAO,YAAY,cAAe,QAAO;AACzD,MAAI,QAAQ,WAAW,mBAAmB,EAAG,QAAO;AACpD,SAAO;AACT;AAEA,SAAS,oBAAoB,GAAgB,UAAkB,UAA0B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AAO,EAAE,EAAE,IAAI,WAAU,WAAW,YAAE,MAAK;AAAA,eARnD,EAAE,EASZ;AAAA,QAEJ,CAAC,GACH;AAAA,QACA,oBAAC,SAAI,WAAU,QACb,8BAAC,UAAO,SAAQ,WAAU,SAAS,MAAM,iBAAiB,IAAI,GAAI,YAAE,kCAAkC,yBAAyB,GAAE,GACnI;AAAA,QACC,2BACC,oBAAC,SAAI,WAAU,oHACZ,YAAE,gCAAgC,mJAAmJ,GACxL;AAAA,SAEJ;AAAA,OAEJ;AAAA,KAEJ;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -81,7 +81,7 @@ async function GET(req, ctx) {
81
81
  throw notFound(translate("customers.errors.company_not_found", "Company not found"));
82
82
  }
83
83
  if (!isOrganizationReadAccessAllowed({ scope, auth, organizationId: company.organizationId })) {
84
- throw new CrudHttpError(403, { error: translate("customers.errors.access_denied", "Access denied") });
84
+ throw notFound(translate("customers.errors.company_not_found", "Company not found"));
85
85
  }
86
86
  const entityScope = { tenantId: auth.tenantId, organizationId: company.organizationId };
87
87
  const union = await loadCompanyPeopleUnion(em, company, entityScope);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/customers/api/companies/%5Bid%5D/people/route.ts"],
4
- "sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError, isCrudHttpError, notFound } from '@open-mercato/shared/lib/crud/errors'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { isOrganizationReadAccessAllowed } from '@open-mercato/core/modules/directory/utils/organizationScopeGuard'\nimport { CustomerEntity } from '../../../../data/entities'\nimport { loadCompanyPeopleUnion } from '../../../../lib/personCompanies'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('customers')\n\nconst paramsSchema = z.object({\n id: z.string().uuid(),\n})\n\nconst querySchema = z.object({\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(100).default(20),\n search: z.string().optional(),\n sort: z.enum(['name-asc', 'name-desc', 'recent']).default('name-asc'),\n})\n\ntype CompanyPersonItem = {\n id: string\n displayName: string\n primaryEmail: string | null\n primaryPhone: string | null\n status: string | null\n lifecycleStage: string | null\n jobTitle: string | null\n department: string | null\n createdAt: string\n organizationId: string\n temperature: string | null\n source: string | null\n linkedAt: string | null\n}\n\nfunction matchesSearch(item: CompanyPersonItem, query: string): boolean {\n const normalized = query.trim().toLowerCase()\n if (!normalized.length) return true\n return [\n item.displayName,\n item.primaryEmail,\n item.primaryPhone,\n item.jobTitle,\n item.department,\n item.status,\n item.lifecycleStage,\n item.source,\n ]\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n .some((value) => value.toLowerCase().includes(normalized))\n}\n\nfunction sortItems(items: CompanyPersonItem[], sort: 'name-asc' | 'name-desc' | 'recent'): CompanyPersonItem[] {\n if (sort === 'recent') {\n return [...items].sort((left, right) => {\n const leftTimestamp = left.linkedAt ? new Date(left.linkedAt).getTime() : new Date(left.createdAt).getTime()\n const rightTimestamp = right.linkedAt ? new Date(right.linkedAt).getTime() : new Date(right.createdAt).getTime()\n if (leftTimestamp === rightTimestamp) return left.displayName.localeCompare(right.displayName)\n return rightTimestamp - leftTimestamp\n })\n }\n\n return [...items].sort((left, right) => {\n const compare = left.displayName.localeCompare(right.displayName, undefined, { sensitivity: 'base' })\n return sort === 'name-asc' ? compare : -compare\n })\n}\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['customers.companies.view'] },\n}\n\nexport async function GET(req: Request, ctx: { params?: { id?: string } }) {\n const { translate } = await resolveTranslations()\n try {\n const { id } = paramsSchema.parse({ id: ctx.params?.id })\n const auth = await getAuthFromRequest(req)\n if (!auth?.tenantId) throw new CrudHttpError(401, { error: 'Unauthorized' })\n\n const query = querySchema.parse({\n page: new URL(req.url).searchParams.get('page') ?? undefined,\n pageSize: new URL(req.url).searchParams.get('pageSize') ?? undefined,\n search: new URL(req.url).searchParams.get('search') ?? undefined,\n sort: new URL(req.url).searchParams.get('sort') ?? undefined,\n })\n\n const container = await createRequestContainer()\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const em = (container.resolve('em') as EntityManager).fork()\n const decryptionScope = {\n tenantId: auth.tenantId,\n organizationId: scope?.selectedId ?? auth.orgId ?? null,\n }\n\n const company = await findOneWithDecryption(\n em,\n CustomerEntity,\n { id, kind: 'company', tenantId: auth.tenantId, deletedAt: null },\n {},\n decryptionScope,\n )\n if (!company) {\n throw notFound(translate('customers.errors.company_not_found', 'Company not found'))\n }\n\n if (!isOrganizationReadAccessAllowed({ scope, auth, organizationId: company.organizationId })) {\n throw new CrudHttpError(403, { error: translate('customers.errors.access_denied', 'Access denied') })\n }\n\n const entityScope = { tenantId: auth.tenantId, organizationId: company.organizationId }\n const union = await loadCompanyPeopleUnion(em, company, entityScope)\n\n const items = union.map(({ entity: person, profile, linkedAt }) => ({\n id: person.id,\n displayName: person.displayName ?? person.primaryEmail ?? person.id,\n primaryEmail: person.primaryEmail ?? null,\n primaryPhone: person.primaryPhone ?? null,\n status: person.status ?? null,\n lifecycleStage: person.lifecycleStage ?? null,\n jobTitle: profile?.jobTitle ?? null,\n department: profile?.department ?? null,\n createdAt: person.createdAt.toISOString(),\n organizationId: person.organizationId,\n temperature: person.temperature ?? null,\n source: person.source ?? null,\n linkedAt,\n } satisfies CompanyPersonItem))\n\n const filtered = query.search?.trim().length ? items.filter((item) => matchesSearch(item, query.search ?? '')) : items\n const sorted = sortItems(filtered, query.sort)\n const total = sorted.length\n const totalPages = Math.max(1, Math.ceil(total / query.pageSize))\n const page = Math.min(query.page, totalPages)\n const start = (page - 1) * query.pageSize\n\n return NextResponse.json({\n items: sorted.slice(start, start + query.pageSize),\n total,\n page,\n pageSize: query.pageSize,\n totalPages,\n })\n } catch (error) {\n if (isCrudHttpError(error)) {\n return NextResponse.json(error.body, { status: error.status })\n }\n logger.error('customers.companies.people.GET', { err: error })\n return NextResponse.json({ error: translate('customers.errors.company_people_load_failed', 'Failed to load linked people') }, { status: 500 })\n }\n}\n\nconst companyPeopleItemSchema = z.object({\n id: z.string().uuid(),\n displayName: z.string(),\n primaryEmail: z.string().nullable(),\n primaryPhone: z.string().nullable(),\n status: z.string().nullable(),\n lifecycleStage: z.string().nullable(),\n jobTitle: z.string().nullable(),\n department: z.string().nullable(),\n createdAt: z.string(),\n organizationId: z.string().uuid().nullable(),\n temperature: z.string().nullable(),\n source: z.string().nullable(),\n linkedAt: z.string().nullable(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Customers',\n methods: {\n GET: {\n summary: 'List linked people for a company',\n query: querySchema,\n responses: [\n {\n status: 200,\n description: 'Paginated linked people',\n schema: z.object({\n items: z.array(companyPeopleItemSchema),\n total: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n pageSize: z.number().int().min(1),\n totalPages: z.number().int().min(1),\n }),\n },\n ],\n },\n },\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,eAAe,iBAAiB,gBAAgB;AACzD,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AACnD,SAAS,2BAA2B;AAEpC,SAAS,6BAA6B;AACtC,SAAS,uCAAuC;AAChD,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,WAAW;AAEvC,MAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,IAAI,EAAE,OAAO,EAAE,KAAK;AACtB,CAAC;AAED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ACR,aAAa;AAAA,UACb,QAAQ,EAAE,OAAO;AAAA,YACf,OAAO,EAAE,MAAM,uBAAuB;AAAA,YACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAAA,YACpC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,YAC5B,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,YAChC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,UACpC,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError, isCrudHttpError, notFound } from '@open-mercato/shared/lib/crud/errors'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { isOrganizationReadAccessAllowed } from '@open-mercato/core/modules/directory/utils/organizationScopeGuard'\nimport { CustomerEntity } from '../../../../data/entities'\nimport { loadCompanyPeopleUnion } from '../../../../lib/personCompanies'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('customers')\n\nconst paramsSchema = z.object({\n id: z.string().uuid(),\n})\n\nconst querySchema = z.object({\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(100).default(20),\n search: z.string().optional(),\n sort: z.enum(['name-asc', 'name-desc', 'recent']).default('name-asc'),\n})\n\ntype CompanyPersonItem = {\n id: string\n displayName: string\n primaryEmail: string | null\n primaryPhone: string | null\n status: string | null\n lifecycleStage: string | null\n jobTitle: string | null\n department: string | null\n createdAt: string\n organizationId: string\n temperature: string | null\n source: string | null\n linkedAt: string | null\n}\n\nfunction matchesSearch(item: CompanyPersonItem, query: string): boolean {\n const normalized = query.trim().toLowerCase()\n if (!normalized.length) return true\n return [\n item.displayName,\n item.primaryEmail,\n item.primaryPhone,\n item.jobTitle,\n item.department,\n item.status,\n item.lifecycleStage,\n item.source,\n ]\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n .some((value) => value.toLowerCase().includes(normalized))\n}\n\nfunction sortItems(items: CompanyPersonItem[], sort: 'name-asc' | 'name-desc' | 'recent'): CompanyPersonItem[] {\n if (sort === 'recent') {\n return [...items].sort((left, right) => {\n const leftTimestamp = left.linkedAt ? new Date(left.linkedAt).getTime() : new Date(left.createdAt).getTime()\n const rightTimestamp = right.linkedAt ? new Date(right.linkedAt).getTime() : new Date(right.createdAt).getTime()\n if (leftTimestamp === rightTimestamp) return left.displayName.localeCompare(right.displayName)\n return rightTimestamp - leftTimestamp\n })\n }\n\n return [...items].sort((left, right) => {\n const compare = left.displayName.localeCompare(right.displayName, undefined, { sensitivity: 'base' })\n return sort === 'name-asc' ? compare : -compare\n })\n}\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['customers.companies.view'] },\n}\n\nexport async function GET(req: Request, ctx: { params?: { id?: string } }) {\n const { translate } = await resolveTranslations()\n try {\n const { id } = paramsSchema.parse({ id: ctx.params?.id })\n const auth = await getAuthFromRequest(req)\n if (!auth?.tenantId) throw new CrudHttpError(401, { error: 'Unauthorized' })\n\n const query = querySchema.parse({\n page: new URL(req.url).searchParams.get('page') ?? undefined,\n pageSize: new URL(req.url).searchParams.get('pageSize') ?? undefined,\n search: new URL(req.url).searchParams.get('search') ?? undefined,\n sort: new URL(req.url).searchParams.get('sort') ?? undefined,\n })\n\n const container = await createRequestContainer()\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const em = (container.resolve('em') as EntityManager).fork()\n const decryptionScope = {\n tenantId: auth.tenantId,\n organizationId: scope?.selectedId ?? auth.orgId ?? null,\n }\n\n const company = await findOneWithDecryption(\n em,\n CustomerEntity,\n { id, kind: 'company', tenantId: auth.tenantId, deletedAt: null },\n {},\n decryptionScope,\n )\n if (!company) {\n throw notFound(translate('customers.errors.company_not_found', 'Company not found'))\n }\n\n // Existence oracle (#5504): deny a cross-org read as not-found \u2014 identical to\n // the parent-not-found above \u2014 so it cannot reveal that a company exists in an\n // organization the caller cannot see.\n if (!isOrganizationReadAccessAllowed({ scope, auth, organizationId: company.organizationId })) {\n throw notFound(translate('customers.errors.company_not_found', 'Company not found'))\n }\n\n const entityScope = { tenantId: auth.tenantId, organizationId: company.organizationId }\n const union = await loadCompanyPeopleUnion(em, company, entityScope)\n\n const items = union.map(({ entity: person, profile, linkedAt }) => ({\n id: person.id,\n displayName: person.displayName ?? person.primaryEmail ?? person.id,\n primaryEmail: person.primaryEmail ?? null,\n primaryPhone: person.primaryPhone ?? null,\n status: person.status ?? null,\n lifecycleStage: person.lifecycleStage ?? null,\n jobTitle: profile?.jobTitle ?? null,\n department: profile?.department ?? null,\n createdAt: person.createdAt.toISOString(),\n organizationId: person.organizationId,\n temperature: person.temperature ?? null,\n source: person.source ?? null,\n linkedAt,\n } satisfies CompanyPersonItem))\n\n const filtered = query.search?.trim().length ? items.filter((item) => matchesSearch(item, query.search ?? '')) : items\n const sorted = sortItems(filtered, query.sort)\n const total = sorted.length\n const totalPages = Math.max(1, Math.ceil(total / query.pageSize))\n const page = Math.min(query.page, totalPages)\n const start = (page - 1) * query.pageSize\n\n return NextResponse.json({\n items: sorted.slice(start, start + query.pageSize),\n total,\n page,\n pageSize: query.pageSize,\n totalPages,\n })\n } catch (error) {\n if (isCrudHttpError(error)) {\n return NextResponse.json(error.body, { status: error.status })\n }\n logger.error('customers.companies.people.GET', { err: error })\n return NextResponse.json({ error: translate('customers.errors.company_people_load_failed', 'Failed to load linked people') }, { status: 500 })\n }\n}\n\nconst companyPeopleItemSchema = z.object({\n id: z.string().uuid(),\n displayName: z.string(),\n primaryEmail: z.string().nullable(),\n primaryPhone: z.string().nullable(),\n status: z.string().nullable(),\n lifecycleStage: z.string().nullable(),\n jobTitle: z.string().nullable(),\n department: z.string().nullable(),\n createdAt: z.string(),\n organizationId: z.string().uuid().nullable(),\n temperature: z.string().nullable(),\n source: z.string().nullable(),\n linkedAt: z.string().nullable(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Customers',\n methods: {\n GET: {\n summary: 'List linked people for a company',\n query: querySchema,\n responses: [\n {\n status: 200,\n description: 'Paginated linked people',\n schema: z.object({\n items: z.array(companyPeopleItemSchema),\n total: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n pageSize: z.number().int().min(1),\n totalPages: z.number().int().min(1),\n }),\n },\n ],\n },\n },\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,eAAe,iBAAiB,gBAAgB;AACzD,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AACnD,SAAS,2BAA2B;AAEpC,SAAS,6BAA6B;AACtC,SAAS,uCAAuC;AAChD,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,WAAW;AAEvC,MAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,IAAI,EAAE,OAAO,EAAE,KAAK;AACtB,CAAC;AAED,MAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,MAAM,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;AAAA,EACxC,UAAU,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AAAA,EACtD,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,KAAK,CAAC,YAAY,aAAa,QAAQ,CAAC,EAAE,QAAQ,UAAU;AACtE,C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;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -42,7 +42,7 @@ import {
42
42
  loadCompanyPeopleUnion
43
43
  } from "../../../lib/personCompanies.js";
44
44
  import { normalizeCustomerDetailCustomFields } from "../../detailCustomFields.js";
45
- import { isOrganizationReadAccessAllowed } from "@open-mercato/core/modules/directory/utils/organizationScopeGuard";
45
+ import { denyCustomerDetailReadAsNotFound } from "../../../lib/detailReadAccess.js";
46
46
  import { runWithCacheTenant } from "@open-mercato/cache";
47
47
  import {
48
48
  buildCollectionTags,
@@ -107,9 +107,6 @@ function parseIncludeParams(request) {
107
107
  });
108
108
  return tokens;
109
109
  }
110
- function forbidden(message) {
111
- return NextResponse.json({ error: message }, { status: 403 });
112
- }
113
110
  function notFound(message) {
114
111
  return NextResponse.json({ error: message }, { status: 404 });
115
112
  }
@@ -371,9 +368,11 @@ async function GET(_req, ctx) {
371
368
  }
372
369
  );
373
370
  if (!company) return notFound("Company not found");
374
- if (!isOrganizationReadAccessAllowed({ scope, auth, organizationId: company.organizationId })) {
375
- return forbidden("Access denied");
376
- }
371
+ const organizationReadDenied = denyCustomerDetailReadAsNotFound(
372
+ { scope, auth, organizationId: company.organizationId },
373
+ "Company not found"
374
+ );
375
+ if (organizationReadDenied) return organizationReadDenied;
377
376
  const companyScope = {
378
377
  tenantId: company.tenantId ?? auth.tenantId ?? null,
379
378
  organizationId: company.organizationId ?? scope?.selectedId ?? auth.orgId ?? null
@@ -1150,8 +1149,8 @@ const openApi = {
1150
1149
  errors: [
1151
1150
  { status: 400, description: "Invalid identifier", schema: companyDetailErrorSchema },
1152
1151
  { status: 401, description: "Unauthorized", schema: companyDetailErrorSchema },
1153
- { status: 403, description: "Forbidden for tenant/organization scope", schema: companyDetailErrorSchema },
1154
- { status: 404, description: "Company not found", schema: companyDetailErrorSchema }
1152
+ { status: 403, description: "Forbidden \u2014 caller lacks the required feature", schema: companyDetailErrorSchema },
1153
+ { status: 404, description: "Company not found, or its organization is not in the caller\u2019s scope", schema: companyDetailErrorSchema }
1155
1154
  ]
1156
1155
  }
1157
1156
  }