fix: Switch to Tailwind v3 - v4 incompatible with Astro
This commit is contained in:
37
node_modules/@zeit/schemas/.editorconfig
generated
vendored
Normal file
37
node_modules/@zeit/schemas/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{*.json,*.json.example,*.gyp,*.yml,*.yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[{*.py,*.asm}]
|
||||
indent_style = space
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[*.asm]
|
||||
indent_size = 8
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
# Ideal settings - some plugins might support these.
|
||||
[*.js]
|
||||
quote_type = single
|
||||
|
||||
[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}]
|
||||
curly_bracket_next_line = false
|
||||
spaces_around_operators = true
|
||||
spaces_around_brackets = outside
|
||||
# close enough to 1TB
|
||||
indent_brace_style = K&R
|
||||
23
node_modules/@zeit/schemas/.github/workflows/ci.yaml
generated
vendored
Normal file
23
node_modules/@zeit/schemas/.github/workflows/ci.yaml
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- uses: actions/setup-node@v3
|
||||
timeout-minutes: 5 # See https://github.com/actions/cache/issues/810
|
||||
with:
|
||||
cache: 'yarn'
|
||||
|
||||
- run: yarn install --network-timeout 1000000 --frozen-lockfile
|
||||
- run: yarn test
|
||||
24
node_modules/@zeit/schemas/.github/workflows/publish.yaml
generated
vendored
Normal file
24
node_modules/@zeit/schemas/.github/workflows/publish.yaml
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Publish Package
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
timeout-minutes: 5 # See https://github.com/actions/cache/issues/810
|
||||
with:
|
||||
cache: 'yarn'
|
||||
node-version: '18.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- run: yarn install --network-timeout 1000000 --frozen-lockfile
|
||||
- run: yarn test
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
|
||||
1
node_modules/@zeit/schemas/.yarnrc
generated
vendored
Normal file
1
node_modules/@zeit/schemas/.yarnrc
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
save-prefix ""
|
||||
21
node_modules/@zeit/schemas/LICENSE
generated
vendored
Normal file
21
node_modules/@zeit/schemas/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 ZEIT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
35
node_modules/@zeit/schemas/README.md
generated
vendored
Normal file
35
node_modules/@zeit/schemas/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Vercel Schemas
|
||||
|
||||
Schemas used across many Vercel packages to validating config files, requests to APIs, and more.
|
||||
|
||||
## Why?
|
||||
|
||||
- Keep schemas used across Vercel projects in sync
|
||||
- We use `.js` instead of `.json` because parsing JSON takes longer
|
||||
|
||||
## Usage
|
||||
|
||||
To get started, pick one of the schemas in this repository and load it:
|
||||
|
||||
```js
|
||||
const schema = require('@zeit/schemas/deployment/config');
|
||||
```
|
||||
|
||||
Next, set up [AJV](https://github.com/epoberezkin/ajv) (the validator) and run the schema through it:
|
||||
|
||||
```js
|
||||
const AJV = require('ajv');
|
||||
|
||||
const ajv = new AJV({ allErrors: true });
|
||||
const isValid = ajv.validate(schema, <object-to-validate>);
|
||||
|
||||
if (!isValid) {
|
||||
console.error(`The following entries are wrong: ${JSON.stringify(ajv.errors)}`);
|
||||
}
|
||||
```
|
||||
|
||||
That is all! :tada:
|
||||
|
||||
## Contributing
|
||||
|
||||
We are currently not accepting external contributions for this repository.
|
||||
41
node_modules/@zeit/schemas/deployment/config-env.js
generated
vendored
Normal file
41
node_modules/@zeit/schemas/deployment/config-env.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
const maxEnvLength = 100;
|
||||
|
||||
const EnvKey = {
|
||||
type: 'string',
|
||||
pattern: '^[A-z0-9_]+$',
|
||||
minLength: 1,
|
||||
maxLength: 256
|
||||
};
|
||||
|
||||
const EnvKeys = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: maxEnvLength,
|
||||
uniqueItems: true,
|
||||
items: EnvKey,
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const EnvValue = {
|
||||
type: 'string',
|
||||
minLength: 0,
|
||||
maxLength: 65536
|
||||
};
|
||||
|
||||
// { 'FOO': 'BAR' }
|
||||
const EnvObject = {
|
||||
type: 'object',
|
||||
minProperties: 0,
|
||||
maxProperties: maxEnvLength,
|
||||
patternProperties: {
|
||||
'.+': EnvValue
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
EnvKey,
|
||||
EnvKeys,
|
||||
EnvValue,
|
||||
EnvObject
|
||||
};
|
||||
82
node_modules/@zeit/schemas/deployment/config-static.js
generated
vendored
Normal file
82
node_modules/@zeit/schemas/deployment/config-static.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
module.exports = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
'public': {
|
||||
type: 'string'
|
||||
},
|
||||
'cleanUrls': {
|
||||
type: [
|
||||
'boolean',
|
||||
'array'
|
||||
]
|
||||
},
|
||||
'rewrites': {
|
||||
type: 'array'
|
||||
},
|
||||
'redirects': {
|
||||
type: 'array'
|
||||
},
|
||||
'headers': {
|
||||
type: 'array',
|
||||
maxItems: 50,
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['source', 'headers'],
|
||||
properties: {
|
||||
source: {
|
||||
type: 'string',
|
||||
maxLength: 100,
|
||||
minLength: 1
|
||||
},
|
||||
headers: {
|
||||
type: 'array',
|
||||
maxItems: 50,
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['key', 'value'],
|
||||
properties: {
|
||||
key: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 128,
|
||||
pattern: "^[a-zA-Z0-9_!#$%&'*+.^`|~-]+$"
|
||||
},
|
||||
value: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 2048,
|
||||
pattern: '^[\u0020-\u007e\u00a0-\u00ff]+$'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
'directoryListing': {
|
||||
type: [
|
||||
'boolean',
|
||||
'array'
|
||||
]
|
||||
},
|
||||
'unlisted': {
|
||||
type: 'array'
|
||||
},
|
||||
'trailingSlash': {
|
||||
type: 'boolean'
|
||||
},
|
||||
'renderSingle': {
|
||||
type: 'boolean'
|
||||
},
|
||||
'symlinks': {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
170
node_modules/@zeit/schemas/deployment/config.js
generated
vendored
Normal file
170
node_modules/@zeit/schemas/deployment/config.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
const {Service} = require('./service');
|
||||
const {EnvKeys, EnvObject} = require('./config-env');
|
||||
const staticSchema = require('./config-static');
|
||||
|
||||
module.exports = {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
dependencies: {
|
||||
slot: {
|
||||
type: 'object',
|
||||
required: ['features'],
|
||||
properties: {
|
||||
features: {
|
||||
type: 'object',
|
||||
required: ['cloud'],
|
||||
properties: {
|
||||
cloud: {
|
||||
'const': 'v2'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
properties: {
|
||||
'name': {
|
||||
type: 'string',
|
||||
minLength: 1
|
||||
},
|
||||
'project': {
|
||||
type: 'string',
|
||||
minLength: 1
|
||||
},
|
||||
'alias': {
|
||||
type: [
|
||||
'string',
|
||||
'array'
|
||||
]
|
||||
},
|
||||
'env': { anyOf: [EnvObject, EnvKeys] },
|
||||
'build': {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
env: EnvObject
|
||||
}
|
||||
},
|
||||
'scale': {
|
||||
type: 'object',
|
||||
patternProperties: {
|
||||
'.+': {
|
||||
'type': 'object',
|
||||
'required': ['max', 'min'],
|
||||
'properties': {
|
||||
max: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'number',
|
||||
minimum: 1
|
||||
},
|
||||
{'const': 'auto'}
|
||||
]
|
||||
},
|
||||
min: {
|
||||
type: 'number',
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
'if': {
|
||||
properties: {
|
||||
max: {
|
||||
type: 'number'
|
||||
}
|
||||
}
|
||||
},
|
||||
'then': {
|
||||
properties: {
|
||||
min: {
|
||||
maximum: {
|
||||
$data: '1/max'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
'regions': {
|
||||
type: 'array'
|
||||
},
|
||||
'dotenv': {
|
||||
type: [
|
||||
'boolean',
|
||||
'string'
|
||||
]
|
||||
},
|
||||
'files': {
|
||||
type: 'array'
|
||||
},
|
||||
'type': {
|
||||
type: 'string'
|
||||
},
|
||||
'forwardNpm': {
|
||||
type: 'boolean'
|
||||
},
|
||||
'public': {
|
||||
type: 'boolean'
|
||||
},
|
||||
'engines': {
|
||||
type: 'object'
|
||||
},
|
||||
'api': {
|
||||
type: 'string'
|
||||
},
|
||||
'static': staticSchema,
|
||||
'limits': {
|
||||
type: 'object',
|
||||
properties: {
|
||||
duration: {
|
||||
type: 'number',
|
||||
minimum: 60000,
|
||||
maximum: 60000 * 15 // max 15m runtime
|
||||
},
|
||||
maxConcurrentReqs: {
|
||||
type: 'number',
|
||||
minimum: 1,
|
||||
maximum: 256
|
||||
},
|
||||
timeout: {
|
||||
type: 'number',
|
||||
minimum: 60000,
|
||||
maximum: 60000 * 15 // max duration
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
'features': {
|
||||
type: 'object',
|
||||
patternProperties: {
|
||||
'.*': {
|
||||
type: ['string', 'number', 'boolean']
|
||||
}
|
||||
}
|
||||
},
|
||||
'github': {
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: {
|
||||
type: 'boolean'
|
||||
},
|
||||
autoAlias: {
|
||||
type: 'boolean'
|
||||
},
|
||||
autoJobCancelation: {
|
||||
type: 'boolean'
|
||||
},
|
||||
silent: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
'slot': {
|
||||
type: 'string',
|
||||
pattern: 'c.125-m512|c1-m4096|staging-*'
|
||||
},
|
||||
'service': Service
|
||||
}
|
||||
};
|
||||
15
node_modules/@zeit/schemas/deployment/service.js
generated
vendored
Normal file
15
node_modules/@zeit/schemas/deployment/service.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
const Service = {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
port: {
|
||||
type: 'number',
|
||||
minimum: 1,
|
||||
maximum: 32767
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
Service
|
||||
};
|
||||
28
node_modules/@zeit/schemas/package.json
generated
vendored
Normal file
28
node_modules/@zeit/schemas/package.json
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@zeit/schemas",
|
||||
"version": "2.36.0",
|
||||
"description": "All schemas used for validation that are shared between our projects",
|
||||
"scripts": {
|
||||
"test": "yarn run lint && best --verbose",
|
||||
"lint": "zeit-eslint --ext .jsx,.js .",
|
||||
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint"
|
||||
},
|
||||
"repository": "zeit/schemas",
|
||||
"author": "leo",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@zeit/best": "0.4.3",
|
||||
"@zeit/eslint-config-node": "0.3.0",
|
||||
"@zeit/git-hooks": "0.1.4",
|
||||
"ajv": "6.5.1",
|
||||
"eslint": "4.19.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"@zeit/eslint-config-node"
|
||||
]
|
||||
},
|
||||
"git": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
}
|
||||
88
node_modules/@zeit/schemas/test/deployment-env.js
generated
vendored
Normal file
88
node_modules/@zeit/schemas/test/deployment-env.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/* eslint camelcase: 0 */
|
||||
const AJV = require('ajv');
|
||||
const assert = require('assert');
|
||||
const {
|
||||
EnvKeys,
|
||||
EnvObject
|
||||
} = require('../deployment/config-env');
|
||||
|
||||
const ajv = new AJV({allErrors: true});
|
||||
|
||||
// EnvKeys
|
||||
exports.test_env_keys_valid = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
'BAR'
|
||||
]);
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_env_keys_too_short = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
''
|
||||
]);
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'minLength');
|
||||
};
|
||||
|
||||
exports.test_env_keys_too_long = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
'A'.repeat(257)
|
||||
]);
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'maxLength');
|
||||
};
|
||||
|
||||
exports.test_env_keys_invalid_chars = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
'BA,D'
|
||||
]);
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'pattern');
|
||||
};
|
||||
|
||||
exports.test_env_keys_invalid_type = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
true
|
||||
]);
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'type');
|
||||
};
|
||||
|
||||
exports.test_env_keys_non_unique = () => {
|
||||
const isValid = ajv.validate(EnvKeys, [
|
||||
'FOO',
|
||||
'FOO'
|
||||
]);
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'uniqueItems');
|
||||
};
|
||||
|
||||
// EnvObject
|
||||
exports.test_env_object_valid = () => {
|
||||
const isValid = ajv.validate(EnvObject, {
|
||||
FOO: 'BAR',
|
||||
BAZ: '@secret'
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_env_object_bad_type = () => {
|
||||
const isValid = ajv.validate(EnvObject, {
|
||||
FOO: true
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'type');
|
||||
};
|
||||
|
||||
exports.test_env_object_too_long = () => {
|
||||
const isValid = ajv.validate(EnvObject, {
|
||||
FOO: 'a'.repeat(70000)
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors[0].keyword, 'maxLength');
|
||||
};
|
||||
404
node_modules/@zeit/schemas/test/deployment.js
generated
vendored
Normal file
404
node_modules/@zeit/schemas/test/deployment.js
generated
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
/* eslint camelcase: 0 */
|
||||
const AJV = require('ajv');
|
||||
const assert = require('assert');
|
||||
const deploymentConfigSchema = require('../deployment/config');
|
||||
|
||||
const ajv = new AJV({allErrors: true, $data: true});
|
||||
|
||||
exports.test_unknown_keys = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
foo: 1,
|
||||
bar: 2
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 2);
|
||||
['foo', 'bar'].forEach((prop, i) => {
|
||||
const error = ajv.errors[i];
|
||||
assert.equal(error.keyword, 'additionalProperties');
|
||||
assert.equal(error.params.additionalProperty, prop);
|
||||
});
|
||||
};
|
||||
|
||||
exports.test_features_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
features: {
|
||||
foo: 'v2',
|
||||
bar: 2
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_slot_key = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
features: {
|
||||
cloud: 'v2'
|
||||
},
|
||||
slot: 'c.125-m512'
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_staging_slot_key = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
features: {
|
||||
cloud: 'v2'
|
||||
},
|
||||
slot: 'staging-c.5-t1-w-m1024'
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_invalid_slot_key = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
features: {
|
||||
cloud: 'v2'
|
||||
},
|
||||
slot: 'invalid-key'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_slot_key_without_cloud_v2 = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
slot: 'c.125-m512'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_invalid_features_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
features: {
|
||||
foo: []
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_features_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
limits: {
|
||||
duration: 60000,
|
||||
maxConcurrentReqs: 2,
|
||||
timeout: 60000 * 2
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_invalid_limits_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
limits: {
|
||||
foo: []
|
||||
}
|
||||
});
|
||||
assert.equal(!isValid, true);
|
||||
};
|
||||
|
||||
exports.test_valid_env_types = () => {
|
||||
let isValid = ajv.validate(deploymentConfigSchema, {
|
||||
env: {
|
||||
VALID: '1'
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
|
||||
isValid = ajv.validate(deploymentConfigSchema, {
|
||||
env: [
|
||||
'VALID'
|
||||
]
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_invalid_env_types = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
env: {
|
||||
INVALID: true
|
||||
}
|
||||
});
|
||||
assert.equal(!isValid, true);
|
||||
};
|
||||
|
||||
exports.test_valid_build_env_types = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
build: {
|
||||
env: {
|
||||
VALID: '1'
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_invalid_build_env_types = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
build: {
|
||||
env: {
|
||||
INVALID: true
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(!isValid, true);
|
||||
};
|
||||
|
||||
exports.test_invalid_static_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
foo: []
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_valid_static_headers_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
headers: [
|
||||
{
|
||||
source: '/_next/webpack/chunks/*',
|
||||
headers: [{
|
||||
key: 'Cache-Control',
|
||||
value: 'adssds'
|
||||
}]
|
||||
},
|
||||
{
|
||||
source: '/_next/static/commons/**',
|
||||
headers: [{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable'
|
||||
}]
|
||||
},
|
||||
{
|
||||
source: '/_next/*/page/**/*.js',
|
||||
headers: [{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable'
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(isValid, true);
|
||||
|
||||
for (let i = 0x20; i <= 0xff; i++) {
|
||||
if (i > 0x7e && i < 0xa0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const result = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
headers: [
|
||||
{
|
||||
source: '/',
|
||||
headers: [{
|
||||
key: 'X-Test',
|
||||
value: `value ${String.fromCharCode(i)}`
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(result, true, `Failed to validate for char: 0x${i.toString(16)}`);
|
||||
}
|
||||
};
|
||||
|
||||
exports.test_invalid_static_headers_object = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
headers: [
|
||||
{
|
||||
source: '/_next/webpack/chunks/*',
|
||||
headers: [{
|
||||
key: ':alternate-protocol',
|
||||
value: 'foo\x00bar'
|
||||
}]
|
||||
},
|
||||
{
|
||||
source: '/_next/static/commons/**',
|
||||
headers: [{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable'
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(isValid, false);
|
||||
|
||||
// Use 256 to go above 0xff
|
||||
for (let i = 0; i <= 256; i++) {
|
||||
if ((i >= 0x20 && i <= 0x7e) || (i >= 0xa0 && i <= 0xff)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const result = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
headers: {
|
||||
source: '/',
|
||||
headers: [{
|
||||
key: 'X-Test',
|
||||
value: `value ${String.fromCharCode(i)}`
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(result, false, `Failed to error for char: 0x${i.toString(16)}`);
|
||||
}
|
||||
};
|
||||
|
||||
exports.test_valid_static_object_trailing_slash = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
trailingSlash: true
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_valid_static_object_invalid_prop = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
'static': {
|
||||
trailingSlash: []
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_project = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
project: 'cool-project'
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_github_enabled = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
github: {
|
||||
enabled: false
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_github_silent = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
github: {
|
||||
silent: true
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_github_auto_alias = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
github: {
|
||||
autoAlias: false
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_github_auto_job_cancelation = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
github: {
|
||||
autoJobCancelation: false
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_github_additional_field = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
github: {
|
||||
abc: 'bbc'
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_scale_sfo1 = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
scale: {
|
||||
sfo1: {
|
||||
min: 0,
|
||||
max: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_scale_all = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
scale: {
|
||||
all: {
|
||||
min: 0,
|
||||
max: 'auto'
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_scale_invalid = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
scale: {
|
||||
foo: {
|
||||
min: -1,
|
||||
max: 'auto'
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_scale_invalid_min = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
scale: {
|
||||
foo: {
|
||||
min: 2,
|
||||
max: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_service_invalid = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
service: 'foo'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_service_port_valid = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
service: {
|
||||
port: 80
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, true);
|
||||
};
|
||||
|
||||
exports.test_service_port_invalid = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
service: {
|
||||
port: 0
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_service_port_invalid_type = () => {
|
||||
const isValid = ajv.validate(deploymentConfigSchema, {
|
||||
service: {
|
||||
port: '3000'
|
||||
}
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
418
node_modules/@zeit/schemas/test/user.js
generated
vendored
Normal file
418
node_modules/@zeit/schemas/test/user.js
generated
vendored
Normal file
@@ -0,0 +1,418 @@
|
||||
/* eslint camelcase: 0 */
|
||||
const AJV = require('ajv');
|
||||
const assert = require('assert');
|
||||
const { User } = require('../user');
|
||||
|
||||
const ajv = new AJV({ allErrors: true });
|
||||
|
||||
// Username
|
||||
exports.test_username_null = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
username: null
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.username');
|
||||
assert.equal(ajv.errors[0].message, 'should be string');
|
||||
};
|
||||
|
||||
exports.test_username_invalid_pattern = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
username: '!!!'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.username');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_username_too_short = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
username: ''
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 2);
|
||||
assert.equal(ajv.errors[0].dataPath, '.username');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be shorter than 1 characters'
|
||||
);
|
||||
assert.equal(ajv.errors[1].dataPath, '.username');
|
||||
assert.equal(
|
||||
ajv.errors[1].message,
|
||||
'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_username_too_long = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
username: 'a'.repeat(50)
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.username');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be longer than 48 characters'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_username_valid = () => {
|
||||
assert(ajv.validate(User, { username: 'n8' }));
|
||||
assert(ajv.validate(User, { username: 'rauchg' }));
|
||||
};
|
||||
|
||||
// Name
|
||||
exports.test_name_too_short = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
name: ''
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.name');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be shorter than 1 characters'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_name_too_long = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
name: 'a'.repeat(50)
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.name');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be longer than 32 characters'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_name_valid = () => {
|
||||
assert(ajv.validate(User, { name: 'Nate' }));
|
||||
};
|
||||
|
||||
// BillingChecked
|
||||
exports.test_billing_checked_null = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
billingChecked: null
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.billingChecked');
|
||||
assert.equal(ajv.errors[0].message, 'should be boolean');
|
||||
};
|
||||
|
||||
exports.test_billing_checked_valid = () => {
|
||||
assert(ajv.validate(User, { billingChecked: true }));
|
||||
};
|
||||
|
||||
// Avatar
|
||||
exports.test_avatar_too_short = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
avatar: 'abc'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.avatar');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be shorter than 40 characters'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_avatar_too_long = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
avatar: 'a'.repeat(50)
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.avatar');
|
||||
assert.equal(
|
||||
ajv.errors[0].message,
|
||||
'should NOT be longer than 40 characters'
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_avatar_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
avatar: 'n'.repeat(40)
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
assert.equal(ajv.errors.length, 1);
|
||||
assert.equal(ajv.errors[0].dataPath, '.avatar');
|
||||
assert.equal(ajv.errors[0].message, 'should match pattern "^[0-9a-f]+$"');
|
||||
};
|
||||
|
||||
exports.test_avatar_valid = () => {
|
||||
assert(ajv.validate(User, { avatar: 'a'.repeat(40) }));
|
||||
};
|
||||
|
||||
exports.test_email_valid = () => {
|
||||
assert(ajv.validate(User, { email: 'nate@zeit.co' }));
|
||||
};
|
||||
|
||||
exports.test_email_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
email: `${'n'.repeat(256)}@zeit.co`
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_avatar_invalid_length = () => {
|
||||
assert(ajv.validate(User, { avatar: 'a'.repeat(40) }));
|
||||
};
|
||||
|
||||
exports.test_platformVersion_null_valid = () => {
|
||||
assert(ajv.validate(User, { platformVersion: null }));
|
||||
};
|
||||
|
||||
exports.test_platformVersion_zero_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
platformVersion: 0
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_platformVersion_one_valid = () => {
|
||||
assert(ajv.validate(User, { platformVersion: 1 }));
|
||||
};
|
||||
|
||||
exports.test_platformVersion_two_valid = () => {
|
||||
assert(ajv.validate(User, { platformVersion: 2 }));
|
||||
};
|
||||
|
||||
exports.test_platformVersion_three_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
platformVersion: 3
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_github_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitProvider: 'github' }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_gitlab_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitProvider: 'gitlab' }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_bitbucket_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitProvider: 'bitbucket' }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_null_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitProvider: null }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_invalid_value = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
importFlowGitProvider: 'test'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_importFlowGitProvider_number_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
importFlowGitProvider: 10
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespace_string_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitNamespace: 'test' }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespace_null_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitNamespace: null }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespace_number_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
importFlowGitNamespace: 10
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespace_boolean_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
importFlowGitNamespace: true
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespaceId_string_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitNamespaceId: 'test' }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespaceId_number_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitNamespaceId: 10 }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespaceId_null_valid = () => {
|
||||
assert(ajv.validate(User, { importFlowGitNamespaceId: null }));
|
||||
};
|
||||
|
||||
exports.test_importFlowGitNamespaceId_boolean_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
importFlowGitNamespaceId: true
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_scopeId_valid = () => {
|
||||
assert(ajv.validate(User, { scopeId: '123test' }));
|
||||
};
|
||||
|
||||
exports.test_scopeId_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
scopeId: null
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_gitNamespaceId_string_valid = () => {
|
||||
assert(ajv.validate(User, { gitNamespaceId: 'test' }));
|
||||
};
|
||||
|
||||
exports.test_gitNamespaceId_number_valid = () => {
|
||||
assert(ajv.validate(User, { gitNamespaceId: 123 }));
|
||||
};
|
||||
|
||||
exports.test_gitNamespaceId_null_valid = () => {
|
||||
assert(ajv.validate(User, { gitNamespaceId: null }));
|
||||
};
|
||||
|
||||
exports.test_gitNamespaceId_boolean_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
gitNamespaceId: true
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_viewPreference_cards_valid = () => {
|
||||
assert(ajv.validate(User, { viewPreference: 'cards' }));
|
||||
};
|
||||
|
||||
exports.test_viewPreference_list_valid = () => {
|
||||
assert(ajv.validate(User, { viewPreference: 'list' }));
|
||||
};
|
||||
|
||||
exports.test_viewPreference_null_valid = () => {
|
||||
assert(ajv.validate(User, { viewPreference: null }));
|
||||
};
|
||||
|
||||
exports.test_viewPreference_invalid_value = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
viewPreference: 'test'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_viewPreference_number_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
viewPreference: 10
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_favoritesViewPreference_open_valid = () => {
|
||||
assert(ajv.validate(User, { favoritesViewPreference: 'open' }));
|
||||
};
|
||||
|
||||
exports.test_favoritesViewPreference_closed_valid = () => {
|
||||
assert(ajv.validate(User, { favoritesViewPreference: 'closed' }));
|
||||
};
|
||||
|
||||
exports.test_favoritesViewPreference_null_valid = () => {
|
||||
assert(ajv.validate(User, { favoritesViewPreference: null }));
|
||||
};
|
||||
|
||||
exports.test_favoritesViewPreference_invalid_value = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
favoritesViewPreference: 'test'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_favoritesViewPreference_number_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
favoritesViewPreference: 10
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_recentsViewPreference_open_valid = () => {
|
||||
assert(ajv.validate(User, { recentsViewPreference: 'open' }));
|
||||
};
|
||||
|
||||
exports.test_recentsViewPreference_closed_valid = () => {
|
||||
assert(ajv.validate(User, { recentsViewPreference: 'closed' }));
|
||||
};
|
||||
|
||||
exports.test_recentsViewPreference_null_valid = () => {
|
||||
assert(ajv.validate(User, { recentsViewPreference: null }));
|
||||
};
|
||||
|
||||
exports.test_recentsViewPreference_invalid_value = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
recentsViewPreference: 'test'
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_recentsViewPreference_number_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
recentsViewPreference: 10
|
||||
});
|
||||
assert.equal(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_remoteCaching_valid = () => {
|
||||
assert(ajv.validate(User, { remoteCaching: { enabled: true } }));
|
||||
};
|
||||
|
||||
exports.test_remoteCaching_valid = () => {
|
||||
const isValid = ajv.validate(User, { remoteCaching: { enabled: 'yes' } });
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_dismissedToasts_valid = () => {
|
||||
assert(ajv.validate(User, { dismissedToasts: [] }));
|
||||
};
|
||||
|
||||
exports.test_dismissedToasts_valid = () => {
|
||||
assert(ajv.validate(User, { dismissedToasts: [{ name: ' exampleToast', dismissals: [{ scopeId: 'exampleScopeId', createdAt: 1656442351576 }] }] }));
|
||||
};
|
||||
|
||||
exports.test_dismissedToasts_invalid = () => {
|
||||
const isValid = ajv.validate(User, { dismissedToasts: [{ name: ' exampleToast', otherProp: 'abc' }] });
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
|
||||
exports.test_favoriteProjectsAndSpaces_valid = () => {
|
||||
assert(ajv.validate(User, { favoriteProjectsAndSpaces: [] }));
|
||||
};
|
||||
|
||||
exports.test_favoriteProjectsAndSpaces_valid = () => {
|
||||
assert(
|
||||
ajv.validate(User, {
|
||||
favoriteProjectsAndSpaces: [
|
||||
{ projectId: '123', scopeId: '123', scopeSlug: 'A Slug' },
|
||||
{ projectId: '123', scopeId: '123', scopeSlug: 'A Slug' },
|
||||
{ spaceId: '123', scopeId: '123', scopeSlug: 'A Slug' }
|
||||
]
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
exports.test_favoriteProjectsAndSpaces_invalid = () => {
|
||||
const isValid = ajv.validate(User, {
|
||||
favoriteProjectsAndSpaces: [{ projectId: '123', missing: '123', unknownProp: 'A Slug' }]
|
||||
});
|
||||
assert.strictEqual(isValid, false);
|
||||
};
|
||||
296
node_modules/@zeit/schemas/user/index.js
generated
vendored
Normal file
296
node_modules/@zeit/schemas/user/index.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
const Username = {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 48,
|
||||
pattern: '^[a-z0-9][a-z0-9-]*[a-z0-9]$'
|
||||
};
|
||||
|
||||
const Name = {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 32
|
||||
};
|
||||
|
||||
const Email = {
|
||||
type: 'string',
|
||||
minLength: 5,
|
||||
maxLength: 256
|
||||
};
|
||||
|
||||
const ImportFlowGitProvider = {
|
||||
oneOf: [
|
||||
{
|
||||
'enum': ['github', 'gitlab', 'bitbucket']
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const ImportFlowGitNamespace = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const ImportFlowGitNamespaceId = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
type: 'number'
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const ScopeId = {
|
||||
type: 'string'
|
||||
};
|
||||
|
||||
const GitNamespaceId = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
type: 'number'
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const ViewPreference = {
|
||||
oneOf: [
|
||||
{
|
||||
'enum': ['cards', 'list']
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const ToggleViewPreference = {
|
||||
oneOf: [
|
||||
{
|
||||
'enum': ['open', 'closed']
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const PlatformVersion = {
|
||||
oneOf: [
|
||||
{
|
||||
// A `null` platform version means to always use the latest
|
||||
type: 'null'
|
||||
},
|
||||
{
|
||||
type: 'integer',
|
||||
minimum: 1,
|
||||
maximum: 2
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const Avatar = {
|
||||
type: 'string',
|
||||
minLength: 40,
|
||||
maxLength: 40,
|
||||
pattern: '^[0-9a-f]+$'
|
||||
};
|
||||
|
||||
const Bio = {
|
||||
type: 'string'
|
||||
};
|
||||
|
||||
const Website = {
|
||||
type: 'string',
|
||||
minLength: 4,
|
||||
maxLength: 40
|
||||
};
|
||||
|
||||
const Profile = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
service: {
|
||||
type: 'string'
|
||||
},
|
||||
link: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const Profiles = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: 100,
|
||||
uniqueItems: true,
|
||||
items: Profile,
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const RemoteCaching = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const ToastDismissal = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
scopeId: {
|
||||
type: 'string'
|
||||
},
|
||||
createdAt: {
|
||||
type: 'number'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const DismissedToast = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string'
|
||||
},
|
||||
dismissals: {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: 50,
|
||||
items: ToastDismissal
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const DismissedToasts = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: 50,
|
||||
items: DismissedToast,
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const FavoriteProjectOrSpace = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
projectId: {
|
||||
type: 'string'
|
||||
},
|
||||
spaceId: {
|
||||
type: 'string'
|
||||
},
|
||||
scopeId: {
|
||||
type: 'string'
|
||||
},
|
||||
scopeSlug: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const FavoriteProjectsAndSpaces = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: FavoriteProjectOrSpace,
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const EnablePreviewFeedback = {
|
||||
oneOf: [
|
||||
{
|
||||
'enum': [
|
||||
'on',
|
||||
'off',
|
||||
'default',
|
||||
'on-force',
|
||||
'off-force',
|
||||
'default-force'
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const DefaultTeamId = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
maxLength: 29
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const User = {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
username: Username,
|
||||
name: Name,
|
||||
email: Email,
|
||||
billingChecked: { type: 'boolean' },
|
||||
avatar: Avatar,
|
||||
platformVersion: PlatformVersion,
|
||||
bio: Bio,
|
||||
website: Website,
|
||||
profiles: Profiles,
|
||||
importFlowGitProvider: ImportFlowGitProvider,
|
||||
importFlowGitNamespace: ImportFlowGitNamespace,
|
||||
importFlowGitNamespaceId: ImportFlowGitNamespaceId,
|
||||
scopeId: ScopeId,
|
||||
gitNamespaceId: GitNamespaceId,
|
||||
viewPreference: ViewPreference,
|
||||
favoritesViewPreference: ToggleViewPreference,
|
||||
recentsViewPreference: ToggleViewPreference,
|
||||
remoteCaching: RemoteCaching,
|
||||
dismissedToasts: DismissedToasts,
|
||||
enablePreviewFeedback: EnablePreviewFeedback,
|
||||
favoriteProjectsAndSpaces: FavoriteProjectsAndSpaces,
|
||||
defaultTeamId: DefaultTeamId
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
User,
|
||||
Username,
|
||||
Name,
|
||||
Email,
|
||||
Avatar,
|
||||
PlatformVersion,
|
||||
ImportFlowGitProvider,
|
||||
ImportFlowGitNamespace,
|
||||
ImportFlowGitNamespaceId,
|
||||
ScopeId,
|
||||
GitNamespaceId,
|
||||
ViewPreference,
|
||||
ToggleViewPreference,
|
||||
DismissedToasts
|
||||
};
|
||||
Reference in New Issue
Block a user