@xapp/stentor-templates 0.78.1-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.3.0](https://github.com/XappMedia/stentor-core/compare/v1.0.0-beta.17...v1.3.0) (2019-07-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Adds back Alexa Application ID fix ([#1164](https://github.com/XappMedia/stentor-core/issues/1164)) ([f89c8d6](https://github.com/XappMedia/stentor-core/commit/f89c8d6))
12
+ * Array Slot Values ([#1137](https://github.com/XappMedia/stentor-core/issues/1137)) ([350bd7d](https://github.com/XappMedia/stentor-core/commit/350bd7d))
13
+ * Fix for Walmart Stories & Social Radio ([#1168](https://github.com/XappMedia/stentor-core/issues/1168)) ([a8aea07](https://github.com/XappMedia/stentor-core/commit/a8aea07))
14
+ * Removing aws-sdk as dependency for client ([#1154](https://github.com/XappMedia/stentor-core/issues/1154)) ([0f8d938](https://github.com/XappMedia/stentor-core/commit/0f8d938))
15
+ * Request.rawQuery on Dialogflow V2 ([#1134](https://github.com/XappMedia/stentor-core/issues/1134)) ([2a76c72](https://github.com/XappMedia/stentor-core/commit/2a76c72))
16
+ * Splits out AnalyticsService from stentor-service ([#1132](https://github.com/XappMedia/stentor-core/issues/1132)) ([11ef151](https://github.com/XappMedia/stentor-core/commit/11ef151))
17
+ * Staging fixes ([#1166](https://github.com/XappMedia/stentor-core/issues/1166)) ([e3aeebb](https://github.com/XappMedia/stentor-core/commit/e3aeebb))
18
+
19
+
20
+ ### Features
21
+
22
+ * Assistant analytics events ([#1159](https://github.com/XappMedia/stentor-core/issues/1159)) ([ed9a55f](https://github.com/XappMedia/stentor-core/commit/ed9a55f))
23
+ * Pii service to assistant ([#1148](https://github.com/XappMedia/stentor-core/issues/1148)) ([08a22fe](https://github.com/XappMedia/stentor-core/commit/08a22fe))
24
+ * preExecution Hook & Alexa Verify on Alexa Channel ([#1128](https://github.com/XappMedia/stentor-core/issues/1128)) ([d07396c](https://github.com/XappMedia/stentor-core/commit/d07396c))
25
+
26
+
27
+
28
+
29
+
30
+ # [1.2.0](https://github.com/XappMedia/stentor-core/compare/v1.0.0-beta.17...v1.2.0) (2019-07-25)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * Adds back Alexa Application ID fix ([#1164](https://github.com/XappMedia/stentor-core/issues/1164)) ([f89c8d6](https://github.com/XappMedia/stentor-core/commit/f89c8d6))
36
+ * Array Slot Values ([#1137](https://github.com/XappMedia/stentor-core/issues/1137)) ([350bd7d](https://github.com/XappMedia/stentor-core/commit/350bd7d))
37
+ * Fix for Walmart Stories & Social Radio ([#1168](https://github.com/XappMedia/stentor-core/issues/1168)) ([a8aea07](https://github.com/XappMedia/stentor-core/commit/a8aea07))
38
+ * Removing aws-sdk as dependency for client ([#1154](https://github.com/XappMedia/stentor-core/issues/1154)) ([0f8d938](https://github.com/XappMedia/stentor-core/commit/0f8d938))
39
+ * Request.rawQuery on Dialogflow V2 ([#1134](https://github.com/XappMedia/stentor-core/issues/1134)) ([2a76c72](https://github.com/XappMedia/stentor-core/commit/2a76c72))
40
+ * Splits out AnalyticsService from stentor-service ([#1132](https://github.com/XappMedia/stentor-core/issues/1132)) ([11ef151](https://github.com/XappMedia/stentor-core/commit/11ef151))
41
+ * Staging fixes ([#1166](https://github.com/XappMedia/stentor-core/issues/1166)) ([e3aeebb](https://github.com/XappMedia/stentor-core/commit/e3aeebb))
42
+
43
+
44
+ ### Features
45
+
46
+ * Assistant analytics events ([#1159](https://github.com/XappMedia/stentor-core/issues/1159)) ([ed9a55f](https://github.com/XappMedia/stentor-core/commit/ed9a55f))
47
+ * Pii service to assistant ([#1148](https://github.com/XappMedia/stentor-core/issues/1148)) ([08a22fe](https://github.com/XappMedia/stentor-core/commit/08a22fe))
48
+ * preExecution Hook & Alexa Verify on Alexa Channel ([#1128](https://github.com/XappMedia/stentor-core/issues/1128)) ([d07396c](https://github.com/XappMedia/stentor-core/commit/d07396c))
49
+
50
+
51
+
52
+
53
+
54
+ # [1.1.0](https://github.com/XappMedia/stentor-core/compare/v1.0.0-beta.17...v1.1.0) (2019-07-25)
55
+
56
+
57
+ ### Bug Fixes
58
+
59
+ * Adds back Alexa Application ID fix ([#1164](https://github.com/XappMedia/stentor-core/issues/1164)) ([f89c8d6](https://github.com/XappMedia/stentor-core/commit/f89c8d6))
60
+ * Array Slot Values ([#1137](https://github.com/XappMedia/stentor-core/issues/1137)) ([350bd7d](https://github.com/XappMedia/stentor-core/commit/350bd7d))
61
+ * Fix for Walmart Stories & Social Radio ([#1168](https://github.com/XappMedia/stentor-core/issues/1168)) ([a8aea07](https://github.com/XappMedia/stentor-core/commit/a8aea07))
62
+ * Removing aws-sdk as dependency for client ([#1154](https://github.com/XappMedia/stentor-core/issues/1154)) ([0f8d938](https://github.com/XappMedia/stentor-core/commit/0f8d938))
63
+ * Request.rawQuery on Dialogflow V2 ([#1134](https://github.com/XappMedia/stentor-core/issues/1134)) ([2a76c72](https://github.com/XappMedia/stentor-core/commit/2a76c72))
64
+ * Splits out AnalyticsService from stentor-service ([#1132](https://github.com/XappMedia/stentor-core/issues/1132)) ([11ef151](https://github.com/XappMedia/stentor-core/commit/11ef151))
65
+ * Staging fixes ([#1166](https://github.com/XappMedia/stentor-core/issues/1166)) ([e3aeebb](https://github.com/XappMedia/stentor-core/commit/e3aeebb))
66
+
67
+
68
+ ### Features
69
+
70
+ * Assistant analytics events ([#1159](https://github.com/XappMedia/stentor-core/issues/1159)) ([ed9a55f](https://github.com/XappMedia/stentor-core/commit/ed9a55f))
71
+ * Pii service to assistant ([#1148](https://github.com/XappMedia/stentor-core/issues/1148)) ([08a22fe](https://github.com/XappMedia/stentor-core/commit/08a22fe))
72
+ * preExecution Hook & Alexa Verify on Alexa Channel ([#1128](https://github.com/XappMedia/stentor-core/issues/1128)) ([d07396c](https://github.com/XappMedia/stentor-core/commit/d07396c))
73
+
74
+
75
+
76
+
77
+
78
+ # [1.0.0](https://github.com/XappMedia/stentor-core/compare/v1.0.0-beta.17...v1.0.0) (2019-07-25)
79
+
80
+
81
+ ### Bug Fixes
82
+
83
+ * Adds back Alexa Application ID fix ([#1164](https://github.com/XappMedia/stentor-core/issues/1164)) ([f89c8d6](https://github.com/XappMedia/stentor-core/commit/f89c8d6))
84
+ * Array Slot Values ([#1137](https://github.com/XappMedia/stentor-core/issues/1137)) ([350bd7d](https://github.com/XappMedia/stentor-core/commit/350bd7d))
85
+ * Fix for Walmart Stories & Social Radio ([#1168](https://github.com/XappMedia/stentor-core/issues/1168)) ([a8aea07](https://github.com/XappMedia/stentor-core/commit/a8aea07))
86
+ * Removing aws-sdk as dependency for client ([#1154](https://github.com/XappMedia/stentor-core/issues/1154)) ([0f8d938](https://github.com/XappMedia/stentor-core/commit/0f8d938))
87
+ * Request.rawQuery on Dialogflow V2 ([#1134](https://github.com/XappMedia/stentor-core/issues/1134)) ([2a76c72](https://github.com/XappMedia/stentor-core/commit/2a76c72))
88
+ * Splits out AnalyticsService from stentor-service ([#1132](https://github.com/XappMedia/stentor-core/issues/1132)) ([11ef151](https://github.com/XappMedia/stentor-core/commit/11ef151))
89
+ * Staging fixes ([#1166](https://github.com/XappMedia/stentor-core/issues/1166)) ([e3aeebb](https://github.com/XappMedia/stentor-core/commit/e3aeebb))
90
+
91
+
92
+ ### Features
93
+
94
+ * Assistant analytics events ([#1159](https://github.com/XappMedia/stentor-core/issues/1159)) ([ed9a55f](https://github.com/XappMedia/stentor-core/commit/ed9a55f))
95
+ * Pii service to assistant ([#1148](https://github.com/XappMedia/stentor-core/issues/1148)) ([08a22fe](https://github.com/XappMedia/stentor-core/commit/08a22fe))
96
+ * preExecution Hook & Alexa Verify on Alexa Channel ([#1128](https://github.com/XappMedia/stentor-core/issues/1128)) ([d07396c](https://github.com/XappMedia/stentor-core/commit/d07396c))
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Copy this to create a new package under `/packages`
@@ -0,0 +1,5 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { CustomType, Template } from "@xapp/stentor-models";
3
+ export declare const CUSTOM_TYPE: CustomType;
4
+ export declare const GLOBAL_KEYWORDS: string[];
5
+ export declare const TEMPLATE_DEFAULTS: Template;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CUSTOM_TYPE = "CUSTOM";
4
+ exports.GLOBAL_KEYWORDS = ["XAPP", "XAPPmedia"];
5
+ exports.TEMPLATE_DEFAULTS = {
6
+ templateType: exports.CUSTOM_TYPE,
7
+ keywords: exports.GLOBAL_KEYWORDS.slice()
8
+ };
9
+ //# sourceMappingURL=Constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;AAGa,QAAA,WAAW,GAAe,QAAQ,CAAC;AAEnC,QAAA,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAExC,QAAA,iBAAiB,GAAa;IACvC,YAAY,EAAE,mBAAW;IACzB,QAAQ,EAAE,uBAAe,CAAC,KAAK,EAAE;CACpC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { App, Handler, Intent, Template } from "@xapp/stentor-models";
2
+ /**
3
+ * Abstract TemplateFactory for generating Templates of a certain type.
4
+ */
5
+ export declare abstract class TemplateFactory<T extends Template> {
6
+ /**
7
+ * Generate a template from provided existing App and Intents/Handler.
8
+ *
9
+ * This method is used to seed a Template model for display, typically used in a React
10
+ * component constructor or in the React component method #componentWillReceiveProps()
11
+ *
12
+ * Note to implementer: This method should only be concerned with setting the parameters
13
+ * on the template it generates.
14
+ *
15
+ * @abstract
16
+ * @param {App} app
17
+ * @param {((Handler | Intent)[])} handlers
18
+ * @returns {(T | undefined)}
19
+ * @memberof TemplateFactory
20
+ */
21
+ abstract generateTemplate(app: App, handlers: (Handler | Intent)[]): T | undefined;
22
+ /**
23
+ * Overrides template properties with those from the provided app
24
+ *
25
+ * @protected
26
+ * @param {T} template
27
+ * @param {App} [app]
28
+ * @returns {T}
29
+ * @memberof TemplateFactory
30
+ */
31
+ protected overrideWithAppProps(template: T, app?: App): T;
32
+ /**
33
+ * Generate an App from the provided template with optional App is used to fill in
34
+ * already existing information that did not exist on the template.
35
+ *
36
+ * @abstract
37
+ * @param {T} template
38
+ * @param {App} [app]
39
+ * @returns {App}
40
+ * @memberof TemplateFactory
41
+ */
42
+ generateApp(template: T, app?: App): App;
43
+ /**
44
+ * Template specific cleaner to remove the template properties making it
45
+ * just a partial App.
46
+ *
47
+ * @protected
48
+ * @abstract
49
+ * @returns {Partial<App>}
50
+ * @memberof TemplateFactory
51
+ */
52
+ protected abstract removeTemplateProperties(template: T): Partial<App>;
53
+ /**
54
+ * Generate an array of Intents & Handlers from the provided template and optional existing handlers
55
+ * that are merged with the new handlers. Additionally, if other Intents or Handler are in the optional
56
+ * array, they are passed through to the new array.
57
+ *
58
+ * @abstract
59
+ * @param {T} template
60
+ * @param {((Handler | Intent)[])} handlers
61
+ * @returns {((Handler | Intent)[])}
62
+ * @memberof TemplateFactory
63
+ */
64
+ abstract generateHandlers(template: T, handlers: (Handler | Intent)[]): (Handler | Intent)[];
65
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_app_1 = require("@xapp/stentor-app");
5
+ const stentor_constants_1 = require("@xapp/stentor-constants");
6
+ /**
7
+ * Abstract TemplateFactory for generating Templates of a certain type.
8
+ */
9
+ class TemplateFactory {
10
+ /**
11
+ * Overrides template properties with those from the provided app
12
+ *
13
+ * @protected
14
+ * @param {T} template
15
+ * @param {App} [app]
16
+ * @returns {T}
17
+ * @memberof TemplateFactory
18
+ */
19
+ overrideWithAppProps(template, app) {
20
+ // Check to see if we have a donor App to build from
21
+ if (app) {
22
+ // Set the required keywords if they don't exist
23
+ template.keywords = [...new Set((app.keywords || []).concat(template.keywords))];
24
+ // if we do we need to set some parameters from it
25
+ if (app.testingInstructions) {
26
+ // See if we can pull the URL out of the testing instructions
27
+ const matches = app.testingInstructions.match(stentor_constants_1.URL_REGEX) || [];
28
+ // Only take the first one
29
+ template.collaborationAgreementUrl = matches[0];
30
+ }
31
+ // Also, set the location information
32
+ if (app.location) {
33
+ if (app.location.streetAddress && app.location.streetAddress.length > 0) {
34
+ template.location.streetAddress = app.location.streetAddress;
35
+ }
36
+ if (app.location.geocode && typeof app.location.geocode.latitude === "number") {
37
+ template.location.geocode.latitude = app.location.geocode.latitude;
38
+ }
39
+ if (app.location.geocode && typeof app.location.geocode.longitude === "number") {
40
+ template.location.geocode.longitude = app.location.geocode.longitude;
41
+ }
42
+ }
43
+ // Get the icons
44
+ template.smallIcon = app.smallIcon || stentor_app_1.generateSmallIconUrl(app.icon);
45
+ template.largeIcon = app.largeIcon || stentor_app_1.generateLargeIconUrl(app.icon);
46
+ template.endPoint = app.endPoint || stentor_app_1.generateEndpointMap(app);
47
+ // Set the platformData
48
+ if (app.platformData && app.platformData.alexa && app.platformData.alexa.privacyAndCompliance) {
49
+ template.platformData.alexa.privacyAndCompliance = app.platformData.alexa.privacyAndCompliance;
50
+ }
51
+ }
52
+ return template;
53
+ }
54
+ /**
55
+ * Generate an App from the provided template with optional App is used to fill in
56
+ * already existing information that did not exist on the template.
57
+ *
58
+ * @abstract
59
+ * @param {T} template
60
+ * @param {App} [app]
61
+ * @returns {App}
62
+ * @memberof TemplateFactory
63
+ */
64
+ generateApp(template, app) {
65
+ // Clean up un-App items off the template before merging
66
+ const copy = Object.assign({}, template);
67
+ const cleanedTemplate = this.removeTemplateProperties(copy);
68
+ // Merge the existing properties of the template
69
+ const newApp = Object.assign({}, app, cleanedTemplate);
70
+ // Set the street address if it exists.
71
+ if (template.location && template.location.streetAddress) {
72
+ newApp.location = Object.assign({}, newApp.location, { streetAddress: template.location.streetAddress });
73
+ }
74
+ // Testing instructions contains the collab agreement
75
+ // The testing instructions, it is a template
76
+ newApp.testingInstructions =
77
+ `We have collaborated with the owner of this content to create and publish this skill.\n\n` +
78
+ `The signed IP rights for the app can be downloaded at: https://go.xappmedia.com/${newApp.organizationId}/iprights \n\n` +
79
+ `You will be prompted to login in first. The username is "alexa.cert@xappmedia.com" and the password is "S&9jDq@9".\n\n` +
80
+ `After successful login, the pdf should automatically download. If it does not download, then refresh https://go.xappmedia.com/${newApp.organizationId}/iprights or ` +
81
+ `click the link on the page to try again.`;
82
+ // Get the invocationName
83
+ let invocationName;
84
+ if (Array.isArray(template.invocationName)) {
85
+ invocationName = template.invocationName[0];
86
+ }
87
+ else {
88
+ invocationName = template.invocationName;
89
+ }
90
+ // If it exists at this point, lowercase it and set it, otherwise leave it undefined.
91
+ newApp.invocationName = invocationName ? invocationName.toLowerCase() : undefined;
92
+ // Description and example phrases include the invocation name, don't generate them unless
93
+ // we have one.
94
+ if (newApp.invocationName) {
95
+ // For the description, we use the summary but at one line
96
+ // Make sure the summary ends in a period!
97
+ newApp.description =
98
+ template.summary +
99
+ `\n\nOnce you've enabled the skill, you can say "Alexa, open ${newApp.invocationName}“ to start listening.`;
100
+ // The example phrase are straight forward
101
+ newApp.examplePhrases = [`Alexa, open ${newApp.invocationName}`, `Alexa, pause`, `Alexa, resume`];
102
+ }
103
+ // Icons!
104
+ newApp.icon = template.icon;
105
+ newApp.smallIcon = stentor_app_1.generateSmallIconUrl(newApp.icon);
106
+ newApp.largeIcon = stentor_app_1.generateLargeIconUrl(newApp.icon);
107
+ // And make sure the endpoint is up to date
108
+ newApp.endPoint = newApp.endPoint || stentor_app_1.generateEndpointMap(newApp);
109
+ // Be free new App!
110
+ return newApp;
111
+ }
112
+ }
113
+ exports.TemplateFactory = TemplateFactory;
114
+ //# sourceMappingURL=TemplateFactory.js.map
@@ -0,0 +1 @@
1
+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QACnB,OAAO,MAAM,CAAC;IAClB,CAAC;CAyBJ;AAtKD,0CAsKC"}
package/lib/Types.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { OnDemandTemplateType, RadioTemplateType } from "@xapp/stentor-models";
3
+ import { ON_DEMAND_TEMPLATE } from "./onDemand";
4
+ import { RADIO_TEMPLATE } from "./radio";
5
+ export { RADIO_TEMPLATE, ON_DEMAND_TEMPLATE, OnDemandTemplateType, RadioTemplateType };
package/lib/Types.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const onDemand_1 = require("./onDemand");
4
+ exports.ON_DEMAND_TEMPLATE = onDemand_1.ON_DEMAND_TEMPLATE;
5
+ const radio_1 = require("./radio");
6
+ exports.RADIO_TEMPLATE = radio_1.RADIO_TEMPLATE;
7
+ //# sourceMappingURL=Types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../src/Types.ts"],"names":[],"mappings":";;AAEA,yCAAgD;AAGvB,6BAHhB,6BAAkB,CAGgB;AAF3C,mCAAyC;AAEhC,yBAFA,sBAAc,CAEA"}
@@ -0,0 +1,13 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { OnDemandTemplateType } from "@xapp/stentor-models";
3
+ import { OnDemandTemplate } from "./OnDemandTemplate";
4
+ export declare const ON_DEMAND_TEMPLATE: OnDemandTemplateType;
5
+ export declare const ON_DEMAND_CONTENT_TYPE_STAND_ALONE = "STAND_ALONE";
6
+ export declare const ON_DEMAND_CONTENT_TYPE_REPLACED = "REPLACED";
7
+ export declare const ON_DEMAND_TEMPLATE_HELP_RESPONSE: {
8
+ outputSpeech: string;
9
+ reprompt: string;
10
+ }[];
11
+ export declare const ON_DEMAND_DIALOGFLOW_DEFAULT_AGENT_TOKEN = "9c34733274c743b18d9860995d22a1ba";
12
+ export declare const ON_DEMAND_TEMPLATE_REQUIRED: (keyof OnDemandTemplate)[];
13
+ export declare const ON_DEMAND_TEMPLATE_KEYWORDS: string[];
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Constants_1 = require("../Constants");
4
+ exports.ON_DEMAND_TEMPLATE = "PODCAST_TEMPLATE";
5
+ exports.ON_DEMAND_CONTENT_TYPE_STAND_ALONE = "STAND_ALONE";
6
+ exports.ON_DEMAND_CONTENT_TYPE_REPLACED = "REPLACED";
7
+ exports.ON_DEMAND_TEMPLATE_HELP_RESPONSE = [
8
+ {
9
+ outputSpeech: "<speak>During playback, you can either pause or resume.</speak>",
10
+ reprompt: "<speak>During playback, you can either pause or resume.</speak>"
11
+ }
12
+ ];
13
+ exports.ON_DEMAND_DIALOGFLOW_DEFAULT_AGENT_TOKEN = "9c34733274c743b18d9860995d22a1ba";
14
+ exports.ON_DEMAND_TEMPLATE_REQUIRED = [
15
+ "rssFeedUrl",
16
+ "name",
17
+ "invocationName",
18
+ "contentType",
19
+ "summary",
20
+ "icon"
21
+ ];
22
+ exports.ON_DEMAND_TEMPLATE_KEYWORDS = Constants_1.GLOBAL_KEYWORDS.concat(["PODCAST", "ON DEMAND", "RSS FEED"]);
23
+ //# sourceMappingURL=Constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/onDemand/Constants.ts"],"names":[],"mappings":";;AAEA,4CAA+C;AAGlC,QAAA,kBAAkB,GAAyB,kBAAkB,CAAC;AAE9D,QAAA,kCAAkC,GAAG,aAAa,CAAC;AAEnD,QAAA,+BAA+B,GAAG,UAAU,CAAC;AAE7C,QAAA,gCAAgC,GAAG;IAC5C;QACI,YAAY,EAAE,iEAAiE;QAC/E,QAAQ,EAAE,iEAAiE;KAC9E;CACJ,CAAC;AAEW,QAAA,wCAAwC,GAAG,kCAAkC,CAAC;AAE9E,QAAA,2BAA2B,GAA+B;IACnE,YAAY;IACZ,MAAM;IACN,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,MAAM;CACT,CAAC;AAEW,QAAA,2BAA2B,GAAG,2BAAe,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { Response, Template } from "@xapp/stentor-models";
3
+ export declare type OnDemandContentTypeStandAlone = "STAND_ALONE";
4
+ /**
5
+ * Content where as soon as a new one is
6
+ * available, the old one is no longer relevant.
7
+ *
8
+ * It will always play the latest and "next"
9
+ * takes you to older episodes.
10
+ *
11
+ */
12
+ export declare type OnDemandContentTypeReplaced = "REPLACED";
13
+ export declare type OnDemandContentType = OnDemandContentTypeStandAlone | OnDemandContentTypeReplaced;
14
+ export interface OnDemandTemplate extends Template {
15
+ /**
16
+ * Describes the type of content in the RSS feed.
17
+ *
18
+ * @type {OnDemandContentType}
19
+ * @memberof OnDemandTemplate
20
+ */
21
+ contentType?: OnDemandContentType;
22
+ /**
23
+ * The URL for the RSS feed.
24
+ *
25
+ * @type {string}
26
+ * @memberof PodcastTemplate
27
+ */
28
+ rssFeedUrl?: string;
29
+ /**
30
+ * Custom intros
31
+ *
32
+ * @type {Response[]}
33
+ * @memberof PodcastTemplate
34
+ */
35
+ customIntros?: Response[];
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=OnDemandTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnDemandTemplate.js","sourceRoot":"","sources":["../../src/onDemand/OnDemandTemplate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { App, Handler, Intent } from "@xapp/stentor-models";
2
+ import { TemplateFactory } from "../TemplateFactory";
3
+ import { OnDemandTemplate } from "./OnDemandTemplate";
4
+ export declare class OnDemandTemplateFactory extends TemplateFactory<OnDemandTemplate> {
5
+ generateTemplate(app: App, handlers?: (Handler | Intent)[]): OnDemandTemplate | undefined;
6
+ removeTemplateProperties(template: OnDemandTemplate): Partial<App>;
7
+ generateHandlers(template: OnDemandTemplate, handlers?: (Handler | Intent)[]): (Handler | Intent)[];
8
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_alexa_1 = require("@xapp/stentor-alexa");
5
+ const stentor_handler_media_1 = require("@xapp/stentor-handler-media");
6
+ const stentor_interaction_model_1 = require("@xapp/stentor-interaction-model");
7
+ const Constants_1 = require("../Constants");
8
+ const TemplateFactory_1 = require("../TemplateFactory");
9
+ const Constants_2 = require("./Constants");
10
+ class OnDemandTemplateFactory extends TemplateFactory_1.TemplateFactory {
11
+ generateTemplate(app, handlers = []) {
12
+ let template = Object.assign({}, Constants_1.TEMPLATE_DEFAULTS, app, { templateType: Constants_2.ON_DEMAND_TEMPLATE, customIntros: [], alexaCategory: stentor_alexa_1.PODCAST,
13
+ // on google we use the same Dialogflow client
14
+ dialogflowClientToken: Constants_2.ON_DEMAND_DIALOGFLOW_DEFAULT_AGENT_TOKEN, keywords: Constants_2.ON_DEMAND_TEMPLATE_KEYWORDS.slice() });
15
+ template = super.overrideWithAppProps(template, app);
16
+ if (handlers) {
17
+ // Try to find the handler and take the data!
18
+ handlers.forEach(handler => {
19
+ if (stentor_handler_media_1.isPlayPodcastHandlerProps(handler)) {
20
+ const data = handler.data;
21
+ if (data) {
22
+ if (data.url) {
23
+ template.rssFeedUrl = handler.data.url;
24
+ }
25
+ if (data.alwaysPlayLatest) {
26
+ template.contentType = Constants_2.ON_DEMAND_CONTENT_TYPE_REPLACED;
27
+ }
28
+ if (data.offerToPlayLatest) {
29
+ template.contentType = Constants_2.ON_DEMAND_CONTENT_TYPE_STAND_ALONE;
30
+ }
31
+ }
32
+ template.customIntros = handler.content ? handler.content[handler.intentId] : [];
33
+ }
34
+ });
35
+ }
36
+ return template;
37
+ }
38
+ removeTemplateProperties(template) {
39
+ delete template.contentType;
40
+ delete template.rssFeedUrl;
41
+ delete template.customIntros;
42
+ delete template.collaborationAgreementUrl;
43
+ return template;
44
+ }
45
+ generateHandlers(template, handlers) {
46
+ handlers = handlers ? handlers.slice() : [];
47
+ // We want to pull out the podcast handler if they have it
48
+ // and delete the existing launch request
49
+ let existingPlayPodcastHandlerProps;
50
+ let existingPlayPodcastData;
51
+ let oldLaunchRequestIndex = -1;
52
+ let oldHelpIntentIndex = -1;
53
+ handlers.forEach((handler, index) => {
54
+ if (stentor_handler_media_1.isPlayPodcastHandlerProps(handler)) {
55
+ existingPlayPodcastHandlerProps = Object.assign({}, handler);
56
+ existingPlayPodcastData = Object.assign({}, existingPlayPodcastHandlerProps.data);
57
+ }
58
+ if (handler.intentId === "LaunchRequest") {
59
+ oldLaunchRequestIndex = index;
60
+ }
61
+ if (handler.intentId === stentor_interaction_model_1.HELP_INTENT) {
62
+ oldHelpIntentIndex = index;
63
+ }
64
+ });
65
+ // remove the old launch request if existed
66
+ if (oldLaunchRequestIndex > -1) {
67
+ handlers.splice(oldLaunchRequestIndex, 1);
68
+ }
69
+ // and the old help
70
+ if (oldHelpIntentIndex > -1) {
71
+ handlers.splice(oldHelpIntentIndex, 1);
72
+ }
73
+ // We need to also check nextIsOlder on the existing props
74
+ // if they exist.
75
+ let nextIsOlder = template.contentType === Constants_2.ON_DEMAND_CONTENT_TYPE_REPLACED;
76
+ if (existingPlayPodcastData && existingPlayPodcastData.nextIsOlder !== undefined) {
77
+ // and use the existing one instead of just
78
+ // setting it to whatever replacedContent is
79
+ nextIsOlder = existingPlayPodcastData.nextIsOlder;
80
+ }
81
+ const url = template.rssFeedUrl ? template.rssFeedUrl.trim() : "";
82
+ const newLaunchRequestHandler = Object.assign({}, existingPlayPodcastHandlerProps, {
83
+ // overwrite with what needs to be standard
84
+ organizationId: template.organizationId, appId: template.appId, intentId: "LaunchRequest", name: "Play Podcast", type: stentor_handler_media_1.PLAY_PODCAST_HANDLER_TYPE, data: {
85
+ url,
86
+ alwaysPlayLatest: template.contentType === Constants_2.ON_DEMAND_CONTENT_TYPE_REPLACED,
87
+ nextIsOlder,
88
+ offerToPlayLatest: template.contentType === Constants_2.ON_DEMAND_CONTENT_TYPE_STAND_ALONE
89
+ }, content: {
90
+ ["LaunchRequest"]: template.customIntros,
91
+ [`${stentor_interaction_model_1.HELP_INTENT}|${stentor_interaction_model_1.INPUT_UNKNOWN}`]: Constants_2.ON_DEMAND_TEMPLATE_HELP_RESPONSE,
92
+ [stentor_interaction_model_1.CANCEL_INTENT]: [
93
+ {
94
+ outputSpeech: "<speak>Goodbye</speak>"
95
+ }
96
+ ]
97
+ } });
98
+ handlers = handlers.concat([newLaunchRequestHandler]);
99
+ return handlers;
100
+ }
101
+ }
102
+ exports.OnDemandTemplateFactory = OnDemandTemplateFactory;
103
+ //# sourceMappingURL=OnDemandTemplateFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnDemandTemplateFactory.js","sourceRoot":"","sources":["../../src/onDemand/OnDemandTemplateFactory.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAA8C;AAC9C,uEAKqC;AACrC,+EAA4F;AAE5F,4CAAiD;AACjD,wDAAqD;AACrD,2CAOqB;AAGrB,MAAa,uBAAwB,SAAQ,iCAAiC;IAC1E,gBAAgB,CAAC,GAAQ,EAAE,WAAiC,EAAE;QAC1D,IAAI,QAAQ,qBACL,6BAAiB,EACjB,GAAG,IACN,YAAY,EAAE,8BAAkB,EAChC,YAAY,EAAE,EAAE,EAChB,aAAa,EAAE,uBAAO;YACtB,8CAA8C;YAC9C,qBAAqB,EAAE,oDAAwC,EAC/D,QAAQ,EAAE,uCAA2B,CAAC,KAAK,EAAE,GAChD,CAAC;QAEF,QAAQ,GAAG,KAAK,CAAC,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAErD,IAAI,QAAQ,EAAE;YACV,6CAA6C;YAC7C,Q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EAAE,iDAAyB,EAC/B,IAAI,EAAE;gBACF,GAAG;gBACH,gBAAgB,EAAE,QAAQ,CAAC,WAAW,KAAK,2CAA+B;gBAC1E,WAAW;gBACX,iBAAiB,EAAE,QAAQ,CAAC,WAAW,KAAK,8CAAkC;aACjF,EACD,OAAO,EAAE;gBACL,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,YAAY;gBACxC,CAAC,GAAG,uCAAW,IAAI,yCAAa,EAAE,CAAC,EAAE,4CAAgC;gBACrE,CAAC,yCAAa,CAAC,EAAE;oBACb;wBACI,YAAY,EAAE,wBAAwB;qBACzC;iBACJ;aACJ,GACJ,CAAC;QAEF,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAEtD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AA/HD,0DA+HC"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ export * from "./Constants";
3
+ export * from "./OnDemandTemplate";
4
+ export * from "./OnDemandTemplateFactory";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*! Copyright (c) 2019, XAPPmedia */
7
+ __export(require("./Constants"));
8
+ __export(require("./OnDemandTemplateFactory"));
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/onDemand/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,iCAA4B;AAE5B,+CAA0C"}
@@ -0,0 +1,10 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { RadioTemplateType } from "@xapp/stentor-models";
3
+ import { RadioTemplate } from "./RadioTemplate";
4
+ export declare const RADIO_TEMPLATE: RadioTemplateType;
5
+ export declare const RADIO_TEMPLATE_HELP_RESPONSE: {
6
+ outputSpeech: string;
7
+ reprompt: string;
8
+ }[];
9
+ export declare const RADIO_TEMPLATE_REQUIRED: (keyof RadioTemplate)[];
10
+ export declare const RADIO_TEMPLATE_KEYWORDS: string[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Constants_1 = require("../Constants");
4
+ exports.RADIO_TEMPLATE = "RADIO_TEMPLATE";
5
+ exports.RADIO_TEMPLATE_HELP_RESPONSE = [
6
+ {
7
+ outputSpeech: "<speak>During playback, you can either pause or resume</speak>",
8
+ reprompt: "<speak>During playback, you can either pause or resume</speak>"
9
+ }
10
+ ];
11
+ exports.RADIO_TEMPLATE_REQUIRED = [
12
+ "liveStreamUrl",
13
+ "name",
14
+ "invocationName",
15
+ "summary",
16
+ "icon"
17
+ ];
18
+ exports.RADIO_TEMPLATE_KEYWORDS = Constants_1.GLOBAL_KEYWORDS.concat(["VOICE RADIO", "RADIO"]);
19
+ //# sourceMappingURL=Constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/radio/Constants.ts"],"names":[],"mappings":";;AAEA,4CAA+C;AAGlC,QAAA,cAAc,GAAsB,gBAAgB,CAAC;AAErD,QAAA,4BAA4B,GAAG;IACxC;QACI,YAAY,EAAE,gEAAgE;QAC9E,QAAQ,EAAE,gEAAgE;KAC7E;CACJ,CAAC;AAEW,QAAA,uBAAuB,GAA4B;IAC5D,eAAe;IACf,MAAM;IACN,gBAAgB;IAChB,SAAS;IACT,MAAM;CACT,CAAC;AAEW,QAAA,uBAAuB,GAAG,2BAAe,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { Response, Template } from "@xapp/stentor-models";
3
+ /**
4
+ * A wonderful little template for radio stations.
5
+ *
6
+ * @export
7
+ * @interface RadioTemplate
8
+ * @extends {Template}
9
+ */
10
+ export interface RadioTemplate extends Template {
11
+ /**
12
+ * The HTTPS URL of the radio station's live stream
13
+ *
14
+ * @type {string}
15
+ * @memberof RadioTemplate
16
+ */
17
+ liveStreamUrl?: string;
18
+ /**
19
+ * The custom intros we play before the live stream starts
20
+ *
21
+ * @type {Response[]}
22
+ * @memberof RadioTemplate
23
+ */
24
+ customIntros?: Response[];
25
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=RadioTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioTemplate.js","sourceRoot":"","sources":["../../src/radio/RadioTemplate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { App, Handler, Intent } from "@xapp/stentor-models";
2
+ import { TemplateFactory } from "../TemplateFactory";
3
+ import { RadioTemplate } from "./RadioTemplate";
4
+ export declare class RadioTemplateFactory extends TemplateFactory<RadioTemplate> {
5
+ generateTemplate(app: App, handlers?: (Handler | Intent)[]): RadioTemplate | undefined;
6
+ removeTemplateProperties(template: RadioTemplate): Partial<App>;
7
+ generateHandlers(template: RadioTemplate, handlers?: (Handler | Intent)[]): (Handler | Intent)[];
8
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_alexa_1 = require("@xapp/stentor-alexa");
5
+ const stentor_constants_1 = require("@xapp/stentor-constants");
6
+ const stentor_handler_1 = require("@xapp/stentor-handler");
7
+ const stentor_handler_media_1 = require("@xapp/stentor-handler-media");
8
+ const stentor_interaction_model_1 = require("@xapp/stentor-interaction-model");
9
+ const stentor_request_1 = require("@xapp/stentor-request");
10
+ const Constants_1 = require("../Constants");
11
+ const TemplateFactory_1 = require("../TemplateFactory");
12
+ const Constants_2 = require("./Constants");
13
+ class RadioTemplateFactory extends TemplateFactory_1.TemplateFactory {
14
+ generateTemplate(app, handlers = []) {
15
+ let template = Object.assign({}, Constants_1.TEMPLATE_DEFAULTS, app, {
16
+ // Template type
17
+ templateType: Constants_2.RADIO_TEMPLATE,
18
+ // and template specific default values
19
+ liveStreamUrl: "", customIntros: [], alexaCategory: stentor_alexa_1.STREAMING_SERVICE, keywords: Constants_2.RADIO_TEMPLATE_KEYWORDS.slice() });
20
+ template = super.overrideWithAppProps(template, app);
21
+ if (handlers) {
22
+ // Try to find the handler and take the data!
23
+ handlers.forEach(handler => {
24
+ if (stentor_handler_1.isHandler(handler) && handler.type === stentor_handler_media_1.PLAY_LIVE_STREAM_HANDLER_TYPE) {
25
+ if (handler.data.url) {
26
+ template.liveStreamUrl = handler.data.url;
27
+ }
28
+ template.customIntros = handler.content ? handler.content[handler.intentId] : [];
29
+ }
30
+ });
31
+ }
32
+ return template;
33
+ }
34
+ removeTemplateProperties(template) {
35
+ // Clean template
36
+ delete template.liveStreamUrl;
37
+ delete template.customIntros;
38
+ delete template.collaborationAgreementUrl;
39
+ return template;
40
+ }
41
+ generateHandlers(template, handlers) {
42
+ handlers = handlers ? handlers.slice() : [];
43
+ // We want to pull out the live stream handler if they have it
44
+ // and delete the existing launch request
45
+ let playLiveStreamHandler;
46
+ let oldLaunchRequestIndex = -1;
47
+ let oldHelpIntentIndex = -1;
48
+ handlers.forEach((handler, index) => {
49
+ if (stentor_handler_1.isHandler(handler) && handler.type === stentor_handler_media_1.PLAY_LIVE_STREAM_HANDLER_TYPE) {
50
+ playLiveStreamHandler = Object.assign({}, handler);
51
+ }
52
+ if (handler.intentId === "LaunchRequest") {
53
+ oldLaunchRequestIndex = index;
54
+ }
55
+ if (handler.intentId === stentor_interaction_model_1.HELP_INTENT) {
56
+ oldHelpIntentIndex = index;
57
+ }
58
+ });
59
+ // remove the old launch request if existed
60
+ if (oldLaunchRequestIndex > -1) {
61
+ handlers.splice(oldLaunchRequestIndex, 1);
62
+ }
63
+ // and the old help
64
+ if (oldHelpIntentIndex > -1) {
65
+ handlers.splice(oldHelpIntentIndex, 1);
66
+ }
67
+ const url = template.liveStreamUrl ? template.liveStreamUrl.trim() : "";
68
+ const newLaunchRequestHandler = Object.assign({}, playLiveStreamHandler, { organizationId: template.organizationId, appId: template.appId, intentId: stentor_request_1.LAUNCH_REQUEST_ID, name: "Live Stream", type: stentor_handler_media_1.PLAY_LIVE_STREAM_HANDLER_TYPE, data: {
69
+ url
70
+ }, content: {
71
+ [stentor_request_1.LAUNCH_REQUEST_ID]: template.customIntros,
72
+ [`${stentor_interaction_model_1.HELP_INTENT}|${stentor_interaction_model_1.INPUT_UNKNOWN}`]: Constants_2.RADIO_TEMPLATE_HELP_RESPONSE,
73
+ [stentor_interaction_model_1.CANCEL_INTENT]: [...stentor_constants_1.GOODBYE]
74
+ } });
75
+ // concat with the old ones and return
76
+ return handlers.concat([newLaunchRequestHandler]);
77
+ }
78
+ }
79
+ exports.RadioTemplateFactory = RadioTemplateFactory;
80
+ //# sourceMappingURL=RadioTemplateFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioTemplateFactory.js","sourceRoot":"","sources":["../../src/radio/RadioTemplateFactory.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAAwD;AACxD,+DAAkD;AAClD,2DAAkD;AAClD,uEAAmH;AACnH,+EAA4F;AAE5F,2DAA0D;AAE1D,4CAAiD;AACjD,wDAAqD;AACrD,2CAAoG;AAGpG,MAAa,oBAAqB,SAAQ,iCAA8B;IACpE,gBAAgB,CAAC,GAAQ,EAAE,WAAiC,EAAE;QAC1D,IAAI,QAAQ,qBAEL,6BAAiB,EAEjB,GAAG;YACN,gBAAgB;YAChB,YAAY,EAAE,0BAAc;YAC5B,uCAAuC;YACvC,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,EAAE,EAChB,aAAa,EAAE,iCAAiB,EAChC,QAAQ,EAAE,mCAAuB,CAAC,KAAK,EAAE,GAC5C,CAAC;QAEF,QAAQ,GAAG,KAAK,CAAC,oBAAo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from "./RadioTemplate";
4
+ export * from "./RadioTemplateFactory";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*! Copyright (c) 2019, XAPPmedia */
7
+ __export(require("./Constants"));
8
+ __export(require("./RadioTemplateFactory"));
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/radio/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,iCAA4B;AAE5B,4CAAuC"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@xapp/stentor-templates",
3
+ "license": "UNLICENSED",
4
+ "publishConfig": {
5
+ "access": "restricted"
6
+ },
7
+ "version": "0.78.1-alpha.16+803abee0",
8
+ "description": "PLACEHOLDER DESCRIPTION OF PACKAGE",
9
+ "types": "lib/index",
10
+ "main": "lib/index",
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "engines": {
15
+ "node": "10.x"
16
+ },
17
+ "devDependencies": {
18
+ "@types/chai": "4.1.7",
19
+ "@xapp/config": "0.2.3",
20
+ "chai": "4.2.0",
21
+ "mocha": "6.2.0",
22
+ "ts-node": "8.1.0",
23
+ "typescript": "3.5.3"
24
+ },
25
+ "dependencies": {
26
+ "@xapp/stentor-alexa": "^1.3.0",
27
+ "@xapp/stentor-app": "^1.3.0",
28
+ "@xapp/stentor-constants": "^1.3.0",
29
+ "@xapp/stentor-handler": "^0.78.1-alpha.16+803abee0",
30
+ "@xapp/stentor-handler-media": "^0.78.1-alpha.16+803abee0",
31
+ "@xapp/stentor-interaction-model": "^1.3.0",
32
+ "@xapp/stentor-models": "^1.3.0",
33
+ "@xapp/stentor-request": "^1.3.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -d true -p .",
37
+ "clean": "rm -rf ./lib/*",
38
+ "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\""
39
+ },
40
+ "gitHead": "803abee059c2fe894dbfe145872e4e76d5b7ba1a"
41
+ }