scalar DateTime

# keeping enums same with graphql-product
enum ProfileType {
    ABACUS
    ACCOUNT360
    ARTIST
    AUDIENCE
    COLLABORATORS
    CONTENT
    DISTRIBUTION
    DOCUMENTS
    INSIGHTS
    LABEL
    MONEYHUB
    ORCHADMIN
    PODCAST
    PUBLISHING
    SETTINGS
    SONGWHIP
}
enum Role {
    ACCOUNT360
    ACCOUNTING
    ADMINISTRATOR
    ADVERTISING
    ANALYTICS
    AUDIENCE
    BULK_CREATE_DIGITAL_AUDIO
    CATALOG
    CREATE_ADMIN_TOOLS
    CREATE_BUNDLE
    DELIVER_PHYSICAL_AUDIO
    DOCUMENTS
    DOLBY_ATMOS_PACKAGER_ALPHA
    MANAGE_DIGITAL_AUDIO
    MANAGE_NR_DELIVERIES
    MANAGE_NR_OWNERSHIP
    MANAGE_NR_REPERTOIRE
    MANAGE_RIGHTS # Deprecated
    MARKETING
    NETWORK_ADMIN
    OWS_DELIVERY_METADATA
    PAYEE_MANAGEMENT
    PAYMENTS
    PODCAST_ADMIN
    PRODUCER
    PUBLISHING_COMPOSITIONS_CHANGELOG
    READ_ONLY_PRODUCER_ROLE
    REVIEW_DIGITAL_AUDIO
    ROYALTIES
    SONGWHIP
    TOOLS_ARTIST_NAME_CHANGE
    TOOLS_CATALOG_METADATA_SPREADSHEETS
    VIEW_DIGITAL_AUDIO
    VIEW_ORCHARD_SOUND_RECORDING
}
enum ApplicationType {
    ABACUS_APP
    ACCOUNT360_APP
    AUDIENCE_DEVELOPMENT_APP
    COLLABORATORS_APP
    CONTENT_APP
    DISTRIBUTION_SUITE_APP
    DOCUMENTS_APP
    HELP_CENTER_APP
    INSIGHTS_APP
    MONEYHUB_APP
    ORCHADMIN_APP
    ORCHARDGO_APP
    PODCASTS_APP
    PUBLISHING_APP
    SETTINGS_APP
    SONGWHIP_APP
    WORKSTATION_APP
}
enum UserType {
    ARTIST
    EMPLOYEE
    LABEL
}

"""
Application describes an Identity's access to appropriate applications with roles for them.

An Identity can have multiple applications with different roles.
"""
type Application {
    id: ApplicationType!
    name: String!
    roles: [Role]
    updatedBy: String
    updatedOn: DateTime
    url: String
}

"""
IdentityResourceAccess describes an access from Identity to resource
(e.g.Vendor, Subaccount, LabelParticipant, ProfileResource or Collaborator) with appropriate roles (e.g. 'ADMINISTARTOR', 'ANALYTICS').
"""
type IdentityResourceAccess {
    resource: GenericResource
    roles: [Role!]!
    updatedOn: DateTime
}

"""
UserAccount describes relation between an Identity and AR info from vendor table for that user
(gives a company, sets/gives a support email, vendorId and vendorName that are associated with an Identity).
"""
type UserAccount {
    auth0Primary: Boolean
    company: String
    supportEmail: String
    vcId: Int!
    vendorId: Int!
    vendorName: String
}

"""
LinkedAccount describes another account (label profile plus its vendor/subaccount details)
belonging to the same Identity as the session's active label profile
(e.g. the accounts offered by the workstation account switcher).
"""
type LinkedAccount {
    company: String
    labelProfileId: Int!
    subaccountId: Int
    subaccountName: String
    vendorId: Int!
}

"""
Notification describes the minimal shape of any notification
"""
interface Notification {
    message: String!
}

"""
SuiteNotification is the generic notification shape for all suite-level notifications
"""
type SuiteNotification implements Notification {
    id: ID!
    link: String
    linkGlyphName: String
    """
    message is leaved for backwards compatibility and in cases message cant be translated
    but clients should use the id to build a intl message and link text
    """
    message: String!
    """
    Optional dictionary containing values used by the message localization.
    Format: { [string]: number | string }
    """
    messageData: JSON
    variant: String!
}

"""
IdentityNotifications describes number of received notifications with their messages.
"""
type IdentityNotifications {
    count: Int!
    items: [Notification!]!
}

"""
Identity type is a general type that describes all palette of params associated with an identity
(e.g. is an identity in active state or not, email, first and last names, auth0UserId and associated profiles that give access to different apps).
"""
type Identity @key(fields: "id") {
    active: Boolean
    adminResourceAccess(limit: Int, offset: Int): [IdentityResourceAccess]!
    adminTenantTypes: [AdminTenantType!]
    applications: [Application!]
    auth0UserId: String
    canManageUsers: Boolean
    """
    Identity.canPerform is dependent on PP and is a WIP.

    **Only use this if your application is on-boarded to PP.**
    """
    canPerform(
        resourceTypeActions: [PPResourceTypeActionInput!]!
    ): [PPResourceTypeActionDecision!]!
    createdAt: DateTime
    dateFormat: String
    defaultBrand: String
    email: String!
    firstName: String
    googleUserId: String
    id: ID!
    """
    Identity.isAuthorizedForTenants is dependent on PP and is a WIP.

    **Only use this if your application is on-boarded to PP.**
    """
    isAuthorizedForTenants(
        resourceTypeActions: [PPResourceTypeActionInput!]!
    ): [PPResourceTypeActionAuthorizedTenants!]!
    lastName: String
    localization: String
    name: String
    notifications: IdentityNotifications!
    numberFormat: String
    pending: Boolean!
    picture: String
    profiles(
        profileId: String
        profileType: ProfileType
        profileUUID: String
    ): [Profile!]!
    # this will return resources that this user direct access with roles.
    resourceAccess(
        limit: Int
        offset: Int
        resourceTypes: [String!]
    ): [IdentityResourceAccess!]!
    tenantProfileRoles: IdentityTenantProfileRoleResults!
    """
    Identity.tenantRoles is dependent on PP and is a WIP.
    Optional cursor is used to paginate the results.

    **Only use this if your application is on-boarded to PP.**
    """
    tenantRoles(cursor: String = null): IdentityTenantRoleResults!
    updatedOn: DateTime
    userAccounts: [UserAccount!]
    userTypes: [UserType!]
    """
    Accounts linked to the same identity as the session's active label profile
    (the workstation account switcher list). Only available for the
    authenticated user with an active label profile.
    """
    workstationLinkedAccounts: [LinkedAccount!]!
    zendeskToken(
        brandExperience: BrandExperience = null
        tokenVersion: String = "v1"
    ): ZendeskToken
}

enum LabelAccess {
    ALL
    NONE
    SOME
}

"""
Profile describes identity access to appropriate application based on profileType
(e.g. profileType: "LabelProfile" -> gives access to Workstation).
"""
type Profile @key(fields: "profileId profileType") {
    countryFilters: [CountryFilter!]!
    """
    regex has now been deprecated, use prefix instead
    """
    features(prefix: String, regex: String): [Feature!]!
        @override(from: "graphql-product")
    # TODO: add profileName and override from graphql-knowledge after removing from graphql-product.
    firstName: String @override(from: "graphql-product")
    hasD3Access: Boolean!
    imageLocation: String @override(from: "graphql-product")
    labelAccess: LabelAccess! @override(from: "graphql-product")
    lastName: String @override(from: "graphql-product")
    profileId: String!
    profileType: ProfileType!
    profileTypeName: String!
    profileUUID: String!
    resources(resource: String): [ProfileResource!]!
        @override(from: "graphql-product")
    roles: [Role!]! @override(from: "graphql-product")
    updatedBy: String
    updatedOn: DateTime
    userIdentity: Identity
    vendorId: Int @override(from: "graphql-product")
}

"""
UserResults gives a list of users that based on set params as limit, offset and totalRecords for appropriate Identity.
"""
type UserResults {
    limit: Int!
    offset: Int!
    totalRecords: Int!
    userIdentity: [Identity!]!
}

"""
CountryFilter describes countries that should be included to filter results.
"""
type CountryFilter {
    countries: [String!]!
}
"""
Feature describes feature and level of access for that feature
(e.g. { feature: 'mobile_games', value: 'control' }).
"""
type Feature @shareable {
    feature: String
    value: String
}

"""
ZendeskToken describes zendesk authorization token
"""
type ZendeskToken {
    value: String!
}

type Account {
    """
    regex has now been deprecated, use prefix instead
    """
    features(prefix: String, regex: String): [Feature!]!
        @override(from: "graphql-product")
    profiles(profileTypes: [ProfileType!]): [Profile!]!
        @override(from: "graphql-product")
}
