@xapp/stentor-validation 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +1 -0
  3. package/lib/AppValidator/AppValidator.d.ts +20 -0
  4. package/lib/AppValidator/AppValidator.js +96 -0
  5. package/lib/AppValidator/AppValidator.js.map +1 -0
  6. package/lib/AppValidator/containsIllegalCharacters.d.ts +10 -0
  7. package/lib/AppValidator/containsIllegalCharacters.js +24 -0
  8. package/lib/AppValidator/containsIllegalCharacters.js.map +1 -0
  9. package/lib/AppValidator/containsNumbers.d.ts +9 -0
  10. package/lib/AppValidator/containsNumbers.js +24 -0
  11. package/lib/AppValidator/containsNumbers.js.map +1 -0
  12. package/lib/AppValidator/containsReservedAlexaWords.d.ts +10 -0
  13. package/lib/AppValidator/containsReservedAlexaWords.js +47 -0
  14. package/lib/AppValidator/containsReservedAlexaWords.js.map +1 -0
  15. package/lib/AppValidator/containsReservedGrammarWords.d.ts +8 -0
  16. package/lib/AppValidator/containsReservedGrammarWords.js +29 -0
  17. package/lib/AppValidator/containsReservedGrammarWords.js.map +1 -0
  18. package/lib/AppValidator/containsUppercase.d.ts +8 -0
  19. package/lib/AppValidator/containsUppercase.js +23 -0
  20. package/lib/AppValidator/containsUppercase.js.map +1 -0
  21. package/lib/AppValidator/index.d.ts +2 -0
  22. package/lib/AppValidator/index.js +8 -0
  23. package/lib/AppValidator/index.js.map +1 -0
  24. package/lib/HandlerValidator/HandlerValidator.d.ts +13 -0
  25. package/lib/HandlerValidator/HandlerValidator.js +32 -0
  26. package/lib/HandlerValidator/HandlerValidator.js.map +1 -0
  27. package/lib/HandlerValidator/index.d.ts +2 -0
  28. package/lib/HandlerValidator/index.js +8 -0
  29. package/lib/HandlerValidator/index.js.map +1 -0
  30. package/lib/LogicValidator.d.ts +6 -0
  31. package/lib/LogicValidator.js +16 -0
  32. package/lib/LogicValidator.js.map +1 -0
  33. package/lib/analyzeModelAndContent.d.ts +12 -0
  34. package/lib/analyzeModelAndContent.js +139 -0
  35. package/lib/analyzeModelAndContent.js.map +1 -0
  36. package/lib/index.d.ts +5 -0
  37. package/lib/index.js +11 -0
  38. package/lib/index.js.map +1 -0
  39. package/package.json +38 -0
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,20 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { App } from "@xapp/stentor-models";
3
+ import { Validator } from "lakmus";
4
+ export declare const MIN_APP_NAME_LENGTH = 2;
5
+ export declare const MAX_APP_NAME_LENGTH = 50;
6
+ export declare const MIN_INVOCATION_NAME_LENGTH = 2;
7
+ export declare const MAX_INVOCATION_NAME_LENGTH = 50;
8
+ export declare const MAX_SUMMARY_LENGTH = 160;
9
+ export declare const MAX_DESCRIPTION_LENGTH = 4000;
10
+ export declare const MAX_KEYWORDS_LENGTH = 30;
11
+ /**
12
+ * Validation for App model.
13
+ *
14
+ * @export
15
+ * @class AppValidator
16
+ * @extends {Validator<App>}
17
+ */
18
+ export declare class AppValidator extends Validator<App> {
19
+ constructor();
20
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lakmus_1 = require("lakmus");
4
+ const containsIllegalCharacters_1 = require("./containsIllegalCharacters");
5
+ const containsNumbers_1 = require("./containsNumbers");
6
+ const containsReservedAlexaWords_1 = require("./containsReservedAlexaWords");
7
+ const containsReservedGrammarWords_1 = require("./containsReservedGrammarWords");
8
+ const containsUppercase_1 = require("./containsUppercase");
9
+ exports.MIN_APP_NAME_LENGTH = 2;
10
+ exports.MAX_APP_NAME_LENGTH = 50;
11
+ exports.MIN_INVOCATION_NAME_LENGTH = 2;
12
+ exports.MAX_INVOCATION_NAME_LENGTH = 50;
13
+ exports.MAX_SUMMARY_LENGTH = 160;
14
+ exports.MAX_DESCRIPTION_LENGTH = 4000;
15
+ exports.MAX_KEYWORDS_LENGTH = 30;
16
+ /**
17
+ * Validation for App model.
18
+ *
19
+ * @export
20
+ * @class AppValidator
21
+ * @extends {Validator<App>}
22
+ */
23
+ class AppValidator extends lakmus_1.Validator {
24
+ constructor() {
25
+ super();
26
+ // Required fields
27
+ this.ruleFor(x => x.appId)
28
+ .notNull()
29
+ .notEmpty();
30
+ this.ruleFor(x => x.organizationId)
31
+ .notNull()
32
+ .notEmpty();
33
+ this.ruleFor(x => x.name)
34
+ .notNull()
35
+ .notEmpty()
36
+ .minLength(exports.MIN_APP_NAME_LENGTH)
37
+ .maxLength(exports.MAX_APP_NAME_LENGTH);
38
+ // Invocation Name Requirements
39
+ // Alexa https://developer.amazon.com/docs/custom-skills/choose-the-invocation-name-for-a-custom-skill.html#cert-invocation-name-req
40
+ // Google (none specified)
41
+ this.ruleFor(x => x.invocationName)
42
+ .when(x => !!x.invocationName)
43
+ .minLength(exports.MIN_INVOCATION_NAME_LENGTH)
44
+ .maxLength(exports.MAX_INVOCATION_NAME_LENGTH)
45
+ .withMessage("Invocation phrase must be at least two characters and no longer than fifty.");
46
+ this.ruleFor(x => x.invocationName)
47
+ .when(x => !!x.invocationName)
48
+ .must((invocationName, app) => {
49
+ return !containsReservedGrammarWords_1.containsReservedGrammarWords(invocationName);
50
+ })
51
+ .withMessage("Two word invocation phrases must not include the definite article, an indefinite article, or a preposition.");
52
+ this.ruleFor(x => x.invocationName)
53
+ .when(x => !!x.invocationName)
54
+ .must((invocationName, app) => {
55
+ return !containsNumbers_1.containsNumbers(invocationName);
56
+ })
57
+ .withMessage("All numbers in the invocation phrase must be spelled out, for example 'twenty one' not '21'.");
58
+ this.ruleFor(x => x.invocationName)
59
+ .when(x => !!x.invocationName)
60
+ .must((invocationName, app) => {
61
+ return !containsUppercase_1.containsUppercase(invocationName);
62
+ })
63
+ .withMessage("Invocation phrase must not include uppercase letters.");
64
+ this.ruleFor(x => x.invocationName)
65
+ .when(x => !!x.invocationName)
66
+ .must((invocationName, app) => {
67
+ return !containsIllegalCharacters_1.containsIllegalCharacters(invocationName);
68
+ })
69
+ .withMessage("Invocation phrase can only include periods and apostrophes.");
70
+ this.ruleFor(x => x.invocationName)
71
+ .when(x => !!x.invocationName)
72
+ .must((invocationName, app) => {
73
+ return !containsReservedAlexaWords_1.containsReservedAlexaWords(invocationName);
74
+ })
75
+ .withMessage("Invocation phrases must not include wake words, launch phrases or connecting words.");
76
+ // Summary, max 160
77
+ this.ruleFor(x => x.summary)
78
+ .when(x => !!x.summary)
79
+ .notEmpty()
80
+ .maxLength(exports.MAX_SUMMARY_LENGTH);
81
+ // Description, max 4000
82
+ this.ruleFor(x => x.description)
83
+ .when(x => !!x.description)
84
+ .notEmpty()
85
+ .maxLength(exports.MAX_DESCRIPTION_LENGTH);
86
+ // Keywords, max 30
87
+ this.ruleFor(x => x.keywords)
88
+ .when(x => Array.isArray(x.keywords))
89
+ .must((keywords, app) => {
90
+ return keywords.length <= exports.MAX_KEYWORDS_LENGTH;
91
+ })
92
+ .withMessage("30 keywords is the maximum amount allowed.");
93
+ }
94
+ }
95
+ exports.AppValidator = AppValidator;
96
+ //# sourceMappingURL=AppValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppValidator.js","sourceRoot":"","sources":["../../src/AppValidator/AppValidator.ts"],"names":[],"mappings":";;AAEA,mCAAmC;AACnC,2EAAwE;AACxE,uDAAoD;AACpD,6EAA0E;AAC1E,iFAA8E;AAC9E,2DAAwD;AAE3C,QAAA,mBAAmB,GAAG,CAAC,CAAC;AACxB,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEzB,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAC/B,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAEhC,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEzB,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE9B,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,kBAAc;IAC5C;QACI,KAAK,EAAE,CAAC;QAER,kBAAkB;QAClB,IAAI,CAAC,OAAO,CAAC,CAAC,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AAC;aACtB,QAAQ,EAAE;aACV,SAAS,CAAC,0BAAkB,CAAC,CAAC;QAEnC,wBAAwB;QACxB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;aAC3B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;aAC1B,QAAQ,EAAE;aACV,SAAS,CAAC,8BAAsB,CAAC,CAAC;QAEvC,mBAAmB;QACnB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;aACpC,IAAI,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE;YACpB,OAAO,QAAQ,CAAC,MAAM,IAAI,2BAAmB,CAAC;QAClD,CAAC,CAAC;aACD,WAAW,CAAC,4CAA4C,CAAC,CAAC;IACnE,CAAC;CACJ;AAhFD,oCAgFC"}
@@ -0,0 +1,10 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ /**
3
+ * Does the provided string or array of strings contain anything besides
4
+ * lowercase letters, periods, and apostrophes.
5
+ *
6
+ * @export
7
+ * @param {(string | string[])} invocationName
8
+ * @returns {boolean}
9
+ */
10
+ export declare function containsIllegalCharacters(invocationName: string | string[]): boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ /**
5
+ * Does the provided string or array of strings contain anything besides
6
+ * lowercase letters, periods, and apostrophes.
7
+ *
8
+ * @export
9
+ * @param {(string | string[])} invocationName
10
+ * @returns {boolean}
11
+ */
12
+ function containsIllegalCharacters(invocationName) {
13
+ const sentences = [].concat(invocationName);
14
+ let result = false;
15
+ sentences.forEach(sentence => {
16
+ // This regex allows periods, spaces, and apostrophes
17
+ if (/[^\w. ']/.test(sentence)) {
18
+ result = true;
19
+ }
20
+ });
21
+ return result;
22
+ }
23
+ exports.containsIllegalCharacters = containsIllegalCharacters;
24
+ //# sourceMappingURL=containsIllegalCharacters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containsIllegalCharacters.js","sourceRoot":"","sources":["../../src/AppValidator/containsIllegalCharacters.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAAC,cAAiC;IACvE,MAAM,SAAS,GAAa,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACzB,qDAAqD;QACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC3B,MAAM,GAAG,IAAI,CAAC;SACjB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAbD,8DAaC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Does the provided string or array of strings contains numerical
3
+ * characters.
4
+ *
5
+ * @export
6
+ * @param {(string | string[])} invocationName
7
+ * @returns {boolean}
8
+ */
9
+ export declare function containsNumbers(invocationName: string | string[]): boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_utils_1 = require("@xapp/stentor-utils");
5
+ /**
6
+ * Does the provided string or array of strings contains numerical
7
+ * characters.
8
+ *
9
+ * @export
10
+ * @param {(string | string[])} invocationName
11
+ * @returns {boolean}
12
+ */
13
+ function containsNumbers(invocationName) {
14
+ const sentences = [].concat(invocationName);
15
+ let result = false;
16
+ sentences.forEach(sentence => {
17
+ if (stentor_utils_1.containsNumbers(sentence)) {
18
+ result = true;
19
+ }
20
+ });
21
+ return result;
22
+ }
23
+ exports.containsNumbers = containsNumbers;
24
+ //# sourceMappingURL=containsNumbers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containsNumbers.js","sourceRoot":"","sources":["../../src/AppValidator/containsNumbers.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAA0E;AAE1E;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,cAAiC;IAC7D,MAAM,SAAS,GAAa,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACzB,IAAI,+BAAgB,CAAC,QAAQ,CAAC,EAAE;YAC5B,MAAM,GAAG,IAAI,CAAC;SACjB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAZD,0CAYC"}
@@ -0,0 +1,10 @@
1
+ export declare const ALEXA_RESERVED_WORDS: string[];
2
+ /**
3
+ * Does the provided string or array of strings contain any of the Alexa reserved
4
+ * words for launching, invocation, or connecting.
5
+ *
6
+ * @export
7
+ * @param {(string | string[])} invocationName
8
+ * @returns {boolean}
9
+ */
10
+ export declare function containsReservedAlexaWords(invocationName: string | string[]): boolean;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_utils_1 = require("@xapp/stentor-utils");
5
+ exports.ALEXA_RESERVED_WORDS = [
6
+ "alexa",
7
+ "and",
8
+ "app",
9
+ "ask",
10
+ "begin",
11
+ "by",
12
+ "computer",
13
+ "echo",
14
+ "enable",
15
+ "from",
16
+ "if",
17
+ "launch",
18
+ "load",
19
+ "skill",
20
+ "tell",
21
+ "to",
22
+ "whether"
23
+ ];
24
+ /**
25
+ * Does the provided string or array of strings contain any of the Alexa reserved
26
+ * words for launching, invocation, or connecting.
27
+ *
28
+ * @export
29
+ * @param {(string | string[])} invocationName
30
+ * @returns {boolean}
31
+ */
32
+ function containsReservedAlexaWords(invocationName) {
33
+ const sentences = [].concat(invocationName);
34
+ let result = false;
35
+ sentences.forEach(sentence => {
36
+ // rule only applies if they have two words
37
+ const words = stentor_utils_1.toWords(sentence);
38
+ words.forEach(word => {
39
+ if (exports.ALEXA_RESERVED_WORDS.indexOf(word.toLowerCase()) !== -1) {
40
+ result = true;
41
+ }
42
+ });
43
+ });
44
+ return result;
45
+ }
46
+ exports.containsReservedAlexaWords = containsReservedAlexaWords;
47
+ //# sourceMappingURL=containsReservedAlexaWords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containsReservedAlexaWords.js","sourceRoot":"","sources":["../../src/AppValidator/containsReservedAlexaWords.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAA8C;AAEjC,QAAA,oBAAoB,GAAG;IAChC,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,IAAI;IACJ,UAAU;IACV,MAAM;IACN,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,IAAI;IACJ,SAAS;CACZ,CAAC;AAEF;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CAAC,cAAiC;IACxE,MAAM,SAAS,GAAa,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACzB,2CAA2C;QAC3C,MAAM,KAAK,GAAG,uBAAO,CAAC,QAAQ,CAAC,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,IAAI,4BAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;gBACzD,MAAM,GAAG,IAAI,CAAC;aACjB;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAhBD,gEAgBC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Does the provided string or array of strings include a preposition, definite article, or indefinite article.
3
+ *
4
+ * @export
5
+ * @param {(string | string[])} invocationName
6
+ * @returns {boolean}
7
+ */
8
+ export declare function containsReservedGrammarWords(invocationName: string | string[]): boolean;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_utils_1 = require("@xapp/stentor-utils");
5
+ /**
6
+ * Does the provided string or array of strings include a preposition, definite article, or indefinite article.
7
+ *
8
+ * @export
9
+ * @param {(string | string[])} invocationName
10
+ * @returns {boolean}
11
+ */
12
+ function containsReservedGrammarWords(invocationName) {
13
+ const sentences = [].concat(invocationName);
14
+ let result = false;
15
+ sentences.forEach(sentence => {
16
+ // rule only applies if they have two words
17
+ const words = stentor_utils_1.toWords(sentence);
18
+ if (words.length === 2) {
19
+ words.forEach(word => {
20
+ if (stentor_utils_1.isPreposition(word) || stentor_utils_1.isDefiniteArticle(word) || stentor_utils_1.isIndefiniteArticle(word)) {
21
+ result = true;
22
+ }
23
+ });
24
+ }
25
+ });
26
+ return result;
27
+ }
28
+ exports.containsReservedGrammarWords = containsReservedGrammarWords;
29
+ //# sourceMappingURL=containsReservedGrammarWords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containsReservedGrammarWords.js","sourceRoot":"","sources":["../../src/AppValidator/containsReservedGrammarWords.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAAqG;AAErG;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAC,cAAiC;IAC1E,MAAM,SAAS,GAAa,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACzB,2CAA2C;QAC3C,MAAM,KAAK,GAAG,uBAAO,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjB,IAAI,6BAAa,CAAC,IAAI,CAAC,IAAI,iCAAiB,CAAC,IAAI,CAAC,IAAI,mCAAmB,CAAC,IAAI,CAAC,EAAE;oBAC7E,MAAM,GAAG,IAAI,CAAC;iBACjB;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAlBD,oEAkBC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * If the provided string or array of strings contains uppercase characters.
3
+ *
4
+ * @export
5
+ * @param {(string | string[])} invocationName
6
+ * @returns {boolean}
7
+ */
8
+ export declare function containsUppercase(invocationName: string | string[]): boolean;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_utils_1 = require("@xapp/stentor-utils");
5
+ /**
6
+ * If the provided string or array of strings contains uppercase characters.
7
+ *
8
+ * @export
9
+ * @param {(string | string[])} invocationName
10
+ * @returns {boolean}
11
+ */
12
+ function containsUppercase(invocationName) {
13
+ const sentences = [].concat(invocationName);
14
+ let result = false;
15
+ sentences.forEach(sentence => {
16
+ if (stentor_utils_1.containsUppercase(sentence)) {
17
+ result = true;
18
+ }
19
+ });
20
+ return result;
21
+ }
22
+ exports.containsUppercase = containsUppercase;
23
+ //# sourceMappingURL=containsUppercase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containsUppercase.js","sourceRoot":"","sources":["../../src/AppValidator/containsUppercase.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,uDAA8E;AAE9E;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,cAAiC;IAC/D,MAAM,SAAS,GAAa,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACzB,IAAI,iCAAkB,CAAC,QAAQ,CAAC,EAAE;YAC9B,MAAM,GAAG,IAAI,CAAC;SACjB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAZD,8CAYC"}
@@ -0,0 +1,2 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ export * from "./AppValidator";
@@ -0,0 +1,8 @@
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("./AppValidator"));
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/AppValidator/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,oCAA+B"}
@@ -0,0 +1,13 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { Handler } from "@xapp/stentor-models";
3
+ import { Validator } from "lakmus";
4
+ /**
5
+ * Handler validation.
6
+ *
7
+ * @export
8
+ * @class HandlerValidator
9
+ * @extends {Validator<Handler>}
10
+ */
11
+ export declare class HandlerValidator extends Validator<Handler> {
12
+ constructor();
13
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lakmus_1 = require("lakmus");
4
+ /**
5
+ * Handler validation.
6
+ *
7
+ * @export
8
+ * @class HandlerValidator
9
+ * @extends {Validator<Handler>}
10
+ */
11
+ class HandlerValidator extends lakmus_1.Validator {
12
+ constructor() {
13
+ super();
14
+ // Required fields
15
+ this.ruleFor(x => x.intentId)
16
+ .notNull()
17
+ .notEmpty();
18
+ this.ruleFor(x => x.appId)
19
+ .notNull()
20
+ .notEmpty();
21
+ this.ruleFor(x => x.type)
22
+ .notNull()
23
+ .notEmpty();
24
+ this.ruleFor(x => x.content)
25
+ .notNull()
26
+ .must((content, handler) => {
27
+ return typeof content === "object";
28
+ });
29
+ }
30
+ }
31
+ exports.HandlerValidator = HandlerValidator;
32
+ //# sourceMappingURL=HandlerValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HandlerValidator.js","sourceRoot":"","sources":["../../src/HandlerValidator/HandlerValidator.ts"],"names":[],"mappings":";;AAEA,mCAAmC;AAEnC;;;;;;GAMG;AACH,MAAa,gBAAiB,SAAQ,kBAAkB;IACpD;QACI,KAAK,EAAE,CAAC;QAER,kBAAkB;QAClB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aACxB,OAAO,EAAE;aACT,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;aACrB,OAAO,EAAE;aACT,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACpB,OAAO,EAAE;aACT,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACvB,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACvB,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC;QACvC,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AApBD,4CAoBC"}
@@ -0,0 +1,2 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ export * from "./HandlerValidator";
@@ -0,0 +1,8 @@
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("./HandlerValidator"));
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/HandlerValidator/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,wCAAmC"}
@@ -0,0 +1,6 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ import { Logic } from "@xapp/stentor-models";
3
+ import { Validator } from "lakmus";
4
+ export declare class LogicValidator extends Validator<Logic> {
5
+ constructor();
6
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lakmus_1 = require("lakmus");
4
+ class LogicValidator extends lakmus_1.Validator {
5
+ constructor() {
6
+ super();
7
+ this.ruleFor(x => x.compiled).notEmpty();
8
+ this.ruleFor(x => x.compiled)
9
+ .must((property, logic) => {
10
+ return logic.compiled ? logic.compiled.indexOf("done()") !== -1 : false;
11
+ })
12
+ .withMessage("You must include the 'done()' call in your logic");
13
+ }
14
+ }
15
+ exports.LogicValidator = LogicValidator;
16
+ //# sourceMappingURL=LogicValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogicValidator.js","sourceRoot":"","sources":["../src/LogicValidator.ts"],"names":[],"mappings":";;AAEA,mCAAmC;AAEnC,MAAa,cAAe,SAAQ,kBAAgB;IAChD;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aACxB,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YACtB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5E,CAAC,CAAC;aACD,WAAW,CAAC,kDAAkD,CAAC,CAAC;IACzE,CAAC;CACJ;AAVD,wCAUC"}
@@ -0,0 +1,12 @@
1
+ import { Handler, Intent } from "@xapp/stentor-models";
2
+ export interface AnalyzeModelAndContentResult {
3
+ info: AnalysisResult[];
4
+ warnings: AnalysisResult[];
5
+ errors: AnalysisResult[];
6
+ }
7
+ export interface AnalysisResult {
8
+ id: string;
9
+ message: string;
10
+ }
11
+ export declare function analyzeModelAndContent(value: (Intent | Handler)[]): AnalyzeModelAndContentResult;
12
+ export declare function printResult(results: AnalyzeModelAndContentResult): void;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*! Copyright (c) 2019, XAPPmedia */
4
+ const stentor_handler_1 = require("@xapp/stentor-handler");
5
+ const chalk_1 = require("chalk");
6
+ const OPEN_ENDED_RESPONSE = "^((?!(StopIntent|HelpIntent|CancelIntent)).)*$";
7
+ function analyzeModelAndContent(value) {
8
+ const results = {
9
+ info: [],
10
+ warnings: [],
11
+ errors: []
12
+ };
13
+ const map = stentor_handler_1.toMap(value);
14
+ // Look for any without utterance patterns or content.
15
+ Object.keys(map).forEach(intentId => {
16
+ /* tslint:disable:cyclomatic-complexity */
17
+ const intent = map[intentId];
18
+ const referenceName = `${intent.name ? intent.name + " / " : ""}${intentId}`;
19
+ if (stentor_handler_1.isGlobalHandler(intent)) {
20
+ results.info.push({
21
+ id: intentId,
22
+ message: `${referenceName} is a global handler (it has utterances and content).`
23
+ });
24
+ }
25
+ // Warning if it doesn't have any utterances or content
26
+ if (!stentor_handler_1.hasUtterances(intent) && !stentor_handler_1.hasContent(intent)) {
27
+ results.warnings.push({
28
+ id: intentId,
29
+ message: `${referenceName} has neither utterances or content.`
30
+ });
31
+ }
32
+ // Warning if it doesn't have content for itself
33
+ if (stentor_handler_1.hasContent(intent)) {
34
+ if (stentor_handler_1.isHandler(intent) && !intent.content[intent.intentId]) {
35
+ results.warnings.push({
36
+ id: intentId,
37
+ message: `${referenceName} does not have content for it's own ID`
38
+ });
39
+ }
40
+ }
41
+ // Warning if it forwards to itself
42
+ if (stentor_handler_1.forwardsTo(intent, intent.intentId)) {
43
+ results.warnings.push({
44
+ id: intentId,
45
+ message: `${referenceName} forwards to itself.`
46
+ });
47
+ }
48
+ // Info that is has an open ended response
49
+ if (stentor_handler_1.handles(intent, OPEN_ENDED_RESPONSE, stentor_handler_1.HandledIn.Forward)) {
50
+ results.info.push({
51
+ id: intentId,
52
+ message: `${intentId} handles an open-ended forward.`
53
+ });
54
+ }
55
+ // Warning if it has forwards and no reprompt
56
+ if (stentor_handler_1.hasForwards(intent) && !stentor_handler_1.hasReprompt(intent)) {
57
+ results.errors.push({
58
+ id: intentId,
59
+ message: `${referenceName} has forwards but no reprompts.`
60
+ });
61
+ }
62
+ // Warning if it has reprompt but no forwards
63
+ if (!stentor_handler_1.hasForwards(intent) && stentor_handler_1.hasReprompt(intent)) {
64
+ results.warnings.push({
65
+ id: intentId,
66
+ message: `${referenceName} has a reprompt but no forwards`
67
+ });
68
+ }
69
+ // Error if content contains . “Help!” (bad characters) ". “Help!” "
70
+ /* if (responsesContain(intent, "“") || responsesContain(intent, "”")) {
71
+ results.errors.push({
72
+ id: intentId,
73
+ message: `${referenceName} contains illegal characters “” in the response.`
74
+ })
75
+ } */
76
+ // Error Contains improper comments
77
+ if (stentor_handler_1.responsesContain(intent, "<! --")) {
78
+ results.errors.push({
79
+ id: intentId,
80
+ message: `${referenceName} contains improperly formated comments (<! -- instead of <!--) in the response.`
81
+ });
82
+ }
83
+ // Error contains improper comments <!—
84
+ if (stentor_handler_1.responsesContain(intent, "<!—")) {
85
+ results.errors.push({
86
+ id: intentId,
87
+ message: `${referenceName} contains improperly formated comments (<!— instead of <!--) in the response.`
88
+ });
89
+ }
90
+ const containsInvalid = stentor_handler_1.containsInvalidResponse(intent);
91
+ if (containsInvalid.error) {
92
+ results.errors.push({
93
+ id: intentId,
94
+ message: `${referenceName} contains invalid XML in response ${containsInvalid.response}`
95
+ });
96
+ }
97
+ // Warning, has only one forward that isn't the open ended key
98
+ if (stentor_handler_1.hasForwards(intent)) {
99
+ if (stentor_handler_1.isHandler(intent)) {
100
+ if (Object.keys(intent.forward).length === 1) {
101
+ const key = Object.keys(intent.forward)[0];
102
+ const paths = intent.forward[key];
103
+ // We need to check for multiple paths
104
+ const hasMultiplePaths = paths.length > 1;
105
+ // Or if it is the open ended request.
106
+ const isOpenEnded = OPEN_ENDED_RESPONSE === key;
107
+ // If it is
108
+ // !true && !true
109
+ if (!hasMultiplePaths && !isOpenEnded) {
110
+ results.warnings.push({
111
+ id: intentId,
112
+ message: `${referenceName} has only one forward and it is not the open ended forward or has multiple paths on the forward`
113
+ });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ /* tslint:enable:cyclomatic-complexity */
119
+ });
120
+ return results;
121
+ }
122
+ exports.analyzeModelAndContent = analyzeModelAndContent;
123
+ function printResult(results) {
124
+ // Info
125
+ results.info.forEach(result => {
126
+ console.log(chalk_1.default.blue("INFO ") + " " + result.message);
127
+ });
128
+ // Warning
129
+ results.warnings.forEach(result => {
130
+ console.log(chalk_1.default.yellow("WARNING") + " " + result.message);
131
+ });
132
+ // Errors
133
+ // Info
134
+ results.errors.forEach(result => {
135
+ console.log(chalk_1.default.red("ERROR ") + " " + result.message);
136
+ });
137
+ }
138
+ exports.printResult = printResult;
139
+ //# sourceMappingURL=analyzeModelAndContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeModelAndContent.js","sourceRoot":"","sources":["../src/analyzeModelAndContent.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,2DAc+B;AAE/B,iCAA0B;AAE1B,MAAM,mBAAmB,GAAG,gDAAgD,CAAC;AAa7E,SA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IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,UAAU;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,SAAS;IACT,OAAO;IACP,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACP,CAAC;AAhBD,kCAgBC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /*! Copyright (c) 2019, XAPPmedia */
2
+ export * from "./analyzeModelAndContent";
3
+ export * from "./AppValidator";
4
+ export * from "./HandlerValidator";
5
+ export * from "./LogicValidator";
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
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("./analyzeModelAndContent"));
8
+ __export(require("./AppValidator"));
9
+ __export(require("./HandlerValidator"));
10
+ __export(require("./LogicValidator"));
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,8CAAyC;AACzC,oCAA+B;AAC/B,wCAAmC;AACnC,sCAAiC"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@xapp/stentor-validation",
3
+ "license": "UNLICENSED",
4
+ "publishConfig": {
5
+ "access": "restricted"
6
+ },
7
+ "version": "0.78.1-alpha.16+803abee0",
8
+ "description": "Model validation for Stentor",
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
+ "@types/mocha": "5.2.7",
20
+ "@xapp/config": "0.2.3",
21
+ "chai": "4.2.0",
22
+ "mocha": "6.2.0",
23
+ "ts-node": "8.2.0",
24
+ "typescript": "3.5.3"
25
+ },
26
+ "dependencies": {
27
+ "@xapp/stentor-handler": "^0.78.1-alpha.16+803abee0",
28
+ "@xapp/stentor-models": "^1.3.0",
29
+ "@xapp/stentor-utils": "^1.3.0",
30
+ "lakmus": "0.3.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -d true -p .",
34
+ "clean": "rm -rf ./lib/*",
35
+ "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\""
36
+ },
37
+ "gitHead": "803abee059c2fe894dbfe145872e4e76d5b7ba1a"
38
+ }