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

@jargon/alexa-skill-sdk

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jargon/alexa-skill-sdk - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

CHANGELOG.md

@@ -0,1 +1,3 @@

### 1.0.3
* Add ResourceManager.selectedVariation\[s\]()
### 1.0.2

@@ -2,0 +4,0 @@ * Add ResourceManager.renderBatch()

5

dist/resourceManager/i18next.d.ts
import * as i18n from 'i18next';
import { RenderItem, ResourceManager, ResourceManagerFactory, ResourceManagerOptions, RenderOptions } from '.';
import { RenderItem, ResourceManager, ResourceManagerFactory, ResourceManagerOptions, RenderOptions, SelectedVariation } from '.';
export declare class I18NextResourceManager implements ResourceManager {

@@ -8,2 +8,3 @@ protected _translator: i18n.i18n;

protected readonly _rv: number;
protected _selectedVariants: SelectedVariation[];
constructor(_translator: i18n.i18n, locale: string, _opts: Required<ResourceManagerOptions>);

@@ -13,2 +14,4 @@ render(item: RenderItem): Promise<string>;

renderObject<T>(item: RenderItem): Promise<T>;
selectedVariation(item: RenderItem): Promise<SelectedVariation>;
selectedVariations(): Promise<SelectedVariation[]>;
protected selectKey(keys: string[], opts?: RenderOptions): string;

@@ -15,0 +18,0 @@ }

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

this._rv = Math.random();
this._selectedVariants = [];
}

@@ -46,5 +47,14 @@ I18NextResourceManager.prototype.render = function (item) {

var v = s[key];
var fk = item.key + "." + key;
if (typeof v !== 'string') {
return Promise.reject(new Error("Unexpected type " + typeof v + " for item key " + item.key + "." + key));
return Promise.reject(new Error("Unexpected type " + typeof v + " for item key " + fk));
}
if (this._opts.trackSelectedVariations) {
var sv = {
item: item,
key: fk,
variationKey: v
};
this._selectedVariants.push(sv);
}
return Promise.resolve(v);

@@ -80,2 +90,12 @@ }

};
I18NextResourceManager.prototype.selectedVariation = function (item) {
var v = this._selectedVariants.filter(function (i) { return i.item === item; });
if (v.length === 0) {
return Promise.reject(new Error('Item was not used for any render calls that selected a variation'));
}
return Promise.resolve(v[0]);
};
I18NextResourceManager.prototype.selectedVariations = function () {
return Promise.resolve(this._selectedVariants);
};
I18NextResourceManager.prototype.selectKey = function (keys, opts) {

@@ -82,0 +102,0 @@ var rv = this._rv;

export interface ResourceManagerOptions {
/** When true (default), the response builder will use the same random value
/** When true (default), the resource manager will use the same random value
* when randomly selecting among variations; this ensures that calls to different routines

@@ -14,2 +14,6 @@ * (speak, reprompt, etc.) with identical RenderItem inputs will render the same output.

localesToPreload?: string[];
/** When true (default), the resource manager will keep track of which variation it selected,
* allowing clients to view those selections through a call to selectedVariation(s)
*/
trackSelectedVariations?: boolean;
}

@@ -48,2 +52,18 @@ export declare const DefaultResourceManagerOptions: Required<ResourceManagerOptions>;

renderObject<T>(item: RenderItem): Promise<T>;
/** Retrieves information about the selected variant for a rendered item. This
* will only return a result when rendering the item required a variation
* selection. If item has been used for multiple calls to a render routine
* the result of the first operation will be returned; use selectedVariations
* to see all results.
* @param {RenderItem} item The item to retrieve the selected variant for
* @return {Promise<SelectedVariation>} A promise to the selected variation
*/
selectedVariation(item: RenderItem): Promise<SelectedVariation>;
/** Retrieves information about all selected variations for rendered item. This
* will only return a result for items that required a variation selection
* during rendering. Results are ordered by the ordering of the calls to render
* routines.
* @return {Promise<SelectedVariation[]>} A promise to the selected variations
*/
selectedVariations(): Promise<SelectedVariation[]>;
/** The locale the resource manager uses */

@@ -88,2 +108,10 @@ readonly locale: string;

export declare function ri(key: string, params?: RenderParams, options?: RenderOptions): RenderItem;
export interface SelectedVariation {
/** The RenderItem instance passed to render(Batch) */
readonly item: RenderItem;
/** The full key of the selected variation (i.e., this.ri.key + '.' + this.variationKey) */
readonly key: string;
/** The selected variation subkey */
readonly variationKey: string;
}
export * from './i18next';

@@ -20,3 +20,4 @@ "use strict";

consistentRandom: true,
localesToPreload: []
localesToPreload: [],
trackSelectedVariations: true
};

@@ -23,0 +24,0 @@ exports.DefaultRenderOptions = {

{
"name": "@jargon/alexa-skill-sdk",
"version": "1.0.2",
"version": "1.0.3",
"description": "The Jargon Alexa Skill SDK makes it easy to manage the content of your custom Alexa skill",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -85,2 +85,4 @@ # Jargon SDK for Amazon Alexa (nodejs)

You can determine which variation the SDK chose via the ResourceManager's selectedVariation(s) routines.
## Runtime interface

@@ -126,2 +128,4 @@

* response directives that internally have locale-specific content (such as an upsell directive)
* batch rendering of multiple resources
* determining which variation the ResourceManager chose

@@ -149,2 +153,20 @@ ```typescript

/** Retrieves information about the selected variant for a rendered item. This
* will only return a result when rendering the item required a variation
* selection. If item has been used for multiple calls to a render routine
* the result of the first operation will be returned; use selectedVariations
* to see all results.
* @param {RenderItem} item The item to retrieve the selected variant for
* @return {Promise<SelectedVariation>} A promise to the selected variation
*/
selectedVariation (item: RenderItem): Promise<SelectedVariation>
/** Retrieves information about all selected variations for rendered item. This
* will only return a result for items that required a variation selection
* during rendering. Results are ordered by the ordering of the calls to render
* routines.
* @return {Promise<SelectedVariation[]>} A promise to the selected variations
*/
selectedVariations (): Promise<SelectedVariation[]>
/** The locale the resource manager uses */

@@ -151,0 +173,0 @@ readonly locale: string

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