Socket
Socket
Sign inDemoInstall

@salutejs/scenario

Package Overview
Dependencies
Maintainers
2
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salutejs/scenario - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

23

dist/lib/createSaluteResponse.js

@@ -15,7 +15,6 @@ "use strict";

exports.createSaluteResponse = void 0;
var types_1 = require("@salutejs/types");
var createSaluteResponse = function (req) {
var messageId = req.messageId, sessionId = req.sessionId, uuid = req.uuid, payload = req.payload;
var message = {
messageName: types_1.NLPResponseType.ANSWER_TO_USER,
messageName: 'ANSWER_TO_USER',
messageId: messageId,

@@ -37,3 +36,3 @@ sessionId: sessionId,

uuid: uuid,
messageName: types_1.NLPResponseType.POLICY_RUN_APP,
messageName: 'POLICY_RUN_APP',
payload: {

@@ -52,3 +51,3 @@ projectName: payload.projectName,

if (options === void 0) { options = {}; }
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -66,3 +65,3 @@ }

appendCard: function (card) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -73,3 +72,3 @@ }

appendCommand: function (command) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -81,3 +80,3 @@ }

appendItem: function (item) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -88,3 +87,3 @@ }

appendError: function (error) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -95,3 +94,3 @@ }

appendSuggestions: function (suggestions) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -126,3 +125,3 @@ }

setIntent: function (intent) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -133,3 +132,3 @@ }

setPronounceText: function (text) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -140,3 +139,3 @@ }

setEmotion: function (emotion) {
if (message.messageName !== types_1.NLPResponseType.ANSWER_TO_USER) {
if (message.messageName !== 'ANSWER_TO_USER') {
throw new Error('Wrong message type');

@@ -143,0 +142,0 @@ }

@@ -5,6 +5,6 @@ import { IntentsDict, SaluteRequest, SaluteResponse, SaluteSession, Recognizer, SaluteRequestVariable, AppState } from '@salutejs/types';

interface ScenarioWalkerOptions {
intents: IntentsDict;
intents?: IntentsDict;
recognizer?: Recognizer;
systemScenario: SystemScenario;
userScenario: ReturnType<typeof createUserScenario>;
userScenario?: ReturnType<typeof createUserScenario>;
slotFillingConfidence?: number;

@@ -11,0 +11,0 @@ }

@@ -95,2 +95,3 @@ "use strict";

});
if (!(typeof intents !== undefined && typeof userScenario !== undefined)) return [3 /*break*/, 4];
// restore request from server_action payload

@@ -102,3 +103,3 @@ if (req.serverAction) {

}
if (!(req.voiceAction && typeof recognizer !== 'undefined')) return [3 /*break*/, 2];
if (!(req.voiceAction && typeof recognizer !== 'undefined' && typeof intents !== 'undefined')) return [3 /*break*/, 2];
// INFERENCE LOGIC START

@@ -140,3 +141,3 @@ return [4 /*yield*/, recognizer.inference({ req: req, res: res, session: session })];

scenarioState = userScenario.resolve(session.path, req);
if (req.serverAction) {
if (req.serverAction && typeof intents !== 'undefined') {
if (!scenarioState) {

@@ -143,0 +144,0 @@ res.appendError({

@@ -7,3 +7,2 @@ "use strict";

exports.i18n = void 0;
var types_1 = require("@salutejs/types");
var ru_1 = __importDefault(require("./plural/ru"));

@@ -76,3 +75,3 @@ var pluralMap = {

if (options === void 0) { options = {}; }
var keysetKey = (keyset[character] && keyset[character][key]) || keyset[types_1.CharacterId.sber][key];
var keysetKey = (keyset[character] && keyset[character][key]) || keyset.sber[key];
if (Array.isArray(keysetKey)) {

@@ -98,3 +97,3 @@ return generateText(keysetKey[Math.floor(Math.random() * keysetKey.length)], options);

var i18n = function (character) {
if (character === void 0) { character = types_1.CharacterId.sber; }
if (character === void 0) { character = 'sber'; }
return function (keyset) { return function (key, options) {

@@ -101,0 +100,0 @@ if (options === void 0) { options = {}; }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var types_1 = require("@salutejs/types");
var i18n_1 = require("./i18n");

@@ -49,9 +48,9 @@ describe('i18n', function () {

it('should get simple text', function () {
expect(i18n_1.i18n(types_1.CharacterId.joy)(keysetDict)('Пример')).toEqual('Example');
expect(i18n_1.i18n('joy')(keysetDict)('Пример')).toEqual('Example');
});
it('should substitute params', function () {
expect(i18n_1.i18n(types_1.CharacterId.joy)(keysetDict)('ул. {street} неподалеку', { street: 'Тверская' })).toEqual('Тверская st. nearby');
expect(i18n_1.i18n('joy')(keysetDict)('ул. {street} неподалеку', { street: 'Тверская' })).toEqual('Тверская st. nearby');
});
it('should handle pluralization', function () {
var adapterI18n = i18n_1.i18n(types_1.CharacterId.joy)(keysetDict);
var adapterI18n = i18n_1.i18n('joy')(keysetDict);
expect(adapterI18n('{count} яблок', { count: 0 })).toEqual('no apples');

@@ -65,8 +64,8 @@ expect(adapterI18n('{count} яблок', { count: 1 })).toEqual('1 apple');

it('missing in athena', function () {
expect(i18n_1.i18n(types_1.CharacterId.athena)(keysetDict)('Только СБЕР')).toEqual('Только СБЕР');
expect(i18n_1.i18n('athena')(keysetDict)('Только СБЕР')).toEqual('Только СБЕР');
});
it('missing in everywhere', function () {
expect(i18n_1.i18n(types_1.CharacterId.athena)(keysetDict)('Нигде нет перевода')).toEqual('Нигде нет перевода');
expect(i18n_1.i18n('athena')(keysetDict)('Нигде нет перевода')).toEqual('Нигде нет перевода');
});
});
});

@@ -9,3 +9,3 @@ import { IntentsDict, SaluteRequest } from '@salutejs/types';

selectItem: (expected: Partial<R['state']['item_selector']['items'][number]>) => (req: R) => {
[key: string]: unknown;
[k: string]: unknown;
number?: number;

@@ -19,3 +19,3 @@ id?: string;

selectItems: (expected: Partial<R['state']['item_selector']['items'][number]>) => (req: R) => {
[key: string]: unknown;
[k: string]: unknown;
number?: number;

@@ -22,0 +22,0 @@ id?: string;

{
"name": "@salutejs/scenario",
"version": "0.4.0",
"version": "0.5.0",
"description": "Tiny helpers to make scenario for Salute family",

@@ -35,6 +35,6 @@ "author": "SberDevices Frontend Team <sberdevices.frontend@gmail.com>",

"dependencies": {
"@salutejs/types": "0.4.0",
"@salutejs/types": "0.5.0",
"node-fetch": "2.6.1"
},
"gitHead": "38c3e2badbb38a4d31bbe64341bb2faf77e385f2"
"gitHead": "40cd4fcb637366dc43fad1b9a1447b331e458fac"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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