# ------------------------------------------------------
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------

type ServerConfigType {
  """server version"""
  version: String!

  """server flavor"""
  flavor: String!
}

type UserQuotaHumanReadable {
  name: String!
  blobLimit: String!
  storageQuota: String!
  historyPeriod: String!
  memberLimit: String!
}

type UserQuota {
  name: String!
  blobLimit: Float!
  storageQuota: Float!
  historyPeriod: Float!
  memberLimit: Int!
  humanReadable: UserQuotaHumanReadable!
}

type UserType {
  id: ID!

  """User name"""
  name: String!

  """User email"""
  email: String!

  """User avatar url"""
  avatarUrl: String

  """User email verified"""
  emailVerified: DateTime

  """User created date"""
  createdAt: DateTime

  """User password has been set"""
  hasPassword: Boolean
  token: TokenType!
  quota: UserQuota

  """Get user invoice count"""
  invoiceCount: Int!
  subscription: UserSubscription
  invoices(take: Int = 8, skip: Int): [UserInvoice!]!
}

"""
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.
"""
scalar DateTime

type DeleteAccount {
  success: Boolean!
}

type RemoveAvatar {
  success: Boolean!
}

type TokenType {
  token: String!
  refresh: String!
  sessionToken: String
}

type SubscriptionPrice {
  type: String!
  plan: SubscriptionPlan!
  currency: String!
  amount: Int!
  yearlyAmount: Int!
}

enum SubscriptionPlan {
  Free
  Pro
  Team
  Enterprise
  SelfHosted
}

type UserSubscription {
  id: String!
  plan: SubscriptionPlan!
  recurring: SubscriptionRecurring!
  status: SubscriptionStatus!
  start: DateTime!
  end: DateTime!
  trialStart: DateTime
  trialEnd: DateTime
  nextBillAt: DateTime
  canceledAt: DateTime
  createdAt: DateTime!
  updatedAt: DateTime!
}

enum SubscriptionRecurring {
  Monthly
  Yearly
}

enum SubscriptionStatus {
  Active
  PastDue
  Unpaid
  Canceled
  Incomplete
  Paused
  IncompleteExpired
  Trialing
}

type UserInvoice {
  id: String!
  plan: SubscriptionPlan!
  recurring: SubscriptionRecurring!
  currency: String!
  amount: Int!
  status: InvoiceStatus!
  reason: String!
  lastPaymentError: String
  link: String
  createdAt: DateTime!
  updatedAt: DateTime!
}

enum InvoiceStatus {
  Draft
  Open
  Void
  Paid
  Uncollectible
}

type InviteUserType {
  """User name"""
  name: String

  """User email"""
  email: String

  """User avatar url"""
  avatarUrl: String

  """User email verified"""
  emailVerified: DateTime

  """User created date"""
  createdAt: DateTime

  """User password has been set"""
  hasPassword: Boolean
  id: ID!

  """User permission in workspace"""
  permission: Permission!

  """Invite id"""
  inviteId: String!

  """User accepted"""
  accepted: Boolean!
}

"""User permission in workspace"""
enum Permission {
  Read
  Write
  Admin
  Owner
}

type WorkspaceType {
  id: ID!

  """is Public workspace"""
  public: Boolean!

  """Workspace created date"""
  createdAt: DateTime!

  """Members of workspace"""
  members(skip: Int, take: Int): [InviteUserType!]!

  """Permission of current signed in user in workspace"""
  permission: Permission!

  """member count of workspace"""
  memberCount: Int!

  """Owner of workspace"""
  owner: UserType!

  """Blobs size of workspace"""
  blobsSize: Int!

  """Shared pages of workspace"""
  sharedPages: [String!]! @deprecated(reason: "use WorkspaceType.publicPages")

  """Public pages of a workspace"""
  publicPages: [WorkspacePage!]!
  histories(guid: String!, before: DateTime, take: Int): [DocHistoryType!]!
}

type InvitationWorkspaceType {
  id: ID!

  """Workspace name"""
  name: String!

  """Base64 encoded avatar"""
  avatar: String!
}

type WorkspaceBlobSizes {
  size: Float!
}

type InvitationType {
  """Workspace information"""
  workspace: InvitationWorkspaceType!

  """User information"""
  user: UserType!

  """Invitee information"""
  invitee: UserType!
}

type WorkspacePage {
  id: String!
  workspaceId: String!
  mode: PublicPageMode!
  public: Boolean!
}

"""The mode which the public page default in"""
enum PublicPageMode {
  Page
  Edgeless
}

type DocHistoryType {
  workspaceId: String!
  id: String!
  timestamp: DateTime!
}

type Query {
  """server config"""
  serverConfig: ServerConfigType!

  """Get is owner of workspace"""
  isOwner(workspaceId: String!): Boolean!

  """Get all accessible workspaces for current user"""
  workspaces: [WorkspaceType!]!

  """Get public workspace by id"""
  publicWorkspace(id: String!): WorkspaceType!

  """Get workspace by id"""
  workspace(id: String!): WorkspaceType!

  """Update workspace"""
  getInviteInfo(inviteId: String!): InvitationType!

  """List blobs of workspace"""
  listBlobs(workspaceId: String!): [String!]!
  collectAllBlobSizes: WorkspaceBlobSizes!
  checkBlobSize(workspaceId: String!, size: Float!): WorkspaceBlobSizes!

  """Get current user"""
  currentUser: UserType

  """Get user by email"""
  user(email: String!): UserType
  earlyAccessUsers: [UserType!]!
  prices: [SubscriptionPrice!]!
}

type Mutation {
  signUp(name: String!, email: String!, password: String!): UserType!
  signIn(email: String!, password: String!): UserType!
  changePassword(token: String!, newPassword: String!): UserType!
  changeEmail(token: String!): UserType!
  sendChangePasswordEmail(email: String!, callbackUrl: String!): Boolean!
  sendSetPasswordEmail(email: String!, callbackUrl: String!): Boolean!
  sendChangeEmail(email: String!, callbackUrl: String!): Boolean!
  sendVerifyChangeEmail(token: String!, email: String!, callbackUrl: String!): Boolean!

  """Create a new workspace"""
  createWorkspace(init: Upload): WorkspaceType!

  """Update workspace"""
  updateWorkspace(input: UpdateWorkspaceInput!): WorkspaceType!
  deleteWorkspace(id: String!): Boolean!
  invite(workspaceId: String!, email: String!, permission: Permission!, sendInviteMail: Boolean): String!
  revoke(workspaceId: String!, userId: String!): Boolean!
  acceptInviteById(workspaceId: String!, inviteId: String!, sendAcceptMail: Boolean): Boolean!
  leaveWorkspace(workspaceId: String!, workspaceName: String!, sendLeaveMail: Boolean): Boolean!
  setBlob(workspaceId: String!, blob: Upload!): String!
  deleteBlob(workspaceId: String!, hash: String!): Boolean!
  sharePage(workspaceId: String!, pageId: String!): Boolean! @deprecated(reason: "renamed to publicPage")
  publishPage(workspaceId: String!, pageId: String!, mode: PublicPageMode = Page): WorkspacePage!
  revokePage(workspaceId: String!, pageId: String!): Boolean! @deprecated(reason: "use revokePublicPage")
  revokePublicPage(workspaceId: String!, pageId: String!): WorkspacePage!
  recoverDoc(workspaceId: String!, guid: String!, timestamp: DateTime!): DateTime!

  """Upload user avatar"""
  uploadAvatar(avatar: Upload!): UserType!

  """Remove user avatar"""
  removeAvatar: RemoveAvatar!
  deleteAccount: DeleteAccount!
  addToEarlyAccess(email: String!): Int!
  removeEarlyAccess(email: String!): Int!

  """Create a subscription checkout link of stripe"""
  checkout(recurring: SubscriptionRecurring!, idempotencyKey: String!): String!

  """Create a stripe customer portal to manage payment methods"""
  createCustomerPortal: String!
  cancelSubscription(idempotencyKey: String!): UserSubscription!
  resumeSubscription(idempotencyKey: String!): UserSubscription!
  updateSubscriptionRecurring(recurring: SubscriptionRecurring!, idempotencyKey: String!): UserSubscription!
}

"""The `Upload` scalar type represents a file upload."""
scalar Upload

input UpdateWorkspaceInput {
  """is Public workspace"""
  public: Boolean
  id: ID!
}