import { AppName } from '../types/resources/app_name' import { SourceType, GraphId } from '../types/resources/group_resource' interface DestructuredChatGroupGraphIdType { sourceAppName?: AppName sourceType?: SourceType sourceId?: number } export function destructureChatGroupGraphId( chatGroupGraphId?: GraphId ): DestructuredChatGroupGraphIdType { if (!chatGroupGraphId) return { sourceAppName: undefined, sourceType: undefined, sourceId: undefined } const [sourceAppName, sourceType, sourceIdString] = chatGroupGraphId.split('-') as [ AppName, SourceType, string, ] const sourceIdNumber = Number(sourceIdString) return { sourceAppName, sourceType, sourceId: sourceIdNumber } }