type Account {
	id: ID!
	accountId: UUID!
	version: Int!
	code: String!
	name: String!
	normalBalanceType: DebitOrCredit!
	status: Status!
	externalId: String
	description: String
	metadata: JSON
	createdAt: Timestamp!
	modifiedAt: Timestamp!
	balance(journalId: UUID!, currency: CurrencyCode!): Balance
	sets(first: Int!, after: String): AccountSetConnection!
	entries(first: Int!, after: String): EntryConnection!
}

type AccountConnection {
	"""
	Information to aid in pagination.
	"""
	pageInfo: PageInfo!
	"""
	A list of edges.
	"""
	edges: [AccountEdge!]!
	"""
	A list of nodes.
	"""
	nodes: [Account!]!
}

input AccountCreateInput {
	accountId: UUID!
	externalId: String
	code: String!
	name: String!
	normalBalanceType: DebitOrCredit! = CREDIT
	description: String
	status: Status! = ACTIVE
	metadata: JSON
	accountSetIds: [UUID!]
}

type AccountCreatePayload {
	account: Account!
}

"""
An edge in a connection.
"""
type AccountEdge {
	"""
	The item at the end of the edge
	"""
	node: Account!
	"""
	A cursor for use in pagination
	"""
	cursor: String!
}

type AccountSet {
	id: ID!
	accountSetId: UUID!
	version: Int!
	journalId: UUID!
	name: String!
	normalBalanceType: DebitOrCredit!
	description: String
	metadata: JSON
	createdAt: Timestamp!
	modifiedAt: Timestamp!
	balance(currency: CurrencyCode!): Balance
	members(first: Int!, after: String): AccountSetMemberConnection!
	sets(first: Int!, after: String): AccountSetConnection!
	entries(first: Int!, after: String): EntryConnection!
}

type AccountSetConnection {
	"""
	Information to aid in pagination.
	"""
	pageInfo: PageInfo!
	"""
	A list of edges.
	"""
	edges: [AccountSetEdge!]!
	"""
	A list of nodes.
	"""
	nodes: [AccountSet!]!
}

input AccountSetCreateInput {
	accountSetId: UUID!
	journalId: UUID!
	name: String!
	normalBalanceType: DebitOrCredit! = CREDIT
	description: String
	metadata: JSON
}

type AccountSetCreatePayload {
	accountSet: AccountSet!
}

"""
An edge in a connection.
"""
type AccountSetEdge {
	"""
	The item at the end of the edge
	"""
	node: AccountSet!
	"""
	A cursor for use in pagination
	"""
	cursor: String!
}

union AccountSetMember = Account | AccountSet

type AccountSetMemberConnection {
	"""
	Information to aid in pagination.
	"""
	pageInfo: PageInfo!
	"""
	A list of edges.
	"""
	edges: [AccountSetMemberEdge!]!
	"""
	A list of nodes.
	"""
	nodes: [AccountSetMember!]!
}

"""
An edge in a connection.
"""
type AccountSetMemberEdge {
	"""
	The item at the end of the edge
	"""
	node: AccountSetMember!
	"""
	A cursor for use in pagination
	"""
	cursor: String!
}

enum AccountSetMemberType {
	ACCOUNT
	ACCOUNT_SET
}

input AccountSetUpdateInput {
	name: String
	normalBalanceType: DebitOrCredit
	description: String
	metadata: JSON
}

type AccountSetUpdatePayload {
	accountSet: AccountSet!
}

input AccountUpdateInput {
	externalId: String
	code: String
	name: String
	normalBalanceType: DebitOrCredit
	description: String
	status: Status
	metadata: JSON
}

type AccountUpdatePayload {
	account: Account!
}

input AddToAccountSetInput {
	accountSetId: UUID!
	memberId: UUID!
	memberType: AccountSetMemberType!
}

type AddToAccountSetPayload {
	accountSet: AccountSet!
}

type Balance {
	id: ID!
	journalId: UUID!
	accountId: UUID!
	entryId: UUID!
	currency: CurrencyCode!
	settled: BalanceAmount!
	pending: BalanceAmount!
	encumbrance: BalanceAmount!
	version: Int!
	available(layer: Layer!): BalanceAmount!
}

type BalanceAmount {
	drBalance: Money!
	crBalance: Money!
	normalBalance: Money!
	entryId: UUID!
}

type BalanceLimit {
	layer: Expression!
	amount: Expression!
	normalBalanceType: Expression!
	start: Expression
	end: Expression
}

input BalanceLimitInput {
	limitType: BalanceLimitType! = AVAILABLE
	layer: Expression!
	amount: Expression!
	normalBalanceType: Expression!
	start: Expression
	end: Expression
}

enum BalanceLimitType {
	AVAILABLE
}

input CalaOutboxImportJobCreateInput {
	jobId: UUID!
	name: String!
	description: String
	endpoint: String!
}

type CalaOutboxImportJobCreatePayload {
	job: Job!
}

scalar CurrencyCode

scalar Date

enum DebitOrCredit {
	DEBIT
	CREDIT
}

scalar Decimal

type Entry {
	id: ID!
	entryId: UUID!
	version: Int!
	transactionId: UUID!
	journalId: UUID!
	accountId: UUID!
	entryType: String!
	sequence: Int!
	layer: Layer!
	units: Decimal!
	direction: DebitOrCredit!
	description: String
	createdAt: Timestamp!
	account: Account!
	transaction: Transaction!
}

type EntryConnection {
	"""
	Information to aid in pagination.
	"""
	pageInfo: PageInfo!
	"""
	A list of edges.
	"""
	edges: [EntryEdge!]!
	"""
	A list of nodes.
	"""
	nodes: [Entry!]!
}

"""
An edge in a connection.
"""
type EntryEdge {
	"""
	The item at the end of the edge
	"""
	node: Entry!
	"""
	A cursor for use in pagination
	"""
	cursor: String!
}

scalar Expression

scalar JSON

type Job {
	id: ID!
	jobId: UUID!
	name: String!
	description: String
}

type Journal {
	id: ID!
	journalId: UUID!
	version: Int!
	name: String!
	status: Status!
	description: String
	createdAt: Timestamp!
	modifiedAt: Timestamp!
}

input JournalCreateInput {
	journalId: UUID!
	name: String!
	status: Status! = ACTIVE
	description: String
}

type JournalCreatePayload {
	journal: Journal!
}

input JournalUpdateInput {
	name: String
	status: Status
	description: String
}

type JournalUpdatePayload {
	journal: Journal!
}

enum Layer {
	SETTLED
	PENDING
	ENCUMBRANCE
}

type Limit {
	timestampSource: Expression
	balance: [BalanceLimit!]!
}

input LimitInput {
	timestampSource: Expression
	balance: [BalanceLimitInput!]!
}

type Money {
	units: Decimal!
	currency: CurrencyCode!
}

type Mutation {
	calaOutboxImportJobCreate(input: CalaOutboxImportJobCreateInput!): CalaOutboxImportJobCreatePayload!
	accountCreate(input: AccountCreateInput!): AccountCreatePayload!
	accountUpdate(id: UUID!, input: AccountUpdateInput!): AccountUpdatePayload!
	accountSetCreate(input: AccountSetCreateInput!): AccountSetCreatePayload!
	accountSetUpdate(id: UUID!, input: AccountSetUpdateInput!): AccountSetUpdatePayload!
	addToAccountSet(input: AddToAccountSetInput!): AddToAccountSetPayload!
	removeFromAccountSet(input: RemoveFromAccountSetInput!): RemoveFromAccountSetPayload!
	journalCreate(input: JournalCreateInput!): JournalCreatePayload!
	journalUpdate(id: UUID!, input: JournalUpdateInput!): JournalUpdatePayload!
	txTemplateCreate(input: TxTemplateCreateInput!): TxTemplateCreatePayload!
	transactionPost(input: TransactionInput!): TransactionPostPayload!
	velocityLimitCreate(input: VelocityLimitCreateInput!): VelocityLimitCreatePayload!
	velocityControlCreate(input: VelocityControlCreateInput!): VelocityControlCreatePayload!
	velocityControlAddLimit(input: VelocityControlAddLimitInput!): VelocityControlAddLimitPayload!
	velocityControlAttach(input: VelocityControlAttachInput!): VelocityControlAttachPayload!
}

"""
Information about pagination in a connection
"""
type PageInfo {
	"""
	When paginating backwards, are there more items?
	"""
	hasPreviousPage: Boolean!
	"""
	When paginating forwards, are there more items?
	"""
	hasNextPage: Boolean!
	"""
	When paginating backwards, the cursor to continue.
	"""
	startCursor: String
	"""
	When paginating forwards, the cursor to continue.
	"""
	endCursor: String
}

enum ParamDataType {
	STRING
	INTEGER
	DECIMAL
	BOOLEAN
	UUID
	DATE
	TIMESTAMP
	JSON
}

type ParamDefinition {
	name: String!
	type: ParamDataType!
	default: Expression
	description: String
}

input ParamDefinitionInput {
	name: String!
	type: ParamDataType!
	default: Expression
	description: String
}

type PartitionKey {
	alias: String!
	value: Expression!
}

input PartitionKeyInput {
	alias: String!
	value: Expression!
}

type Query {
	serverVersion: String!
	account(id: UUID!): Account
	accountByExternalId(externalId: String!): Account
	accountByCode(code: String!): Account
	accounts(first: Int!, after: String): AccountConnection!
	accountSet(id: UUID!): AccountSet
	journal(id: UUID!): Journal
	balance(journalId: UUID!, accountId: UUID!, currency: CurrencyCode!): Balance
	transaction(id: UUID!): Transaction
	transactionByExternalId(externalId: String!): Transaction
	txTemplate(id: UUID!): TxTemplate
	txTemplateByCode(code: String!): TxTemplate
	velocityLimit(id: UUID!): VelocityLimit
	velocityControl(id: UUID!): VelocityControl
}

input RemoveFromAccountSetInput {
	accountSetId: UUID!
	memberId: UUID!
	memberType: AccountSetMemberType!
}

type RemoveFromAccountSetPayload {
	accountSet: AccountSet!
}

enum Status {
	ACTIVE
	LOCKED
}

scalar Timestamp

type Transaction {
	id: ID!
	transactionId: UUID!
	version: Int!
	txTemplateId: UUID!
	journalId: UUID!
	effective: Date!
	correlationId: String!
	externalId: String
	description: String
	metadata: JSON
	createdAt: Timestamp!
	modifiedAt: Timestamp!
}

input TransactionInput {
	transactionId: UUID!
	txTemplateCode: String!
	params: JSON
}

type TransactionPostPayload {
	transaction: Transaction!
}

type TxTemplate {
	id: ID!
	txTemplateId: UUID!
	version: Int!
	code: String!
	params: [ParamDefinition!]
	transaction: TxTemplateTransaction!
	entries: [TxTemplateEntry!]!
	description: String
	metadata: JSON
	createdAt: Timestamp!
	modifiedAt: Timestamp!
}

input TxTemplateCreateInput {
	txTemplateId: UUID!
	code: String!
	params: [ParamDefinitionInput!]
	transaction: TxTemplateTransactionInput!
	entries: [TxTemplateEntryInput!]!
	description: String
	metadata: JSON
}

type TxTemplateCreatePayload {
	txTemplate: TxTemplate!
}

type TxTemplateEntry {
	entryType: Expression!
	accountId: Expression!
	layer: Expression!
	direction: Expression!
	units: Expression!
	currency: Expression!
	description: Expression
	metadata: Expression
}

input TxTemplateEntryInput {
	entryType: Expression!
	accountId: Expression!
	layer: Expression!
	direction: Expression!
	units: Expression!
	currency: Expression!
	description: Expression
}

type TxTemplateTransaction {
	effective: Expression!
	journalId: Expression!
	correlationId: Expression
	externalId: Expression
	description: Expression
	metadata: Expression
}

input TxTemplateTransactionInput {
	effective: Expression!
	journalId: Expression!
	correlationId: Expression
	externalId: Expression
	description: Expression
	metadata: Expression
}

scalar UUID

type VelocityControl {
	id: ID!
	velocityControlId: UUID!
	name: String!
	description: String!
	enforcement: VelocityEnforcement!
	condition: Expression
	limits: [VelocityLimit!]!
}

input VelocityControlAddLimitInput {
	velocityControlId: UUID!
	velocityLimitId: UUID!
}

type VelocityControlAddLimitPayload {
	velocityControl: VelocityControl!
}

input VelocityControlAttachInput {
	velocityControlId: UUID!
	accountId: UUID!
	params: JSON!
}

type VelocityControlAttachPayload {
	velocityControl: VelocityControl!
}

input VelocityControlCreateInput {
	velocityControlId: UUID!
	name: String!
	description: String!
	enforcement: VelocityEnforcementInput!
	condition: Expression
}

type VelocityControlCreatePayload {
	velocityControl: VelocityControl!
}

type VelocityEnforcement {
	velocityEnforcementAction: VelocityEnforcementAction!
}

enum VelocityEnforcementAction {
	REJECT
}

input VelocityEnforcementInput {
	velocityEnforcementAction: VelocityEnforcementAction! = REJECT
}

type VelocityLimit {
	id: ID!
	velocityLimitId: UUID!
	name: String!
	description: String!
	condition: Expression
	window: [PartitionKey!]!
	currency: CurrencyCode
	params: [ParamDefinition!]
	limit: Limit!
}

input VelocityLimitCreateInput {
	velocityLimitId: UUID!
	name: String!
	description: String!
	window: [PartitionKeyInput!]!
	condition: Expression
	limit: LimitInput!
	currency: CurrencyCode
	params: [ParamDefinitionInput!]
}

type VelocityLimitCreatePayload {
	velocityLimit: VelocityLimit!
}

"""
Directs the executor to include this field or fragment only when the `if` argument is true.
"""
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"""
Directs the executor to skip this field or fragment when the `if` argument is true.
"""
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
schema {
	query: Query
	mutation: Mutation
}
