@vritti/api-sdk 0.3.3 → 0.3.5

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 (133) hide show
  1. package/dist/auth.cjs +942 -0
  2. package/dist/auth.cjs.map +1 -0
  3. package/dist/auth.d.cts +95 -0
  4. package/dist/auth.d.ts +95 -0
  5. package/dist/auth.js +884 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/cache.cjs +182 -14
  8. package/dist/cache.cjs.map +1 -1
  9. package/dist/cache.d.cts +48 -4
  10. package/dist/cache.d.ts +48 -4
  11. package/dist/cache.js +177 -12
  12. package/dist/cache.js.map +1 -1
  13. package/dist/catalog-resolver.cjs +226 -51
  14. package/dist/catalog-resolver.cjs.map +1 -1
  15. package/dist/catalog-resolver.d.cts +41 -19
  16. package/dist/catalog-resolver.d.ts +41 -19
  17. package/dist/catalog-resolver.js +212 -46
  18. package/dist/catalog-resolver.js.map +1 -1
  19. package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
  20. package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
  21. package/dist/context.cjs +93 -0
  22. package/dist/context.cjs.map +1 -0
  23. package/dist/context.d.cts +19 -0
  24. package/dist/context.d.ts +19 -0
  25. package/dist/context.js +64 -0
  26. package/dist/context.js.map +1 -0
  27. package/dist/countries.cjs +1559 -0
  28. package/dist/countries.cjs.map +1 -0
  29. package/dist/countries.d.cts +13 -0
  30. package/dist/countries.d.ts +13 -0
  31. package/dist/countries.js +1532 -0
  32. package/dist/countries.js.map +1 -0
  33. package/dist/data-table.cjs +1280 -0
  34. package/dist/data-table.cjs.map +1 -0
  35. package/dist/data-table.d.cts +123 -0
  36. package/dist/data-table.d.ts +123 -0
  37. package/dist/data-table.js +1260 -0
  38. package/dist/data-table.js.map +1 -0
  39. package/dist/database.cjs +1510 -0
  40. package/dist/database.cjs.map +1 -0
  41. package/dist/database.d.cts +287 -0
  42. package/dist/database.d.ts +287 -0
  43. package/dist/database.js +1469 -0
  44. package/dist/database.js.map +1 -0
  45. package/dist/decimal.d.cts +0 -1
  46. package/dist/decimal.d.ts +0 -1
  47. package/dist/decorators.cjs +1817 -0
  48. package/dist/decorators.cjs.map +1 -0
  49. package/dist/decorators.d.cts +24 -0
  50. package/dist/decorators.d.ts +24 -0
  51. package/dist/decorators.js +1780 -0
  52. package/dist/decorators.js.map +1 -0
  53. package/dist/drizzle-pg-core.cjs +25 -0
  54. package/dist/drizzle-pg-core.cjs.map +1 -1
  55. package/dist/drizzle-pg-core.d.cts +7 -0
  56. package/dist/drizzle-pg-core.d.ts +7 -0
  57. package/dist/drizzle-pg-core.js +22 -0
  58. package/dist/drizzle-pg-core.js.map +1 -1
  59. package/dist/exceptions.cjs +301 -0
  60. package/dist/exceptions.cjs.map +1 -0
  61. package/dist/exceptions.d.cts +90 -0
  62. package/dist/exceptions.d.ts +90 -0
  63. package/dist/exceptions.js +257 -0
  64. package/dist/exceptions.js.map +1 -0
  65. package/dist/filter.types-PuARU9XD.d.cts +50 -0
  66. package/dist/filter.types-PuARU9XD.d.ts +50 -0
  67. package/dist/filters.cjs +407 -0
  68. package/dist/filters.cjs.map +1 -0
  69. package/dist/filters.d.cts +55 -0
  70. package/dist/filters.d.ts +55 -0
  71. package/dist/filters.js +377 -0
  72. package/dist/filters.js.map +1 -0
  73. package/dist/index.cjs +0 -5423
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +93 -854
  76. package/dist/index.d.ts +93 -854
  77. package/dist/index.js +0 -5301
  78. package/dist/index.js.map +1 -1
  79. package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
  80. package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
  81. package/dist/license.d.cts +1 -1
  82. package/dist/license.d.ts +1 -1
  83. package/dist/lodash.cjs.map +1 -1
  84. package/dist/lodash.js.map +1 -1
  85. package/dist/logger.cjs +862 -0
  86. package/dist/logger.cjs.map +1 -0
  87. package/dist/logger.d.cts +118 -0
  88. package/dist/logger.d.ts +118 -0
  89. package/dist/logger.js +816 -0
  90. package/dist/logger.js.map +1 -0
  91. package/dist/migrate.cjs +2 -2
  92. package/dist/migrate.cjs.map +1 -1
  93. package/dist/migrate.d.cts +2 -0
  94. package/dist/migrate.d.ts +2 -0
  95. package/dist/migrate.js +2 -2
  96. package/dist/migrate.js.map +1 -1
  97. package/dist/money.cjs +18 -3
  98. package/dist/money.cjs.map +1 -1
  99. package/dist/money.d.cts +13 -13
  100. package/dist/money.d.ts +13 -13
  101. package/dist/money.js +18 -3
  102. package/dist/money.js.map +1 -1
  103. package/dist/nats.cjs +34 -35
  104. package/dist/nats.cjs.map +1 -1
  105. package/dist/nats.d.cts +14 -14
  106. package/dist/nats.d.ts +14 -14
  107. package/dist/nats.js +32 -33
  108. package/dist/nats.js.map +1 -1
  109. package/dist/root.cjs +225 -0
  110. package/dist/root.cjs.map +1 -0
  111. package/dist/root.d.cts +4 -0
  112. package/dist/root.d.ts +4 -0
  113. package/dist/root.js +200 -0
  114. package/dist/root.js.map +1 -0
  115. package/dist/{types-DQRwj5rr.d.cts → types-C9jPdQqH.d.cts} +32 -6
  116. package/dist/{types-DQRwj5rr.d.ts → types-C9jPdQqH.d.ts} +32 -6
  117. package/dist/types.cjs +19 -0
  118. package/dist/types.cjs.map +1 -0
  119. package/dist/types.d.cts +17 -0
  120. package/dist/types.d.ts +17 -0
  121. package/dist/types.js +1 -0
  122. package/dist/types.js.map +1 -0
  123. package/dist/utils.cjs +273 -0
  124. package/dist/utils.cjs.map +1 -0
  125. package/dist/utils.d.cts +8 -0
  126. package/dist/utils.d.ts +8 -0
  127. package/dist/utils.js +245 -0
  128. package/dist/utils.js.map +1 -0
  129. package/package.json +122 -1
  130. package/dist/cache.service-_SuJIcNA.d.cts +0 -20
  131. package/dist/cache.service-_SuJIcNA.d.ts +0 -20
  132. package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
  133. package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/catalog-resolver/index.ts","../src/catalog-resolver/catalog.builder.ts","../src/catalog-resolver/types.ts","../src/catalog-resolver/bu-matrix.builder.ts","../src/catalog-resolver/compose-role-grants.ts","../src/catalog-resolver/resolve-user-features.ts"],"sourcesContent":["// Catalog resolver — the single shared implementation of snapshot resolution (BU catalog, BU matrix, user features)\nexport {\n type BuMatrix,\n type BuMatrixApp,\n type BuMatrixCell,\n type BuMatrixFeature,\n type BuMatrixPermission,\n buildBuMatrix,\n} from './bu-matrix.builder';\nexport { buildBuCatalog, buildBuRoles, isBuLockedOnPlatform, isPlanMember } from './catalog.builder';\nexport { type ComposeRoleGrantsParams, composeRoleGrants, type RevokedGrants } from './compose-role-grants';\nexport {\n type ClientPlatform,\n type LockedPermission,\n type PermissionFeature,\n pickRouteForPlatform,\n type ResolveUserFeaturesParams,\n resolveUserFeatures,\n} from './resolve-user-features';\nexport {\n type BuFeatureLocks,\n type CatalogPermission,\n type FeatureCatalogEntry,\n type FeatureUnlocks,\n type LockReason,\n PLATFORMS,\n type PlatformBucket,\n type PlatformCodes,\n type PlatformDenyCodes,\n type RoleItem,\n SNAPSHOT_SCHEMA_VERSION,\n type SnapshotApp,\n type SnapshotBusiness,\n type SnapshotFeature,\n type SnapshotMicrofrontendMobile,\n type SnapshotMicrofrontends,\n type SnapshotMicrofrontendWeb,\n type SnapshotPermission,\n type SnapshotPlan,\n type SnapshotRoleTemplate,\n type VersionSnapshot,\n} from './types';\n","import type {\n BuFeatureLocks,\n CatalogPermission,\n FeatureCatalogEntry,\n LockReason,\n PlatformBucket,\n PlatformCodes,\n RoleItem,\n SnapshotFeature,\n SnapshotPlan,\n VersionSnapshot,\n} from './types';\n\n// Builds the per-BU catalog for ONE platform bucket. The plan is the ceiling (membership + unlocks); buLocks is a\n// deny-list within the plan (undefined or absent entries ⇒ fully available). Each permission carries\n// locked + lockReason + unlockPlans, all evaluated against the requested bucket only.\nexport function buildBuCatalog(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n buLocks: BuFeatureLocks | undefined,\n bucket: PlatformBucket,\n): FeatureCatalogEntry[] {\n if (!businessCode) return [];\n const business = snapshot.businesses?.[businessCode];\n if (!business) return [];\n const plan = planCode ? business.plans?.[planCode] : undefined;\n const plans = business.plans ?? {};\n\n const catalog: FeatureCatalogEntry[] = [];\n for (const app of business.apps) {\n // The app's renderable features (each feature pins to exactly one app)\n const businessAppFeatures = app.features\n .map((code) => snapshot.features?.[code])\n .filter((f): f is SnapshotFeature => !!f && !!(f.microfrontends?.web || f.microfrontends?.mobile));\n\n if (businessAppFeatures.length === 0) continue;\n\n // Emit EVERY business feature so a role's grant on a plan-omitted feature still resolves (rendered as a locked\n // tile with an upsell) instead of vanishing. Core filters the catalog down to what the user's role grants.\n for (const feature of businessAppFeatures) {\n const membership = plan?.unlockedPermissions?.[feature.code];\n // Routes are exposed wherever the feature SHIPS — membership never hides them. A role grant on a\n // plan-omitted (feature or platform) still resolves as a locked tile with an upsell instead of vanishing.\n const web = feature.microfrontends?.web;\n const mobile = feature.microfrontends?.mobile;\n\n const permissions = buildPermissions(feature, businessCode, membership, buLocks, plans, bucket);\n // Feature-level lock is EXPLICIT, never derived from permission locks: the plan must include the feature\n // on this bucket (membership) and the BU must not null-lock the platform. Permission-code locks only\n // disable individual actions — the feature still renders (sidebar/tile stays enabled).\n const memberOnBucket = membership?.[bucket] !== undefined;\n const buPlatformLocked = buLocks?.[feature.code]?.[bucket] === null;\n const locked = !memberOnBucket || buPlatformLocked;\n const lockReason: LockReason | null = !memberOnBucket ? 'PLAN' : buPlatformLocked ? 'BU' : null;\n const unlockPlans = lockReason === 'PLAN' ? plansIncludingFeature(plans, feature.code, bucket) : [];\n\n catalog.push({\n code: feature.code,\n name: feature.name,\n lucideIcon: feature.lucideIcon ?? null,\n sfSymbol: feature.sfSymbol ?? 'square',\n materialSymbol: feature.materialSymbol ?? 'square',\n web: web\n ? {\n remoteEntry: web.remoteEntry ?? '',\n exposedModule: web.exposedModule ?? '',\n routePrefix: web.routePrefix ?? '',\n }\n : null,\n mobile: mobile\n ? {\n remoteEntryAndroid: mobile.remoteEntryAndroid ?? '',\n remoteEntryIos: mobile.remoteEntryIos ?? '',\n exposedModule: mobile.exposedModule ?? '',\n routePrefix: mobile.routePrefix ?? '',\n }\n : null,\n appCode: app.code,\n appName: app.name,\n appIcon: app.icon ?? null,\n appSortOrder: app.sortOrder ?? 0,\n locked,\n lockReason,\n unlockPlans,\n permissions,\n });\n }\n }\n return catalog;\n}\n\n// A feature is a plan member when its unlock entry exists on at least one platform (even with zero actions)\nexport function isPlanMember(entry: PlatformCodes | undefined): boolean {\n return !!entry && (entry.web !== undefined || entry.mobile !== undefined);\n}\n\n// Per-platform BU-lock primitive: platform null locks the whole feature there; string[] locks those codes;\n// entry/platform absent ⇒ not locked\nexport function isBuLockedOnPlatform(\n entry: BuFeatureLocks[string] | undefined,\n platform: PlatformBucket,\n code: string,\n): boolean {\n const locks = entry?.[platform];\n return locks === null || (locks?.includes(code) ?? false);\n}\n\n// A feature's business-scoped permissions, each tagged with locked + reason against the plan and the BU deny-list.\n// Everything is bucket-scoped: a web resolution ignores mobile unlocks and mobile locks entirely.\nfunction buildPermissions(\n feature: SnapshotFeature,\n businessCode: string,\n planMembership: PlatformCodes | undefined,\n buLocks: BuFeatureLocks | undefined,\n plans: Record<string, SnapshotPlan>,\n bucket: PlatformBucket,\n): CatalogPermission[] {\n const planUnlocked = new Set(planMembership?.[bucket] ?? []);\n const lockEntry = buLocks?.[feature.code];\n\n return (feature.permissions ?? [])\n .filter((p) => p.isGlobal || p.businesses.includes(businessCode))\n .map((p) => {\n const planAllows = planUnlocked.has(p.code);\n const buAllows = !isBuLockedOnPlatform(lockEntry, bucket, p.code);\n const locked = !planAllows || !buAllows;\n // Plan is the ceiling, so a plan-lock wins over a BU-lock when reporting the reason\n const lockReason: LockReason | null = !planAllows ? 'PLAN' : !buAllows ? 'BU' : null;\n const unlockPlans = lockReason === 'PLAN' ? plansUnlockingPermission(plans, feature.code, p.code, bucket) : [];\n return { code: p.code, locked, lockReason, unlockPlans };\n });\n}\n\n// Plan codes (in the business) whose unlocked set includes this feature+permission on the bucket — upsell targets\nfunction plansUnlockingPermission(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n permCode: string,\n bucket: PlatformBucket,\n): string[] {\n const result: string[] = [];\n for (const [code, plan] of Object.entries(plans)) {\n if (plan.unlockedPermissions?.[featureCode]?.[bucket]?.includes(permCode)) result.push(code);\n }\n return result;\n}\n\n// Plan codes (in the business) that include this feature on the bucket — the feature-level upsell targets\nfunction plansIncludingFeature(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n bucket: PlatformBucket,\n): string[] {\n const result: string[] = [];\n for (const [code, plan] of Object.entries(plans)) {\n if (plan.unlockedPermissions?.[featureCode]?.[bucket] !== undefined) result.push(code);\n }\n return result;\n}\n\n// The business's role templates as provisionable role items for core (identical shapes)\nexport function buildBuRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[] {\n if (!businessCode) return [];\n const business = snapshot.businesses?.[businessCode];\n if (!business) return [];\n return Object.values(business.roleTemplates ?? {});\n}\n","// ——— Platform algebra ———\n// Everything in this domain (plan unlocks, role grants, BU locks) is stored per UI platform bucket.\n\nexport type PlatformBucket = 'web' | 'mobile';\n\nexport const PLATFORMS: PlatformBucket[] = ['web', 'mobile'];\n\n// Allow entry: a bucket key present (even []) = membership on that platform; the array holds permission codes\nexport interface PlatformCodes {\n web?: string[];\n mobile?: string[];\n}\n\n// Deny entry: null locks/revokes the whole bucket, string[] the listed codes, absent = untouched\nexport interface PlatformDenyCodes {\n web?: string[] | null;\n mobile?: string[] | null;\n}\n\n// Code-keyed allow-list — plan unlocks, role grants, and matrix selections all share this exact shape\nexport type FeatureUnlocks = Record<string, PlatformCodes>;\n\n// BU deny-list overlay (same shape as role revokes) — feature absent = fully available within the plan\nexport type BuFeatureLocks = Record<string, PlatformDenyCodes>;\n\n// ——— Snapshot document shape — what gets stored in versions.snapshot and signed into the catalog license ———\n\nexport interface SnapshotPermission {\n code: string;\n label: string;\n isGlobal: boolean;\n businesses: string[];\n}\n// WEB microfrontend route — a single remote entry. All non-null: a WEB microfrontend row is\n// CHECK-constrained to have remoteEntry set, and the feature↔MF link's module/route are NOT NULL.\nexport interface SnapshotMicrofrontendWeb {\n code: string;\n name: string;\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n}\n// MOBILE microfrontend route — per-OS remote entries (android + ios). All non-null: a MOBILE row is\n// CHECK-constrained to have both android + ios set, and the link's module/route are NOT NULL.\nexport interface SnapshotMicrofrontendMobile {\n code: string;\n name: string;\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n}\n// Per-platform microfrontend routes — mirrors the PlatformCodes {web?, mobile?} bucket shape\nexport interface SnapshotMicrofrontends {\n web?: SnapshotMicrofrontendWeb;\n mobile?: SnapshotMicrofrontendMobile;\n}\nexport interface SnapshotFeature {\n code: string;\n name: string;\n lucideIcon: string;\n sfSymbol: string;\n materialSymbol: string;\n permissions: SnapshotPermission[];\n microfrontends: SnapshotMicrofrontends;\n}\nexport interface SnapshotApp {\n code: string;\n name: string;\n icon: string;\n sortOrder: number;\n features: string[];\n}\n// Also the shape provisioned to core as a role stub (the template's code is the durable org-role link)\nexport interface SnapshotRoleTemplate {\n name: string;\n code: string;\n // featureCode -> per-platform granted permission codes\n features: FeatureUnlocks;\n}\n// A plan is a lock overlay: the feature-permissions it UNLOCKS per platform (everything else renders locked).\n// Apps are derived from these.\nexport interface SnapshotPlan {\n code: string;\n name: string;\n isCustom: boolean;\n maxBusinessUnits: number | null;\n unlockedPermissions: FeatureUnlocks;\n}\nexport interface SnapshotBusiness {\n name: string;\n apps: SnapshotApp[];\n // Keyed by template code — the same key org roles link to\n roleTemplates: Record<string, SnapshotRoleTemplate>;\n plans: Record<string, SnapshotPlan>;\n}\nexport interface VersionSnapshot {\n // Shape revision hook for future migrations (absent = pre-versioned snapshots)\n schemaVersion?: number;\n features: Record<string, SnapshotFeature>;\n businesses: Record<string, SnapshotBusiness>;\n}\n\n// The current snapshot shape revision written by the cloud snapshot builder\nexport const SNAPSHOT_SCHEMA_VERSION = 1;\n\n// Why a permission/feature is locked: PLAN (org's plan doesn't unlock it) or BU (this BU restricts it)\nexport type LockReason = 'PLAN' | 'BU';\n\n// A catalog permission: its lock state + reason + (when plan-locked) the plans that would unlock it (upsell)\nexport interface CatalogPermission {\n code: string;\n locked: boolean;\n lockReason: LockReason | null;\n unlockPlans: string[];\n}\n\n// One resolved feature of the per-BU catalog\nexport interface FeatureCatalogEntry {\n code: string;\n name: string;\n lucideIcon: string | null;\n sfSymbol: string;\n materialSymbol: string;\n // Per-platform MF route — symmetric { web?, mobile? }; null when the feature has no MF for that platform.\n web: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n mobile: {\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n appCode: string;\n appName: string;\n appIcon: string | null;\n appSortOrder: number;\n // Feature-level lock is explicit — plan non-membership or a BU whole-platform lock (never derived from\n // permission-code locks, which only disable individual actions)\n locked: boolean;\n lockReason: LockReason | null;\n // Plans (in the business) that would unlock the feature when it's plan-locked — for upsell\n unlockPlans: string[];\n permissions: CatalogPermission[];\n}\n\n// Role template pushed to core for provisioning — identical to the snapshot template shape\nexport type RoleItem = SnapshotRoleTemplate;\n","import { isBuLockedOnPlatform, isPlanMember } from './catalog.builder';\nimport { type BuFeatureLocks, PLATFORMS, type PlatformBucket, type SnapshotPlan, type VersionSnapshot } from './types';\n\n// A single (permission, platform) cell. null ⇒ the feature doesn't ship on that platform.\nexport interface BuMatrixCell {\n inPlan: boolean; // the org's plan unlocks this (feature, platform, permission)\n selected: boolean; // the BU currently has it enabled (never true when !inPlan)\n availableIn: string[]; // other plan names that unlock it — upsell; only when !inPlan\n}\n\nexport interface BuMatrixPermission {\n code: string;\n label: string;\n web: BuMatrixCell | null;\n mobile: BuMatrixCell | null;\n}\n\nexport interface BuMatrixFeature {\n code: string;\n name: string;\n icon: string | null;\n platforms: PlatformBucket[]; // platforms the feature ships on\n inPlan: boolean; // FEATURE-level: is this feature a member of the org's plan at all?\n availableIn: string[]; // plans that include the feature — upsell when !inPlan\n permissions: BuMatrixPermission[];\n}\n\nexport interface BuMatrixApp {\n code: string;\n name: string;\n icon: string | null;\n unlockedCount: number; // (feature × platform × permission) cells the plan unlocks\n totalCount: number; // all possible cells in this app\n features: BuMatrixFeature[];\n}\n\nexport interface BuMatrix {\n plan: { code: string; name: string };\n apps: BuMatrixApp[];\n // The stored BU deny-list verbatim — lock editors seed from this, never from derived selected flags\n locks: BuFeatureLocks;\n}\n\n// Builds the full apps/features/permissions matrix from the version snapshot — NOT filtered to plan members.\n// Every app/feature/permission renders; plan-locked items carry inPlan=false + availableIn (the upsell plans).\n// buLocks layers the BU's deny-list within the plan (undefined or absent entries ⇒ the full plan is selected).\nexport function buildBuMatrix(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n buLocks: BuFeatureLocks | undefined,\n): BuMatrix {\n const business = businessCode ? snapshot.businesses?.[businessCode] : undefined;\n const plans = business?.plans ?? {};\n const plan = planCode ? plans[planCode] : undefined;\n const planMeta = { code: planCode ?? '', name: plan?.name ?? planCode ?? '' };\n const locks = buLocks ?? {};\n if (!business || !plan) return { plan: planMeta, apps: [], locks };\n\n const apps: BuMatrixApp[] = [];\n for (const app of business.apps) {\n let unlockedCount = 0;\n let totalCount = 0;\n const features: BuMatrixFeature[] = [];\n\n for (const code of app.features) {\n const feature = snapshot.features?.[code];\n if (!feature) continue;\n const platforms = PLATFORMS.filter((p) => !!feature.microfrontends?.[p]);\n if (platforms.length === 0) continue;\n\n const membership = plan.unlockedPermissions?.[code];\n const featureInPlan = isPlanMember(membership);\n const buEntry = buLocks?.[code];\n\n const permissions: BuMatrixPermission[] = (feature.permissions ?? [])\n .filter((p) => p.isGlobal || p.businesses.includes(businessCode ?? ''))\n .map((p) => {\n const cell = (plat: PlatformBucket): BuMatrixCell | null => {\n if (!platforms.includes(plat)) return null;\n const planCodes = membership?.[plat];\n const inPlan = featureInPlan && planCodes !== undefined && planCodes.includes(p.code);\n // Deny-list: an in-plan cell is selected unless the BU locks it on this platform\n const selected = inPlan && !isBuLockedOnPlatform(buEntry, plat, p.code);\n const availableIn = inPlan ? [] : plansUnlockingPerm(plans, code, p.code, plat, planCode);\n totalCount += 1;\n if (inPlan) unlockedCount += 1;\n return { inPlan, selected, availableIn };\n };\n return { code: p.code, label: p.label, web: cell('web'), mobile: cell('mobile') };\n });\n\n features.push({\n code: feature.code,\n name: feature.name,\n icon: feature.lucideIcon ?? null,\n platforms,\n inPlan: featureInPlan,\n availableIn: featureInPlan ? [] : plansIncludingFeature(plans, code, planCode),\n permissions,\n });\n }\n\n apps.push({ code: app.code, name: app.name, icon: app.icon ?? null, unlockedCount, totalCount, features });\n }\n\n return { plan: planMeta, apps, locks };\n}\n\n// Names of other plans (excluding the org's own) that unlock this feature+permission on the given platform\nfunction plansUnlockingPerm(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n permCode: string,\n platform: PlatformBucket,\n excludeCode: string | undefined,\n): string[] {\n const names: string[] = [];\n for (const [code, p] of Object.entries(plans)) {\n if (code === excludeCode) continue;\n if ((p.unlockedPermissions?.[featureCode]?.[platform] ?? []).includes(permCode)) names.push(p.name);\n }\n return names;\n}\n\n// Names of other plans (excluding the org's own) that include this feature at all (membership) — feature-level upsell\nfunction plansIncludingFeature(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n excludeCode: string | undefined,\n): string[] {\n const names: string[] = [];\n for (const [code, p] of Object.entries(plans)) {\n if (code === excludeCode) continue;\n if (isPlanMember(p.unlockedPermissions?.[featureCode])) names.push(p.name);\n }\n return names;\n}\n","import { type FeatureUnlocks, PLATFORMS, type PlatformCodes, type PlatformDenyCodes } from './types';\n\n// Grants removed from a base template — same deny algebra as BU locks\nexport type RevokedGrants = Record<string, PlatformDenyCodes>;\n\nexport interface ComposeRoleGrantsParams {\n baseFeatures: FeatureUnlocks | undefined;\n additions: FeatureUnlocks;\n revoked: RevokedGrants | undefined;\n}\n\n// Deduped union of two optional code lists — undefined on both sides means no platform membership\nfunction unionBucket(base: string[] | undefined, add: string[] | undefined): string[] | undefined {\n if (base === undefined && add === undefined) return undefined;\n return [...new Set([...(base ?? []), ...(add ?? [])])];\n}\n\n// Composes a based custom role's effective grants: merge(base ∪ additions) − revoked (design doc §10).\n// Platform membership survives a code revoke (may leave [] = view-only); a null revoke removes the\n// platform entirely; a feature with no surviving platform disappears. Inputs are never mutated.\nexport function composeRoleGrants(params: ComposeRoleGrantsParams): FeatureUnlocks {\n const { baseFeatures, additions, revoked } = params;\n\n const result: FeatureUnlocks = {};\n const featureCodes = new Set([...Object.keys(baseFeatures ?? {}), ...Object.keys(additions ?? {})]);\n\n for (const code of featureCodes) {\n const base = baseFeatures?.[code] ?? {};\n const add = additions?.[code] ?? {};\n const revokes = revoked?.[code];\n\n const composed: PlatformCodes = {};\n for (const bucket of PLATFORMS) {\n const merged = unionBucket(base[bucket], add[bucket]);\n if (merged === undefined) continue;\n const revoke = revokes?.[bucket];\n // null revokes the whole platform (membership + all codes); string[] subtracts codes but keeps membership\n if (revoke === null) continue;\n composed[bucket] = revoke === undefined ? merged : merged.filter((c) => !revoke.includes(c));\n }\n\n // A feature with no surviving platform membership disappears from the effective set\n if (composed.web === undefined && composed.mobile === undefined) continue;\n result[code] = composed;\n }\n\n return result;\n}\n","import { buildBuCatalog } from './catalog.builder';\nimport type { BuFeatureLocks, FeatureUnlocks, LockReason, PlatformBucket, VersionSnapshot } from './types';\n\n// Client surface requesting resolution — web picks the WEB route block, ios/android pick the MOBILE block per-OS\nexport type ClientPlatform = 'web' | 'ios' | 'android';\n\n// A granted permission that is locked, with why and which plans would unlock it (for upsell)\nexport interface LockedPermission {\n code: string;\n reason: LockReason | null;\n unlockPlans: string[];\n}\n\nexport interface PermissionFeature {\n code: string;\n name: string;\n lucideIcon: string | null;\n sfSymbol: string;\n materialSymbol: string;\n permissions: string[];\n // Lock overlay (for upsell): feature-level locked + reason + unlock plans, and the granted-but-locked permissions\n locked: boolean;\n lockReason: LockReason | null;\n unlockPlans: string[];\n lockedPermissions: LockedPermission[];\n route: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n };\n appCode: string;\n appName: string;\n appIcon: string | null;\n appSortOrder: number;\n}\n\nexport interface ResolveUserFeaturesParams {\n snapshot: VersionSnapshot;\n businessCode: string;\n planCode: string | undefined;\n // undefined = nothing BU-locked (the full plan is available)\n buLocks: BuFeatureLocks | undefined;\n // The user's composed role grants: featureCode -> { web?: [permCode…], mobile?: [permCode…] }\n roleFeatures: FeatureUnlocks;\n platform: ClientPlatform;\n}\n\n// Resolves the features + MF config a user sees at a BU: plan ∧ BU catalog intersected with the role's grants.\n// platform picks which microfrontend block flows into PermissionFeature.route:\n// 'web' → WEB block (remoteEntry + exposedModule + routePrefix)\n// 'ios' → MOBILE block, remoteEntry = remoteEntryIos\n// 'android' → MOBILE block, remoteEntry = remoteEntryAndroid\n// Features missing the requested platform's block are filtered out.\nexport function resolveUserFeatures(params: ResolveUserFeaturesParams): PermissionFeature[] {\n const { snapshot, businessCode, planCode, buLocks, roleFeatures, platform } = params;\n\n // Plan unlocks, BU locks, and role grants are all stored per platform; resolve only the requesting\n // surface's bucket. web → 'web'; ios/android → 'mobile'. (platform still drives the per-OS route below.)\n const bucket: PlatformBucket = platform === 'web' ? 'web' : 'mobile';\n\n // Plan ∧ BU overlay for this bucket — emits EVERY business feature (plan non-members come out fully locked)\n const catalog = buildBuCatalog(snapshot, businessCode, planCode, buLocks, bucket);\n const catalogMap = new Map(catalog.map((f) => [f.code, f]));\n\n // Granted permission set per feature, taking only this platform's grants\n const grantedFeatures = new Map<string, Set<string>>();\n for (const [code, grant] of Object.entries(roleFeatures ?? {})) {\n // Membership is the gate: undefined = not a member on this platform; [] = member with no actions (view-only)\n const granted = grant?.[bucket];\n if (granted === undefined) continue;\n if (!grantedFeatures.has(code)) grantedFeatures.set(code, new Set());\n for (const perm of granted) grantedFeatures.get(code)?.add(perm);\n }\n\n // Cross-reference the granted features with the catalog to build the response\n const features: PermissionFeature[] = [];\n for (const [code, permsSet] of grantedFeatures) {\n const catalogEntry = catalogMap.get(code);\n if (!catalogEntry) continue;\n\n const route = pickRouteForPlatform(catalogEntry, platform);\n // Feature isn't published to this platform — omit so client doesn't see an unloadable tile.\n if (!route) continue;\n\n // Plan/BU lock a subset of permissions; surface which GRANTED ones are locked + why + how to unlock (upsell)\n const permByCode = new Map((catalogEntry.permissions ?? []).map((p) => [p.code, p]));\n const grantedPerms = [...permsSet];\n const lockedPermissions: LockedPermission[] = grantedPerms\n .map((c) => permByCode.get(c))\n .filter((p): p is NonNullable<typeof p> => !!p?.locked)\n .map((p) => ({ code: p.code, reason: p.lockReason ?? null, unlockPlans: p.unlockPlans ?? [] }));\n\n features.push({\n code,\n name: catalogEntry.name,\n lucideIcon: catalogEntry.lucideIcon,\n sfSymbol: catalogEntry.sfSymbol,\n materialSymbol: catalogEntry.materialSymbol,\n permissions: grantedPerms,\n locked: catalogEntry.locked ?? false,\n lockReason: catalogEntry.lockReason ?? null,\n unlockPlans: catalogEntry.unlockPlans ?? [],\n lockedPermissions,\n route,\n appCode: catalogEntry.appCode,\n appName: catalogEntry.appName,\n appIcon: catalogEntry.appIcon,\n appSortOrder: catalogEntry.appSortOrder,\n });\n }\n\n return features;\n}\n\n// Selects the route block from a catalog entry for the requested platform.\n// Returns null when the catalog entry doesn't publish to that platform.\nexport function pickRouteForPlatform(\n entry: {\n web: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n mobile: {\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n },\n platform: ClientPlatform,\n): { remoteEntry: string; exposedModule: string; routePrefix: string } | null {\n if (platform === 'ios' || platform === 'android') {\n if (!entry.mobile) return null;\n return {\n remoteEntry: platform === 'ios' ? entry.mobile.remoteEntryIos : entry.mobile.remoteEntryAndroid,\n exposedModule: entry.mobile.exposedModule,\n routePrefix: entry.mobile.routePrefix,\n };\n }\n // Web\n if (!entry.web) return null;\n return {\n remoteEntry: entry.web.remoteEntry,\n exposedModule: entry.web.exposedModule,\n routePrefix: entry.web.routePrefix,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;ACgBO,SAASA,eACdC,UACAC,cACAC,UACAC,SACAC,QAAsB;AAEtB,MAAI,CAACH,aAAc,QAAO,CAAA;AAC1B,QAAMI,WAAWL,SAASM,aAAaL,YAAAA;AACvC,MAAI,CAACI,SAAU,QAAO,CAAA;AACtB,QAAME,OAAOL,WAAWG,SAASG,QAAQN,QAAAA,IAAYO;AACrD,QAAMD,QAAQH,SAASG,SAAS,CAAC;AAEjC,QAAME,UAAiC,CAAA;AACvC,aAAWC,OAAON,SAASO,MAAM;AAE/B,UAAMC,sBAAsBF,IAAIG,SAC7BC,IAAI,CAACC,SAAShB,SAASc,WAAWE,IAAAA,CAAK,EACvCC,OAAO,CAACC,MAA4B,CAAC,CAACA,KAAK,CAAC,EAAEA,EAAEC,gBAAgBC,OAAOF,EAAEC,gBAAgBE,OAAK;AAEjG,QAAIR,oBAAoBS,WAAW,EAAG;AAItC,eAAWC,WAAWV,qBAAqB;AACzC,YAAMW,aAAajB,MAAMkB,sBAAsBF,QAAQP,IAAI;AAG3D,YAAMI,MAAMG,QAAQJ,gBAAgBC;AACpC,YAAMC,SAASE,QAAQJ,gBAAgBE;AAEvC,YAAMK,cAAcC,iBAAiBJ,SAAStB,cAAcuB,YAAYrB,SAASK,OAAOJ,MAAAA;AAIxF,YAAMwB,iBAAiBJ,aAAapB,MAAAA,MAAYK;AAChD,YAAMoB,mBAAmB1B,UAAUoB,QAAQP,IAAI,IAAIZ,MAAAA,MAAY;AA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BAAwCD,aAC3CvB,IAAI,CAACyB,MAAML,WAAWP,IAAIY,CAAAA,CAAAA,EAC1BC,OAAO,CAACJ,MAAkC,CAAC,CAACA,GAAGK,MAAAA,EAC/C3B,IAAI,CAACsB,OAAO;MAAEpB,MAAMoB,EAAEpB;MAAM0B,QAAQN,EAAEO,cAAc;MAAMC,aAAaR,EAAEQ,eAAe,CAAA;IAAG,EAAA;AAE9Ff,aAASgB,KAAK;MACZ7B;MACA8B,MAAMf,aAAae;MACnBC,YAAYhB,aAAagB;MACzBC,UAAUjB,aAAaiB;MACvBC,gBAAgBlB,aAAakB;MAC7Bd,aAAaE;MACbI,QAAQV,aAAaU,UAAU;MAC/BE,YAAYZ,aAAaY,cAAc;MACvCC,aAAab,aAAaa,eAAe,CAAA;MACzCN;MACAN;MACAkB,SAASnB,aAAamB;MACtBC,SAASpB,aAAaoB;MACtBC,SAASrB,aAAaqB;MACtBC,cAActB,aAAasB;IAC7B,CAAA;EACF;AAEA,SAAOxB;AACT;AA3DgB5B;AA+DT,SAASgC,qBACdqB,OAaA9C,UAAwB;AAExB,MAAIA,aAAa,SAASA,aAAa,WAAW;AAChD,QAAI,CAAC8C,MAAMC,OAAQ,QAAO;AAC1B,WAAO;MACLC,aAAahD,aAAa,QAAQ8C,MAAMC,OAAOE,iBAAiBH,MAAMC,OAAOG;MAC7EC,eAAeL,MAAMC,OAAOI;MAC5BC,aAAaN,MAAMC,OAAOK;IAC5B;EACF;AAEA,MAAI,CAACN,MAAMO,IAAK,QAAO;AACvB,SAAO;IACLL,aAAaF,MAAMO,IAAIL;IACvBG,eAAeL,MAAMO,IAAIF;IACzBC,aAAaN,MAAMO,IAAID;EACzB;AACF;AA/BgB3B;","names":["buildBuCatalog","snapshot","businessCode","planCode","buLocks","bucket","business","businesses","plan","plans","undefined","catalog","app","apps","businessAppFeatures","features","map","code","filter","f","microfrontends","web","mobile","length","feature","membership","unlockedPermissions","permissions","buildPermissions","memberOnBucket","buPlatformLocked","locked","lockReason","unlockPlans","plansIncludingFeature","push","name","lucideIcon","sfSymbol","materialSymbol","remoteEntry","exposedModule","routePrefix","remoteEntryAndroid","remoteEntryIos","appCode","appName","appIcon","icon","appSortOrder","sortOrder","isPlanMember","entry","isBuLockedOnPlatform","platform","locks","includes","planMembership","planUnlocked","Set","lockEntry","p","isGlobal","planAllows","has","buAllows","plansUnlockingPermission","featureCode","permCode","result","Object","entries","buildBuRoles","values","roleTemplates","PLATFORMS","SNAPSHOT_SCHEMA_VERSION","buildBuMatrix","snapshot","businessCode","planCode","buLocks","business","businesses","undefined","plans","plan","planMeta","code","name","locks","apps","app","unlockedCount","totalCount","features","feature","platforms","PLATFORMS","filter","p","microfrontends","length","membership","unlockedPermissions","featureInPlan","isPlanMember","buEntry","permissions","isGlobal","includes","map","cell","plat","planCodes","inPlan","selected","isBuLockedOnPlatform","availableIn","plansUnlockingPerm","label","web","mobile","push","icon","lucideIcon","plansIncludingFeature","featureCode","permCode","platform","excludeCode","names","Object","entries","unionBucket","base","add","undefined","Set","composeRoleGrants","params","baseFeatures","additions","revoked","result","featureCodes","Object","keys","code","revokes","composed","bucket","PLATFORMS","merged","revoke","filter","c","includes","web","mobile","resolveUserFeatures","params","snapshot","businessCode","planCode","buLocks","roleFeatures","platform","bucket","catalog","buildBuCatalog","catalogMap","Map","map","f","code","grantedFeatures","grant","Object","entries","granted","undefined","has","set","Set","perm","get","add","features","permsSet","catalogEntry","route","pickRouteForPlatform","permByCode","permissions","p","grantedPerms","lockedPermissions","c","filter","locked","reason","lockReason","unlockPlans","push","name","lucideIcon","sfSymbol","materialSymbol","appCode","appName","appIcon","appSortOrder","entry","mobile","remoteEntry","remoteEntryIos","remoteEntryAndroid","exposedModule","routePrefix","web"]}
1
+ {"version":3,"sources":["../src/catalog-resolver/index.ts","../src/catalog-resolver/permission-deps.ts","../src/catalog-resolver/types.ts","../src/catalog-resolver/catalog.builder.ts","../src/catalog-resolver/site-matrix.builder.ts","../src/catalog-resolver/compose-role-grants.ts","../src/catalog-resolver/resolve-user-features.ts"],"sourcesContent":["// Catalog resolver — the single shared implementation of snapshot resolution (BU catalog, BU matrix, user features)\nexport {\n type SiteMatrix,\n type SiteMatrixApp,\n type SiteMatrixCell,\n type SiteMatrixFeature,\n type SiteMatrixPermission,\n buildSiteMatrix,\n buildPlanMatrix,\n} from './site-matrix.builder';\nexport {\n buildSiteCatalog,\n buildSiteRoles,\n featureAppliesAtNode,\n findFeatureByCode,\n isSiteLockedOnPlatform,\n isPlanMember,\n} from './catalog.builder';\nexport { type ComposeRoleGrantsParams, composeRoleGrants, type RevokedGrants } from './compose-role-grants';\nexport {\n buildDependsMap,\n cascadeLocked,\n type DependsMap,\n filterGrantedByDeps,\n prereqClosure,\n} from './permission-deps';\nexport {\n type ClientPlatform,\n type LockedPermission,\n type PermissionFeature,\n pickRouteForPlatform,\n type ResolveUserFeaturesParams,\n resolveUserFeatures,\n} from './resolve-user-features';\nexport {\n type FeatureLocks,\n type SiteFeatureLocks,\n type CatalogPermission,\n type FeatureCatalogEntry,\n type FeatureUnlocks,\n type LockReason,\n PLATFORMS,\n type PlatformBucket,\n type PlatformCodes,\n type PlatformDenyCodes,\n type RoleItem,\n SITE_TYPES,\n type ScopeType,\n type SiteType,\n SNAPSHOT_SCHEMA_VERSION,\n type SnapshotApp,\n type SnapshotAppFeatureRef,\n type BusinessVocabulary,\n type VocabularyEntry,\n type SnapshotBusiness,\n type SnapshotFeature,\n type SnapshotMicrofrontendMobile,\n type SnapshotMicrofrontends,\n type SnapshotMicrofrontendWeb,\n type SnapshotPermission,\n type SnapshotPlan,\n type SnapshotRoleTemplate,\n snapshotFeatureKey,\n type VersionSnapshot,\n} from './types';\n","// Intra-feature permission prerequisites — only DIRECT edges are declared; the transitive closure is computed by recursion, cycle-guarded\n\nexport type DependsMap = Map<string, string[]>;\n\n// Builds a dependency map from a feature's permissions, keeping only edges to codes present in the set\nexport function buildDependsMap(permissions: Array<{ code: string; dependsOn?: string[] }>): DependsMap {\n const present = new Set(permissions.map((p) => p.code));\n const map: DependsMap = new Map();\n for (const p of permissions) {\n map.set(\n p.code,\n (p.dependsOn ?? []).filter((dep) => dep !== p.code && present.has(dep)),\n );\n }\n return map;\n}\n\n// Transitive prerequisite closure of a code (excludes the code itself), cycle-safe\nexport function prereqClosure(code: string, deps: DependsMap): string[] {\n const out = new Set<string>();\n const seen = new Set<string>([code]);\n const stack = [code];\n while (stack.length > 0) {\n const current = stack.pop() as string;\n for (const dep of deps.get(current) ?? []) {\n if (seen.has(dep)) continue;\n seen.add(dep);\n out.add(dep);\n stack.push(dep);\n }\n }\n return [...out];\n}\n\n// Codes locked after cascade: a code is locked if directly locked or any transitive prerequisite is (cycle-safe)\nexport function cascadeLocked(codes: string[], directlyLocked: Set<string>, deps: DependsMap): Set<string> {\n const locked = new Set<string>();\n const visiting = new Set<string>();\n const check = (code: string): boolean => {\n if (locked.has(code)) return true;\n if (directlyLocked.has(code)) {\n locked.add(code);\n return true;\n }\n if (visiting.has(code)) return false;\n visiting.add(code);\n const viaDep = (deps.get(code) ?? []).some(check);\n visiting.delete(code);\n if (viaDep) locked.add(code);\n return viaDep;\n };\n for (const code of codes) check(code);\n return locked;\n}\n\n// Keeps only codes whose FULL prerequisite closure is also present — drops a dependent missing any prerequisite (cycle-safe)\nexport function filterGrantedByDeps(granted: Set<string>, deps: DependsMap): Set<string> {\n const ok = new Set<string>();\n const visiting = new Set<string>();\n const check = (code: string): boolean => {\n if (ok.has(code)) return true;\n if (!granted.has(code)) return false;\n if (visiting.has(code)) return true;\n visiting.add(code);\n const satisfied = (deps.get(code) ?? []).every(check);\n visiting.delete(code);\n if (satisfied) ok.add(code);\n return satisfied;\n };\n for (const code of granted) check(code);\n return ok;\n}\n","// ——— Platform algebra — plan unlocks, role grants, and BU locks are all stored per UI platform bucket ———\n\nexport type PlatformBucket = 'web' | 'mobile';\n\nexport const PLATFORMS: PlatformBucket[] = ['web', 'mobile'];\n\nexport interface PlatformCodes {\n web?: string[];\n mobile?: string[];\n}\n\nexport interface PlatformDenyCodes {\n web?: string[] | null;\n mobile?: string[] | null;\n}\n\nexport type FeatureUnlocks = Record<string, PlatformCodes>;\n\nexport type FeatureLocks = Record<string, PlatformDenyCodes>;\nexport type SiteFeatureLocks = FeatureLocks;\n\n// ——— Snapshot document shape — what gets stored in versions.snapshot and signed into the catalog license ———\n\nexport interface SnapshotPermission {\n code: string;\n label: string;\n isGlobal: boolean;\n businesses: string[];\n dependsOn: string[];\n}\nexport interface SnapshotMicrofrontendWeb {\n code: string;\n name: string;\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n}\nexport interface SnapshotMicrofrontendMobile {\n code: string;\n name: string;\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n}\nexport interface SnapshotMicrofrontends {\n web?: SnapshotMicrofrontendWeb;\n mobile?: SnapshotMicrofrontendMobile;\n}\nexport type ScopeType = 'ORG' | 'LE' | 'SITE_GROUP' | 'SITE';\nexport type SiteType = 'OUTLET' | 'WAREHOUSE' | 'PRODUCTION';\nexport const SITE_TYPES: SiteType[] = ['OUTLET', 'WAREHOUSE', 'PRODUCTION'];\nexport interface SnapshotFeature {\n code: string;\n name: string;\n lucideIcon: string;\n sfSymbol: string;\n materialSymbol: string;\n scope: ScopeType;\n applicableSiteTypes: SiteType[];\n permissions: SnapshotPermission[];\n microfrontends: SnapshotMicrofrontends;\n}\nexport interface SnapshotAppFeatureRef {\n code: string;\n scope: ScopeType;\n}\nexport interface SnapshotApp {\n code: string;\n name: string;\n icon: string;\n sortOrder: number;\n features: SnapshotAppFeatureRef[];\n}\nexport interface SnapshotRoleTemplate {\n name: string;\n code: string;\n scope: ScopeType;\n siteType: SiteType;\n features: FeatureUnlocks;\n}\nexport interface SnapshotPlan {\n code: string;\n name: string;\n isCustom: boolean;\n maxSites: number | null;\n unlockedPermissions: FeatureUnlocks;\n}\nexport interface VocabularyEntry {\n singular: string;\n plural: string;\n}\nexport interface BusinessVocabulary {\n site?: VocabularyEntry;\n siteGroup?: VocabularyEntry;\n outlet?: VocabularyEntry;\n warehouse?: VocabularyEntry;\n production?: VocabularyEntry;\n}\nexport interface SnapshotBusiness {\n name: string;\n vocabulary?: BusinessVocabulary;\n apps: SnapshotApp[];\n roleTemplates: Record<string, SnapshotRoleTemplate>;\n plans: Record<string, SnapshotPlan>;\n}\nexport interface VersionSnapshot {\n schemaVersion?: number;\n // Flat feature dictionary keyed by `${scope}.${code}` (see snapshotFeatureKey) — same-code features at different scopes stay distinct\n features: Record<string, SnapshotFeature>;\n businesses: Record<string, SnapshotBusiness>;\n}\n\n// Composite key for the snapshot feature dictionary — feature identity is (scope, code)\nexport function snapshotFeatureKey(code: string, scope: ScopeType): string {\n return `${scope}.${code}`;\n}\n\nexport const SNAPSHOT_SCHEMA_VERSION = 2;\n\nexport type LockReason = 'PLAN' | 'SITE';\n\nexport interface CatalogPermission {\n code: string;\n locked: boolean;\n lockReason: LockReason | null;\n unlockPlans: string[];\n}\n\nexport interface FeatureCatalogEntry {\n code: string;\n name: string;\n lucideIcon: string | null;\n sfSymbol: string;\n materialSymbol: string;\n web: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n mobile: {\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n appCode: string;\n appName: string;\n appIcon: string | null;\n appSortOrder: number;\n locked: boolean;\n lockReason: LockReason | null;\n unlockPlans: string[];\n permissions: CatalogPermission[];\n}\n\nexport type RoleItem = SnapshotRoleTemplate;\n","import { buildDependsMap, cascadeLocked, prereqClosure } from './permission-deps';\nimport type {\n ScopeType,\n SiteType,\n SiteFeatureLocks,\n CatalogPermission,\n FeatureCatalogEntry,\n LockReason,\n PlatformBucket,\n PlatformCodes,\n RoleItem,\n SnapshotFeature,\n SnapshotPlan,\n VersionSnapshot,\n} from './types';\nimport { snapshotFeatureKey } from './types';\n\n// Whether a feature with the given site-type applicability is exposed at this site type\nexport function featureAppliesAtNode(applicableSiteTypes: SiteType[], siteType: SiteType): boolean {\n return applicableSiteTypes.includes(siteType);\n}\n\n// Scope-agnostic lookup of a feature by bare code — grants/locks key features by code alone, so the first scope-variant's shared metadata (permission graph) answers\nexport function findFeatureByCode(snapshot: VersionSnapshot, code: string): SnapshotFeature | undefined {\n for (const feature of Object.values(snapshot.features ?? {})) {\n if (feature?.code === code) return feature;\n }\n return undefined;\n}\n\n// Builds the per-site catalog for ONE platform bucket — plan is the ceiling, siteLocks is a deny-list within it; each permission carries locked + lockReason + unlockPlans\nexport function buildSiteCatalog(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n siteLocks: SiteFeatureLocks | undefined,\n bucket: PlatformBucket,\n siteType?: SiteType,\n scope?: ScopeType,\n): FeatureCatalogEntry[] {\n if (!businessCode) return [];\n const business = snapshot.businesses?.[businessCode];\n if (!business) return [];\n const plan = planCode ? business.plans?.[planCode] : undefined;\n const plans = business.plans ?? {};\n\n const catalog: FeatureCatalogEntry[] = [];\n // Iterate apps alphabetically by name so the resolved feature list (→ core-web sidebar) is app-alphabetical without any frontend re-sort\n const sortedApps = [...business.apps].sort((a, b) => a.name.localeCompare(b.name));\n for (const app of sortedApps) {\n // The app's renderable features (each ref pins scope+code to one app), dropped when they don't belong to this workspace scope or node type (outlet vs container)\n const businessAppFeatures = app.features\n .filter((ref) => scope === undefined || ref.scope === scope)\n .map((ref) => snapshot.features?.[snapshotFeatureKey(ref.code, ref.scope)])\n .filter(\n (f): f is SnapshotFeature =>\n !!f &&\n !!(f.microfrontends?.web || f.microfrontends?.mobile) &&\n (siteType === undefined || featureAppliesAtNode(f.applicableSiteTypes, siteType)),\n );\n\n if (businessAppFeatures.length === 0) continue;\n\n // Emit EVERY business feature so a role's grant on a plan-omitted feature still resolves as a locked tile instead of vanishing\n for (const feature of businessAppFeatures) {\n const membership = plan?.unlockedPermissions?.[feature.code];\n // Routes are exposed wherever the feature SHIPS — membership never hides them\n const web = feature.microfrontends?.web;\n const mobile = feature.microfrontends?.mobile;\n\n const permissions = buildPermissions(feature, businessCode, membership, siteLocks, plans, bucket);\n // Feature-level lock is EXPLICIT: plan must include the feature on this bucket and the site must not null-lock the platform\n const memberOnBucket = membership?.[bucket] !== undefined;\n const sitePlatformLocked = siteLocks?.[feature.code]?.[bucket] === null;\n const locked = !memberOnBucket || sitePlatformLocked;\n const lockReason: LockReason | null = !memberOnBucket ? 'PLAN' : sitePlatformLocked ? 'SITE' : null;\n const unlockPlans = lockReason === 'PLAN' ? plansIncludingFeature(plans, feature.code, bucket) : [];\n\n catalog.push({\n code: feature.code,\n name: feature.name,\n lucideIcon: feature.lucideIcon ?? null,\n sfSymbol: feature.sfSymbol ?? 'square',\n materialSymbol: feature.materialSymbol ?? 'square',\n web: web\n ? {\n remoteEntry: web.remoteEntry ?? '',\n exposedModule: web.exposedModule ?? '',\n routePrefix: web.routePrefix ?? '',\n }\n : null,\n mobile: mobile\n ? {\n remoteEntryAndroid: mobile.remoteEntryAndroid ?? '',\n remoteEntryIos: mobile.remoteEntryIos ?? '',\n exposedModule: mobile.exposedModule ?? '',\n routePrefix: mobile.routePrefix ?? '',\n }\n : null,\n appCode: app.code,\n appName: app.name,\n appIcon: app.icon ?? null,\n appSortOrder: app.sortOrder ?? 0,\n locked,\n lockReason,\n unlockPlans,\n permissions,\n });\n }\n }\n return catalog;\n}\n\n// A feature is a plan member when its unlock entry exists on at least one platform (even with zero actions)\nexport function isPlanMember(entry: PlatformCodes | undefined): boolean {\n return !!entry && (entry.web !== undefined || entry.mobile !== undefined);\n}\n\n// Per-platform site-lock primitive: null locks the whole feature, string[] locks those codes, absent = not locked\nexport function isSiteLockedOnPlatform(\n entry: SiteFeatureLocks[string] | undefined,\n platform: PlatformBucket,\n code: string,\n): boolean {\n const locks = entry?.[platform];\n return locks === null || (locks?.includes(code) ?? false);\n}\n\n// A feature's business-scoped permissions, each tagged with locked + reason against the plan and site deny-list (bucket-scoped)\nfunction buildPermissions(\n feature: SnapshotFeature,\n businessCode: string,\n planMembership: PlatformCodes | undefined,\n siteLocks: SiteFeatureLocks | undefined,\n plans: Record<string, SnapshotPlan>,\n bucket: PlatformBucket,\n): CatalogPermission[] {\n const planUnlocked = new Set(planMembership?.[bucket] ?? []);\n const lockEntry = siteLocks?.[feature.code];\n\n const perms = (feature.permissions ?? []).filter((p) => p.isGlobal || p.businesses.includes(businessCode));\n const deps = buildDependsMap(perms);\n const codes = perms.map((p) => p.code);\n\n // Direct plan/site locks, then cascade so a locked prerequisite (e.g. view) locks its dependents (add/edit/delete)\n const directlyPlanLocked = new Set<string>();\n const directlySiteLocked = new Set<string>();\n for (const p of perms) {\n if (!planUnlocked.has(p.code)) directlyPlanLocked.add(p.code);\n if (isSiteLockedOnPlatform(lockEntry, bucket, p.code)) directlySiteLocked.add(p.code);\n }\n const directlyLocked = new Set<string>([...directlyPlanLocked, ...directlySiteLocked]);\n const lockedSet = cascadeLocked(codes, directlyLocked, deps);\n\n return perms.map((p) => {\n const locked = lockedSet.has(p.code);\n // A permission is enabled only if it AND its whole prerequisite closure are unlocked — reason/upsell reflect that\n const closure = [p.code, ...prereqClosure(p.code, deps)];\n const planReason = closure.some((c) => directlyPlanLocked.has(c));\n const siteReason = closure.some((c) => directlySiteLocked.has(c));\n // Plan is the ceiling, so a plan-lock anywhere in the closure wins over a site-lock when reporting the reason\n const lockReason: LockReason | null = !locked ? null : planReason ? 'PLAN' : siteReason ? 'SITE' : null;\n const unlockPlans =\n locked && lockReason === 'PLAN' ? plansUnlockingClosure(plans, feature.code, closure, bucket) : [];\n return { code: p.code, locked, lockReason, unlockPlans };\n });\n}\n\n// Plan codes (in the business) whose unlocked set includes the permission AND its whole prerequisite closure — upsell targets\nfunction plansUnlockingClosure(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n closure: string[],\n bucket: PlatformBucket,\n): string[] {\n const result: string[] = [];\n for (const [code, plan] of Object.entries(plans)) {\n const unlocked = plan.unlockedPermissions?.[featureCode]?.[bucket];\n if (unlocked && closure.every((c) => unlocked.includes(c))) result.push(code);\n }\n return result;\n}\n\n// Plan codes (in the business) that include this feature on the bucket — the feature-level upsell targets\nfunction plansIncludingFeature(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n bucket: PlatformBucket,\n): string[] {\n const result: string[] = [];\n for (const [code, plan] of Object.entries(plans)) {\n if (plan.unlockedPermissions?.[featureCode]?.[bucket] !== undefined) result.push(code);\n }\n return result;\n}\n\n// The business's role templates as provisionable role items for core (identical shapes)\nexport function buildSiteRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[] {\n if (!businessCode) return [];\n const business = snapshot.businesses?.[businessCode];\n if (!business) return [];\n return Object.values(business.roleTemplates ?? {});\n}\n","import { featureAppliesAtNode, isSiteLockedOnPlatform, isPlanMember } from './catalog.builder';\nimport {\n type ScopeType,\n type SiteFeatureLocks,\n type SiteType,\n PLATFORMS,\n type PlatformBucket,\n type SnapshotPlan,\n snapshotFeatureKey,\n type VersionSnapshot,\n} from './types';\n\nexport interface SiteMatrixCell {\n inPlan: boolean;\n selected: boolean;\n availableIn: string[];\n}\n\nexport interface SiteMatrixPermission {\n code: string;\n label: string;\n dependsOn: string[];\n web: SiteMatrixCell | null;\n mobile: SiteMatrixCell | null;\n}\n\nexport interface SiteMatrixFeature {\n code: string;\n name: string;\n icon: string | null;\n scope: ScopeType;\n applicableSiteTypes: SiteType[];\n platforms: PlatformBucket[];\n inPlan: boolean;\n availableIn: string[];\n permissions: SiteMatrixPermission[];\n}\n\nexport interface SiteMatrixApp {\n code: string;\n name: string;\n icon: string | null;\n unlockedCount: number;\n totalCount: number;\n features: SiteMatrixFeature[];\n}\n\nexport interface SiteMatrix {\n plan: { code: string; name: string };\n apps: SiteMatrixApp[];\n locks: SiteFeatureLocks;\n}\n\n// Builds the SITE-only apps/features/permissions matrix — not filtered to plan members; plan-locked items carry inPlan=false + availableIn\nexport function buildSiteMatrix(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n siteLocks: SiteFeatureLocks | undefined,\n siteType?: SiteType,\n): SiteMatrix {\n return buildMatrix(snapshot, businessCode, planCode, siteLocks, false, siteType);\n}\n\n// Builds the all-scopes apps/features/permissions matrix — every scope's features included, each carrying its real scope; powers the Plan Overview + Create Custom Role picker\nexport function buildPlanMatrix(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n siteLocks?: SiteFeatureLocks,\n): SiteMatrix {\n return buildMatrix(snapshot, businessCode, planCode, siteLocks, true);\n}\n\n// Shared matrix builder — allScopes=false keeps only SITE refs; allScopes=true includes every scope and emits each feature's real scope\nfunction buildMatrix(\n snapshot: VersionSnapshot,\n businessCode: string | undefined,\n planCode: string | undefined,\n siteLocks: SiteFeatureLocks | undefined,\n allScopes: boolean,\n siteType?: SiteType,\n): SiteMatrix {\n const business = businessCode ? snapshot.businesses?.[businessCode] : undefined;\n const plans = business?.plans ?? {};\n const plan = planCode ? plans[planCode] : undefined;\n const planMeta = { code: planCode ?? '', name: plan?.name ?? planCode ?? '' };\n const locks = siteLocks ?? {};\n if (!business || !plan) return { plan: planMeta, apps: [], locks };\n\n const apps: SiteMatrixApp[] = [];\n for (const app of business.apps) {\n let unlockedCount = 0;\n let totalCount = 0;\n const features: SiteMatrixFeature[] = [];\n\n for (const ref of app.features) {\n if (!allScopes && ref.scope !== 'SITE') continue;\n const code = ref.code;\n const feature = snapshot.features?.[snapshotFeatureKey(code, ref.scope)];\n if (!feature) continue;\n if (siteType !== undefined && !featureAppliesAtNode(feature.applicableSiteTypes, siteType)) continue;\n const platforms = PLATFORMS.filter((p) => !!feature.microfrontends?.[p]);\n if (platforms.length === 0) continue;\n\n const membership = plan.unlockedPermissions?.[code];\n const featureInPlan = isPlanMember(membership);\n const siteEntry = siteLocks?.[code];\n\n const permissions: SiteMatrixPermission[] = (feature.permissions ?? [])\n .filter((p) => p.isGlobal || p.businesses.includes(businessCode ?? ''))\n .map((p) => {\n const cell = (plat: PlatformBucket): SiteMatrixCell | null => {\n if (!platforms.includes(plat)) return null;\n const planCodes = membership?.[plat];\n const inPlan = featureInPlan && planCodes !== undefined && planCodes.includes(p.code);\n // Deny-list: an in-plan cell is selected unless the site locks it on this platform\n const selected = inPlan && !isSiteLockedOnPlatform(siteEntry, plat, p.code);\n const availableIn = inPlan ? [] : plansUnlockingPerm(plans, code, p.code, plat, planCode);\n totalCount += 1;\n if (inPlan) unlockedCount += 1;\n return { inPlan, selected, availableIn };\n };\n return {\n code: p.code,\n label: p.label,\n dependsOn: p.dependsOn ?? [],\n web: cell('web'),\n mobile: cell('mobile'),\n };\n });\n\n features.push({\n code: feature.code,\n name: feature.name,\n icon: feature.lucideIcon ?? null,\n scope: feature.scope,\n applicableSiteTypes: feature.applicableSiteTypes,\n platforms,\n inPlan: featureInPlan,\n availableIn: featureInPlan ? [] : plansIncludingFeature(plans, code, planCode),\n permissions,\n });\n }\n\n if (features.length === 0) continue;\n apps.push({ code: app.code, name: app.name, icon: app.icon ?? null, unlockedCount, totalCount, features });\n }\n\n // Emit apps alphabetically by name so every consumer (Plan Overview, Role picker, all Locks screens) renders them sorted\n apps.sort((a, b) => a.name.localeCompare(b.name));\n\n return { plan: planMeta, apps, locks };\n}\n\n// Names of other plans (excluding the org's own) that unlock this feature+permission on the given platform\nfunction plansUnlockingPerm(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n permCode: string,\n platform: PlatformBucket,\n excludeCode: string | undefined,\n): string[] {\n const names: string[] = [];\n for (const [code, p] of Object.entries(plans)) {\n if (code === excludeCode) continue;\n if ((p.unlockedPermissions?.[featureCode]?.[platform] ?? []).includes(permCode)) names.push(p.name);\n }\n return names;\n}\n\n// Names of other plans (excluding the org's own) that include this feature at all (membership) — feature-level upsell\nfunction plansIncludingFeature(\n plans: Record<string, SnapshotPlan>,\n featureCode: string,\n excludeCode: string | undefined,\n): string[] {\n const names: string[] = [];\n for (const [code, p] of Object.entries(plans)) {\n if (code === excludeCode) continue;\n if (isPlanMember(p.unlockedPermissions?.[featureCode])) names.push(p.name);\n }\n return names;\n}\n","import { type FeatureUnlocks, PLATFORMS, type PlatformCodes, type PlatformDenyCodes } from './types';\n\nexport type RevokedGrants = Record<string, PlatformDenyCodes>;\n\nexport interface ComposeRoleGrantsParams {\n baseFeatures: FeatureUnlocks | undefined;\n additions: FeatureUnlocks;\n revoked: RevokedGrants | undefined;\n}\n\n// Deduped union of two optional code lists — undefined on both sides means no platform membership\nfunction unionBucket(base: string[] | undefined, add: string[] | undefined): string[] | undefined {\n if (base === undefined && add === undefined) return undefined;\n return [...new Set([...(base ?? []), ...(add ?? [])])];\n}\n\n// Composes a custom role's effective grants: merge(base ∪ additions) − revoked (design doc §10); inputs are never mutated\nexport function composeRoleGrants(params: ComposeRoleGrantsParams): FeatureUnlocks {\n const { baseFeatures, additions, revoked } = params;\n\n const result: FeatureUnlocks = {};\n const featureCodes = new Set([...Object.keys(baseFeatures ?? {}), ...Object.keys(additions ?? {})]);\n\n for (const code of featureCodes) {\n const base = baseFeatures?.[code] ?? {};\n const add = additions?.[code] ?? {};\n const revokes = revoked?.[code];\n\n const composed: PlatformCodes = {};\n for (const bucket of PLATFORMS) {\n const merged = unionBucket(base[bucket], add[bucket]);\n if (merged === undefined) continue;\n const revoke = revokes?.[bucket];\n // null revokes the whole platform (membership + all codes); string[] subtracts codes but keeps membership\n if (revoke === null) continue;\n composed[bucket] = revoke === undefined ? merged : merged.filter((c) => !revoke.includes(c));\n }\n\n // A feature with no surviving platform membership disappears from the effective set\n if (composed.web === undefined && composed.mobile === undefined) continue;\n result[code] = composed;\n }\n\n return result;\n}\n","import { buildSiteCatalog, findFeatureByCode } from './catalog.builder';\nimport { buildDependsMap, filterGrantedByDeps } from './permission-deps';\nimport type {\n SiteFeatureLocks,\n FeatureUnlocks,\n LockReason,\n PlatformBucket,\n ScopeType,\n SiteType,\n VersionSnapshot,\n} from './types';\nimport { snapshotFeatureKey } from './types';\n\nexport type ClientPlatform = 'web' | 'ios' | 'android';\n\nexport interface LockedPermission {\n code: string;\n reason: LockReason | null;\n unlockPlans: string[];\n}\n\nexport interface PlanUpsell {\n plan: string;\n features: string[];\n}\n\nexport interface PermissionFeature {\n code: string;\n name: string;\n lucideIcon: string | null;\n sfSymbol: string;\n materialSymbol: string;\n permissions: string[];\n locked: boolean;\n lockReason: LockReason | null;\n unlockPlans: string[];\n lockedPermissions: LockedPermission[];\n upsell: PlanUpsell[];\n route: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n };\n appCode: string;\n appName: string;\n appIcon: string | null;\n appSortOrder: number;\n}\n\nexport interface ResolveUserFeaturesParams {\n snapshot: VersionSnapshot;\n businessCode: string;\n planCode: string | undefined;\n siteLocks: SiteFeatureLocks | undefined;\n roleFeatures: FeatureUnlocks;\n platform: ClientPlatform;\n siteType?: SiteType;\n scope?: ScopeType;\n}\n\n// Resolves the features + MF config a user sees at a BU: plan ∧ BU catalog intersected with the role's grants, filtered to the requested platform\nexport function resolveUserFeatures(params: ResolveUserFeaturesParams): PermissionFeature[] {\n const { snapshot, businessCode, planCode, siteLocks, roleFeatures, platform, siteType, scope } = params;\n\n // Plan unlocks, BU locks, and role grants are stored per platform; resolve only the requesting surface's bucket (web → 'web'; ios/android → 'mobile')\n const bucket: PlatformBucket = platform === 'web' ? 'web' : 'mobile';\n\n // Grants/plans/locks key features by bare code; resolve to the workspace scope's variant (or any variant when unscoped)\n const featureByCode = (code: string) =>\n scope ? snapshot.features?.[snapshotFeatureKey(code, scope)] : findFeatureByCode(snapshot, code);\n\n // Plan ∧ BU overlay for this bucket, filtered to features that apply to this workspace scope and node type — emits EVERY applicable business feature (plan non-members come out fully locked)\n const catalog = buildSiteCatalog(snapshot, businessCode, planCode, siteLocks, bucket, siteType, scope);\n const catalogMap = new Map(catalog.map((f) => [f.code, f]));\n\n // Per-plan feature-name delta vs the current plan — feeds the plan-locked upsell screen\n const businessPlans = snapshot.businesses[businessCode]?.plans ?? {};\n const currentUnlockedCodes = new Set<string>();\n if (planCode && businessPlans[planCode]) {\n for (const [featureCode, platforms] of Object.entries(businessPlans[planCode].unlockedPermissions ?? {})) {\n if (platforms?.[bucket] !== undefined) currentUnlockedCodes.add(featureCode);\n }\n }\n const planAdds = new Map<string, Array<{ code: string; name: string }>>();\n for (const [planKey, plan] of Object.entries(businessPlans)) {\n if (planKey === planCode) continue;\n const adds: Array<{ code: string; name: string }> = [];\n for (const [featureCode, platforms] of Object.entries(plan.unlockedPermissions ?? {})) {\n if (platforms?.[bucket] === undefined || currentUnlockedCodes.has(featureCode)) continue;\n const name = featureByCode(featureCode)?.name;\n if (name) adds.push({ code: featureCode, name });\n }\n planAdds.set(planKey, adds);\n }\n\n // Granted permission set per feature, taking only this platform's grants\n const grantedFeatures = new Map<string, Set<string>>();\n for (const [code, grant] of Object.entries(roleFeatures ?? {})) {\n // Membership is the gate: undefined = not a member on this platform; [] = member with no actions (view-only)\n const granted = grant?.[bucket];\n if (granted === undefined) continue;\n if (!grantedFeatures.has(code)) grantedFeatures.set(code, new Set());\n for (const perm of granted) grantedFeatures.get(code)?.add(perm);\n }\n\n // Cross-reference the granted features with the catalog to build the response\n const features: PermissionFeature[] = [];\n for (const [code, permsSet] of grantedFeatures) {\n const catalogEntry = catalogMap.get(code);\n if (!catalogEntry) continue;\n\n const route = pickRouteForPlatform(catalogEntry, platform);\n // Feature isn't published to this platform — omit so client doesn't see an unloadable tile.\n if (!route) continue;\n\n // Drop granted permissions whose intra-feature prerequisites aren't also granted (e.g. add needs view)\n const featureDeps = buildDependsMap(featureByCode(code)?.permissions ?? []);\n // Plan/BU lock a subset of permissions; surface which GRANTED ones are locked + why + how to unlock (upsell)\n const permByCode = new Map((catalogEntry.permissions ?? []).map((p) => [p.code, p]));\n const grantedPerms = [...filterGrantedByDeps(permsSet, featureDeps)];\n const lockedPermissions: LockedPermission[] = grantedPerms\n .map((c) => permByCode.get(c))\n .filter((p): p is NonNullable<typeof p> => !!p?.locked)\n .map((p) => ({ code: p.code, reason: p.lockReason ?? null, unlockPlans: p.unlockPlans ?? [] }));\n\n // For a plan-locked feature, list the extra features each unlocking plan would add (excluding this feature)\n const upsell: PlanUpsell[] =\n catalogEntry.locked && catalogEntry.lockReason === 'PLAN'\n ? (catalogEntry.unlockPlans ?? [])\n .map((plan) => ({\n plan,\n features: (planAdds.get(plan) ?? []).filter((f) => f.code !== code).map((f) => f.name),\n }))\n .filter((group) => group.features.length > 0)\n : [];\n\n features.push({\n code,\n name: catalogEntry.name,\n lucideIcon: catalogEntry.lucideIcon,\n sfSymbol: catalogEntry.sfSymbol,\n materialSymbol: catalogEntry.materialSymbol,\n permissions: grantedPerms,\n locked: catalogEntry.locked ?? false,\n lockReason: catalogEntry.lockReason ?? null,\n unlockPlans: catalogEntry.unlockPlans ?? [],\n lockedPermissions,\n upsell,\n route,\n appCode: catalogEntry.appCode,\n appName: catalogEntry.appName,\n appIcon: catalogEntry.appIcon,\n appSortOrder: catalogEntry.appSortOrder,\n });\n }\n\n // Order app-alphabetically so the core-web sidebar (groups by app) renders apps sorted without any frontend re-sort;\n // stable sort keeps each app's features in their existing relative order\n features.sort((a, b) => a.appName.localeCompare(b.appName));\n\n return features;\n}\n\n// Selects the route block from a catalog entry for the requested platform, or null when it doesn't publish there\nexport function pickRouteForPlatform(\n entry: {\n web: {\n remoteEntry: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n mobile: {\n remoteEntryAndroid: string;\n remoteEntryIos: string;\n exposedModule: string;\n routePrefix: string;\n } | null;\n },\n platform: ClientPlatform,\n): { remoteEntry: string; exposedModule: string; routePrefix: string } | null {\n if (platform === 'ios' || platform === 'android') {\n if (!entry.mobile) return null;\n return {\n remoteEntry: platform === 'ios' ? entry.mobile.remoteEntryIos : entry.mobile.remoteEntryAndroid,\n exposedModule: entry.mobile.exposedModule,\n routePrefix: entry.mobile.routePrefix,\n };\n }\n // Web\n if (!entry.web) return null;\n return {\n remoteEntry: entry.web.remoteEntry,\n exposedModule: entry.web.exposedModule,\n routePrefix: entry.web.routePrefix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MC,OAAOG;MAC7EC,eAAeL,MAAMC,OAAOI;MAC5BC,aAAaN,MAAMC,OAAOK;IAC5B;EACF;AAEA,MAAI,CAACN,MAAMO,IAAK,QAAO;AACvB,SAAO;IACLL,aAAaF,MAAMO,IAAIL;IACvBG,eAAeL,MAAMO,IAAIF;IACzBC,aAAaN,MAAMO,IAAID;EACzB;AACF;AA/BgBnC;","names":["buildDependsMap","permissions","present","Set","map","p","code","Map","set","dependsOn","filter","dep","has","prereqClosure","deps","out","seen","stack","length","current","pop","get","add","push","cascadeLocked","codes","directlyLocked","locked","visiting","check","viaDep","some","delete","filterGrantedByDeps","granted","ok","satisfied","every","PLATFORMS","SITE_TYPES","snapshotFeatureKey","code","scope","SNAPSHOT_SCHEMA_VERSION","featureAppliesAtNode","applicableSiteTypes","siteType","includes","findFeatureByCode","snapshot","code","feature","Object","values","features","undefined","buildSiteCatalog","businessCode","planCode","siteLocks","bucket","scope","business","businesses","plan","plans","catalog","sortedApps","apps","sort","a","b","name","localeCompare","app","businessAppFeatures","filter","ref","map","snapshotFeatureKey","f","microfrontends","web","mobile","length","membership","unlockedPermissions","permissions","buildPermissions","memberOnBucket","sitePlatformLocked","locked","lockReason","unlockPlans","plansIncludingFeature","push","lucideIcon","sfSymbol","materialSymbol","remoteEntry","exposedModule","routePrefix","remoteEntryAndroid","remoteEntryIos","appCode","appName","appIcon","icon","appSortOrder","sortOrder","isPlanMember","entry","isSiteLockedOnPlatform","platform","locks","planMembership","planUnlocked","Set","lockEntry","perms","p","isGlobal","deps","buildDependsMap","codes","directlyPlanLocked","directlySiteLocked","has","add","directlyLocked","lockedSet","cascadeLocked","closure","prereqClosure","planReason","some","c","siteReason","plansUnlockingClosure","featureCode","result","entries","unlocked","every","buildSiteRoles","roleTemplates","buildSiteMatrix","snapshot","businessCode","planCode","siteLocks","siteType","buildMatrix","buildPlanMatrix","allScopes","business","businesses","undefined","plans","plan","planMeta","code","name","locks","apps","app","unlockedCount","totalCount","features","ref","scope","feature","snapshotFeatureKey","featureAppliesAtNode","applicableSiteTypes","platforms","PLATFORMS","filter","p","microfrontends","length","membership","unlockedPermissions","featureInPlan","isPlanMember","siteEntry","permissions","isGlobal","includes","map","cell","plat","planCodes","inPlan","selected","isSiteLockedOnPlatform","availableIn","plansUnlockingPerm","label","dependsOn","web","mobile","push","icon","lucideIcon","plansIncludingFeature","sort","a","b","localeCompare","featureCode","permCode","platform","excludeCode","names","Object","entries","unionBucket","base","add","undefined","Set","composeRoleGrants","params","baseFeatures","additions","revoked","result","featureCodes","Object","keys","code","revokes","composed","bucket","PLATFORMS","merged","revoke","filter","c","includes","web","mobile","resolveUserFeatures","params","snapshot","businessCode","planCode","siteLocks","roleFeatures","platform","siteType","scope","bucket","featureByCode","code","features","snapshotFeatureKey","findFeatureByCode","catalog","buildSiteCatalog","catalogMap","Map","map","f","businessPlans","businesses","plans","currentUnlockedCodes","Set","featureCode","platforms","Object","entries","unlockedPermissions","undefined","add","planAdds","planKey","plan","adds","has","name","push","set","grantedFeatures","grant","granted","perm","get","permsSet","catalogEntry","route","pickRouteForPlatform","featureDeps","buildDependsMap","permissions","permByCode","p","grantedPerms","filterGrantedByDeps","lockedPermissions","c","filter","locked","reason","lockReason","unlockPlans","upsell","group","length","lucideIcon","sfSymbol","materialSymbol","appCode","appName","appIcon","appSortOrder","sort","a","b","localeCompare","entry","mobile","remoteEntry","remoteEntryIos","remoteEntryAndroid","exposedModule","routePrefix","web"]}
@@ -1,48 +1,54 @@
1
- import { P as PlatformBucket, B as BuFeatureLocks, V as VersionSnapshot, F as FeatureCatalogEntry, R as RoleItem, a as PlatformCodes, b as FeatureUnlocks, c as PlatformDenyCodes, L as LockReason } from './types-DQRwj5rr.cjs';
2
- export { C as CatalogPermission, d as PLATFORMS, S as SNAPSHOT_SCHEMA_VERSION, e as SnapshotApp, f as SnapshotBusiness, g as SnapshotFeature, h as SnapshotMicrofrontendMobile, j as SnapshotMicrofrontendWeb, i as SnapshotMicrofrontends, k as SnapshotPermission, l as SnapshotPlan, m as SnapshotRoleTemplate } from './types-DQRwj5rr.cjs';
1
+ import { S as ScopeType, a as SiteType, P as PlatformBucket, b as SiteFeatureLocks, V as VersionSnapshot, F as FeatureCatalogEntry, R as RoleItem, c as SnapshotFeature, d as PlatformCodes, e as FeatureUnlocks, f as PlatformDenyCodes, L as LockReason } from './types-C9jPdQqH.cjs';
2
+ export { B as BusinessVocabulary, C as CatalogPermission, g as FeatureLocks, h as PLATFORMS, i as SITE_TYPES, j as SNAPSHOT_SCHEMA_VERSION, k as SnapshotApp, l as SnapshotAppFeatureRef, n as SnapshotBusiness, o as SnapshotMicrofrontendMobile, q as SnapshotMicrofrontendWeb, p as SnapshotMicrofrontends, r as SnapshotPermission, s as SnapshotPlan, t as SnapshotRoleTemplate, m as VocabularyEntry, u as snapshotFeatureKey } from './types-C9jPdQqH.cjs';
3
3
 
4
- interface BuMatrixCell {
4
+ interface SiteMatrixCell {
5
5
  inPlan: boolean;
6
6
  selected: boolean;
7
7
  availableIn: string[];
8
8
  }
9
- interface BuMatrixPermission {
9
+ interface SiteMatrixPermission {
10
10
  code: string;
11
11
  label: string;
12
- web: BuMatrixCell | null;
13
- mobile: BuMatrixCell | null;
12
+ dependsOn: string[];
13
+ web: SiteMatrixCell | null;
14
+ mobile: SiteMatrixCell | null;
14
15
  }
15
- interface BuMatrixFeature {
16
+ interface SiteMatrixFeature {
16
17
  code: string;
17
18
  name: string;
18
19
  icon: string | null;
20
+ scope: ScopeType;
21
+ applicableSiteTypes: SiteType[];
19
22
  platforms: PlatformBucket[];
20
23
  inPlan: boolean;
21
24
  availableIn: string[];
22
- permissions: BuMatrixPermission[];
25
+ permissions: SiteMatrixPermission[];
23
26
  }
24
- interface BuMatrixApp {
27
+ interface SiteMatrixApp {
25
28
  code: string;
26
29
  name: string;
27
30
  icon: string | null;
28
31
  unlockedCount: number;
29
32
  totalCount: number;
30
- features: BuMatrixFeature[];
33
+ features: SiteMatrixFeature[];
31
34
  }
32
- interface BuMatrix {
35
+ interface SiteMatrix {
33
36
  plan: {
34
37
  code: string;
35
38
  name: string;
36
39
  };
37
- apps: BuMatrixApp[];
38
- locks: BuFeatureLocks;
40
+ apps: SiteMatrixApp[];
41
+ locks: SiteFeatureLocks;
39
42
  }
40
- declare function buildBuMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, buLocks: BuFeatureLocks | undefined): BuMatrix;
43
+ declare function buildSiteMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks: SiteFeatureLocks | undefined, siteType?: SiteType): SiteMatrix;
44
+ declare function buildPlanMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks?: SiteFeatureLocks): SiteMatrix;
41
45
 
42
- declare function buildBuCatalog(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, buLocks: BuFeatureLocks | undefined, bucket: PlatformBucket): FeatureCatalogEntry[];
46
+ declare function featureAppliesAtNode(applicableSiteTypes: SiteType[], siteType: SiteType): boolean;
47
+ declare function findFeatureByCode(snapshot: VersionSnapshot, code: string): SnapshotFeature | undefined;
48
+ declare function buildSiteCatalog(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks: SiteFeatureLocks | undefined, bucket: PlatformBucket, siteType?: SiteType, scope?: ScopeType): FeatureCatalogEntry[];
43
49
  declare function isPlanMember(entry: PlatformCodes | undefined): boolean;
44
- declare function isBuLockedOnPlatform(entry: BuFeatureLocks[string] | undefined, platform: PlatformBucket, code: string): boolean;
45
- declare function buildBuRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[];
50
+ declare function isSiteLockedOnPlatform(entry: SiteFeatureLocks[string] | undefined, platform: PlatformBucket, code: string): boolean;
51
+ declare function buildSiteRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[];
46
52
 
47
53
  type RevokedGrants = Record<string, PlatformDenyCodes>;
48
54
  interface ComposeRoleGrantsParams {
@@ -52,12 +58,25 @@ interface ComposeRoleGrantsParams {
52
58
  }
53
59
  declare function composeRoleGrants(params: ComposeRoleGrantsParams): FeatureUnlocks;
54
60
 
61
+ type DependsMap = Map<string, string[]>;
62
+ declare function buildDependsMap(permissions: Array<{
63
+ code: string;
64
+ dependsOn?: string[];
65
+ }>): DependsMap;
66
+ declare function prereqClosure(code: string, deps: DependsMap): string[];
67
+ declare function cascadeLocked(codes: string[], directlyLocked: Set<string>, deps: DependsMap): Set<string>;
68
+ declare function filterGrantedByDeps(granted: Set<string>, deps: DependsMap): Set<string>;
69
+
55
70
  type ClientPlatform = 'web' | 'ios' | 'android';
56
71
  interface LockedPermission {
57
72
  code: string;
58
73
  reason: LockReason | null;
59
74
  unlockPlans: string[];
60
75
  }
76
+ interface PlanUpsell {
77
+ plan: string;
78
+ features: string[];
79
+ }
61
80
  interface PermissionFeature {
62
81
  code: string;
63
82
  name: string;
@@ -69,6 +88,7 @@ interface PermissionFeature {
69
88
  lockReason: LockReason | null;
70
89
  unlockPlans: string[];
71
90
  lockedPermissions: LockedPermission[];
91
+ upsell: PlanUpsell[];
72
92
  route: {
73
93
  remoteEntry: string;
74
94
  exposedModule: string;
@@ -83,9 +103,11 @@ interface ResolveUserFeaturesParams {
83
103
  snapshot: VersionSnapshot;
84
104
  businessCode: string;
85
105
  planCode: string | undefined;
86
- buLocks: BuFeatureLocks | undefined;
106
+ siteLocks: SiteFeatureLocks | undefined;
87
107
  roleFeatures: FeatureUnlocks;
88
108
  platform: ClientPlatform;
109
+ siteType?: SiteType;
110
+ scope?: ScopeType;
89
111
  }
90
112
  declare function resolveUserFeatures(params: ResolveUserFeaturesParams): PermissionFeature[];
91
113
  declare function pickRouteForPlatform(entry: {
@@ -106,4 +128,4 @@ declare function pickRouteForPlatform(entry: {
106
128
  routePrefix: string;
107
129
  } | null;
108
130
 
109
- export { BuFeatureLocks, type BuMatrix, type BuMatrixApp, type BuMatrixCell, type BuMatrixFeature, type BuMatrixPermission, type ClientPlatform, type ComposeRoleGrantsParams, FeatureCatalogEntry, FeatureUnlocks, LockReason, type LockedPermission, type PermissionFeature, PlatformBucket, PlatformCodes, PlatformDenyCodes, type ResolveUserFeaturesParams, type RevokedGrants, RoleItem, VersionSnapshot, buildBuCatalog, buildBuMatrix, buildBuRoles, composeRoleGrants, isBuLockedOnPlatform, isPlanMember, pickRouteForPlatform, resolveUserFeatures };
131
+ export { type ClientPlatform, type ComposeRoleGrantsParams, type DependsMap, FeatureCatalogEntry, FeatureUnlocks, LockReason, type LockedPermission, type PermissionFeature, PlatformBucket, PlatformCodes, PlatformDenyCodes, type ResolveUserFeaturesParams, type RevokedGrants, RoleItem, ScopeType, SiteFeatureLocks, type SiteMatrix, type SiteMatrixApp, type SiteMatrixCell, type SiteMatrixFeature, type SiteMatrixPermission, SiteType, SnapshotFeature, VersionSnapshot, buildDependsMap, buildPlanMatrix, buildSiteCatalog, buildSiteMatrix, buildSiteRoles, cascadeLocked, composeRoleGrants, featureAppliesAtNode, filterGrantedByDeps, findFeatureByCode, isPlanMember, isSiteLockedOnPlatform, pickRouteForPlatform, prereqClosure, resolveUserFeatures };
@@ -1,48 +1,54 @@
1
- import { P as PlatformBucket, B as BuFeatureLocks, V as VersionSnapshot, F as FeatureCatalogEntry, R as RoleItem, a as PlatformCodes, b as FeatureUnlocks, c as PlatformDenyCodes, L as LockReason } from './types-DQRwj5rr.js';
2
- export { C as CatalogPermission, d as PLATFORMS, S as SNAPSHOT_SCHEMA_VERSION, e as SnapshotApp, f as SnapshotBusiness, g as SnapshotFeature, h as SnapshotMicrofrontendMobile, j as SnapshotMicrofrontendWeb, i as SnapshotMicrofrontends, k as SnapshotPermission, l as SnapshotPlan, m as SnapshotRoleTemplate } from './types-DQRwj5rr.js';
1
+ import { S as ScopeType, a as SiteType, P as PlatformBucket, b as SiteFeatureLocks, V as VersionSnapshot, F as FeatureCatalogEntry, R as RoleItem, c as SnapshotFeature, d as PlatformCodes, e as FeatureUnlocks, f as PlatformDenyCodes, L as LockReason } from './types-C9jPdQqH.js';
2
+ export { B as BusinessVocabulary, C as CatalogPermission, g as FeatureLocks, h as PLATFORMS, i as SITE_TYPES, j as SNAPSHOT_SCHEMA_VERSION, k as SnapshotApp, l as SnapshotAppFeatureRef, n as SnapshotBusiness, o as SnapshotMicrofrontendMobile, q as SnapshotMicrofrontendWeb, p as SnapshotMicrofrontends, r as SnapshotPermission, s as SnapshotPlan, t as SnapshotRoleTemplate, m as VocabularyEntry, u as snapshotFeatureKey } from './types-C9jPdQqH.js';
3
3
 
4
- interface BuMatrixCell {
4
+ interface SiteMatrixCell {
5
5
  inPlan: boolean;
6
6
  selected: boolean;
7
7
  availableIn: string[];
8
8
  }
9
- interface BuMatrixPermission {
9
+ interface SiteMatrixPermission {
10
10
  code: string;
11
11
  label: string;
12
- web: BuMatrixCell | null;
13
- mobile: BuMatrixCell | null;
12
+ dependsOn: string[];
13
+ web: SiteMatrixCell | null;
14
+ mobile: SiteMatrixCell | null;
14
15
  }
15
- interface BuMatrixFeature {
16
+ interface SiteMatrixFeature {
16
17
  code: string;
17
18
  name: string;
18
19
  icon: string | null;
20
+ scope: ScopeType;
21
+ applicableSiteTypes: SiteType[];
19
22
  platforms: PlatformBucket[];
20
23
  inPlan: boolean;
21
24
  availableIn: string[];
22
- permissions: BuMatrixPermission[];
25
+ permissions: SiteMatrixPermission[];
23
26
  }
24
- interface BuMatrixApp {
27
+ interface SiteMatrixApp {
25
28
  code: string;
26
29
  name: string;
27
30
  icon: string | null;
28
31
  unlockedCount: number;
29
32
  totalCount: number;
30
- features: BuMatrixFeature[];
33
+ features: SiteMatrixFeature[];
31
34
  }
32
- interface BuMatrix {
35
+ interface SiteMatrix {
33
36
  plan: {
34
37
  code: string;
35
38
  name: string;
36
39
  };
37
- apps: BuMatrixApp[];
38
- locks: BuFeatureLocks;
40
+ apps: SiteMatrixApp[];
41
+ locks: SiteFeatureLocks;
39
42
  }
40
- declare function buildBuMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, buLocks: BuFeatureLocks | undefined): BuMatrix;
43
+ declare function buildSiteMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks: SiteFeatureLocks | undefined, siteType?: SiteType): SiteMatrix;
44
+ declare function buildPlanMatrix(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks?: SiteFeatureLocks): SiteMatrix;
41
45
 
42
- declare function buildBuCatalog(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, buLocks: BuFeatureLocks | undefined, bucket: PlatformBucket): FeatureCatalogEntry[];
46
+ declare function featureAppliesAtNode(applicableSiteTypes: SiteType[], siteType: SiteType): boolean;
47
+ declare function findFeatureByCode(snapshot: VersionSnapshot, code: string): SnapshotFeature | undefined;
48
+ declare function buildSiteCatalog(snapshot: VersionSnapshot, businessCode: string | undefined, planCode: string | undefined, siteLocks: SiteFeatureLocks | undefined, bucket: PlatformBucket, siteType?: SiteType, scope?: ScopeType): FeatureCatalogEntry[];
43
49
  declare function isPlanMember(entry: PlatformCodes | undefined): boolean;
44
- declare function isBuLockedOnPlatform(entry: BuFeatureLocks[string] | undefined, platform: PlatformBucket, code: string): boolean;
45
- declare function buildBuRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[];
50
+ declare function isSiteLockedOnPlatform(entry: SiteFeatureLocks[string] | undefined, platform: PlatformBucket, code: string): boolean;
51
+ declare function buildSiteRoles(snapshot: VersionSnapshot, businessCode: string | undefined): RoleItem[];
46
52
 
47
53
  type RevokedGrants = Record<string, PlatformDenyCodes>;
48
54
  interface ComposeRoleGrantsParams {
@@ -52,12 +58,25 @@ interface ComposeRoleGrantsParams {
52
58
  }
53
59
  declare function composeRoleGrants(params: ComposeRoleGrantsParams): FeatureUnlocks;
54
60
 
61
+ type DependsMap = Map<string, string[]>;
62
+ declare function buildDependsMap(permissions: Array<{
63
+ code: string;
64
+ dependsOn?: string[];
65
+ }>): DependsMap;
66
+ declare function prereqClosure(code: string, deps: DependsMap): string[];
67
+ declare function cascadeLocked(codes: string[], directlyLocked: Set<string>, deps: DependsMap): Set<string>;
68
+ declare function filterGrantedByDeps(granted: Set<string>, deps: DependsMap): Set<string>;
69
+
55
70
  type ClientPlatform = 'web' | 'ios' | 'android';
56
71
  interface LockedPermission {
57
72
  code: string;
58
73
  reason: LockReason | null;
59
74
  unlockPlans: string[];
60
75
  }
76
+ interface PlanUpsell {
77
+ plan: string;
78
+ features: string[];
79
+ }
61
80
  interface PermissionFeature {
62
81
  code: string;
63
82
  name: string;
@@ -69,6 +88,7 @@ interface PermissionFeature {
69
88
  lockReason: LockReason | null;
70
89
  unlockPlans: string[];
71
90
  lockedPermissions: LockedPermission[];
91
+ upsell: PlanUpsell[];
72
92
  route: {
73
93
  remoteEntry: string;
74
94
  exposedModule: string;
@@ -83,9 +103,11 @@ interface ResolveUserFeaturesParams {
83
103
  snapshot: VersionSnapshot;
84
104
  businessCode: string;
85
105
  planCode: string | undefined;
86
- buLocks: BuFeatureLocks | undefined;
106
+ siteLocks: SiteFeatureLocks | undefined;
87
107
  roleFeatures: FeatureUnlocks;
88
108
  platform: ClientPlatform;
109
+ siteType?: SiteType;
110
+ scope?: ScopeType;
89
111
  }
90
112
  declare function resolveUserFeatures(params: ResolveUserFeaturesParams): PermissionFeature[];
91
113
  declare function pickRouteForPlatform(entry: {
@@ -106,4 +128,4 @@ declare function pickRouteForPlatform(entry: {
106
128
  routePrefix: string;
107
129
  } | null;
108
130
 
109
- export { BuFeatureLocks, type BuMatrix, type BuMatrixApp, type BuMatrixCell, type BuMatrixFeature, type BuMatrixPermission, type ClientPlatform, type ComposeRoleGrantsParams, FeatureCatalogEntry, FeatureUnlocks, LockReason, type LockedPermission, type PermissionFeature, PlatformBucket, PlatformCodes, PlatformDenyCodes, type ResolveUserFeaturesParams, type RevokedGrants, RoleItem, VersionSnapshot, buildBuCatalog, buildBuMatrix, buildBuRoles, composeRoleGrants, isBuLockedOnPlatform, isPlanMember, pickRouteForPlatform, resolveUserFeatures };
131
+ export { type ClientPlatform, type ComposeRoleGrantsParams, type DependsMap, FeatureCatalogEntry, FeatureUnlocks, LockReason, type LockedPermission, type PermissionFeature, PlatformBucket, PlatformCodes, PlatformDenyCodes, type ResolveUserFeaturesParams, type RevokedGrants, RoleItem, ScopeType, SiteFeatureLocks, type SiteMatrix, type SiteMatrixApp, type SiteMatrixCell, type SiteMatrixFeature, type SiteMatrixPermission, SiteType, SnapshotFeature, VersionSnapshot, buildDependsMap, buildPlanMatrix, buildSiteCatalog, buildSiteMatrix, buildSiteRoles, cascadeLocked, composeRoleGrants, featureAppliesAtNode, filterGrantedByDeps, findFeatureByCode, isPlanMember, isSiteLockedOnPlatform, pickRouteForPlatform, prereqClosure, resolveUserFeatures };