@graphcms/validation
Advanced tools
Comparing version 1.4.2 to 1.4.3
# @graphcms/validation | ||
## 1.4.3 | ||
### Patch Changes | ||
- [#40](https://github.com/GraphCMS/validation/pull/40) [`d7902b7`](https://github.com/GraphCMS/validation/commit/d7902b7780f0603e94c54df32b9cf6f011ab6487) Thanks [@mahaveer0496](https://github.com/mahaveer0496)! - Add `app` validation | ||
## 1.4.2 | ||
@@ -4,0 +10,0 @@ |
@@ -1,13 +0,13 @@ | ||
import * as authtoken from './authtoken'; | ||
import * as enumeration from './enumeration'; | ||
import * as field from './field'; | ||
import * as invite from './invite'; | ||
import * as model from './model'; | ||
import * as project from './project'; | ||
import * as role from './role'; | ||
import * as stage from './stage'; | ||
import * as webhook from './webhook'; | ||
import * as locale from './locale'; | ||
import * as viewGroup from './viewGroup'; | ||
import * as component from './component'; | ||
export { authtoken, enumeration, field, invite, model, project, role, stage, webhook, locale, viewGroup, component, }; | ||
export * as authtoken from './authtoken'; | ||
export * as enumeration from './enumeration'; | ||
export * as field from './field'; | ||
export * as invite from './invite'; | ||
export * as model from './model'; | ||
export * as project from './project'; | ||
export * as role from './role'; | ||
export * as stage from './stage'; | ||
export * as webhook from './webhook'; | ||
export * as locale from './locale'; | ||
export * as viewGroup from './viewGroup'; | ||
export * as component from './component'; | ||
export * as appValidation from './app'; |
@@ -23,4 +23,4 @@ var yup = require('yup'); | ||
var name$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$5 = yup__namespace.string().nullable(true); | ||
var name$6 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$6 = yup__namespace.string().nullable(true); | ||
var scope = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).oneOf(['READ', 'WRITE', 'OPEN'], "An authentication token can only be set to one of 'READ', 'WRITE' or 'OPEN'"); | ||
@@ -30,4 +30,4 @@ | ||
__proto__: null, | ||
name: name$5, | ||
description: description$5, | ||
name: name$6, | ||
description: description$6, | ||
scope: scope | ||
@@ -53,3 +53,3 @@ }; | ||
var apiId$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -106,3 +106,3 @@ test: function test(value) { | ||
var description$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
/** | ||
@@ -126,5 +126,5 @@ * Matcher for enumeration api IDs: | ||
__proto__: null, | ||
apiId: apiId$4, | ||
apiId: apiId$5, | ||
displayName: displayName$5, | ||
description: description$4, | ||
description: description$5, | ||
valueItemApiId: valueItemApiId, | ||
@@ -147,3 +147,3 @@ valueItemDisplayName: valueItemDisplayName, | ||
var apiId$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -186,3 +186,3 @@ test: function test(value) { | ||
var reverseRelationFieldApiId = apiId$3.concat(yup__namespace.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
var reverseRelationFieldApiId = apiId$4.concat(yup__namespace.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
/** | ||
@@ -218,3 +218,3 @@ * Matcher for field display names: | ||
var description$3 = yup__namespace.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$4 = yup__namespace.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var isList = yup__namespace["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
@@ -227,6 +227,6 @@ var isHidden = yup__namespace["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
__proto__: null, | ||
apiId: apiId$3, | ||
apiId: apiId$4, | ||
reverseRelationFieldApiId: reverseRelationFieldApiId, | ||
displayName: displayName$4, | ||
description: description$3, | ||
description: description$4, | ||
isList: isList, | ||
@@ -258,3 +258,3 @@ isHidden: isHidden, | ||
var apiId$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -303,3 +303,3 @@ test: function test(value) { | ||
var description$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var modelId = yup__namespace.string().strict(true); | ||
@@ -313,5 +313,5 @@ var previewURLs = yup__namespace.array().of(yup__namespace.object().shape({ | ||
__proto__: null, | ||
apiId: apiId$2, | ||
apiId: apiId$3, | ||
displayName: displayName$3, | ||
description: description$2, | ||
description: description$3, | ||
modelId: modelId, | ||
@@ -323,5 +323,5 @@ previewURLs: previewURLs | ||
var name$4 = yup__namespace.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var name$5 = yup__namespace.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var region = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true).min(1).oneOf(API_REGIONS, 'The region can only be one of these values: ${values}'); | ||
var description$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).url('The custom prisma endpoint must be a valid url!').test('no-end-with-management', 'The custom prisma endpoint may not end with "/management"', function (value) { | ||
@@ -340,16 +340,16 @@ if (!value) return false; | ||
API_REGIONS: API_REGIONS, | ||
name: name$4, | ||
name: name$5, | ||
region: region, | ||
description: description$1, | ||
description: description$2, | ||
customPrisma: customPrisma | ||
}; | ||
var name$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var role = { | ||
__proto__: null, | ||
name: name$3 | ||
name: name$4 | ||
}; | ||
var name$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var name$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var displayName$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Choose a Display Name.').trim('Display names may not have leading or trailing whitespaces.'); | ||
@@ -359,3 +359,3 @@ | ||
__proto__: null, | ||
name: name$2, | ||
name: name$3, | ||
displayName: displayName$2 | ||
@@ -524,3 +524,3 @@ }; | ||
var name$1 = yup__namespace.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var name$2 = yup__namespace.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
@@ -544,3 +544,3 @@ return !!validUrl.isUri(value); | ||
__proto__: null, | ||
name: name$1, | ||
name: name$2, | ||
url: url, | ||
@@ -552,3 +552,3 @@ headerKey: headerKey, | ||
var apiId$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -567,11 +567,11 @@ test: function test(value) { | ||
__proto__: null, | ||
apiId: apiId$1, | ||
apiId: apiId$2, | ||
displayName: displayName$1 | ||
}; | ||
var name = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var viewGroup = { | ||
__proto__: null, | ||
name: name | ||
name: name$1 | ||
}; | ||
@@ -592,3 +592,3 @@ | ||
var apiId = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -637,3 +637,3 @@ test: function test(value) { | ||
var description = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var componentId = yup__namespace.string().strict(true); | ||
@@ -643,8 +643,101 @@ | ||
__proto__: null, | ||
apiId: apiId, | ||
apiId: apiId$1, | ||
displayName: displayName, | ||
description: description, | ||
description: description$1, | ||
componentId: componentId | ||
}; | ||
var name = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an app may not start or end with white space characters.'); | ||
var apiId = yup__namespace.string().typeError('Invalid').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
test: function test(value) { | ||
return !graphQlTypeNames.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).test({ | ||
name: 'no-reserved-word', | ||
test: function test(value) { | ||
var options = this.options; | ||
if (options.context && options.context.isSystem) { | ||
return true; | ||
} | ||
return !reservedFieldApiIds.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).matches(/^[a-z][a-zA-Z0-9_]*$/, 'Start with a lowercase letter and use only alphanumeric characters and underscores.'); // <-- Those are validations enforced by prisma: https://github.com/graphcool/prisma/blob/master/server/servers/deploy/src/main/scala/com/prisma/deploy/validation/NameConstraints.scala | ||
var description = yup__namespace.string().nullable(true); | ||
var urlSchema = yup__namespace.string().test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
return value != null ? !!validUrl.isUri(value) : true; | ||
}).nullable(true); | ||
var avatarUrl = urlSchema; | ||
var setupUrl = urlSchema; | ||
var webhookUrl = urlSchema; | ||
var configurationUrl = urlSchema; | ||
var CONFIG_TYPE = ['string', 'number', 'boolean']; | ||
var configValueSchema = function configValueSchema() { | ||
return yup__namespace.object({ | ||
type: yup__namespace.string().oneOf([].concat(CONFIG_TYPE)).required(), | ||
displayName: yup__namespace.string().nullable(true), | ||
description: yup__namespace.string().nullable(true), | ||
required: yup__namespace.bool().nullable(true), | ||
defaultValue: yup__namespace.mixed().nullable(true) | ||
}).typeError('${path} must be a valid object'); | ||
}; | ||
var APP_ELEMENT_TYPES = ['field', 'formSidebar']; // TODO: Add Codegen and pick these from schema | ||
var FIELD_ELEMENT_TYPES = ['BOOLEAN', 'COLOR', 'DATE', 'DATETIME', 'FLOAT', 'ID', 'INT', 'JSON', 'LOCATION', 'RICHTEXT', 'STRING']; // and these too | ||
var FIELD_ELEMENT_FEATURES = ['ListRenderer', 'TableRenderer', 'FieldRenderer']; | ||
var element = { | ||
src: urlSchema, | ||
name: name, | ||
type: yup__namespace.string().oneOf([].concat(APP_ELEMENT_TYPES)), | ||
description: yup__namespace.string().nullable(true), | ||
config: yup__namespace.object() // @ts-expect-error | ||
.test('is-valid-config', 'invalid config', function (value) { | ||
var shape = {}; | ||
Object.keys(value).forEach(function (key) { | ||
shape[key] = configValueSchema(); | ||
}); | ||
try { | ||
yup__namespace.object().shape(shape).validateSync(value); | ||
} catch (e) { | ||
if (e instanceof yup__namespace.ValidationError) return e; | ||
} | ||
return true; | ||
}).typeError('${path} must be a valid object'), | ||
fieldType: yup__namespace.string().oneOf([].concat(FIELD_ELEMENT_TYPES)).nullable(true), | ||
features: yup__namespace.array().of(yup__namespace.string().oneOf([].concat(FIELD_ELEMENT_FEATURES))).nullable(true) | ||
}; | ||
var app = { | ||
__proto__: null, | ||
name: name, | ||
apiId: apiId, | ||
description: description, | ||
avatarUrl: avatarUrl, | ||
setupUrl: setupUrl, | ||
webhookUrl: webhookUrl, | ||
configurationUrl: configurationUrl, | ||
CONFIG_TYPE: CONFIG_TYPE, | ||
APP_ELEMENT_TYPES: APP_ELEMENT_TYPES, | ||
FIELD_ELEMENT_TYPES: FIELD_ELEMENT_TYPES, | ||
FIELD_ELEMENT_FEATURES: FIELD_ELEMENT_FEATURES, | ||
element: element | ||
}; | ||
exports.appValidation = app; | ||
exports.authtoken = authtoken; | ||
@@ -651,0 +744,0 @@ exports.component = component; |
import * as yup from 'yup'; | ||
var name$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$5 = yup.string().nullable(true); | ||
var name$6 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$6 = yup.string().nullable(true); | ||
var scope = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).oneOf(['READ', 'WRITE', 'OPEN'], "An authentication token can only be set to one of 'READ', 'WRITE' or 'OPEN'"); | ||
@@ -9,4 +9,4 @@ | ||
__proto__: null, | ||
name: name$5, | ||
description: description$5, | ||
name: name$6, | ||
description: description$6, | ||
scope: scope | ||
@@ -32,3 +32,3 @@ }; | ||
var apiId$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -85,3 +85,3 @@ test: function test(value) { | ||
var description$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
/** | ||
@@ -105,5 +105,5 @@ * Matcher for enumeration api IDs: | ||
__proto__: null, | ||
apiId: apiId$4, | ||
apiId: apiId$5, | ||
displayName: displayName$5, | ||
description: description$4, | ||
description: description$5, | ||
valueItemApiId: valueItemApiId, | ||
@@ -126,3 +126,3 @@ valueItemDisplayName: valueItemDisplayName, | ||
var apiId$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -165,3 +165,3 @@ test: function test(value) { | ||
var reverseRelationFieldApiId = apiId$3.concat(yup.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
var reverseRelationFieldApiId = apiId$4.concat(yup.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
/** | ||
@@ -197,3 +197,3 @@ * Matcher for field display names: | ||
var description$3 = yup.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$4 = yup.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var isList = yup["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
@@ -206,6 +206,6 @@ var isHidden = yup["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
__proto__: null, | ||
apiId: apiId$3, | ||
apiId: apiId$4, | ||
reverseRelationFieldApiId: reverseRelationFieldApiId, | ||
displayName: displayName$4, | ||
description: description$3, | ||
description: description$4, | ||
isList: isList, | ||
@@ -237,3 +237,3 @@ isHidden: isHidden, | ||
var apiId$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -282,3 +282,3 @@ test: function test(value) { | ||
var description$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var modelId = yup.string().strict(true); | ||
@@ -292,5 +292,5 @@ var previewURLs = yup.array().of(yup.object().shape({ | ||
__proto__: null, | ||
apiId: apiId$2, | ||
apiId: apiId$3, | ||
displayName: displayName$3, | ||
description: description$2, | ||
description: description$3, | ||
modelId: modelId, | ||
@@ -302,5 +302,5 @@ previewURLs: previewURLs | ||
var name$4 = yup.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var name$5 = yup.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var region = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true).min(1).oneOf(API_REGIONS, 'The region can only be one of these values: ${values}'); | ||
var description$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).url('The custom prisma endpoint must be a valid url!').test('no-end-with-management', 'The custom prisma endpoint may not end with "/management"', function (value) { | ||
@@ -319,16 +319,16 @@ if (!value) return false; | ||
API_REGIONS: API_REGIONS, | ||
name: name$4, | ||
name: name$5, | ||
region: region, | ||
description: description$1, | ||
description: description$2, | ||
customPrisma: customPrisma | ||
}; | ||
var name$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var role = { | ||
__proto__: null, | ||
name: name$3 | ||
name: name$4 | ||
}; | ||
var name$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var name$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var displayName$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Choose a Display Name.').trim('Display names may not have leading or trailing whitespaces.'); | ||
@@ -338,3 +338,3 @@ | ||
__proto__: null, | ||
name: name$2, | ||
name: name$3, | ||
displayName: displayName$2 | ||
@@ -503,3 +503,3 @@ }; | ||
var name$1 = yup.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var name$2 = yup.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
@@ -523,3 +523,3 @@ return !!validUrl.isUri(value); | ||
__proto__: null, | ||
name: name$1, | ||
name: name$2, | ||
url: url, | ||
@@ -531,3 +531,3 @@ headerKey: headerKey, | ||
var apiId$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -546,11 +546,11 @@ test: function test(value) { | ||
__proto__: null, | ||
apiId: apiId$1, | ||
apiId: apiId$2, | ||
displayName: displayName$1 | ||
}; | ||
var name = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var viewGroup = { | ||
__proto__: null, | ||
name: name | ||
name: name$1 | ||
}; | ||
@@ -571,3 +571,3 @@ | ||
var apiId = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -616,3 +616,3 @@ test: function test(value) { | ||
var description = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var componentId = yup.string().strict(true); | ||
@@ -622,9 +622,101 @@ | ||
__proto__: null, | ||
apiId: apiId, | ||
apiId: apiId$1, | ||
displayName: displayName, | ||
description: description, | ||
description: description$1, | ||
componentId: componentId | ||
}; | ||
export { authtoken, component, enumeration, field, invite, locale, model, project, role, stage, viewGroup, webhook }; | ||
var name = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an app may not start or end with white space characters.'); | ||
var apiId = yup.string().typeError('Invalid').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
test: function test(value) { | ||
return !graphQlTypeNames.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).test({ | ||
name: 'no-reserved-word', | ||
test: function test(value) { | ||
var options = this.options; | ||
if (options.context && options.context.isSystem) { | ||
return true; | ||
} | ||
return !reservedFieldApiIds.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).matches(/^[a-z][a-zA-Z0-9_]*$/, 'Start with a lowercase letter and use only alphanumeric characters and underscores.'); // <-- Those are validations enforced by prisma: https://github.com/graphcool/prisma/blob/master/server/servers/deploy/src/main/scala/com/prisma/deploy/validation/NameConstraints.scala | ||
var description = yup.string().nullable(true); | ||
var urlSchema = yup.string().test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
return value != null ? !!validUrl.isUri(value) : true; | ||
}).nullable(true); | ||
var avatarUrl = urlSchema; | ||
var setupUrl = urlSchema; | ||
var webhookUrl = urlSchema; | ||
var configurationUrl = urlSchema; | ||
var CONFIG_TYPE = ['string', 'number', 'boolean']; | ||
var configValueSchema = function configValueSchema() { | ||
return yup.object({ | ||
type: yup.string().oneOf([].concat(CONFIG_TYPE)).required(), | ||
displayName: yup.string().nullable(true), | ||
description: yup.string().nullable(true), | ||
required: yup.bool().nullable(true), | ||
defaultValue: yup.mixed().nullable(true) | ||
}).typeError('${path} must be a valid object'); | ||
}; | ||
var APP_ELEMENT_TYPES = ['field', 'formSidebar']; // TODO: Add Codegen and pick these from schema | ||
var FIELD_ELEMENT_TYPES = ['BOOLEAN', 'COLOR', 'DATE', 'DATETIME', 'FLOAT', 'ID', 'INT', 'JSON', 'LOCATION', 'RICHTEXT', 'STRING']; // and these too | ||
var FIELD_ELEMENT_FEATURES = ['ListRenderer', 'TableRenderer', 'FieldRenderer']; | ||
var element = { | ||
src: urlSchema, | ||
name: name, | ||
type: yup.string().oneOf([].concat(APP_ELEMENT_TYPES)), | ||
description: yup.string().nullable(true), | ||
config: yup.object() // @ts-expect-error | ||
.test('is-valid-config', 'invalid config', function (value) { | ||
var shape = {}; | ||
Object.keys(value).forEach(function (key) { | ||
shape[key] = configValueSchema(); | ||
}); | ||
try { | ||
yup.object().shape(shape).validateSync(value); | ||
} catch (e) { | ||
if (e instanceof yup.ValidationError) return e; | ||
} | ||
return true; | ||
}).typeError('${path} must be a valid object'), | ||
fieldType: yup.string().oneOf([].concat(FIELD_ELEMENT_TYPES)).nullable(true), | ||
features: yup.array().of(yup.string().oneOf([].concat(FIELD_ELEMENT_FEATURES))).nullable(true) | ||
}; | ||
var app = { | ||
__proto__: null, | ||
name: name, | ||
apiId: apiId, | ||
description: description, | ||
avatarUrl: avatarUrl, | ||
setupUrl: setupUrl, | ||
webhookUrl: webhookUrl, | ||
configurationUrl: configurationUrl, | ||
CONFIG_TYPE: CONFIG_TYPE, | ||
APP_ELEMENT_TYPES: APP_ELEMENT_TYPES, | ||
FIELD_ELEMENT_TYPES: FIELD_ELEMENT_TYPES, | ||
FIELD_ELEMENT_FEATURES: FIELD_ELEMENT_FEATURES, | ||
element: element | ||
}; | ||
export { app as appValidation, authtoken, component, enumeration, field, invite, locale, model, project, role, stage, viewGroup, webhook }; | ||
//# sourceMappingURL=validation.m.js.map |
import * as yup from 'yup'; | ||
const name$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
const description$5 = yup.string().nullable(true); | ||
const name$6 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
const description$6 = yup.string().nullable(true); | ||
const scope = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).oneOf(['READ', 'WRITE', 'OPEN'], "An authentication token can only be set to one of 'READ', 'WRITE' or 'OPEN'"); | ||
@@ -9,4 +9,4 @@ | ||
__proto__: null, | ||
name: name$5, | ||
description: description$5, | ||
name: name$6, | ||
description: description$6, | ||
scope: scope | ||
@@ -32,3 +32,3 @@ }; | ||
const apiId$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
const apiId$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -77,3 +77,3 @@ test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
const description$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
const description$5 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
/** | ||
@@ -97,5 +97,5 @@ * Matcher for enumeration api IDs: | ||
__proto__: null, | ||
apiId: apiId$4, | ||
apiId: apiId$5, | ||
displayName: displayName$5, | ||
description: description$4, | ||
description: description$5, | ||
valueItemApiId: valueItemApiId, | ||
@@ -118,3 +118,3 @@ valueItemDisplayName: valueItemDisplayName, | ||
const apiId$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
const apiId$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -151,3 +151,3 @@ test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
const reverseRelationFieldApiId = apiId$3.concat(yup.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
const reverseRelationFieldApiId = apiId$4.concat(yup.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
/** | ||
@@ -183,3 +183,3 @@ * Matcher for field display names: | ||
const description$3 = yup.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const description$4 = yup.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const isList = yup.boolean().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
@@ -192,6 +192,6 @@ const isHidden = yup.boolean().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
__proto__: null, | ||
apiId: apiId$3, | ||
apiId: apiId$4, | ||
reverseRelationFieldApiId: reverseRelationFieldApiId, | ||
displayName: displayName$4, | ||
description: description$3, | ||
description: description$4, | ||
isList: isList, | ||
@@ -223,3 +223,3 @@ isHidden: isHidden, | ||
const apiId$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
const apiId$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -262,3 +262,3 @@ test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
const description$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const description$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const modelId = yup.string().strict(true); | ||
@@ -272,5 +272,5 @@ const previewURLs = yup.array().of(yup.object().shape({ | ||
__proto__: null, | ||
apiId: apiId$2, | ||
apiId: apiId$3, | ||
displayName: displayName$3, | ||
description: description$2, | ||
description: description$3, | ||
modelId: modelId, | ||
@@ -282,5 +282,5 @@ previewURLs: previewURLs | ||
const name$4 = yup.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
const name$5 = yup.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
const region = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true).min(1).oneOf(API_REGIONS, 'The region can only be one of these values: ${values}'); | ||
const description$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
const description$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
const url$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).url('The custom prisma endpoint must be a valid url!').test('no-end-with-management', 'The custom prisma endpoint may not end with "/management"', value => { | ||
@@ -299,16 +299,16 @@ if (!value) return false; | ||
API_REGIONS: API_REGIONS, | ||
name: name$4, | ||
name: name$5, | ||
region: region, | ||
description: description$1, | ||
description: description$2, | ||
customPrisma: customPrisma | ||
}; | ||
const name$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
const name$4 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var role = { | ||
__proto__: null, | ||
name: name$3 | ||
name: name$4 | ||
}; | ||
const name$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
const name$3 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
const displayName$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Choose a Display Name.').trim('Display names may not have leading or trailing whitespaces.'); | ||
@@ -318,3 +318,3 @@ | ||
__proto__: null, | ||
name: name$2, | ||
name: name$3, | ||
displayName: displayName$2 | ||
@@ -483,3 +483,3 @@ }; | ||
const name$1 = yup.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
const name$2 = yup.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
const url = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).test('is-valid-url', 'Only valid URLs are supported!', value => { | ||
@@ -501,3 +501,3 @@ return !!validUrl.isUri(value); | ||
__proto__: null, | ||
name: name$1, | ||
name: name$2, | ||
url: url, | ||
@@ -509,3 +509,3 @@ headerKey: headerKey, | ||
const apiId$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
const apiId$2 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -520,11 +520,11 @@ test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
__proto__: null, | ||
apiId: apiId$1, | ||
apiId: apiId$2, | ||
displayName: displayName$1 | ||
}; | ||
const name = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
const name$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var viewGroup = { | ||
__proto__: null, | ||
name: name | ||
name: name$1 | ||
}; | ||
@@ -545,3 +545,3 @@ | ||
const apiId = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
const apiId$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -584,3 +584,3 @@ test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
const description = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const description$1 = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
const componentId = yup.string().strict(true); | ||
@@ -590,9 +590,93 @@ | ||
__proto__: null, | ||
apiId: apiId, | ||
apiId: apiId$1, | ||
displayName: displayName, | ||
description: description, | ||
description: description$1, | ||
componentId: componentId | ||
}; | ||
export { authtoken, component, enumeration, field, invite, locale, model, project, role, stage, viewGroup, webhook }; | ||
const name = yup.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an app may not start or end with white space characters.'); | ||
const apiId = yup.string().typeError('Invalid').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
test: value => !graphQlTypeNames.some(reservedWord => value ? reservedWord === value.toLowerCase() : false), | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).test({ | ||
name: 'no-reserved-word', | ||
test: function (value) { | ||
const options = this.options; | ||
if (options.context && options.context.isSystem) { | ||
return true; | ||
} | ||
return !reservedFieldApiIds.some(reservedWord => value ? reservedWord === value.toLowerCase() : false); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).matches(/^[a-z][a-zA-Z0-9_]*$/, 'Start with a lowercase letter and use only alphanumeric characters and underscores.'); // <-- Those are validations enforced by prisma: https://github.com/graphcool/prisma/blob/master/server/servers/deploy/src/main/scala/com/prisma/deploy/validation/NameConstraints.scala | ||
const description = yup.string().nullable(true); | ||
const urlSchema = yup.string().test('is-valid-url', 'Only valid URLs are supported!', value => { | ||
return value != null ? !!validUrl.isUri(value) : true; | ||
}).nullable(true); | ||
const avatarUrl = urlSchema; | ||
const setupUrl = urlSchema; | ||
const webhookUrl = urlSchema; | ||
const configurationUrl = urlSchema; | ||
const CONFIG_TYPE = ['string', 'number', 'boolean']; | ||
const configValueSchema = () => yup.object({ | ||
type: yup.string().oneOf([...CONFIG_TYPE]).required(), | ||
displayName: yup.string().nullable(true), | ||
description: yup.string().nullable(true), | ||
required: yup.bool().nullable(true), | ||
defaultValue: yup.mixed().nullable(true) | ||
}).typeError('${path} must be a valid object'); | ||
const APP_ELEMENT_TYPES = ['field', 'formSidebar']; // TODO: Add Codegen and pick these from schema | ||
const FIELD_ELEMENT_TYPES = ['BOOLEAN', 'COLOR', 'DATE', 'DATETIME', 'FLOAT', 'ID', 'INT', 'JSON', 'LOCATION', 'RICHTEXT', 'STRING']; // and these too | ||
const FIELD_ELEMENT_FEATURES = ['ListRenderer', 'TableRenderer', 'FieldRenderer']; | ||
const element = { | ||
src: urlSchema, | ||
name: name, | ||
type: yup.string().oneOf([...APP_ELEMENT_TYPES]), | ||
description: yup.string().nullable(true), | ||
config: yup.object() // @ts-expect-error | ||
.test('is-valid-config', 'invalid config', value => { | ||
const shape = {}; | ||
Object.keys(value).forEach(key => { | ||
shape[key] = configValueSchema(); | ||
}); | ||
try { | ||
yup.object().shape(shape).validateSync(value); | ||
} catch (e) { | ||
if (e instanceof yup.ValidationError) return e; | ||
} | ||
return true; | ||
}).typeError('${path} must be a valid object'), | ||
fieldType: yup.string().oneOf([...FIELD_ELEMENT_TYPES]).nullable(true), | ||
features: yup.array().of(yup.string().oneOf([...FIELD_ELEMENT_FEATURES])).nullable(true) | ||
}; | ||
var app = { | ||
__proto__: null, | ||
name: name, | ||
apiId: apiId, | ||
description: description, | ||
avatarUrl: avatarUrl, | ||
setupUrl: setupUrl, | ||
webhookUrl: webhookUrl, | ||
configurationUrl: configurationUrl, | ||
CONFIG_TYPE: CONFIG_TYPE, | ||
APP_ELEMENT_TYPES: APP_ELEMENT_TYPES, | ||
FIELD_ELEMENT_TYPES: FIELD_ELEMENT_TYPES, | ||
FIELD_ELEMENT_FEATURES: FIELD_ELEMENT_FEATURES, | ||
element: element | ||
}; | ||
export { app as appValidation, authtoken, component, enumeration, field, invite, locale, model, project, role, stage, viewGroup, webhook }; | ||
//# sourceMappingURL=validation.modern.js.map |
@@ -26,4 +26,4 @@ (function (global, factory) { | ||
var name$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$5 = yup__namespace.string().nullable(true); | ||
var name$6 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an authentication token may not start or end with white space characters.'); | ||
var description$6 = yup__namespace.string().nullable(true); | ||
var scope = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).oneOf(['READ', 'WRITE', 'OPEN'], "An authentication token can only be set to one of 'READ', 'WRITE' or 'OPEN'"); | ||
@@ -33,4 +33,4 @@ | ||
__proto__: null, | ||
name: name$5, | ||
description: description$5, | ||
name: name$6, | ||
description: description$6, | ||
scope: scope | ||
@@ -56,3 +56,3 @@ }; | ||
var apiId$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -109,3 +109,3 @@ test: function test(value) { | ||
var description$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$5 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
/** | ||
@@ -129,5 +129,5 @@ * Matcher for enumeration api IDs: | ||
__proto__: null, | ||
apiId: apiId$4, | ||
apiId: apiId$5, | ||
displayName: displayName$5, | ||
description: description$4, | ||
description: description$5, | ||
valueItemApiId: valueItemApiId, | ||
@@ -150,3 +150,3 @@ valueItemDisplayName: valueItemDisplayName, | ||
var apiId$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -189,3 +189,3 @@ test: function test(value) { | ||
var reverseRelationFieldApiId = apiId$3.concat(yup__namespace.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
var reverseRelationFieldApiId = apiId$4.concat(yup__namespace.string().max(64, 'The API ID of a field may not exceed 64 characters.')); | ||
/** | ||
@@ -221,3 +221,3 @@ * Matcher for field display names: | ||
var description$3 = yup__namespace.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$4 = yup__namespace.string().nullable(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var isList = yup__namespace["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
@@ -230,6 +230,6 @@ var isHidden = yup__namespace["boolean"]().strict(true).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "boolean"!'); | ||
__proto__: null, | ||
apiId: apiId$3, | ||
apiId: apiId$4, | ||
reverseRelationFieldApiId: reverseRelationFieldApiId, | ||
displayName: displayName$4, | ||
description: description$3, | ||
description: description$4, | ||
isList: isList, | ||
@@ -261,3 +261,3 @@ isHidden: isHidden, | ||
var apiId$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -306,3 +306,3 @@ test: function test(value) { | ||
var description$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var modelId = yup__namespace.string().strict(true); | ||
@@ -316,5 +316,5 @@ var previewURLs = yup__namespace.array().of(yup__namespace.object().shape({ | ||
__proto__: null, | ||
apiId: apiId$2, | ||
apiId: apiId$3, | ||
displayName: displayName$3, | ||
description: description$2, | ||
description: description$3, | ||
modelId: modelId, | ||
@@ -326,5 +326,5 @@ previewURLs: previewURLs | ||
var name$4 = yup__namespace.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var name$5 = yup__namespace.string().min(1, 'Enter a Name').typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true); | ||
var region = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).strict(true).min(1).oneOf(API_REGIONS, 'The region can only be one of these values: ${values}'); | ||
var description$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var description$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).url('The custom prisma endpoint must be a valid url!').test('no-end-with-management', 'The custom prisma endpoint may not end with "/management"', function (value) { | ||
@@ -343,16 +343,16 @@ if (!value) return false; | ||
API_REGIONS: API_REGIONS, | ||
name: name$4, | ||
name: name$5, | ||
region: region, | ||
description: description$1, | ||
description: description$2, | ||
customPrisma: customPrisma | ||
}; | ||
var name$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$4 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The role name may not start or end with whitespace characters.').min(1, 'Choose a name for this role.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var role = { | ||
__proto__: null, | ||
name: name$3 | ||
name: name$4 | ||
}; | ||
var name$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var name$3 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The name of a stage may not start or end with whitespace characters!').min(1, 'Enter a Name.').max(32, 'Choose a name that is shorter than 32 letters.').matches(new RegExp('^[a-zA-Z][a-zA-Z0-9_]*$'), 'Start with a letter, and use only alphanumeric characters and "_".'); | ||
var displayName$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Choose a Display Name.').trim('Display names may not have leading or trailing whitespaces.'); | ||
@@ -362,3 +362,3 @@ | ||
__proto__: null, | ||
name: name$2, | ||
name: name$3, | ||
displayName: displayName$2 | ||
@@ -527,3 +527,3 @@ }; | ||
var name$1 = yup__namespace.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var name$2 = yup__namespace.string().min(1).nullable(false).typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!'); | ||
var url = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').nullable(false).test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
@@ -547,3 +547,3 @@ return !!validUrl.isUri(value); | ||
__proto__: null, | ||
name: name$1, | ||
name: name$2, | ||
url: url, | ||
@@ -555,3 +555,3 @@ headerKey: headerKey, | ||
var apiId$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$2 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -570,11 +570,11 @@ test: function test(value) { | ||
__proto__: null, | ||
apiId: apiId$1, | ||
apiId: apiId$2, | ||
displayName: displayName$1 | ||
}; | ||
var name = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var name$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).trim('The view group name may not start or end with whitespace characters.').min(1, 'Choose a name for this view group.').max(32, 'Choose an name that is shorter than 32 characters.'); | ||
var viewGroup = { | ||
__proto__: null, | ||
name: name | ||
name: name$1 | ||
}; | ||
@@ -595,3 +595,3 @@ | ||
var apiId = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
var apiId$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1, 'Enter an Api ID.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
@@ -640,3 +640,3 @@ test: function test(value) { | ||
var description = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var description$1 = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').ensure(); | ||
var componentId = yup__namespace.string().strict(true); | ||
@@ -646,8 +646,101 @@ | ||
__proto__: null, | ||
apiId: apiId, | ||
apiId: apiId$1, | ||
displayName: displayName, | ||
description: description, | ||
description: description$1, | ||
componentId: componentId | ||
}; | ||
var name = yup__namespace.string().typeError('The supplied value "${value}" of type "${type}" is not compatible with type "string"!').strict(true).min(1).ensure().trim('The name of an app may not start or end with white space characters.'); | ||
var apiId = yup__namespace.string().typeError('Invalid').strict(true).min(1, 'Enter an Api Id.').max(64, 'Use an Api Id that is shorter than 64 characters.').test({ | ||
name: 'no-graphql-type', | ||
test: function test(value) { | ||
return !graphQlTypeNames.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).test({ | ||
name: 'no-reserved-word', | ||
test: function test(value) { | ||
var options = this.options; | ||
if (options.context && options.context.isSystem) { | ||
return true; | ||
} | ||
return !reservedFieldApiIds.some(function (reservedWord) { | ||
return value ? reservedWord === value.toLowerCase() : false; | ||
}); | ||
}, | ||
message: '"${value}" is a restricted word and cannot be used here.', | ||
exclusive: false | ||
}).matches(/^[a-z][a-zA-Z0-9_]*$/, 'Start with a lowercase letter and use only alphanumeric characters and underscores.'); // <-- Those are validations enforced by prisma: https://github.com/graphcool/prisma/blob/master/server/servers/deploy/src/main/scala/com/prisma/deploy/validation/NameConstraints.scala | ||
var description = yup__namespace.string().nullable(true); | ||
var urlSchema = yup__namespace.string().test('is-valid-url', 'Only valid URLs are supported!', function (value) { | ||
return value != null ? !!validUrl.isUri(value) : true; | ||
}).nullable(true); | ||
var avatarUrl = urlSchema; | ||
var setupUrl = urlSchema; | ||
var webhookUrl = urlSchema; | ||
var configurationUrl = urlSchema; | ||
var CONFIG_TYPE = ['string', 'number', 'boolean']; | ||
var configValueSchema = function configValueSchema() { | ||
return yup__namespace.object({ | ||
type: yup__namespace.string().oneOf([].concat(CONFIG_TYPE)).required(), | ||
displayName: yup__namespace.string().nullable(true), | ||
description: yup__namespace.string().nullable(true), | ||
required: yup__namespace.bool().nullable(true), | ||
defaultValue: yup__namespace.mixed().nullable(true) | ||
}).typeError('${path} must be a valid object'); | ||
}; | ||
var APP_ELEMENT_TYPES = ['field', 'formSidebar']; // TODO: Add Codegen and pick these from schema | ||
var FIELD_ELEMENT_TYPES = ['BOOLEAN', 'COLOR', 'DATE', 'DATETIME', 'FLOAT', 'ID', 'INT', 'JSON', 'LOCATION', 'RICHTEXT', 'STRING']; // and these too | ||
var FIELD_ELEMENT_FEATURES = ['ListRenderer', 'TableRenderer', 'FieldRenderer']; | ||
var element = { | ||
src: urlSchema, | ||
name: name, | ||
type: yup__namespace.string().oneOf([].concat(APP_ELEMENT_TYPES)), | ||
description: yup__namespace.string().nullable(true), | ||
config: yup__namespace.object() // @ts-expect-error | ||
.test('is-valid-config', 'invalid config', function (value) { | ||
var shape = {}; | ||
Object.keys(value).forEach(function (key) { | ||
shape[key] = configValueSchema(); | ||
}); | ||
try { | ||
yup__namespace.object().shape(shape).validateSync(value); | ||
} catch (e) { | ||
if (e instanceof yup__namespace.ValidationError) return e; | ||
} | ||
return true; | ||
}).typeError('${path} must be a valid object'), | ||
fieldType: yup__namespace.string().oneOf([].concat(FIELD_ELEMENT_TYPES)).nullable(true), | ||
features: yup__namespace.array().of(yup__namespace.string().oneOf([].concat(FIELD_ELEMENT_FEATURES))).nullable(true) | ||
}; | ||
var app = { | ||
__proto__: null, | ||
name: name, | ||
apiId: apiId, | ||
description: description, | ||
avatarUrl: avatarUrl, | ||
setupUrl: setupUrl, | ||
webhookUrl: webhookUrl, | ||
configurationUrl: configurationUrl, | ||
CONFIG_TYPE: CONFIG_TYPE, | ||
APP_ELEMENT_TYPES: APP_ELEMENT_TYPES, | ||
FIELD_ELEMENT_TYPES: FIELD_ELEMENT_TYPES, | ||
FIELD_ELEMENT_FEATURES: FIELD_ELEMENT_FEATURES, | ||
element: element | ||
}; | ||
exports.appValidation = app; | ||
exports.authtoken = authtoken; | ||
@@ -654,0 +747,0 @@ exports.component = component; |
{ | ||
"name": "@graphcms/validation", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"main": "dist/validation.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
363142
32
2755