This commit is contained in:
Lars Liden 2018-09-06 15:17:50 -07:00
Родитель 8dafb85523
Коммит 23ebd9d8c6
3 изменённых файлов: 15 добавлений и 8 удалений

4
package-lock.json сгенерированный
Просмотреть файл

@ -793,7 +793,8 @@
"@types/node": {
"version": "8.10.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.12.tgz",
"integrity": "sha512-aRFUGj/f9JVA0qSQiCK9ebaa778mmqMIcy1eKnPktgfm9O6VsnIzzB5wJnjp9/jVrfm7fX1rr3OR1nndppGZUg=="
"integrity": "sha512-aRFUGj/f9JVA0qSQiCK9ebaa778mmqMIcy1eKnPktgfm9O6VsnIzzB5wJnjp9/jVrfm7fX1rr3OR1nndppGZUg==",
"dev": true
},
"@types/shelljs": {
"version": "0.7.0",
@ -820,6 +821,7 @@
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz",
"integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
"dev": true,
"requires": {
"@types/node": "*"
}

Просмотреть файл

@ -94,7 +94,6 @@
"@types/fs-extra": "^5.0.0",
"@types/jest": "^22.1.0",
"@types/node": "^8.0.0",
"@types/uuid": "^3.4.4",
"colors": "^1.1.2",
"commitizen": "^2.9.6",
"coveralls": "^3.0.0",
@ -131,8 +130,5 @@
},
"prettier": {
"printWidth": 140
},
"dependencies": {
"uuid": "^3.3.2"
}
}

Просмотреть файл

@ -9,9 +9,18 @@ import { LogDialog, LogRound, LogScorerStep } from './LogDialog'
import { EntityBase, LabeledEntity, PredictedEntity } from './Entity'
import { ActionBase } from './Action'
import { AppDefinition } from './AppDefinition'
import * as uuid from 'uuid'
export class ModelUtils {
public static generateGUID(): string {
let d = new Date().getTime()
let guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, char => {
let r = ((d + Math.random() * 16) % 16) | 0
d = Math.floor(d / 16)
return (char === 'x' ? r : (r & 0x3) | 0x8).toString(16)
})
return guid
}
/** Remove n words from start of string */
public static RemoveWords(text: string, numWords: number): string {
if (text.length === 0 || numWords === 0) {
@ -216,13 +225,13 @@ export class ModelUtils {
public static InputToActivity(userText: string, userName: string, userId: string, roundNum: number): any {
// Generate activity
return {
id: uuid.v4(),
id: this.generateGUID(),
from: { id: userId, name: userName },
channelData: {
senderType: SenderType.User,
roundIndex: roundNum,
scoreIndex: 0,
clientActivityId: uuid.v4()
clientActivityId: this.generateGUID()
},
type: 'message',
text: userText