Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions clients/LedgerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,35 @@ describe('LedgerClient', () => {
await client.listInformationBlocks('graph_1', { blockType: 'forecast', entityId: 'ent_sub' })
expect(variablesOf(0)).toMatchObject({ blockType: 'forecast', entityId: 'ent_sub' })
})

it('listInformationBlockSummaries returns identities and counts', async () => {
mockFetch.mockResolvedValueOnce(
gqlResponse({
informationBlockSummaries: [
{
id: 'str_1',
blockType: 'schedule',
name: 'Depreciation',
displayName: 'Schedule',
category: 'Close',
taxonomyId: 'tax_1',
taxonomyName: 'My CoA',
entityId: 'ent_parent',
factCount: 12,
connectionCount: 3,
},
],
})
)
const rows = await client.listInformationBlockSummaries('graph_1', {
limit: 200,
entityId: 'ent_sub',
})
expect(rows).toHaveLength(1)
expect(rows[0].factCount).toBe(12)
expect(rows[0]).not.toHaveProperty('facts')
expect(variablesOf(0)).toMatchObject({ limit: 200, entityId: 'ent_sub' })
})
})

describe('getMappingCoverage', () => {
Expand Down
40 changes: 40 additions & 0 deletions clients/LedgerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ import {
GetLedgerTrialBalanceDocument,
ListChartTemplatesDocument,
ListInformationBlocksDocument,
ListInformationBlockSummariesDocument,
ListLedgerAccountsDocument,
ListLedgerAgentsDocument,
ListLedgerBankAccountsDocument,
Expand Down Expand Up @@ -252,6 +253,7 @@ import {
type GetLedgerTrialBalanceQuery,
type ListChartTemplatesQuery,
type ListInformationBlocksQuery,
type ListInformationBlockSummariesQuery,
type ListLedgerAccountsQuery,
type ListLedgerAgentsQuery,
type ListLedgerBlockedSourceGraphsQuery,
Expand Down Expand Up @@ -339,6 +341,8 @@ export type LedgerMappingCoverage = NonNullable<GetLedgerMappingCoverageQuery['m

export type InformationBlock = NonNullable<GetInformationBlockQuery['informationBlock']>
export type InformationBlockList = ListInformationBlocksQuery['informationBlocks']
export type InformationBlockSummaryList =
ListInformationBlockSummariesQuery['informationBlockSummaries']
export type InformationBlockElement = InformationBlock['elements'][number]
export type InformationBlockConnection = InformationBlock['connections'][number]
export type InformationBlockFact = InformationBlock['facts'][number]
Expand Down Expand Up @@ -1675,6 +1679,42 @@ export class LedgerClient {
return blocks ?? []
}

/**
* List Information Blocks as identities and counts, one row per block —
* the rows, filters, order and page of `listInformationBlocks`, read in
* one query instead of an envelope build per block. The call that fills
* a picker: `factCount > 0` marks a block whose envelope carries facts
* (a library-seeded structure variant carries none); a block's atoms
* come from `getInformationBlock`.
*/
async listInformationBlockSummaries(
graphId: string,
options?: {
blockType?: string
category?: string
limit?: number
offset?: number
scenarioId?: string
entityId?: string | null
}
): Promise<InformationBlockSummaryList> {
const rows = await this.gqlQuery(
graphId,
ListInformationBlockSummariesDocument,
{
blockType: options?.blockType ?? null,
category: options?.category ?? null,
limit: options?.limit ?? null,
offset: options?.offset ?? null,
scenarioId: options?.scenarioId ?? null,
entityId: options?.entityId ?? null,
},
'List information block summaries',
(data) => data.informationBlockSummaries
)
return rows ?? []
}

// ── Schedules ──────────────────────────────────────────────────────

/**
Expand Down
125 changes: 125 additions & 0 deletions clients/graphql/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,30 @@ export type ListInformationBlocksQuery = {
}>
}

export type ListInformationBlockSummariesQueryVariables = Exact<{
blockType: string | null | undefined
category: string | null | undefined
limit: number | null | undefined
offset: number | null | undefined
scenarioId: string | null | undefined
entityId: string | null | undefined
}>

export type ListInformationBlockSummariesQuery = {
informationBlockSummaries: Array<{
id: string
blockType: string
name: string
displayName: string
category: string
taxonomyId: string | null
taxonomyName: string | null
entityId: string | null
factCount: number
connectionCount: number
}>
}

export type ListLedgerJournalEntriesQueryVariables = Exact<{
startDate: string | null | undefined
endDate: string | null | undefined
Expand Down Expand Up @@ -5528,6 +5552,107 @@ export const ListInformationBlocksDocument = {
},
],
} as unknown as DocumentNode<ListInformationBlocksQuery, ListInformationBlocksQueryVariables>
export const ListInformationBlockSummariesDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'ListInformationBlockSummaries' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'blockType' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'category' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'limit' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'offset' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'scenarioId' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'entityId' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'informationBlockSummaries' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'blockType' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'blockType' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'category' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'category' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'limit' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'limit' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'offset' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'offset' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'scenarioId' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'scenarioId' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'entityId' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'entityId' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{ kind: 'Field', name: { kind: 'Name', value: 'blockType' } },
{ kind: 'Field', name: { kind: 'Name', value: 'name' } },
{ kind: 'Field', name: { kind: 'Name', value: 'displayName' } },
{ kind: 'Field', name: { kind: 'Name', value: 'category' } },
{ kind: 'Field', name: { kind: 'Name', value: 'taxonomyId' } },
{ kind: 'Field', name: { kind: 'Name', value: 'taxonomyName' } },
{ kind: 'Field', name: { kind: 'Name', value: 'entityId' } },
{ kind: 'Field', name: { kind: 'Name', value: 'factCount' } },
{ kind: 'Field', name: { kind: 'Name', value: 'connectionCount' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<
ListInformationBlockSummariesQuery,
ListInformationBlockSummariesQueryVariables
>
export const ListLedgerJournalEntriesDocument = {
kind: 'Document',
definitions: [
Expand Down
37 changes: 37 additions & 0 deletions clients/graphql/queries/ledger/informationBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,40 @@ export const LIST_INFORMATION_BLOCKS = gql`
}
}
`

/**
* List Information Blocks as identities and counts, one row per block —
* the rows, filters, order and page of `ListInformationBlocks`, read in
* one query instead of an envelope build per block. The document a
* picker fills from.
*/
export const LIST_INFORMATION_BLOCK_SUMMARIES = gql`
query ListInformationBlockSummaries(
$blockType: String
$category: String
$limit: Int
$offset: Int
$scenarioId: String
$entityId: String
) {
informationBlockSummaries(
blockType: $blockType
category: $category
limit: $limit
offset: $offset
scenarioId: $scenarioId
entityId: $entityId
) {
id
blockType
name
displayName
category
taxonomyId
taxonomyName
entityId
factCount
connectionCount
}
}
`
Loading