Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-snips-action-typescript

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-snips-action-typescript - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

static/.eslintignore

3

dynamic/package.json

@@ -11,3 +11,3 @@ {

"dev": "tsc-watch --noClear --onSuccess \"node action-snips.js\"",
"lint": "eslint .",
"lint": "eslint \"**/*.js\" \"**/*.ts\"",
"test": "jest '^.*\\.spec\\.[jt]s$'",

@@ -20,2 +20,3 @@ "clean": "rimraf dist"

"@types/debug": "^4.1.1",
"@types/fetch-mock": "^7.2.3",
"@types/ini": "^1.3.30",

@@ -22,0 +23,0 @@ "@types/jest": "^24.0.6",

@@ -38,8 +38,2 @@ # {{ name }}

When running from the terminal, to enable full depth object printing:
```sh
env DEBUG_DEPTH=null npm run dev
```
## Test

@@ -46,0 +40,0 @@

{
"name": "create-snips-action-typescript",
"version": "0.1.1",
"version": "0.1.2",
"description": "Generator for writing Snips action code in Typescript.",

@@ -5,0 +5,0 @@ "main": "script.js",

@@ -7,11 +7,21 @@ {

},
"extends": "eslint:recommended",
"plugins": ["jest"],
"parser": "@typescript-eslint/parser",
"plugins": [
"jest",
"@typescript-eslint"
],
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": "warn",
"quotes": ["error", "single", { "avoidEscape": true }],
"quote-props": ["error", "as-needed"]
"quote-props": ["error", "as-needed"],
"@typescript-eslint/no-unused-vars": "error",
"semi": ["error", "never"]
}
}
}
#!/usr/bin/env node
// Enables deep printing of objects.
process.env.DEBUG_DEPTH=null
const debug = require('debug')

@@ -3,0 +7,0 @@ const { name } = require('./package.json')

@@ -19,3 +19,3 @@ import { getPokemon } from '../api'

// Get the Pokemon data
const pokemonId = (pokemonSlot instanceof Array ? pokemonSlot[0] : pokemonSlot).value.value
const pokemonId = pokemonSlot.value.value
const pokemon = await getPokemon(pokemonId)

@@ -22,0 +22,0 @@

@@ -1,5 +0,12 @@

import { IntentMessage } from 'hermes-javascript'
import { IntentMessage, NluSlot } from 'hermes-javascript'
type Slot = IntentMessage['slots'][0]
function geometricMean (dataSet: number[]) {
return Math.pow(dataSet.reduce((accumulator, element) => accumulator * element, 1), 1/dataSet.length)
}
type GetSlotsByNameReturn<T> =
T extends undefined ? NluSlot[] :
T extends true ? NluSlot :
NluSlot[]
export const message = {

@@ -9,7 +16,7 @@ // Helper to filter slots given their name, and potentially a lower threshold for the confidence level.

// If no slot match the criterias, then returns null.
getSlotsByName: (
getSlotsByName: <T extends boolean = undefined>(
message: IntentMessage,
slotName: string,
{ threshold = 0, onlyMostConfident = false } = {}
) : Slot | Slot[] | null => {
{ threshold = 0, onlyMostConfident = undefined } : { threshold?: number, onlyMostConfident?: T } = {}
) : GetSlotsByNameReturn<T> => {
if(onlyMostConfident) {

@@ -21,7 +28,12 @@ return message.slots.reduce((acc, slot) => {

}
return acc
return acc as any
}, null)
}
return message.slots.filter(slot => slot.slotName === slotName && slot.confidenceScore > threshold)
return message.slots.filter(slot => slot.slotName === slotName && slot.confidenceScore > threshold) as any
},
getAsrConfidence(message: IntentMessage) {
if(!message.asrTokens || message.asrTokens.length < 1)
return 1
return geometricMean(message.asrTokens[0].map(token => token.confidence))
}
}
}

@@ -27,2 +27,10 @@ import { setupVars } from './setup'

unsubscribe (topic: string) {
return new Promise((resolve, reject) => {
this.mqtt.unsubscribe(topic, err => {
err ? reject(err) : resolve()
})
})
}
async publishMessage ({ intentName, input, ...additionalFields }) {

@@ -62,4 +70,4 @@ return new Promise(resolve => {

// Subscribe to the continueSession/endSession callbacks
this.subscribe('hermes/dialogueManager/continueSession')
this.subscribe('hermes/dialogueManager/endSession')
await this.subscribe('hermes/dialogueManager/continueSession')
await this.subscribe('hermes/dialogueManager/endSession')
// Publish an intent message

@@ -93,4 +101,6 @@ this.publishMessage({ intentName, input, ...additionalFields })

expect(message.sessionId).toBe(this.sessionId)
await this.unsubscribe('hermes/dialogueManager/continueSession')
await this.unsubscribe('hermes/dialogueManager/endSession')
return message
}
}

@@ -23,2 +23,3 @@ /* eslint no-console: off */

beforeAll(async () => {
require('debug').enable('*:error')
const mosquittoPort = await getFreePort()

@@ -31,3 +32,3 @@ console.log('Launching mosquitto on port [' + mosquittoPort + ']')

setupVars.mosquittoPort = mosquittoPort
setupVars.killHermes = index({
setupVars.killHermes = await index({
hermesOptions: {

@@ -34,0 +35,0 @@ address: 'localhost:' + mosquittoPort,

@@ -8,3 +8,3 @@ import { createServer } from 'net'

if(item instanceof Array) {
return item.map(value => module.exports.camelize(value))
return item.map(value => camelize(value))
}

@@ -14,3 +14,3 @@ Object.entries(item).forEach(([ key, value ]) => {

const isSameKey = key === camelizedKey
item[camelizedKey] = module.exports.camelize(value)
item[camelizedKey] = camelize(value)
if(!isSameKey) {

@@ -17,0 +17,0 @@ delete item[key]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc