This commit is contained in:
parent
005c903a4d
commit
590f8233ce
16
.prettierrc
Normal file
16
.prettierrc
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 4,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"semi": false,
|
||||
"newline-before-return": true,
|
||||
"no-duplicate-variable": [true, "check-parameters"],
|
||||
"no-var-keyword": true,
|
||||
|
||||
"svelteSortOrder": "scripts-styles-markup",
|
||||
"svelteStrictMode": true,
|
||||
"svelteBracketNewLine": true,
|
||||
"svelteAllowShorthand": true,
|
||||
"svelteIndentScriptAndStyle": true
|
||||
}
|
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"yaml.customTags": ["!include scalar"],
|
||||
"yaml.schemas": {
|
||||
"schemas/api-config/config.json": "demo-api/config.y*ml",
|
||||
"schemas/api-config/collection.json": "demo-api/collections/*.y*ml",
|
||||
"schemas/api-config/field.json": "demo-api/collections/fields/*.y*ml"
|
||||
},
|
||||
"editor.formatOnSave": true
|
||||
}
|
6
demo-api/collections/fields/testfield.yml
Normal file
6
demo-api/collections/fields/testfield.yml
Normal file
@ -0,0 +1,6 @@
|
||||
name: testfield
|
||||
type: string
|
||||
meta:
|
||||
label:
|
||||
de: test
|
||||
|
22
demo-api/collections/global/test-permissions.yml
Normal file
22
demo-api/collections/global/test-permissions.yml
Normal file
@ -0,0 +1,22 @@
|
||||
# yaml-language-server: $schema=../../../schemas/api-config/permissions.json
|
||||
|
||||
public:
|
||||
methods:
|
||||
get: true
|
||||
post: false
|
||||
put: false
|
||||
delete: false
|
||||
|
||||
user:
|
||||
methods:
|
||||
get: true
|
||||
post: true
|
||||
put: true
|
||||
delete: true
|
||||
|
||||
token:abc:
|
||||
methods:
|
||||
get: true
|
||||
post: true
|
||||
put: true
|
||||
delete: true
|
@ -9,19 +9,8 @@ meta:
|
||||
columns:
|
||||
- title
|
||||
|
||||
permissions:
|
||||
public:
|
||||
methods:
|
||||
get: true
|
||||
post: false
|
||||
put: false
|
||||
delete: false
|
||||
user:
|
||||
methods:
|
||||
get: true
|
||||
post: true
|
||||
put: false
|
||||
delete: false
|
||||
permissions: !include global/test-permissions.yml
|
||||
|
||||
|
||||
hooks:
|
||||
get:
|
||||
|
187
schemas/api-config/collection.json
Normal file
187
schemas/api-config/collection.json
Normal file
@ -0,0 +1,187 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic collection configuration",
|
||||
"description": "WMBasic collection linter",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "collection name, part of api path"
|
||||
},
|
||||
"uploadPath": {
|
||||
"type": "string",
|
||||
"description": "relative to config.yml, path for file uploads"
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "meta object used for admin ui configuration",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"label": {
|
||||
"$ref": "field.json#/definitions/i18nString"
|
||||
},
|
||||
"muiIcon": {
|
||||
"type": "string",
|
||||
"description": "material ui icon name"
|
||||
},
|
||||
"rowIdentTpl": {
|
||||
"description": "template which evaluates to short string to identify entry in pe. select boxes",
|
||||
"$ref": "field.json#/definitions/evalExpressions"
|
||||
},
|
||||
"defaultSort": {
|
||||
"type": "object",
|
||||
"description": "default sort in admin ui lists",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"field": {
|
||||
"$ref": "field.json#/definitions/fieldSource"
|
||||
},
|
||||
"order": {
|
||||
"description": "sort order",
|
||||
"enum": ["ASC", "DESC"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"views": {
|
||||
"type": "array",
|
||||
"description": "list views",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mediaQuery": {
|
||||
"type": "string",
|
||||
"description": "css media query to select this view in ui"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "simpleList"
|
||||
},
|
||||
"primaryText": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "field.json#/definitions/fieldSource"
|
||||
},
|
||||
{
|
||||
"$ref": "field.json#/definitions/evalExpressions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondaryText": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "field.json#/definitions/fieldSource"
|
||||
},
|
||||
{
|
||||
"$ref": "field.json#/definitions/evalExpressions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"tertiaryText": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "field.json#/definitions/fieldSource"
|
||||
},
|
||||
{
|
||||
"$ref": "field.json#/definitions/evalExpressions"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["type", "primaryText"]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "table"
|
||||
},
|
||||
"columns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "field.json#/definitions/fieldSource"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"$ref": "field.json#/definitions/i18nString"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "field.json#/definitions/evalExpressions"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"label": {
|
||||
"$ref": "field.json#/definitions/i18nString"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
},
|
||||
"required": ["type", "columns"]
|
||||
}
|
||||
],
|
||||
"required": ["type"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"projections": {
|
||||
"oneOf": [
|
||||
{ "$comment": "for include tag", "type": "string" },
|
||||
{ "$ref": "projections.json" }
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"oneOf": [
|
||||
{ "$comment": "for include tag", "type": "string" },
|
||||
{ "$ref": "permissions.json" }
|
||||
]
|
||||
},
|
||||
"hooks": {
|
||||
"oneOf": [
|
||||
{ "$comment": "for include tag", "type": "string" },
|
||||
{ "$ref": "hooks.json" }
|
||||
]
|
||||
},
|
||||
"imageFilter": {
|
||||
"oneOf": [
|
||||
{ "$comment": "for include tag", "type": "string" },
|
||||
{ "$ref": "imageFilter.json" }
|
||||
]
|
||||
},
|
||||
"fields": {
|
||||
"type": "array",
|
||||
"description": "fields of collection",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$comment": "for include tag"
|
||||
},
|
||||
{
|
||||
"$ref": "field.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["name", "permissions"]
|
||||
}
|
40
schemas/api-config/config.json
Normal file
40
schemas/api-config/config.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic config file",
|
||||
"description": "WMBasic config.yml linter",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"namespace": {
|
||||
"type": "string",
|
||||
"description": "suffix for mongo db database and part of api url, can be overwritten in database project settings"
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "meta object used for admin ui configuration",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"imageUrl": {
|
||||
"type": "string",
|
||||
"description": "project's teaser image url shown in admin ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
"collections": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$comment": "for include tag",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "list of collections in this project",
|
||||
"items": {
|
||||
"$ref": "collection.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["namespace"]
|
||||
}
|
194
schemas/api-config/field.json
Normal file
194
schemas/api-config/field.json
Normal file
@ -0,0 +1,194 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic field configuration",
|
||||
"description": "WMBasic field linter",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "name of field",
|
||||
"pattern": "^[0-9a-zA-Z_]+$"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"string",
|
||||
"string[]",
|
||||
"number",
|
||||
"number[]",
|
||||
"boolean",
|
||||
"object",
|
||||
"object[]",
|
||||
"any"
|
||||
]
|
||||
},
|
||||
"index": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"enum": ["single", "unique", "text"]
|
||||
}
|
||||
},
|
||||
"subFields": {
|
||||
"type": "array",
|
||||
"description": "sub fields of object",
|
||||
"items": {
|
||||
"$ref": "#"
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "meta object of field",
|
||||
"properties": {
|
||||
"label": {
|
||||
"$ref": "#/definitions/i18nString"
|
||||
},
|
||||
"helperText": {
|
||||
"$ref": "#/definitions/i18nString"
|
||||
},
|
||||
"widget": {
|
||||
"description": "ui widget",
|
||||
"enum": [
|
||||
"richtext",
|
||||
"richText",
|
||||
"html",
|
||||
"checkbox",
|
||||
"select",
|
||||
"selectArray",
|
||||
"date",
|
||||
"file",
|
||||
"image"
|
||||
]
|
||||
},
|
||||
"choices": {
|
||||
"type": "array",
|
||||
"description": "choices to select from",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "name is human readable value",
|
||||
"$ref": "#/definitions/i18nString"
|
||||
},
|
||||
"chipStyle": {
|
||||
"$ref": "https://raw.githubusercontent.com/rcorp/css-schema/master/schema.json"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["id", "name"]
|
||||
}
|
||||
},
|
||||
"valueMap": {
|
||||
"type": "object",
|
||||
"description": "map values to icons",
|
||||
"patternProperties": {
|
||||
".*": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"muiIcon": {
|
||||
"type": "string"
|
||||
},
|
||||
"style": {
|
||||
"$ref": "https://raw.githubusercontent.com/rcorp/css-schema/master/schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["name", "type"],
|
||||
"definitions": {
|
||||
"i18nString": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[a-z]$": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"evalExpressions": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"twig": {
|
||||
"type": "string",
|
||||
"description": "twig template"
|
||||
},
|
||||
"projection": {
|
||||
"type": "string",
|
||||
"description": "query projection to use"
|
||||
}
|
||||
},
|
||||
"required": ["twig"]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"eval": {
|
||||
"type": "string",
|
||||
"description": "javascript code"
|
||||
},
|
||||
"projection": {
|
||||
"type": "string",
|
||||
"description": "query projection to use"
|
||||
}
|
||||
},
|
||||
"required": ["eval"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"fieldSource": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/fieldPath"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source": {
|
||||
"$ref": "#/definitions/fieldPath"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"fieldPath": {
|
||||
"type": "string",
|
||||
"description": "field, sub fields separated with dot (.)",
|
||||
"pattern": "^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*$"
|
||||
}
|
||||
}
|
||||
}
|
92
schemas/api-config/hooks.json
Normal file
92
schemas/api-config/hooks.json
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic hooks configuration",
|
||||
"description": "WMBasic hooks linter",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"get": {
|
||||
"type": "object",
|
||||
"description": "hooks for http GET",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"read": {
|
||||
"description": "hook before reading from database",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"return": {
|
||||
"description": "hook before returning entries read from database",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"type": "object",
|
||||
"description": "hooks for http POST",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"bind": {
|
||||
"description": "hook before binding data from post request",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"create": {
|
||||
"description": "hook before creating entry in database",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"return": {
|
||||
"description": "hook before returning result (after database write)",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"type": "object",
|
||||
"description": "hooks for http PUT",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"bind": {
|
||||
"description": "hook before binding data from put request",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"update": {
|
||||
"description": "hook before updating entry in database",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"return": {
|
||||
"description": "hook before returning result (after database write)",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"type": "object",
|
||||
"description": "hooks for http DELETE",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"delete": {
|
||||
"description": "hook before deleting entry from database",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
},
|
||||
"return": {
|
||||
"description": "hook before returning result (after database write)",
|
||||
"$ref": "#/definitions/hookDef"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"hookDef": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "javascript"
|
||||
},
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "location of javascript hook file relative to config.yml base"
|
||||
}
|
||||
},
|
||||
"required": ["type", "file"]
|
||||
}
|
||||
}
|
||||
}
|
63
schemas/api-config/imageFilter.json
Normal file
63
schemas/api-config/imageFilter.json
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic imageFilter configuration",
|
||||
"description": "WMBasic imageFilter linter",
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[a-zA-Z0-9_-]+$": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"fill": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"height": {
|
||||
"type": "number"
|
||||
},
|
||||
"blur": {
|
||||
"type": "number"
|
||||
},
|
||||
"brightness": {
|
||||
"type": "number"
|
||||
},
|
||||
"contrast": {
|
||||
"type": "number"
|
||||
},
|
||||
"gamma": {
|
||||
"type": "number"
|
||||
},
|
||||
"saturation": {
|
||||
"type": "number"
|
||||
},
|
||||
"sharpen": {
|
||||
"type": "number"
|
||||
},
|
||||
"invert": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"grayscale": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"resampling": {
|
||||
"enum": [
|
||||
"lancos",
|
||||
"nearestNeighbor",
|
||||
"linear",
|
||||
"catmullRom"
|
||||
]
|
||||
},
|
||||
"quality": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
schemas/api-config/permissions.json
Normal file
43
schemas/api-config/permissions.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic permissions configuration",
|
||||
"description": "WMBasic permissions linter",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"public": {
|
||||
"description": "permissions for unauthorized public access",
|
||||
"$ref": "#/definitions/permissionSet"
|
||||
},
|
||||
"user": {
|
||||
"description": "permissions for authorized users (nativ wmbasic auth)",
|
||||
"$ref": "#/definitions/permissionSet"
|
||||
}
|
||||
},
|
||||
"patternProperties": {
|
||||
"^token:": {
|
||||
"description": "permissions for header or query token",
|
||||
"$ref": "#/definitions/permissionSet"
|
||||
}
|
||||
},
|
||||
"required": ["public", "user"],
|
||||
"definitions": {
|
||||
"permissionSet": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"methods": {
|
||||
"type": "object",
|
||||
"description": "permissions for http methods",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"get": { "type": "boolean" },
|
||||
"post": { "type": "boolean" },
|
||||
"put": { "type": "boolean" },
|
||||
"delete": { "type": "boolean" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
schemas/api-config/projections.json
Normal file
22
schemas/api-config/projections.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "JSON Schema WMBasic imageFilter configuration",
|
||||
"description": "WMBasic imageFilter linter",
|
||||
"patternProperties": {
|
||||
"^[a-zA-Z0-9_-]$": {
|
||||
"type": "object",
|
||||
"description": "dataset query projection config",
|
||||
"properties": {
|
||||
"select": {
|
||||
"type": "object",
|
||||
"description": "mongo db selector",
|
||||
"patternProperties": {
|
||||
"^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9]+)*$": {
|
||||
"enum": [0, 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user