const contextValueSeparator = ';' ; const contextValuePrefix = 'azFunc' ; export enum ProjectSource { Remote = 'Remote' , Local = 'Local' } export enum ProjectAccess { ReadOnly = 'ReadOnly' , ReadWrite = 'ReadWrite' } export enum ProjectResource { Functions = 'Functions' , Function = 'Function' } export function getProjectContextValue ( source , access , resource , ... parts ) { return [ contextValuePrefix , source , access , resource , ... parts ] . join ( contextValueSeparator ) + contextValueSeparator ; } export function isProjectCV ( contextValue ) { const data = normalizeContextValue ( contextValue ) ; return data . includes ( contextValueSeparator ) ; } export function isRemoteProjectCV ( contextValue ) { return isProjectCV ( contextValue ) && ( matchesAnyPart ( contextValue , ProjectSource . Remote ) || ! matchesAnyPart ( contextValue , ProjectSource . Local ) ) ; } export function isLocalProjectCV ( contextValue ) { return isProjectCV ( contextValue ) && ( matchesAnyPart ( contextValue , ProjectSource . Local ) || ! matchesAnyPart ( contextValue , ProjectSource . Remote ) ) ; } export function matchesAnyPart ( contextValue , ... parts ) { const data = normalizeContextValue ( contextValue ) ; return parts . some ( part => data . includes ( part . toLowerCase ( ) + contextValueSeparator ) ) ; } function normalizeContextValue ( contextValue ) { const data = typeof contextValue === 'string' ? contextValue : contextValue . source ; return data . toLowerCase ( ) ; }