Files
twenty/packages/twenty-shared/src/application/deterministic-identifier/get-navigation-menu-item-universal-identifier.util.ts
T
Weiko 56e20a81ea Revert 21949 (#22081)
#21949 introduced deterministic uuid utils with usage in the same PR. 
Usage was not uniform and expected a backfill command as well. 
Since we want to release I'm reverting all the changes from that PR that
concerns twenty-server and only keeping the unused utils in
twenty-shared and I'll introduce usages within the same PR as backfill
command
2026-06-24 15:37:16 +02:00

63 lines
2.1 KiB
TypeScript

import { computeDeterministicUuid } from '@/application/deterministic-identifier/compute-deterministic-uuid.util';
// NavigationMenuItem is a single polymorphic entity: every variant shares
// name/icon/color/position/folder, but each type is identified by a different
// target, so each variant has its own discriminator (prefixed by the type to
// keep the shared `navigationMenuItem` namespace collision-free).
// A FOLDER navigation item is identified by its name within its application.
export const getFolderNavigationMenuItemUniversalIdentifier = ({
applicationUniversalIdentifier,
name,
}: {
applicationUniversalIdentifier: string;
name: string;
}): string =>
computeDeterministicUuid({
entityNamespace: 'navigationMenuItem',
value: `FOLDER:${name}`,
applicationUniversalIdentifier,
});
// An OBJECT navigation item is identified by the object it targets.
export const getObjectNavigationMenuItemUniversalIdentifier = ({
applicationUniversalIdentifier,
objectUniversalIdentifier,
}: {
applicationUniversalIdentifier: string;
objectUniversalIdentifier: string;
}): string =>
computeDeterministicUuid({
entityNamespace: 'navigationMenuItem',
value: `OBJECT:${objectUniversalIdentifier}`,
applicationUniversalIdentifier,
});
// A VIEW navigation item is identified by the view it targets.
export const getViewNavigationMenuItemUniversalIdentifier = ({
applicationUniversalIdentifier,
viewUniversalIdentifier,
}: {
applicationUniversalIdentifier: string;
viewUniversalIdentifier: string;
}): string =>
computeDeterministicUuid({
entityNamespace: 'navigationMenuItem',
value: `VIEW:${viewUniversalIdentifier}`,
applicationUniversalIdentifier,
});
// A LINK navigation item is identified by its target URL.
export const getLinkNavigationMenuItemUniversalIdentifier = ({
applicationUniversalIdentifier,
link,
}: {
applicationUniversalIdentifier: string;
link: string;
}): string =>
computeDeterministicUuid({
entityNamespace: 'navigationMenuItem',
value: `LINK:${link}`,
applicationUniversalIdentifier,
});