/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~ ADOBE CONFIDENTIAL
 ~ ___________________
 ~
 ~  Copyright 2021 Adobe
 ~  All Rights Reserved.
 ~
 ~ NOTICE:  All information contained herein is, and remains
 ~ the property of Adobe and its suppliers, if any. The intellectual
 ~ and technical concepts contained herein are proprietary to Adobe
 ~ and its suppliers and are protected by all applicable intellectual
 ~ property laws, including trade secret and copyright laws.
 ~ Dissemination of this information or reproduction of this material
 ~ is strictly forbidden unless prior written permission is obtained
 ~ from Adobe.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

PARTIAL: Content Fragment Ibiza Schema
This partial provides a Content Fragment schema as an extension to an
Ibiza API plane

REQUIRES: ibiza.content

QUERY: ------------------------------------------------------------------------

"""
Retrieves a list of Content Fragment entries to be used for an admin UI.

The list is paginated. The client has to account for this.

Arguments:
    - **filter** - [optional] allows filtering the results;
        Filter arguments:
            - **path** - filters by path
            - **createdAfter** - filters the results by created date > with the provided value
            - **createdBefore** - filters the results by created date < with the provided value
            - **createdBy** - filters the results by the created by property
            - **locale** - filters the results by the locale
            - **tags** - filters the results by tags (multiple tags are combined with OR operator)
            - **modelPath** - filters the results by the fragment model (template)
            - **fts** - filters the results by full text search
            - **modifiedAfter** - filters the results by modified date > with the provided value
            - **modifiedBefore** - filters the results by modified date < with the provided value
            - **modifiedBy** - filters the results by the modified by property
            - **modifiedOrCreatedAfter** - filters the results by modified or created date > with the provided value
            - **modifiedOrCreatedBefore** - filters the results by modified or created date < with the provided value
            - **modifiedOrCreatedBy** - filters the results by the modified or created by property
            - **publishedAfter** - filters the results by published date > with the provided value
            - **publishedBefore** - filters the results by published date < with the provided value
            - **publishedBy** - filters the results by the published by property
            - **lastModifiedOrCreated** - filters the results by the last modified or published by property
            - **status** - filters by status;
                Supported values:
                    - **NEW**
                    - **DRAFT**
                    - **PUBLISHED**
                    - **MODIFIED**
                    - **UNPUBLISHED**
        Syntax:
            The filter value is a `;` separated list of filter expression (arguments & values). Multiple filter
            expression are auto combined using the AND boolean operator.
            Example syntax:
                **filter="ARG1=VAL1;ARG2=VAL2"**
    - **sort** - [optional] properties on which to sort the returned elements;
        Supported arguments:
            - **title**
            - **created**
            - **modified**
            - **modifiedOrCreated**
            - **modifiedBy
            - **name**
            - **publishedBy**
            - **publishedAt**
        Supported value:
            - **ASC** - [default] ascending
            - **DESC** - descending
        Syntax:
            The sorting value is a `,` separated expression (sorting by property & optionally the sorting direction).
            Example syntax:
                **title DESC, created** - sorts the results by title DESC and created ASC
                **title, created** - sorts the results by title ASC and created ASC
    - **after** - [optional] identifies the `Cursor` after which the next results should be retrieved
    - **limit** - [optional] limits the number of results returned
    - **ftsMode** - Mode to interpret any full text search expressions that are part of the filter

"""
contentFragments(filter: String, sort: String, after: String, limit: Int = 50, ftsMode: FullTextSearchMode = AS_IS) : ContentFragmentConnection @connection(for: "ContentFragment") @fetcher(name:"aemremote/cfmlist")

"""
Retrieves a list of folders for a certain path (one level).

The list is paginated. The client has to account for this.

Arguments:
    - **rootPath** - The path to get the list of sub folders for
    - **after** - [optional] identifies the `Cursor` after which the next results should be retrieved
    - **limit** - [optional] limits the number of results returned
"""
folders(rootPath: String!, after: String, limit: Int = 50) : FolderConnection @connection(for: "Folder") @fetcher(name:"aemremote/folderlist")

"""
Allows retrieving a `ContentFragment` by path.

Arguments:
  - **path** - the `ContentFragment` by path;
"""
contentFragment(path: ID!) : ContentFragmentResource @fetcher(name:"ibiza/fetchers/contentResource/cf")

TYPES: ------------------------------------------------------------------------

"""
Represents the Content Fragment Resource.
"""
type ContentFragmentResource implements ContentResource {
  path: ID!
  header: Header!
  links: [Link]!
  backstage: Backstage
  body: UnstructuredContent
}

"""
Represents a Content Fragment.

This type only contains a minimal set of properties that are
required for an admin UI.
"""
type ContentFragment {
    """
    The path pointing to the Content Fragment
    """
    path: ID!
    """
    The UUID of Content Fragment
    """
    id: ID!
    """
    The title of the Content Fragment
    """
    title: String
    """
    Information about the last modification of the Content Fragment
    """
    modified: ModificationInfo
    """
    Combined information about the modification of the Content Fragment; will be the
    info of the last modification or (if the Content Fragment has not been modified yet)
    the creation date
    """
    modifiedOrCreated: ModificationInfo!
    """
    Information about the creation of the Content Fragment
    """
    created: ModificationInfo!
    """
    Information about the last publication (if available) of the Content Fragment
    """
    published: ModificationInfo
    """
    Information about the model of the Content Fragment
    """
    model: Model!
    """
    Information about the parent folder of the Content Fragment
    """
    parent: Folder!
    """
    Information about the status of the Content Fragment
    """
    status: StatusInfo!
    """
    Information about the preview status of the Content Fragment
    """
    statusPreview: StatusPreviewInfo
    """
    Information about the operations applied on a Content Fragment; actions and statuses
    """
    operations: Operations
    """
    The list of the Content Fragment variations
    """
    variations: [String]
    """
    The list of Content Fragment tags
    """
    tags: [Tag]
}

"""
Represents information about modifications to a Content Fragment.
"""
type ModificationInfo {
    """
    Time (ISO 8601) when the modification was done
    """
    at: String
    """
    ID of the user who modified the Content Fragment
    """
    by: String
}

"""
Defines the status of a Content Fragment.
"""
enum StatusInfo {
    """
    A newly created content fragment, available on the author instance(s)
    only; has no content in it
    """
    NEW
    """
    Content Fragment that has been edited, but not yet published; available
    on the author instance(s) only
    """
    DRAFT
    """
    Content Fragment has been published; versions on author and publish are
    the same
    """
    PUBLISHED
    """
    Content Fragment has been published; there's a newer version available
    on the author instance(s); author and publish instances are out of sync
    """
    MODIFIED
    """
    Content Fragment has been published in the past, but is no longer
    available on publish instances
    """
    UNPUBLISHED
}

"""
Defines the status of a Content Fragment.
"""
enum StatusPreviewInfo {
    """
    Author and Preview are in sync
    """
    IN_SYNC
    """
    Author and Preview are out of sync
    """
    OUT_OF_SYNC
}

"""
Info about the model of a Content Fragment.
"""
type Model {
    """
    The name/title of the model
    """
    name: String
    """
    The path pointing to the model
    """
    path: ID!
}

"""
Represents a folder.

This type only contains a minimal set of properties that are
required for an admin UI.
"""
type Folder {
    """
    The path pointing to the folder
    """
    path: ID!
    """
    The name of the parent folder (node)
    """
    name: String!
    """
    The title of the folder
    """
    title: String
    """
    Determines if the folder has sub-folders
    """
    hasChildren: Boolean
    """
    Determines if the folder is hidden
    """
    hidden: Boolean
}

"""
A representation of a tag.
"""
type Tag {
    """
    Short tag ID.
    """
    id: String!
    """
    Represents the node name.
    """
    name: String!
    """
    Title that should be displayed instead of the tag name or tag id.
    """
    title: String
    """
    Optional description for a tag.
    """
    description: String
    """
    Full absolute path of a tag.
    """
    path: String!
    """
    Title of the tag ID according to the request locale.
    """
    localizedTitle: String
    """
    Title variant of the tag ID.
    """
    titlePath: String
    """
    Title variant of the tag ID according to the request locale.
    """
    localizedTitlePath: String
}

"""
Mode for interpreting full text searches.

To yield some control to the frontend, this enumeration can be used to
determine how this translation should be done.

Note that each of the supported modes has its pros/cons, depending on the use case.
"""
enum FullTextSearchMode {
    """
    Use no wildcards at all; e.g. `Two words` will be translated into the query
    `two words` and find `two words`, `two other words` or `words from two worlds`, but not
    `two bywords` or `twentytwo words`
    """
    EXACT_WORDS
    """
    The exact phrase has to match; e.g. `Two words` will be translated into the query
    `"two words"` and find `two words`, but not `two other words` or `words from
    two worlds` or `two bywords`
    """
    EXACT_PHRASE
    """
    Use wildcards at the begin/end of the search only; e.g. `Two words` will be
    translated into the query `*two words*` and find `twentytwo wordsmiths`,
    `three words, two sentences`, but not `twothousand bywords`
    """
    EDGES
    """
    Use wildcards for all partial terms of the search; e.g. `Two words` will be translated
    into the query `*two* *words*` and find `twentytwo wordsmiths`, `three words, two
    sentences`, and `twothousand bywords`
    """
    ALLTERMS
    """
    Uses the exact search term; correct escaping (except for XSS escaping for the
    resulting JCR query) is left to the frontend
    """
    AS_IS
}

"""
Defines the Operations
"""
type Operations {
    """
    The replication operation
    """
    replication: ReplicationOperation
}

"""
Defines the Operation
"""
interface ReplicationOperation @resolver(name : "aemremote/defaulttypeprovider", source : "Operation") {
    """
    The action of the operation
    """
    action: ReplicationOperationAction
    """
    The status of the operation
    """
    status: ReplicationOperationStatus
}

"""
Defines the transient action of a Content Fragment. Can be emitted by Scheduled publishing or by the Replication API.
"""
enum ReplicationOperationAction {
    """
    Defines the Publish (Activate) action
    """
    PUBLISH
    """
    Defines the Un-publish (Deactivate) action
    """
    UNPUBLISH
}

"""
Defines the transient status of a Content Fragment. Can be emitted by Scheduled publishing or by the Replication API.
"""
enum ReplicationOperationStatus {
    """
    The Content Fragment publication is in progress
    """
    PENDING
    """
    The Content Fragment was scheduled for publication and is waiting for activation
    """
    SCHEDULED
    """
    The Content Fragment publication was added to the replication queue but it's not processed yet
    """
    QUEUED
}

"""
Defines the PublicationOperation operation.
"""
type PublicationOperation implements ReplicationOperation {
    """
    The action of the operation
    """
    action: ReplicationOperationAction
    """
    The status of the operation
    """
    status: ReplicationOperationStatus
    """
    The position of the Content Fragment in the replication queue
    """
    queuePosition: Int
}

"""
Defines the ScheduledOperation operation.
"""
type ScheduledOperation implements ReplicationOperation {
    """
    The action of the operation
    """
    action: ReplicationOperationAction
    """
    The status of the operation
    """
    status: ReplicationOperationStatus
    """
    The id of the user who scheduled the replication
    """
    scheduledBy: String
    """
    Time (ISO 8601) of the scheduled date
    """
    scheduledDate: String
}
