Skip to content

Commit 6541da1

Browse files
committed
fix(powerbi): clear the explicit-any and unused-export ratchets on staging
- replace the non-null assertions in the Power BI tests with named guards - drop export from Power BI types and constants used only in their own file - inline the refresh-attempt output properties at their one use, so the docs generator (which only resolves exported consts) renders them without a dead export
1 parent 8a82103 commit 6541da1

5 files changed

Lines changed: 35 additions & 32 deletions

File tree

‎apps/sim/lib/selectors/server/providers/powerbi.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ describe('Power BI selector provider boundary', () => {
136136
manualWorkspaceId: 'stale-manual-workspace',
137137
[field]: workspace,
138138
}
139-
const picker = PowerBIBlock.subBlocks.find((subBlock) => subBlock.id === 'datasetSelector')!
139+
const picker = PowerBIBlock.subBlocks.find((subBlock) => subBlock.id === 'datasetSelector')
140+
if (!picker) throw new Error('Power BI block has no datasetSelector')
140141
const context = buildSelectorContextFromValues({
141142
selectorKey: 'powerbi.datasets',
142143
contextConfigs: getSelectorContextSubBlocks(PowerBIBlock.subBlocks, values),

‎apps/sim/tools/powerbi/__fixtures__/provider-fixture.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type PowerBIFixtureScenario =
3131
| 'missing-identity'
3232
| 'missing-query'
3333

34-
export interface PowerBIFixtureRequest {
34+
interface PowerBIFixtureRequest {
3535
method: string
3636
path: string
3737
body: unknown

‎apps/sim/tools/powerbi/execute-query.test.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { jsonResponse } from '@sim/testing/helpers/http'
22
import { describe, expect, it } from 'vitest'
33
import { powerbiExecuteQueryTool } from '@/tools/powerbi/execute-query'
44

5+
const { transformResponse } = powerbiExecuteQueryTool
6+
if (!transformResponse) throw new Error('powerbi_execute_query has no transformResponse')
7+
58
const params = {
69
accessToken: 'provider-token',
710
groupId: 'workspace-id',
@@ -32,7 +35,7 @@ describe('Power BI DAX result handling', () => {
3235
],
3336
})
3437

35-
const result = await powerbiExecuteQueryTool.transformResponse!(response, params)
38+
const result = await transformResponse(response, params)
3639

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

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

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

100103
it.each(['omitted', 'empty'])('accepts one result table with %s rows', async (kind) => {
101-
const result = await powerbiExecuteQueryTool.transformResponse!(
104+
const result = await transformResponse(
102105
jsonResponse({ results: [{ tables: [kind === 'empty' ? { rows: [] } : {}] }] }),
103106
params
104107
)
@@ -117,7 +120,7 @@ describe('Power BI DAX result handling', () => {
117120
{ code: 'AnalysisServicesErrorCode', detail: { type: 1, value: '3238920194' } },
118121
{ code: 'DetailsMessage', detail: { type: 1, value: 'The DAX query is invalid.' } },
119122
]
120-
const result = await powerbiExecuteQueryTool.transformResponse!(
123+
const result = await transformResponse(
121124
jsonResponse({
122125
error: {
123126
code: 'DatasetExecuteQueriesError',
@@ -174,9 +177,7 @@ describe('Power BI DAX result handling', () => {
174177
: undefined
175178
)
176179

177-
await expect(powerbiExecuteQueryTool.transformResponse!(response, params)).rejects.toThrow(
178-
/maximum size.*20971520/
179-
)
180+
await expect(transformResponse(response, params)).rejects.toThrow(/maximum size.*20971520/)
180181
expect(canceled).toBe(true)
181182
}
182183
)
@@ -191,7 +192,7 @@ describe('Power BI DAX result handling', () => {
191192
},
192193
})
193194
)
194-
const transformed = powerbiExecuteQueryTool.transformResponse!(response, params, {
195+
const transformed = transformResponse(response, params, {
195196
signal: abort.signal,
196197
})
197198
abort.abort(new Error('Execution canceled'))

‎apps/sim/tools/powerbi/types.ts‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { OutputProperty, ToolResponse } from '@/tools/types'
22

3-
export interface PowerBIAuthParams {
3+
interface PowerBIAuthParams {
44
accessToken: string
55
}
66

@@ -27,7 +27,7 @@ export interface PowerBIExecuteQueryParams extends PowerBIDatasetParams {
2727
includeNulls?: boolean
2828
}
2929

30-
export type PowerBINotifyOption = 'NoNotification' | 'MailOnFailure' | 'MailOnCompletion'
30+
type PowerBINotifyOption = 'NoNotification' | 'MailOnFailure' | 'MailOnCompletion'
3131

3232
export interface PowerBIRefreshDatasetParams extends PowerBIDatasetParams {
3333
notifyOption?: PowerBINotifyOption
@@ -71,7 +71,7 @@ export interface PowerBIDataset {
7171
webUrl: string | null
7272
}
7373

74-
export interface PowerBIRefreshAttempt {
74+
interface PowerBIRefreshAttempt {
7575
attemptId: number | null
7676
type: string | null
7777
startTime: string | null
@@ -96,7 +96,7 @@ export interface PowerBIQueryError {
9696
details: unknown | null
9797
}
9898

99-
export interface PowerBIInformationProtectionLabel {
99+
interface PowerBIInformationProtectionLabel {
100100
id: string | null
101101
name: string | null
102102
}
@@ -206,21 +206,6 @@ export const POWERBI_DATASET_OUTPUT_PROPERTIES = {
206206
webUrl: { ...nullableString, description: 'Semantic model URL in Power BI, when available' },
207207
} satisfies Record<string, OutputProperty>
208208

209-
export const POWERBI_REFRESH_ATTEMPT_OUTPUT_PROPERTIES = {
210-
attemptId: {
211-
type: 'number',
212-
nullable: true,
213-
description: 'Refresh attempt index',
214-
},
215-
type: { ...nullableString, description: 'Provider refresh attempt type' },
216-
startTime: { ...nullableString, description: 'Attempt start timestamp' },
217-
endTime: { ...nullableString, description: 'Attempt end timestamp, when available' },
218-
serviceExceptionJson: {
219-
...nullableString,
220-
description: 'Serialized provider failure details, when available',
221-
},
222-
} satisfies Record<string, OutputProperty>
223-
224209
export const POWERBI_REFRESH_OUTPUT_PROPERTIES = {
225210
requestId: { ...nullableString, description: 'Provider refresh request ID' },
226211
refreshType: { ...nullableString, description: 'Provider refresh trigger type' },
@@ -237,7 +222,23 @@ export const POWERBI_REFRESH_OUTPUT_PROPERTIES = {
237222
refreshAttempts: {
238223
type: 'array',
239224
description: 'Refresh attempts supplied by the provider',
240-
items: { type: 'object', properties: POWERBI_REFRESH_ATTEMPT_OUTPUT_PROPERTIES },
225+
items: {
226+
type: 'object',
227+
properties: {
228+
attemptId: {
229+
type: 'number',
230+
nullable: true,
231+
description: 'Refresh attempt index',
232+
},
233+
type: { ...nullableString, description: 'Provider refresh attempt type' },
234+
startTime: { ...nullableString, description: 'Attempt start timestamp' },
235+
endTime: { ...nullableString, description: 'Attempt end timestamp, when available' },
236+
serviceExceptionJson: {
237+
...nullableString,
238+
description: 'Serialized provider failure details, when available',
239+
},
240+
},
241+
},
241242
},
242243
} satisfies Record<string, OutputProperty>
243244

‎apps/sim/tools/powerbi/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
} from '@/tools/powerbi/types'
1111
import { safeUrlPathSegment } from '@/tools/url-path'
1212

13-
export const MAX_POWERBI_RESPONSE_BYTES = 20 * 1024 * 1024
13+
const MAX_POWERBI_RESPONSE_BYTES = 20 * 1024 * 1024
1414

1515
export const POWERBI_ACCESS_TOKEN_PARAM = {
1616
type: 'string',

0 commit comments

Comments
 (0)