Skip to content

Commit

Permalink
tech-feat: upgrade uid to v11.0.0-0 and update packages to use uuid v7
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten17 committed Oct 23, 2024
1 parent f9d4f76 commit c10b76f
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 39 deletions.
49 changes: 32 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/botonic-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-cli/src/analytics/credentials-handler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -36,7 +36,7 @@ export class CredentialsHandler {
}

generateId(): string {
return uuidv4()
return uuidv7()
}

createDirIfNotExists(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-plugin-dialogflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-plugin-dialogflow/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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 || {}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-plugin-flow-builder/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -144,7 +144,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
async getStartContents(locale: string): Promise<FlowContent[]> {
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)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-plugin-flow-builder/src/tracking.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-react/src/components/message/index.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-react/src/util/webchat.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-react/src/webchat/input-panel/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -62,7 +62,7 @@ export const InputPanel = ({

const sendChatEvent = async chatEvent => {
const chatEventInput = {
id: uuidv4(),
id: uuidv7(),
type: INPUT.CHAT_EVENT,
data: chatEvent,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-react/src/webchat/webchat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c10b76f

Please sign in to comment.