Skip to content

Commit abe38b2

Browse files
Bump uuid from 11.1.0 to 14.0.0 in /src/Elastic.Documentation.Site (#3193)
* Bump uuid from 11.1.0 to 14.0.0 in /src/Elastic.Documentation.Site Bumps [uuid](https://github.com/uuidjs/uuid) from 11.1.0 to 14.0.0. - [Release notes](https://github.com/uuidjs/uuid/releases) - [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md) - [Commits](uuidjs/uuid@v11.1.0...v14.0.0) --- updated-dependencies: - dependency-name: uuid dependency-version: 14.0.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * fix(site): generate Ask AI message IDs without importing uuid Parcel could not resolve uuid@14 when bundling chat.store (no ./index entry for the resolver). Use crypto.randomUUID with a fallback instead, and mock randomUUID in tests. Made-with: Cursor --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
1 parent 581c339 commit abe38b2

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

src/Elastic.Documentation.Site/Assets/web-components/AskAi/chat.store.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { chatStore } from './chat.store'
22
import { act } from 'react'
3-
import { v4 as uuidv4 } from 'uuid'
43

54
// Mock idb-keyval (IndexedDB not available in Node.js test environment)
65
jest.mock('idb-keyval', () => ({
@@ -10,18 +9,18 @@ jest.mock('idb-keyval', () => ({
109
createStore: jest.fn().mockReturnValue({}),
1110
}))
1211

13-
// Mock uuid
14-
jest.mock('uuid', () => ({
15-
v4: jest.fn(),
16-
}))
17-
18-
const mockUuidv4 = uuidv4 as jest.MockedFunction<() => string>
19-
2012
describe('chat.store', () => {
2113
beforeEach(() => {
22-
// Setup UUID mock to return unique IDs
14+
// Setup randomUUID mock to return unique IDs
2315
let counter = 0
24-
mockUuidv4.mockImplementation((): string => `mock-uuid-${++counter}`)
16+
Object.defineProperty(globalThis, 'crypto', {
17+
configurable: true,
18+
value: {
19+
randomUUID: jest
20+
.fn()
21+
.mockImplementation((): string => `mock-uuid-${++counter}`),
22+
},
23+
})
2524

2625
// Clear localStorage to ensure clean state
2726
try {

src/Elastic.Documentation.Site/Assets/web-components/AskAi/chat.store.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
del as idbDel,
1212
createStore as createIdbStore,
1313
} from 'idb-keyval'
14-
import { v4 as uuidv4 } from 'uuid'
1514
import { createStore } from 'zustand'
1615
import { persist, PersistStorage, StorageValue } from 'zustand/middleware'
1716
import { useStore } from 'zustand/react'
@@ -180,6 +179,10 @@ const activeStreams = new Map<string, ActiveStream>()
180179

181180
const sentAiMessageIds = new Set<string>()
182181

182+
const createMessageId = () =>
183+
globalThis.crypto?.randomUUID?.() ??
184+
`msg-${Date.now()}-${Math.random().toString(16).slice(2)}`
185+
183186
// Maximum number of conversations to keep (oldest are deleted when exceeded)
184187
// This is a temporary limit to prevent the IndexedDB from growing too large
185188
// As soon as we support multiple conversation in the UI, we will set a more reasonable limit
@@ -244,10 +247,10 @@ export const chatStore = createStore<ChatState>()(
244247
actions: {
245248
submitQuestion: (question: string) => {
246249
const state = get()
247-
const aiMessageId = uuidv4()
250+
const aiMessageId = createMessageId()
248251

249252
const userMessage: ChatMessage = {
250-
id: uuidv4(),
253+
id: createMessageId(),
251254
type: 'user',
252255
content: question,
253256
conversationId: state.activeConversationId ?? '',

src/Elastic.Documentation.Site/package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Documentation.Site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"tailwindcss": "4.2.2",
134134
"tippy.js": "6.3.7",
135135
"ua-parser-js": "2.0.6",
136-
"uuid": "11.1.0",
136+
"uuid": "14.0.0",
137137
"zod": "4.3.6",
138138
"zustand": "5.0.11"
139139
}

0 commit comments

Comments
 (0)