Skip to content

Commit c4201c0

Browse files
committed
fix(integrations): send gamma's folder as folderId instead of the deprecated folderIds
1 parent 8cf9710 commit c4201c0

4 files changed

Lines changed: 38 additions & 11 deletions

File tree

‎apps/sim/tools/gamma/generate.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { GammaGenerateParams, GammaGenerateResponse } from '@/tools/gamma/types'
2-
import { gammaFolderIds } from '@/tools/gamma/utils'
2+
import { gammaFolderId } from '@/tools/gamma/utils'
33
import { GAMMA_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
44
import type { ToolConfig } from '@/tools/types'
55

@@ -158,8 +158,8 @@ export const generateTool: ToolConfig<GammaGenerateParams, GammaGenerateResponse
158158
if (params.cardSplit) body.cardSplit = params.cardSplit
159159
if (params.additionalInstructions) body.additionalInstructions = params.additionalInstructions
160160
if (params.exportAs) body.exportAs = params.exportAs
161-
const folderIds = gammaFolderIds(params.folderIds)
162-
if (folderIds) body.folderIds = folderIds
161+
const folderId = gammaFolderId(params.folderIds)
162+
if (folderId) body.folderId = folderId
163163

164164
const textOptions: Record<string, unknown> = {}
165165
if (params.textAmount) textOptions.amount = params.textAmount

‎apps/sim/tools/gamma/generate_from_template.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
GammaGenerateFromTemplateParams,
33
GammaGenerateFromTemplateResponse,
44
} from '@/tools/gamma/types'
5-
import { gammaFolderIds } from '@/tools/gamma/utils'
5+
import { gammaFolderId } from '@/tools/gamma/utils'
66
import { GAMMA_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
77
import type { ToolConfig } from '@/tools/types'
88

@@ -88,8 +88,8 @@ export const generateFromTemplateTool: ToolConfig<
8888

8989
if (params.themeId) body.themeId = params.themeId
9090
if (params.exportAs) body.exportAs = params.exportAs
91-
const folderIds = gammaFolderIds(params.folderIds)
92-
if (folderIds) body.folderIds = folderIds
91+
const folderId = gammaFolderId(params.folderIds)
92+
if (folderId) body.folderId = folderId
9393

9494
const imageOptions: Record<string, unknown> = {}
9595
if (params.imageModel) imageOptions.model = params.imageModel

‎apps/sim/tools/gamma/utils.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { generateTool } from '@/tools/gamma/generate'
3+
import { generateFromTemplateTool } from '@/tools/gamma/generate_from_template'
4+
5+
describe('Gamma folder', () => {
6+
it('sends one folder as folderId, not the deprecated folderIds array', () => {
7+
const body = generateTool.request.body?.({
8+
apiKey: 'key',
9+
inputText: 'Quarterly review',
10+
textMode: 'generate',
11+
folderIds: ' folder_1 ',
12+
})
13+
expect(body).toMatchObject({ folderId: 'folder_1' })
14+
expect(body).not.toHaveProperty('folderIds')
15+
})
16+
17+
it('rejects more than one folder ID', () => {
18+
expect(() =>
19+
generateFromTemplateTool.request.body?.({
20+
apiKey: 'key',
21+
gammaId: 'g_1',
22+
prompt: 'Refresh',
23+
folderIds: 'folder_1, folder_2',
24+
})
25+
).toThrow('Gamma accepts one folder ID')
26+
})
27+
})

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
2-
* The `folderIds` body value for a generation. Gamma accepts at most one folder there, so a
3-
* comma-separated list with more than one ID is rejected here with a clear message.
2+
* The `folderId` body value for a generation. Gamma places a gamma in one folder (its older
3+
* `folderIds` array is deprecated and capped at one ID), so a comma-separated list with more
4+
* than one ID is rejected here with a clear message.
45
*/
5-
export function gammaFolderIds(value: string | undefined): string[] | undefined {
6+
export function gammaFolderId(value: string | undefined): string | undefined {
67
const ids = (value ?? '')
78
.split(',')
89
.map((id) => id.trim())
910
.filter(Boolean)
10-
if (ids.length === 0) return undefined
1111
if (ids.length > 1) {
1212
throw new Error('Gamma accepts one folder ID; remove the extra folder IDs')
1313
}
14-
return ids
14+
return ids[0]
1515
}

0 commit comments

Comments
 (0)