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
3 changes: 2 additions & 1 deletion apps/sim/lib/selectors/server/providers/powerbi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ describe('Power BI selector provider boundary', () => {
manualWorkspaceId: 'stale-manual-workspace',
[field]: workspace,
}
const picker = PowerBIBlock.subBlocks.find((subBlock) => subBlock.id === 'datasetSelector')!
const picker = PowerBIBlock.subBlocks.find((subBlock) => subBlock.id === 'datasetSelector')
if (!picker) throw new Error('Power BI block has no datasetSelector')
const context = buildSelectorContextFromValues({
selectorKey: 'powerbi.datasets',
contextConfigs: getSelectorContextSubBlocks(PowerBIBlock.subBlocks, values),
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/powerbi/__fixtures__/provider-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type PowerBIFixtureScenario =
| 'missing-identity'
| 'missing-query'

export interface PowerBIFixtureRequest {
interface PowerBIFixtureRequest {
method: string
path: string
body: unknown
Expand Down
19 changes: 10 additions & 9 deletions apps/sim/tools/powerbi/execute-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { jsonResponse } from '@sim/testing/helpers/http'
import { describe, expect, it } from 'vitest'
import { powerbiExecuteQueryTool } from '@/tools/powerbi/execute-query'

const { transformResponse } = powerbiExecuteQueryTool
if (!transformResponse) throw new Error('powerbi_execute_query has no transformResponse')

const params = {
accessToken: 'provider-token',
groupId: 'workspace-id',
Expand Down Expand Up @@ -32,7 +35,7 @@ describe('Power BI DAX result handling', () => {
],
})

const result = await powerbiExecuteQueryTool.transformResponse!(response, params)
const result = await transformResponse(response, params)

expect(result).toMatchObject({
success: false,
Expand All @@ -52,7 +55,7 @@ describe('Power BI DAX result handling', () => {
})

it('preserves provider column names, blank values and falsy values in complete results', async () => {
const result = await powerbiExecuteQueryTool.transformResponse!(
const result = await transformResponse(
jsonResponse({
results: [
{
Expand All @@ -79,7 +82,7 @@ describe('Power BI DAX result handling', () => {
})

it('does not fabricate a query error message when Microsoft supplies only a code', async () => {
const result = await powerbiExecuteQueryTool.transformResponse!(
const result = await transformResponse(
jsonResponse({ error: { code: 'DatasetExecuteQueriesError' } }),
params
)
Expand All @@ -98,7 +101,7 @@ describe('Power BI DAX result handling', () => {
})

it.each(['omitted', 'empty'])('accepts one result table with %s rows', async (kind) => {
const result = await powerbiExecuteQueryTool.transformResponse!(
const result = await transformResponse(
jsonResponse({ results: [{ tables: [kind === 'empty' ? { rows: [] } : {}] }] }),
params
)
Expand All @@ -117,7 +120,7 @@ describe('Power BI DAX result handling', () => {
{ code: 'AnalysisServicesErrorCode', detail: { type: 1, value: '3238920194' } },
{ code: 'DetailsMessage', detail: { type: 1, value: 'The DAX query is invalid.' } },
]
const result = await powerbiExecuteQueryTool.transformResponse!(
const result = await transformResponse(
jsonResponse({
error: {
code: 'DatasetExecuteQueriesError',
Expand Down Expand Up @@ -174,9 +177,7 @@ describe('Power BI DAX result handling', () => {
: undefined
)

await expect(powerbiExecuteQueryTool.transformResponse!(response, params)).rejects.toThrow(
/maximum size.*20971520/
)
await expect(transformResponse(response, params)).rejects.toThrow(/maximum size.*20971520/)
expect(canceled).toBe(true)
}
)
Expand All @@ -191,7 +192,7 @@ describe('Power BI DAX result handling', () => {
},
})
)
const transformed = powerbiExecuteQueryTool.transformResponse!(response, params, {
const transformed = transformResponse(response, params, {
signal: abort.signal,
})
abort.abort(new Error('Execution canceled'))
Expand Down
41 changes: 21 additions & 20 deletions apps/sim/tools/powerbi/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { OutputProperty, ToolResponse } from '@/tools/types'

export interface PowerBIAuthParams {
interface PowerBIAuthParams {
accessToken: string
}

Expand All @@ -27,7 +27,7 @@ export interface PowerBIExecuteQueryParams extends PowerBIDatasetParams {
includeNulls?: boolean
}

export type PowerBINotifyOption = 'NoNotification' | 'MailOnFailure' | 'MailOnCompletion'
type PowerBINotifyOption = 'NoNotification' | 'MailOnFailure' | 'MailOnCompletion'

export interface PowerBIRefreshDatasetParams extends PowerBIDatasetParams {
notifyOption?: PowerBINotifyOption
Expand Down Expand Up @@ -71,7 +71,7 @@ export interface PowerBIDataset {
webUrl: string | null
}

export interface PowerBIRefreshAttempt {
interface PowerBIRefreshAttempt {
attemptId: number | null
type: string | null
startTime: string | null
Expand All @@ -96,7 +96,7 @@ export interface PowerBIQueryError {
details: unknown | null
}

export interface PowerBIInformationProtectionLabel {
interface PowerBIInformationProtectionLabel {
id: string | null
name: string | null
}
Expand Down Expand Up @@ -206,21 +206,6 @@ export const POWERBI_DATASET_OUTPUT_PROPERTIES = {
webUrl: { ...nullableString, description: 'Semantic model URL in Power BI, when available' },
} satisfies Record<string, OutputProperty>

export const POWERBI_REFRESH_ATTEMPT_OUTPUT_PROPERTIES = {
attemptId: {
type: 'number',
nullable: true,
description: 'Refresh attempt index',
},
type: { ...nullableString, description: 'Provider refresh attempt type' },
startTime: { ...nullableString, description: 'Attempt start timestamp' },
endTime: { ...nullableString, description: 'Attempt end timestamp, when available' },
serviceExceptionJson: {
...nullableString,
description: 'Serialized provider failure details, when available',
},
} satisfies Record<string, OutputProperty>

export const POWERBI_REFRESH_OUTPUT_PROPERTIES = {
requestId: { ...nullableString, description: 'Provider refresh request ID' },
refreshType: { ...nullableString, description: 'Provider refresh trigger type' },
Expand All @@ -237,7 +222,23 @@ export const POWERBI_REFRESH_OUTPUT_PROPERTIES = {
refreshAttempts: {
type: 'array',
description: 'Refresh attempts supplied by the provider',
items: { type: 'object', properties: POWERBI_REFRESH_ATTEMPT_OUTPUT_PROPERTIES },
items: {
type: 'object',
properties: {
attemptId: {
type: 'number',
nullable: true,
description: 'Refresh attempt index',
},
type: { ...nullableString, description: 'Provider refresh attempt type' },
startTime: { ...nullableString, description: 'Attempt start timestamp' },
endTime: { ...nullableString, description: 'Attempt end timestamp, when available' },
serviceExceptionJson: {
...nullableString,
description: 'Serialized provider failure details, when available',
},
},
},
},
} satisfies Record<string, OutputProperty>

Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/powerbi/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from '@/tools/powerbi/types'
import { safeUrlPathSegment } from '@/tools/url-path'

export const MAX_POWERBI_RESPONSE_BYTES = 20 * 1024 * 1024
const MAX_POWERBI_RESPONSE_BYTES = 20 * 1024 * 1024

export const POWERBI_ACCESS_TOKEN_PARAM = {
type: 'string',
Expand Down
Loading