From c10b76f7100b007afb73598543b446dfd7b6c929 Mon Sep 17 00:00:00 2001 From: vanbasten17 Date: Wed, 23 Oct 2024 14:59:45 +0200 Subject: [PATCH] tech-feat: upgrade uid to v11.0.0-0 and update packages to use uuid v7 --- package-lock.json | 49 ++++++++++++------- packages/botonic-cli/package.json | 2 +- .../src/analytics/credentials-handler.ts | 4 +- .../botonic-plugin-dialogflow/package.json | 2 +- .../botonic-plugin-dialogflow/src/index.ts | 4 +- .../botonic-plugin-flow-builder/package.json | 2 +- .../botonic-plugin-flow-builder/src/index.ts | 4 +- .../src/tracking.ts | 4 +- packages/botonic-react/package.json | 2 +- .../src/components/message/index.jsx | 4 +- .../components/message/message-feedback.tsx | 4 +- packages/botonic-react/src/util/webchat.js | 4 +- .../src/webchat/input-panel/index.tsx | 4 +- .../botonic-react/src/webchat/webchat.jsx | 4 +- 14 files changed, 54 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 694fecda8c..98f77c41ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27858,7 +27858,7 @@ "qs": "^6.11.2", "tar": "^6.2.0", "tslib": "^2.6.2", - "uuid": "^8.3.2", + "uuid": "^11.0.0-0", "zip-a-folder": "3.1.7" }, "bin": { @@ -27893,10 +27893,15 @@ } }, "packages/botonic-cli/node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", + "version": "11.0.0-0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.0-0.tgz", + "integrity": "sha512-gPhXpKFuxFX0BvpbLtzvYQf+aqKWDGL0mpjrIg6k/DgG/VrOdZ4+RbmSeP89UVLsgGxecQ2n7aE6OESwYYnCpg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "packages/botonic-core": { @@ -28081,7 +28086,7 @@ "@botonic/core": "^0.30.0", "axios": "^1.7.2", "jsrsasign": "^10.9.0", - "uuid": "^8.3.2" + "uuid": "^11.0.0-0" }, "devDependencies": { "@types/jsrsasign": "^10.5.12", @@ -28089,10 +28094,15 @@ } }, "packages/botonic-plugin-dialogflow/node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", + "version": "11.0.0-0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.0-0.tgz", + "integrity": "sha512-gPhXpKFuxFX0BvpbLtzvYQf+aqKWDGL0mpjrIg6k/DgG/VrOdZ4+RbmSeP89UVLsgGxecQ2n7aE6OESwYYnCpg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "packages/botonic-plugin-dynamodb": { @@ -28133,22 +28143,22 @@ "dependencies": { "@botonic/react": "^0.30.0", "axios": "^1.7.2", - "uuid": "^9.0.1" + "uuid": "^11.0.0-0" }, "engines": { "node": ">=20.0.0" } }, "packages/botonic-plugin-flow-builder/node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "version": "11.0.0-0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.0-0.tgz", + "integrity": "sha512-gPhXpKFuxFX0BvpbLtzvYQf+aqKWDGL0mpjrIg6k/DgG/VrOdZ4+RbmSeP89UVLsgGxecQ2n7aE6OESwYYnCpg==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "packages/botonic-plugin-google-analytics": { @@ -28278,7 +28288,7 @@ "react-textarea-autosize": "^8.5.3", "styled-components": "^5.3.0", "ua-parser-js": "^1.0.39", - "uuid": "^8.3.2" + "uuid": "^11.0.0-0" }, "devDependencies": { "@babel/plugin-transform-runtime": "^7.23.9", @@ -28337,10 +28347,15 @@ } }, "packages/botonic-react/node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", + "version": "11.0.0-0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.0-0.tgz", + "integrity": "sha512-gPhXpKFuxFX0BvpbLtzvYQf+aqKWDGL0mpjrIg6k/DgG/VrOdZ4+RbmSeP89UVLsgGxecQ2n7aE6OESwYYnCpg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } } } diff --git a/packages/botonic-cli/package.json b/packages/botonic-cli/package.json index 9d37ffaaaa..a90b242859 100644 --- a/packages/botonic-cli/package.json +++ b/packages/botonic-cli/package.json @@ -38,7 +38,7 @@ "qs": "^6.11.2", "tar": "^6.2.0", "tslib": "^2.6.2", - "uuid": "^8.3.2", + "uuid": "^11.0.0-0", "zip-a-folder": "3.1.7" }, "devDependencies": { diff --git a/packages/botonic-cli/src/analytics/credentials-handler.ts b/packages/botonic-cli/src/analytics/credentials-handler.ts index 379c4cec04..9b107717a5 100644 --- a/packages/botonic-cli/src/analytics/credentials-handler.ts +++ b/packages/botonic-cli/src/analytics/credentials-handler.ts @@ -1,5 +1,5 @@ import { join, resolve } from 'path' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { BOT_CREDS_FILENAME, @@ -36,7 +36,7 @@ export class CredentialsHandler { } generateId(): string { - return uuidv4() + return uuidv7() } createDirIfNotExists(): void { diff --git a/packages/botonic-plugin-dialogflow/package.json b/packages/botonic-plugin-dialogflow/package.json index 98834ed0e7..85442b8a25 100644 --- a/packages/botonic-plugin-dialogflow/package.json +++ b/packages/botonic-plugin-dialogflow/package.json @@ -19,7 +19,7 @@ "@botonic/core": "^0.30.0", "axios": "^1.7.2", "jsrsasign": "^10.9.0", - "uuid": "^8.3.2" + "uuid": "^11.0.0-0" }, "devDependencies": { "@types/jsrsasign": "^10.5.12", diff --git a/packages/botonic-plugin-dialogflow/src/index.ts b/packages/botonic-plugin-dialogflow/src/index.ts index f1f273ae12..65bb0c0469 100644 --- a/packages/botonic-plugin-dialogflow/src/index.ts +++ b/packages/botonic-plugin-dialogflow/src/index.ts @@ -1,7 +1,7 @@ import type { Plugin, PluginPreRequest } from '@botonic/core' import axios, { AxiosResponse } from 'axios' import jsrsasign from 'jsrsasign' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { Credentials, Options } from './types' @@ -12,7 +12,7 @@ export default class BotonicPluginDialogflow implements Plugin { defaultQueryData: Options['queryData'] constructor(options: Options) { const { credentials, queryData } = options - this.sessionId = uuidv4() + this.sessionId = uuidv7() this.creds = credentials this.defaultQueryData = queryData || {} } diff --git a/packages/botonic-plugin-flow-builder/package.json b/packages/botonic-plugin-flow-builder/package.json index 27654f3b19..63ea730830 100644 --- a/packages/botonic-plugin-flow-builder/package.json +++ b/packages/botonic-plugin-flow-builder/package.json @@ -16,7 +16,7 @@ "dependencies": { "@botonic/react": "^0.30.0", "axios": "^1.7.2", - "uuid": "^9.0.1" + "uuid": "^11.0.0-0" }, "repository": { "type": "git", diff --git a/packages/botonic-plugin-flow-builder/src/index.ts b/packages/botonic-plugin-flow-builder/src/index.ts index ad5360ea80..744851a0f0 100644 --- a/packages/botonic-plugin-flow-builder/src/index.ts +++ b/packages/botonic-plugin-flow-builder/src/index.ts @@ -1,6 +1,6 @@ import { Plugin, PluginPreRequest, Session } from '@botonic/core' import { ActionRequest } from '@botonic/react' -import { v4 as uuid } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { FlowBuilderApi } from './api' import { @@ -144,7 +144,7 @@ export default class BotonicPluginFlowBuilder implements Plugin { async getStartContents(locale: string): Promise { const resolvedLocale = this.cmsApi.getResolvedLocale(locale) const startNode = this.cmsApi.getStartNode() - this.currentRequest.session.flow_thread_id = uuid() + this.currentRequest.session.flow_thread_id = uuidv7() return await this.getContentsByNode(startNode, resolvedLocale) } diff --git a/packages/botonic-plugin-flow-builder/src/tracking.ts b/packages/botonic-plugin-flow-builder/src/tracking.ts index a977ab21e0..71f2237663 100644 --- a/packages/botonic-plugin-flow-builder/src/tracking.ts +++ b/packages/botonic-plugin-flow-builder/src/tracking.ts @@ -1,5 +1,5 @@ import { ActionRequest } from '@botonic/react' -import { v4 as uuid } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { FlowContent } from './content-fields' import { HtNodeWithContent } from './content-fields/hubtype-fields' @@ -60,7 +60,7 @@ function getContentEventArgs( isMeaningful: boolean } ) { - const flowThreadId = request.session.flow_thread_id ?? uuid() + const flowThreadId = request.session.flow_thread_id ?? uuidv7() request.session.flow_thread_id = flowThreadId return { diff --git a/packages/botonic-react/package.json b/packages/botonic-react/package.json index 78bd5a5fde..cdeecbb4ec 100644 --- a/packages/botonic-react/package.json +++ b/packages/botonic-react/package.json @@ -32,7 +32,7 @@ "react-textarea-autosize": "^8.5.3", "styled-components": "^5.3.0", "ua-parser-js": "^1.0.39", - "uuid": "^8.3.2" + "uuid": "^11.0.0-0" }, "devDependencies": { "@babel/plugin-transform-runtime": "^7.23.9", diff --git a/packages/botonic-react/src/components/message/index.jsx b/packages/botonic-react/src/components/message/index.jsx index ffd269219c..656743bea0 100644 --- a/packages/botonic-react/src/components/message/index.jsx +++ b/packages/botonic-react/src/components/message/index.jsx @@ -1,6 +1,6 @@ import { INPUT, isBrowser } from '@botonic/core' import React, { useContext, useEffect, useState } from 'react' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { COLORS, WEBCHAT } from '../../constants' import { RequestContext, WebchatContext } from '../../contexts' @@ -49,7 +49,7 @@ export const Message = props => { const { webchatState, addMessage, updateReplies, getThemeProperty } = useContext(WebchatContext) const [state, setState] = useState({ - id: props.id || uuidv4(), + id: props.id || uuidv7(), }) const [disabled, setDisabled] = useState(false) diff --git a/packages/botonic-react/src/components/message/message-feedback.tsx b/packages/botonic-react/src/components/message/message-feedback.tsx index 9b2ebef09c..33c312265a 100644 --- a/packages/botonic-react/src/components/message/message-feedback.tsx +++ b/packages/botonic-react/src/components/message/message-feedback.tsx @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useState } from 'react' -import { v4 as uuid } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import ThumbsDown from '../../assets/thumbs-down.svg' import ThumbsUp from '../../assets/thumbs-up.svg' @@ -70,7 +70,7 @@ export const MessageFeedback = ({ knowledgebaseInferenceId: inferenceId, feedbackBotInteractionId: botInteractionId, feedbackTargetId: messageId, - feedbackGroupId: uuid(), + feedbackGroupId: uuidv7(), possibleOptions: [FeedbackOption.ThumbsDown, FeedbackOption.ThumbsUp], possibleValues: [0, 1], option: isUseful ? FeedbackOption.ThumbsUp : FeedbackOption.ThumbsDown, diff --git a/packages/botonic-react/src/util/webchat.js b/packages/botonic-react/src/util/webchat.js index 0a40492171..80b483aab4 100644 --- a/packages/botonic-react/src/util/webchat.js +++ b/packages/botonic-react/src/util/webchat.js @@ -1,6 +1,6 @@ import merge from 'lodash.merge' import UAParser from 'ua-parser-js' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { WEBCHAT } from '../constants' import { getProperty } from './objects' @@ -31,7 +31,7 @@ export const createUser = () => { let name = `${ua.os.name} ${ua.browser.name}` if (ua.device && ua.device.type) name = `${ua.device.type} ${name}` return { - id: uuidv4(), + id: uuidv7(), name, } } diff --git a/packages/botonic-react/src/webchat/input-panel/index.tsx b/packages/botonic-react/src/webchat/input-panel/index.tsx index 70dde0a718..e6f00c782c 100644 --- a/packages/botonic-react/src/webchat/input-panel/index.tsx +++ b/packages/botonic-react/src/webchat/input-panel/index.tsx @@ -1,6 +1,6 @@ import { INPUT } from '@botonic/core' import React, { useContext } from 'react' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { WEBCHAT } from '../../constants' import { WebchatContext } from '../../contexts' @@ -62,7 +62,7 @@ export const InputPanel = ({ const sendChatEvent = async chatEvent => { const chatEventInput = { - id: uuidv4(), + id: uuidv7(), type: INPUT.CHAT_EVENT, data: chatEvent, } diff --git a/packages/botonic-react/src/webchat/webchat.jsx b/packages/botonic-react/src/webchat/webchat.jsx index bfabddc1a0..7150235959 100644 --- a/packages/botonic-react/src/webchat/webchat.jsx +++ b/packages/botonic-react/src/webchat/webchat.jsx @@ -13,7 +13,7 @@ import React, { useState, } from 'react' import styled, { StyleSheetManager } from 'styled-components' -import { v4 as uuidv4 } from 'uuid' +import { v7 as uuidv7 } from 'uuid' import { Audio, Document, Image, Text, Video } from '../components' import { Handoff } from '../components/handoff' @@ -467,7 +467,7 @@ export const Webchat = forwardRef((props, ref) => { if (!input || Object.keys(input).length == 0) return if (isText(input) && (!input.data || !input.data.trim())) return // in case trim() doesn't work in a browser we can use !/\S/.test(input.data) if (isText(input) && checkBlockInput(input)) return - if (!input.id) input.id = uuidv4() + if (!input.id) input.id = uuidv7() const messageComponent = messageComponentFromInput(input) if (messageComponent) addMessageComponent(messageComponent) if (isMedia(input)) input.data = await readDataURL(input.data)