From 7637dddd4546e9a69838528c4bc2a19d3cc51626 Mon Sep 17 00:00:00 2001 From: Danil Mirgaev Date: Mon, 18 May 2026 19:51:42 +0400 Subject: [PATCH 1/2] remove unnecessary export and cover helper function with tests --- .../commands/__tests__/utils.test.ts | 29 ++++++++++++++++++- .../grid_core/ai_assistant/commands/utils.ts | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/utils.test.ts b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/utils.test.ts index 8b28c55a910d..5673e83e96cf 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/utils.test.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/utils.test.ts @@ -4,7 +4,34 @@ import { it, } from '@jest/globals'; -import { isKeyShapeValid } from '../utils'; +import { isKeyShapeValid, normalizeKey } from '../utils'; + +describe('normalizeKey', () => { + it('returns a string key as-is', () => { + expect(normalizeKey('abc')).toBe('abc'); + }); + + it('returns a number key as-is', () => { + expect(normalizeKey(42)).toBe(42); + }); + + it('converts a single-element CompositeKeyPair array to an object', () => { + expect(normalizeKey([{ field: 'id', value: 1 }])).toEqual({ id: 1 }); + }); + + it('converts a multi-element CompositeKeyPair array to an object', () => { + const pairs = [ + { field: 'region', value: 'us' }, + { field: 'code', value: 100 }, + ]; + + expect(normalizeKey(pairs)).toEqual({ region: 'us', code: 100 }); + }); + + it('returns an empty object for an empty array', () => { + expect(normalizeKey([])).toEqual({}); + }); +}); describe('isKeyShapeValid', () => { describe('single-field keyExpr (string)', () => { diff --git a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/utils.ts b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/utils.ts index cb5b7bd84923..23bcee852150 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/utils.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/utils.ts @@ -9,7 +9,7 @@ export const compositeKeyPairSchema = z.object({ value: z.union([z.string(), z.number()]), }).strict(); -export const compositeKeyToObject = ( +const compositeKeyToObject = ( pairs: CompositeKeyPair[], ): Record => { const result: Record = {}; From f122ada5fb5ee7a855ea4bbb5196ecc70c50d9c0 Mon Sep 17 00:00:00 2001 From: Danil Mirgaev Date: Mon, 18 May 2026 19:55:45 +0400 Subject: [PATCH 2/2] remove comment as the helper is covered with tests --- .../js/__internal/grids/grid_core/ai_assistant/utils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/utils.ts b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/utils.ts index 15d60da45f6a..66d4595dd08d 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/utils.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/ai_assistant/utils.ts @@ -52,10 +52,6 @@ export const getMessageStatus = (commands: CommandResult[]): ResponseStatus => { }; /** - * Recursively converts JSON Schema array-style `type` - * (e.g. `{"type": ["string", "number"]}`) to the equivalent `anyOf` form - * (e.g. `{"anyOf": [{"type": "string"}, {"type": "number"}]}`). - * * Some structured-output APIs do not support array-style `type` fields * and require explicit `anyOf` instead. */