@kayako/apps-manifest
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -0,1 +1,11 @@ | ||
<a name="1.0.3"></a> | ||
## [1.0.3](https://github.com/kayako/apps-manifest/compare/v1.0.2...v1.0.3) (2018-02-12) | ||
### Features | ||
* **validation:** add custom messages ([fbb9aab](https://github.com/kayako/apps-manifest/commit/fbb9aab)) | ||
<a name="1.0.2"></a> | ||
@@ -2,0 +12,0 @@ ## [1.0.2](https://github.com/kayako/apps-manifest/compare/v1.0.1...v1.0.2) (2018-02-12) |
{ | ||
"name": "@kayako/apps-manifest", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Parser and validator for apps manifest.json file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,4 +100,34 @@ 'use strict' | ||
module.exports = (data, messages) => { | ||
return validateAll(data, rules, messages, formatters.JsonApi) | ||
const fieldSubsitutes = { | ||
'slots.*.location': 'slot locations', | ||
'platforms.*': 'platforms', | ||
'prompts.*.access': 'prompt access', | ||
'prompts.*.type': 'prompt types' | ||
} | ||
const defaultMessages = { | ||
required: 'Make sure to define app {{ field }}', | ||
array: 'App {{ field }} must be defined as an array', | ||
string: '{{ field }} must be defined as a valid string', | ||
in: (field, validation, originalArgs) => { | ||
const args = originalArgs.concat([]) | ||
const lastArg = args.splice(-1) | ||
const fieldName = fieldSubsitutes[field] || field | ||
return `Only ${args.join(', ')} or ${lastArg[0]} ${fieldName} are allowed` | ||
}, | ||
'version.semver': 'App version must be a valid as per semver specs', | ||
'bundleDir.required': 'Make sure to define assets bundle directory', | ||
'slots.*.object': 'App slot must be defined as valid object', | ||
'slots.*.url.required': 'App slot must have a url property', | ||
'slots.*.url.string': 'App slot must have a valid url or relative path to a local file', | ||
'slots.*.location.required': 'App slot must have a location property', | ||
'platforms.distinct': 'Duplicate platforms are not allowed', | ||
'prompts.distinct': 'Prompts key must be unqiue', | ||
'secrets.object': 'App slots must be an object of key/value pairs', | ||
'whiteListedDomains.*.string': 'Each whitelisted domain must be a valid string', | ||
'prompts.*.key.string': 'Prompts key must be a string' | ||
} | ||
module.exports = (data, messages = {}) => { | ||
return validateAll(data, rules, Object.assign(defaultMessages, messages), formatters.JsonApi) | ||
} |
@@ -32,3 +32,3 @@ 'use strict' | ||
title: 'required', | ||
detail: 'required validation failed on name', | ||
detail: 'Make sure to define app name', | ||
source: { | ||
@@ -67,3 +67,3 @@ pointer: 'name' | ||
title: 'required', | ||
detail: 'required validation failed on version', | ||
detail: 'Make sure to define app version', | ||
source: { | ||
@@ -86,3 +86,3 @@ pointer: 'version' | ||
title: 'semver', | ||
detail: 'semver validation failed on version', | ||
detail: 'App version must be a valid as per semver specs', | ||
source: { | ||
@@ -106,3 +106,3 @@ pointer: 'version' | ||
title: 'required', | ||
detail: 'required validation failed on bundleDir', | ||
detail: 'Make sure to define assets bundle directory', | ||
source: { | ||
@@ -127,3 +127,3 @@ pointer: 'bundleDir' | ||
title: 'string', | ||
detail: 'string validation failed on bundleDir', | ||
detail: 'bundleDir must be defined as a valid string', | ||
source: { | ||
@@ -148,3 +148,3 @@ pointer: 'bundleDir' | ||
title: 'required', | ||
detail: 'required validation failed on slots', | ||
detail: 'Make sure to define app slots', | ||
source: { | ||
@@ -170,3 +170,3 @@ pointer: 'slots' | ||
title: 'array', | ||
detail: 'array validation failed on slots', | ||
detail: 'App slots must be defined as an array', | ||
source: { | ||
@@ -192,3 +192,3 @@ pointer: 'slots' | ||
title: 'object', | ||
detail: 'object validation failed on slots.0', | ||
detail: 'App slot must be defined as valid object', | ||
source: { | ||
@@ -215,3 +215,3 @@ pointer: 'slots.0' | ||
title: 'required', | ||
detail: 'required validation failed on slots.0.url', | ||
detail: 'App slot must have a url property', | ||
source: { | ||
@@ -239,3 +239,3 @@ pointer: 'slots.0.url' | ||
title: 'string', | ||
detail: 'string validation failed on slots.0.url', | ||
detail: 'App slot must have a valid url or relative path to a local file', | ||
source: { | ||
@@ -263,3 +263,3 @@ pointer: 'slots.0.url' | ||
title: 'required', | ||
detail: 'required validation failed on slots.0.location', | ||
detail: 'App slot must have a location property', | ||
source: { | ||
@@ -288,3 +288,3 @@ pointer: 'slots.0.location' | ||
title: 'in', | ||
detail: 'in validation failed on slots.0.location', | ||
detail: 'Only case-sidebar, user-sidebar, organisation-sidebar or messenger-home-screen slot locations are allowed', | ||
source: { | ||
@@ -313,3 +313,3 @@ pointer: 'slots.0.location' | ||
title: 'required', | ||
detail: 'required validation failed on access', | ||
detail: 'Make sure to define app access', | ||
source: { | ||
@@ -339,3 +339,3 @@ pointer: 'access' | ||
title: 'in', | ||
detail: 'in validation failed on access', | ||
detail: 'Only public or private access are allowed', | ||
source: { | ||
@@ -365,3 +365,3 @@ pointer: 'access' | ||
title: 'required', | ||
detail: 'required validation failed on platforms', | ||
detail: 'Make sure to define app platforms', | ||
source: { | ||
@@ -392,3 +392,3 @@ pointer: 'platforms' | ||
title: 'array', | ||
detail: 'array validation failed on platforms', | ||
detail: 'App platforms must be defined as an array', | ||
source: { | ||
@@ -419,3 +419,3 @@ pointer: 'platforms' | ||
title: 'in', | ||
detail: 'in validation failed on platforms.0', | ||
detail: 'Only agent or messenger platforms are allowed', | ||
source: { | ||
@@ -446,3 +446,3 @@ pointer: 'platforms.0' | ||
title: 'in', | ||
detail: 'in validation failed on platforms.1', | ||
detail: 'Only agent or messenger platforms are allowed', | ||
source: { | ||
@@ -473,3 +473,3 @@ pointer: 'platforms.1' | ||
title: 'distinct', | ||
detail: 'distinct validation failed on platforms', | ||
detail: 'Duplicate platforms are not allowed', | ||
source: { | ||
@@ -500,3 +500,3 @@ pointer: 'platforms' | ||
title: 'required', | ||
detail: 'required validation failed on whiteListedDomains', | ||
detail: 'Make sure to define app whiteListedDomains', | ||
source: { | ||
@@ -528,3 +528,3 @@ pointer: 'whiteListedDomains' | ||
title: 'array', | ||
detail: 'array validation failed on whiteListedDomains', | ||
detail: 'App whiteListedDomains must be defined as an array', | ||
source: { | ||
@@ -556,3 +556,3 @@ pointer: 'whiteListedDomains' | ||
title: 'string', | ||
detail: 'string validation failed on whiteListedDomains.1', | ||
detail: 'Each whitelisted domain must be a valid string', | ||
source: { | ||
@@ -585,3 +585,3 @@ pointer: 'whiteListedDomains.1' | ||
title: 'array', | ||
detail: 'array validation failed on prompts', | ||
detail: 'App prompts must be defined as an array', | ||
source: { | ||
@@ -614,3 +614,3 @@ pointer: 'prompts' | ||
title: 'required', | ||
detail: 'required validation failed on prompts.0.key', | ||
detail: 'Make sure to define app prompts.0.key', | ||
source: { | ||
@@ -645,3 +645,3 @@ pointer: 'prompts.0.key' | ||
title: 'string', | ||
detail: 'string validation failed on prompts.0.key', | ||
detail: 'Prompts key must be a string', | ||
source: { | ||
@@ -679,3 +679,3 @@ pointer: 'prompts.0.key' | ||
title: 'in', | ||
detail: 'in validation failed on prompts.0.access', | ||
detail: 'Only public or protected prompt access are allowed', | ||
source: { | ||
@@ -714,3 +714,3 @@ pointer: 'prompts.0.access' | ||
title: 'in', | ||
detail: 'in validation failed on prompts.0.type', | ||
detail: 'Only text, secure, longtext or json prompt types are allowed', | ||
source: { | ||
@@ -791,3 +791,3 @@ pointer: 'prompts.0.type' | ||
title: 'distinct', | ||
detail: 'distinct validation failed on prompts', | ||
detail: 'Prompts key must be unqiue', | ||
source: { | ||
@@ -828,3 +828,3 @@ pointer: 'prompts' | ||
title: 'object', | ||
detail: 'object validation failed on secrets', | ||
detail: 'App slots must be an object of key/value pairs', | ||
source: { | ||
@@ -831,0 +831,0 @@ pointer: 'secrets' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35946
1124