export enum OperationType {
  QUERY = "query",
  MUTATION = "mutation",
  SUBSCRIPTION = "subscription",
}

export type Query = {
  /**
   * the cache service use this to decide where to put the object
   * the serverRestApi automatically override this by your query/mutation/sub call
   * if you want to use this natively in the cache service, do not forget
   * to define this property.
   * */
  operation?: OperationType;

  /**
   * query name
   */
  endpoint: string;
};

// common -----------------------------------------
export const pingQuery: Query = {
  endpoint: "ping",
};

export const sessionEncryptionKeyQuery: Query = {
  endpoint: "sessionEncryptionKey",
};

export const createNewIdQuery: Query = {
  endpoint: "createNewId",
};

// account ------------------------------------
export const getMeQuery: Query = {
  endpoint: "me",
  operation: OperationType.QUERY,
};

export const nanoMetricsQuery: Query ={
  endpoint: "nanoMetrics",
  operation: OperationType.QUERY
};

// offline query
export const getContactListQuery: Query = {
  endpoint: "contacts",
  operation: OperationType.QUERY,
};

export const getVersionQuery: Query ={
  endpoint: "nanoVersion",
  operation: OperationType.QUERY
}

export const createContactQuery: Query = {
  endpoint: "createContact",
};

export const deleteContactQuery: Query = {
  endpoint: "deleteContact",
};

export const modifyAvatarQuery: Query = {
  endpoint: "editAvatarImage",
};

export const modifyAvatarNameQuery: Query = {
  endpoint: "editAvatarName",
};

export const getAvatarQuery: Query = {
  endpoint: "accountAvatar",
};

export const getAccountQuery: Query = {
  endpoint: "accountAvatar",
  operation: OperationType.QUERY,
};

export const editPasswordQuery: Query = {
  endpoint: "editPassword",
};

export const editTwoFactorModeQuery: Query = {
  endpoint: "editTwoFactorMode",
};

export const getTwoFactorModeQuery: Query = {
  endpoint: "twoFactor",
};

export const prepareEditEmailQuery: Query = {
  endpoint: "prepareEditEmail",
};

export const editEmailQuery: Query = {
  endpoint: "editEmail",
};

// cache query
export const getAllAccountIdQuery: Query = {
  endpoint: "allAccountId",
  operation: OperationType.QUERY,
};

export const getAccountKeysQuery: Query = {
  endpoint: "accountKeys",
};

export const getLoginSessions: Query = {
  endpoint: "loginSessions",
};

export const deleteLoginSession: Query = {
  endpoint: "deleteSession",
}

export const clearUserLoginSessions: Query = {
  endpoint: "clearUserSessions",
}

// workspace ---------------------------------

export const resourceTreeQuery: Query = {
  endpoint: "workspace",
};

export const workspaceQuery: Query = {
  endpoint: "workspace",
};

export const workspaceSubscription: Query = {
  endpoint: "workspaceChanges",
};

export const createResourceGroupQuery: Query = {
  endpoint: "createResourceGroup",
};

export const deleteResourceGroupQuery: Query = {
  endpoint: "deleteResourceGroup",
};

export const editResourceGroupNameQuery: Query = {
  endpoint: "editResourceGroupName",
};

export const editResourceGroupOrderingQuery: Query = {
  endpoint: "editResourceGroupOrdering",
};

export const editResourceGroupClosedQuery: Query = {
  endpoint: "editResourceGroupClosed",
};

export const editRoomPlacementQuery: Query = {
  endpoint: "editRoomPlacement",
};

export const editDialoguePlacementQuery: Query = {
  endpoint: "editDialoguePlacement",
};

// offline query
export const getTimedOffersQuery: Query = {
  endpoint: "timedOffers",
  operation: OperationType.QUERY,
};

export const acceptOfferQuery: Query = {
  endpoint: "acceptOffer",
};

// room  ------------------------------
export const getRoomDataQuery: Query = {
  endpoint: "roomData",
  operation: OperationType.QUERY,
};

export const joinRoomQuery: Query = {
  endpoint: "joinRoom",
};

export const leaveRoomQuery: Query = {
  endpoint: "leaveRoom",
};

// offline query
export const getAllRoomQuery: Query = {
  endpoint: "allRoom",
  operation: OperationType.QUERY,
};

export const roomMessagesQuery: Query = {
  endpoint: "roomMessages",
  operation: OperationType.QUERY,
};

export const createRoomMessageQuery: Query = {
  endpoint: "createRoomMessage",
};

export const deleteRoomMessageQuery: Query = {
  endpoint: "deleteRoomMessage",
};

export const editRoomMessageQuery: Query = {
  endpoint: "editRoomMessage",
};

export const seenRoomMessageQuery: Query = {
  endpoint: "seenRoomMessage",
};

export const roomConfigQuery: Query = {
  endpoint: "roomConfig",
};

export const roomPermissionsQuery: Query = {
  endpoint: "roomPermissions",
  operation: OperationType.QUERY,
};

export const roomMemberQuery: Query = {
  endpoint: "roomMembers",
};

export const roomMyPermissionsQuery: Query = {
  endpoint: "roomMyPermissions",
  operation: OperationType.QUERY,
};

// Note: only for the anonym session
// you should call this only after the lastMessagesQuery, or it will return with error
// because of the preparation
export const chatChangesSubscription: Query = {
  endpoint: "roomChanges",
};

export const createRoomConfigBlockQuery: Query = {
  endpoint: "createRoomConfigBlock",
};

export const createRoomQuery: Query = {
  endpoint: "createRoom",
};

export const deleteRoomQuery: Query = {
  endpoint: "deleteRoom",
};

export const editRoomDataQuery: Query = {
  endpoint: "editRoomData",
};

export const editRoomPermissionQuery: Query = {
  endpoint: "editPermission",
};

export const editRoomAccountPermissionQuery: Query = {
  endpoint: "editAccountPermission",
};

// diagloue -----------------------------------

// offline query
export const getDialogueDataQuery: Query = {
  endpoint: "dialogueData",
  operation: OperationType.QUERY,
};

export const createDialogueQuery: Query = {
  endpoint: "createDialogue",
};

export const dialogueMessagesQuery: Query = {
  endpoint: "dialogueMessages",
  operation: OperationType.QUERY,
};

export const createDialogueMessageQuery: Query = {
  endpoint: "createDialogueMessage",
};

export const deleteDialogueMessageQuery: Query = {
  endpoint: "deleteDialogueMessage",
};

export const editDialogueMessageQuery: Query = {
  endpoint: "editDialogueMessage",
};

export const seenDialogueMessageQuery: Query = {
  endpoint: "seenDialogueMessage",
};

// nano  ------------------------------

export const nanoRequestQuery: Query = {
  endpoint: "nanoRequest",
};

/**
 * offline query
 * result of the query: {[key: string]: number}
 */
export const waitingNanosQuery: Query = {
  endpoint: "waitingNanos",
  operation: OperationType.QUERY,
};

export const nanoDirectRequestQuery: Query = {
  endpoint: "nanoDirectRequest",
};

export const getNanoSlotsQuery: Query = {
  endpoint: "nanoSlots",
};

export const getNanoLicensesQuery: Query = {
  endpoint: "nanoLicensesV2",
};

export const getRecurringOrdersQuery: Query ={
  endpoint: "paymentRecurringOrders"
}

export const cancelRecurringOrderQuery: Query ={
  endpoint: "paymentCancelRecurring"
}
// payment ------------------------------

export const getPaymentShopDataQuery: Query = {
  endpoint: "paymentShopData",
};

export const getPaymentBillingsQuery: Query = {
  endpoint: "paymentBillings",
};

export const savePaymentBillingQuery: Query = {
  endpoint: "paymentSaveBilling",
};

export const deletePaymentBillingQuery: Query = {
  endpoint: "paymentDeleteBilling",
};

export const preparePaymentOrderQuery: Query = {
  endpoint: "paymentPrepareOrder",
};

export const editBuyCodeQuery: Query = {
  endpoint: "editBuyCode",
};

export const getBuyCodeQuery: Query = {
  endpoint: "buyCode",
}

export const paymentOrderQuery: Query ={
  endpoint: "paymentRecordOrder"
}

export const getNanoBundleLicensesQuery: Query = {
  endpoint: "nanoLicenseBundleTokens"
}

export const redeemLicenseTokenQuery: Query = {
  endpoint: "claimLicenseToken"
}

export const getSaleCodesQuery: Query ={
  endpoint: "saleCodes"
}

export const createSaleCodeQuery: Query ={
  endpoint: "createSaleCode"
}

export const editSaleCodeDescriptionQuery: Query ={
  endpoint: "editSaleCodeDescription"
}

export const deleteSaleCodeQuery: Query ={
  endpoint: "deleteSaleCode"
}

export const paymentParseBackQuery: Query ={
  endpoint: "paymentParseBack"
}

// admin specific ------------------------
export const aggregateStats: Query = {
  endpoint: "aggregateStats"
}
