New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

actions-on-google

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

actions-on-google - npm Package Compare versions

Comparing version 2.4.1 to 2.5.0

19

dist/service/actionssdk/conv.js

@@ -49,7 +49,9 @@ "use strict";

}
const { richResponse, expectUserResponse, userStorage, expectedIntent, noInputPrompts, } = this.response();
const { richResponse, expectUserResponse, userStorage, expectedIntent, noInputPrompts, speechBiasingHints, } = this.response();
const inputPrompt = {
richInitialPrompt: richResponse,
noInputPrompts,
};
if (richResponse.items.length) {
inputPrompt.richInitialPrompt = richResponse;
}
const possibleIntents = [expectedIntent || {

@@ -59,5 +61,8 @@ intent: 'actions.intent.TEXT',

const expectedInput = {
inputPrompt,
possibleIntents,
speechBiasingHints,
};
if (inputPrompt.richInitialPrompt || inputPrompt.noInputPrompts) {
expectedInput.inputPrompt = inputPrompt;
}
const response = {

@@ -72,6 +77,8 @@ expectUserResponse,

}
const convDataDefault = deserializeData(this.body, this._init.data);
const convDataIn = serializeData(convDataDefault);
const convDataDefault = deserializeData({}, this._init.data);
const convDataDefaultSerialized = serializeData(convDataDefault);
const convDataDefaulted = deserializeData(this.body, this._init.data);
const convDataIn = serializeData(convDataDefaulted);
const convDataOut = serializeData(this.data);
if (convDataOut !== convDataIn) {
if (convDataOut !== convDataDefaultSerialized || convDataOut !== convDataIn) {
response.conversationToken = convDataOut;

@@ -78,0 +85,0 @@ }

@@ -43,2 +43,3 @@ /**

noInputPrompts?: Api.GoogleActionsV2SimpleResponse[];
speechBiasingHints?: string[];
}

@@ -155,2 +156,17 @@ export interface ConversationOptionsInit<TConvData, TUserStorage> {

noInputs: (string | SimpleResponse)[];
/**
* Sets speech biasing options.
*
* @example
* ``` javascript
*
* app.intent('actions.intent.MAIN', conv => {
* conv.speechBiasing = ['red', 'blue', 'green']
* conv.ask('What is your favorite color out of red, blue, and green?')
* })
* ```
*
* @public
*/
speechBiasing: string[];
/** @hidden */

@@ -157,0 +173,0 @@ _raw?: JsonObject;

@@ -61,2 +61,17 @@ "use strict";

this.noInputs = [];
/**
* Sets speech biasing options.
*
* @example
* ``` javascript
*
* app.intent('actions.intent.MAIN', conv => {
* conv.speechBiasing = ['red', 'blue', 'green']
* conv.ask('What is your favorite color out of red, blue, and green?')
* })
* ```
*
* @public
*/
this.speechBiasing = [];
/** @hidden */

@@ -201,2 +216,3 @@ this._responded = false;

let expectedIntent;
let requireSimpleResponse = false;
for (const response of this.responses) {

@@ -209,8 +225,4 @@ if (typeof response === 'string') {

expectedIntent = response;
if (response instanceof helper_1.SoloHelper) {
// SoloHelper classes don't require a SimpleResponse
// but API still requires a SimpleResponse
// so a placeholder is added to not error
// It won't show up to the user as PLACEHOLDER
richResponse.add('PLACEHOLDER');
if (!(response instanceof helper_1.SoloHelper)) {
requireSimpleResponse = true;
}

@@ -224,9 +236,8 @@ continue;

if (response instanceof response_1.Suggestions) {
if (!richResponse.suggestions) {
richResponse.suggestions = [];
}
richResponse.suggestions.push(...response.suggestions);
requireSimpleResponse = true;
richResponse.addSuggestion(response);
continue;
}
if (response instanceof response_1.Image) {
requireSimpleResponse = true;
richResponse.add(new response_1.BasicCard({ image: response }));

@@ -236,9 +247,26 @@ continue;

if (response instanceof response_1.MediaObject) {
requireSimpleResponse = true;
richResponse.add(new response_1.MediaResponse(response));
continue;
}
if (response instanceof response_1.BasicCard ||
response instanceof response_1.Table ||
response instanceof response_1.BrowseCarousel ||
response instanceof response_1.MediaResponse ||
response instanceof response_1.OrderUpdate ||
response instanceof response_1.LinkOutSuggestion) {
requireSimpleResponse = true;
richResponse.add(response);
continue;
}
richResponse.add(response);
}
if (richResponse.items.length < 2 &&
(!richResponse.items[0] || !richResponse.items[0].simpleResponse)) {
let hasSimpleResponse = false;
for (const response of richResponse.items) {
if (response.simpleResponse) {
hasSimpleResponse = true;
break;
}
}
if (requireSimpleResponse && !hasSimpleResponse) {
throw new Error('A simple response is required in addition to this type of response');

@@ -249,9 +277,3 @@ }

const userStorage = userStorageOut === userStorageIn ? '' : userStorageOut;
let noInputPrompts;
if (this.noInputs.length > 0) {
noInputPrompts = this.noInputs.map(prompt => {
return (typeof prompt === 'string') ? new response_1.SimpleResponse(prompt) : prompt;
});
}
return {
const response = {
expectUserResponse,

@@ -261,4 +283,12 @@ richResponse,

expectedIntent,
noInputPrompts,
};
if (this.noInputs.length > 0) {
response.noInputPrompts = this.noInputs.map(prompt => {
return (typeof prompt === 'string') ? new response_1.SimpleResponse(prompt) : prompt;
});
}
if (this.speechBiasing.length > 0) {
response.speechBiasingHints = this.speechBiasing;
}
return response;
}

@@ -265,0 +295,0 @@ }

@@ -30,8 +30,9 @@ /**

export interface GoogleAssistantResponse {
expectUserResponse: boolean;
expectUserResponse?: boolean;
noInputPrompts?: ActionsApi.GoogleActionsV2SimpleResponse[];
isSsml?: boolean;
richResponse: ActionsApi.GoogleActionsV2RichResponse;
richResponse?: ActionsApi.GoogleActionsV2RichResponse;
systemIntent?: SystemIntent;
userStorage?: string;
speechBiasingHints?: string[];
}

@@ -38,0 +39,0 @@ /** @hidden */

@@ -159,6 +159,5 @@ "use strict";

else {
const { richResponse, expectUserResponse, userStorage, expectedIntent, noInputPrompts, } = this.response();
const { richResponse, expectUserResponse, userStorage, expectedIntent, noInputPrompts, speechBiasingHints, } = this.response();
const google = {
expectUserResponse,
richResponse,
systemIntent: expectedIntent && {

@@ -169,3 +168,7 @@ intent: expectedIntent.intent,

noInputPrompts,
speechBiasingHints,
};
if (richResponse.items.length) {
google.richResponse = richResponse;
}
if (userStorage) {

@@ -197,10 +200,16 @@ google.userStorage = userStorage;

if (simulator && payload) {
const items = payload.google.richResponse.items;
const { richResponse = {} } = payload.google;
const { items = [] } = richResponse;
// Simulator only shows speech response
// Since this is only shown to the simulator as text, the speech is the displayText
response.speech =
(payload.google.systemIntent || items.length > 1) ?
SIMULATOR_WARNING :
(items[0].simpleResponse.displayText ||
items[0].simpleResponse.textToSpeech);
response.speech = SIMULATOR_WARNING;
if (!payload.google.systemIntent && items.length < 2) {
for (const { simpleResponse } of items) {
if (simpleResponse) {
response.speech = simpleResponse.displayText ||
simpleResponse.textToSpeech;
break;
}
}
}
}

@@ -218,8 +227,14 @@ return response;

if (simulator && payload) {
const items = payload.google.richResponse.items;
response.fulfillmentText =
(payload.google.systemIntent || items.length > 1) ?
SIMULATOR_WARNING :
(items[0].simpleResponse.displayText ||
items[0].simpleResponse.textToSpeech);
const { richResponse = {} } = payload.google;
const { items = [] } = richResponse;
response.fulfillmentText = SIMULATOR_WARNING;
if (!payload.google.systemIntent && items.length < 2) {
for (const { simpleResponse } of items) {
if (simpleResponse) {
response.fulfillmentText = simpleResponse.displayText ||
simpleResponse.textToSpeech;
break;
}
}
}
}

@@ -226,0 +241,0 @@ return response;

@@ -19,3 +19,3 @@ /**

export declare type SmartHomeV1ExecuteStatus = 'SUCCESS' | 'PENDING' | 'OFFLINE' | 'ERROR';
export declare type SmartHomeV1ExecuteErrors = 'authExpired' | 'authFailure' | 'deviceOffline' | 'timeout' | 'deviceTurnedOff' | 'deviceNotFound' | 'valueOutOfRange' | 'notSupported' | 'protocolError' | 'unknownError';
export declare type SmartHomeV1ExecuteErrors = string;
export interface SmartHomeV1SyncRequestInputs {

@@ -112,3 +112,3 @@ intent: SmartHomeV1Intents;

debugString?: string;
states?: ApiClientObjectMap<string | boolean | number>;
states?: ApiClientObjectMap<any>;
}

@@ -115,0 +115,0 @@ export interface SmartHomeV1ExecutePayload {

@@ -6,3 +6,3 @@ {

"types": "dist/index.d.ts",
"version": "2.4.1",
"version": "2.5.0",
"license": "Apache-2.0",

@@ -25,3 +25,4 @@ "author": "Google Inc.",

"docs:redirect": "node script/redirect.js",
"docs": "typedoc --options typedoc.json && touch docs/.nojekyll && yarn docs:redirect",
"docs:hide": "echo 'a[href=\"modules/conversation.html\"], a[href=\"conversation.html\"], a[href=\"../modules/conversation.html\"] { display: none !important; }' >> docs/assets/css/main.css",
"docs": "typedoc --options typedoc.json && touch docs/.nojekyll && yarn docs:redirect && yarn docs:hide",
"docs:clean": "rm -rf docs && yarn docs",

@@ -28,0 +29,0 @@ "docs:serve": "yarn docs:clean && live-server docs",

@@ -116,7 +116,10 @@ /**

noInputPrompts,
speechBiasingHints,
} = this.response()
const inputPrompt: Api.GoogleActionsV2InputPrompt = {
richInitialPrompt: richResponse,
noInputPrompts,
}
if (richResponse.items!.length) {
inputPrompt.richInitialPrompt = richResponse
}
const possibleIntents: Api.GoogleActionsV2ExpectedIntent[] = [expectedIntent || {

@@ -126,5 +129,8 @@ intent: 'actions.intent.TEXT',

const expectedInput: Api.GoogleActionsV2ExpectedInput = {
inputPrompt,
possibleIntents,
speechBiasingHints,
}
if (inputPrompt.richInitialPrompt || inputPrompt.noInputPrompts) {
expectedInput.inputPrompt = inputPrompt
}
const response: Api.GoogleActionsV2AppResponse = {

@@ -138,6 +144,8 @@ expectUserResponse,

}
const convDataDefault = deserializeData<TConvData>(this.body, this._init.data)
const convDataIn = serializeData(convDataDefault)
const convDataDefault = deserializeData<TConvData>({}, this._init.data)
const convDataDefaultSerialized = serializeData(convDataDefault)
const convDataDefaulted = deserializeData<TConvData>(this.body, this._init.data)
const convDataIn = serializeData(convDataDefaulted)
const convDataOut = serializeData(this.data)
if (convDataOut !== convDataIn) {
if (convDataOut !== convDataDefaultSerialized || convDataOut !== convDataIn) {
response.conversationToken = convDataOut

@@ -144,0 +152,0 @@ }

@@ -30,2 +30,6 @@ /**

SimpleResponse,
Table,
BrowseCarousel,
OrderUpdate,
LinkOutSuggestion,
} from './response'

@@ -99,2 +103,3 @@ import { Helper, SoloHelper } from './helper'

noInputPrompts?: Api.GoogleActionsV2SimpleResponse[]
speechBiasingHints?: string[]
}

@@ -236,2 +241,18 @@

/**
* Sets speech biasing options.
*
* @example
* ``` javascript
*
* app.intent('actions.intent.MAIN', conv => {
* conv.speechBiasing = ['red', 'blue', 'green']
* conv.ask('What is your favorite color out of red, blue, and green?')
* })
* ```
*
* @public
*/
speechBiasing: string[] = []
/** @hidden */

@@ -400,2 +421,3 @@ _raw?: JsonObject

let expectedIntent: Api.GoogleActionsV2ExpectedIntent | undefined
let requireSimpleResponse = false
for (const response of this.responses) {

@@ -408,9 +430,4 @@ if (typeof response === 'string') {

expectedIntent = response
if (response instanceof SoloHelper) {
// SoloHelper classes don't require a SimpleResponse
// but API still requires a SimpleResponse
// so a placeholder is added to not error
// It won't show up to the user as PLACEHOLDER
richResponse.add('PLACEHOLDER')
if (!(response instanceof SoloHelper)) {
requireSimpleResponse = true
}

@@ -424,9 +441,8 @@ continue

if (response instanceof Suggestions) {
if (!richResponse.suggestions) {
richResponse.suggestions = []
}
richResponse.suggestions.push(...response.suggestions)
requireSimpleResponse = true
richResponse.addSuggestion(response)
continue
}
if (response instanceof Image) {
requireSimpleResponse = true
richResponse.add(new BasicCard({ image: response }))

@@ -436,9 +452,28 @@ continue

if (response instanceof MediaObject) {
requireSimpleResponse = true
richResponse.add(new MediaResponse(response))
continue
}
if (
response instanceof BasicCard ||
response instanceof Table ||
response instanceof BrowseCarousel ||
response instanceof MediaResponse ||
response instanceof OrderUpdate ||
response instanceof LinkOutSuggestion
) {
requireSimpleResponse = true
richResponse.add(response)
continue
}
richResponse.add(response)
}
if (richResponse.items!.length < 2 &&
(!richResponse.items![0] || !richResponse.items![0].simpleResponse)) {
let hasSimpleResponse = false
for (const response of richResponse.items!) {
if (response.simpleResponse) {
hasSimpleResponse = true
break
}
}
if (requireSimpleResponse && !hasSimpleResponse) {
throw new Error('A simple response is required in addition to this type of response')

@@ -449,9 +484,3 @@ }

const userStorage = userStorageOut === userStorageIn ? '' : userStorageOut
let noInputPrompts: Api.GoogleActionsV2SimpleResponse[] | undefined
if (this.noInputs.length > 0) {
noInputPrompts = this.noInputs.map(prompt => {
return (typeof prompt === 'string') ? new SimpleResponse(prompt) : prompt
})
}
return {
const response: ConversationResponse = {
expectUserResponse,

@@ -461,4 +490,12 @@ richResponse,

expectedIntent,
noInputPrompts,
}
if (this.noInputs.length > 0) {
response.noInputPrompts = this.noInputs.map(prompt => {
return (typeof prompt === 'string') ? new SimpleResponse(prompt) : prompt
})
}
if (this.speechBiasing.length > 0) {
response.speechBiasingHints = this.speechBiasing
}
return response
}

@@ -465,0 +502,0 @@ }

@@ -38,8 +38,9 @@ /**

export interface GoogleAssistantResponse {
expectUserResponse: boolean
expectUserResponse?: boolean
noInputPrompts?: ActionsApi.GoogleActionsV2SimpleResponse[]
isSsml?: boolean
richResponse: ActionsApi.GoogleActionsV2RichResponse
richResponse?: ActionsApi.GoogleActionsV2RichResponse
systemIntent?: SystemIntent
userStorage?: string
speechBiasingHints?: string[]
}

@@ -354,6 +355,6 @@

noInputPrompts,
speechBiasingHints,
} = this.response()
const google: GoogleAssistantResponse = {
expectUserResponse,
richResponse,
systemIntent: expectedIntent && {

@@ -364,3 +365,7 @@ intent: expectedIntent.intent!,

noInputPrompts,
speechBiasingHints,
}
if (richResponse.items!.length) {
google.richResponse = richResponse
}
if (userStorage) {

@@ -392,10 +397,16 @@ google.userStorage = userStorage

if (simulator && payload) {
const items = payload.google.richResponse.items!
const { richResponse = {} } = payload.google
const { items = [] } = richResponse
// Simulator only shows speech response
// Since this is only shown to the simulator as text, the speech is the displayText
response.speech =
(payload.google.systemIntent || items.length > 1) ?
SIMULATOR_WARNING :
(items[0].simpleResponse!.displayText ||
items[0].simpleResponse!.textToSpeech)
response.speech = SIMULATOR_WARNING
if (!payload.google.systemIntent && items.length < 2) {
for (const { simpleResponse } of items) {
if (simpleResponse) {
response.speech = simpleResponse.displayText ||
simpleResponse.textToSpeech
break
}
}
}
}

@@ -413,8 +424,14 @@ return response

if (simulator && payload) {
const items = payload.google.richResponse.items!
response.fulfillmentText =
(payload.google.systemIntent || items.length > 1) ?
SIMULATOR_WARNING :
(items[0].simpleResponse!.displayText ||
items[0].simpleResponse!.textToSpeech)
const { richResponse = {} } = payload.google
const { items = [] } = richResponse
response.fulfillmentText = SIMULATOR_WARNING
if (!payload.google.systemIntent && items.length < 2) {
for (const { simpleResponse } of items) {
if (simpleResponse) {
response.fulfillmentText = simpleResponse.displayText ||
simpleResponse.textToSpeech
break
}
}
}
}

@@ -421,0 +438,0 @@ return response

@@ -28,5 +28,5 @@ /**

export type SmartHomeV1ExecuteErrors = 'authExpired' | 'authFailure' | 'deviceOffline' | 'timeout' |
'deviceTurnedOff' | 'deviceNotFound' | 'valueOutOfRange' | 'notSupported' | 'protocolError' |
'unknownError'
// See an extensive list of error codes at
// https://developers.google.com/actions/reference/smarthome/errors-exceptions
export type SmartHomeV1ExecuteErrors = string

@@ -145,3 +145,3 @@ export interface SmartHomeV1SyncRequestInputs {

debugString?: string,
states?: ApiClientObjectMap<string | boolean | number>
states?: ApiClientObjectMap<any>
}

@@ -148,0 +148,0 @@

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