From fafc75a9a0e3b0936db007e9b54c3270b984f3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Popovics=20Andr=C3=A1s?= Date: Tue, 30 Jan 2018 13:34:08 +0000 Subject: [PATCH] [ADF-2134] App config schema (#2892) * Application config schema * Adding descriptions * validate-config npm script * Finishing schema * Package.json modifications * Add validation to demo shell start --- demo-shell/package.json | 3 + demo-shell/src/app.config.json | 1 + lib/core/app-config/schema.json | 319 ++++++++++++++++++++++++++++++++ lib/package.json | 3 +- 4 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 lib/core/app-config/schema.json diff --git a/demo-shell/package.json b/demo-shell/package.json index e4e2b10b85..be0b656832 100644 --- a/demo-shell/package.json +++ b/demo-shell/package.json @@ -5,6 +5,7 @@ "author": "Alfresco Software, Ltd.", "scripts": { "ng": "ng", + "prestart": "npm run validate-config", "start": "npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --app dist --open --aot=false", "start:dev": "npm run lint && npm run server-versions && rimraf dist && npm run clean-lib-angular && concurrently \"ng serve --host 0.0.0.0 --disable-host-check --app dev pp-dev --proxy-config proxy.conf.js --open\" \"npm run style:dev -- --watch\" ", "start:dist": "npm run server-versions && rimraf dist && node --max_old_space_size=30000 node_modules/.bin/ng serve --prod --build-optimizer=false --aot=false --host 0.0.0.0 --disable-host-check --app dist", @@ -15,6 +16,7 @@ "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", + "validate-config": "ajv validate -s ../lib/core/app-config/schema.json -d ./src/app.config.json --errors=text --verbose", "server-versions": "rimraf ./src/versions.json && npm list --depth=0 --json=true --prod=true > ./src/versions.json || exit 0", "clean": "npm run clean-build && rimraf dist node_modules typings dist", "clean-lib-angular": "rimraf ../lib/node_modules/@angular", @@ -105,6 +107,7 @@ "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", + "ajv-cli": "^3.0.0", "codelyzer": "4.0.0", "concurrently": "^3.5.1", "jasmine-core": "~2.6.2", diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json index 5030d4ac60..93d0b0aff8 100644 --- a/demo-shell/src/app.config.json +++ b/demo-shell/src/app.config.json @@ -1,4 +1,5 @@ { + "$schema": "../../lib/core/app-config/schema.json", "ecmHost": "http://{hostname}:{port}", "bpmHost": "http://{hostname}:{port}", "application": { diff --git a/lib/core/app-config/schema.json b/lib/core/app-config/schema.json new file mode 100644 index 0000000000..16417b8c5b --- /dev/null +++ b/lib/core/app-config/schema.json @@ -0,0 +1,319 @@ +{ + "$schema": "http://json-schema.org/schema", + "id": "https://github.com/Alfresco/alfresco-ng2-components/tree/master/lib/core/app-config/schema.json", + "title": "ADF Application config", + "description": "Configuration object for ADF components used by your application", + + "definitions": { + "language": { + "description": "Language definition", + "type": "object", + "properties": { + "key": { "type": "string" }, + "label": { "type": "string" } + } + }, + "document-list-thumbnail": { + "description": "Document list's thumbnail image column definition", + "type": "object", + "required": [ "key", "type", "srTitle", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^\\$thumbnail$" }, + "type": { "type": "string", "pattern": "^image$" }, + "srTitle": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-name": { + "description": "Document list's name column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^name$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-title": { + "description": "Document list's title column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^title$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-visibility": { + "description": "Document list's visibility column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^visibility$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-path": { + "description": "Document list's path column definition", + "type": "object", + "required": [ "key", "type", "title", "format", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^path$" }, + "type": { "type": "string", "pattern": "^location$" }, + "title": { "type": "string" }, + "format": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-modifiedAt": { + "description": "Document list's modifiedAt column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^modifiedAt$" }, + "type": { "type": "string", "pattern": "^date$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-modifiedByUser": { + "description": "Document list's modifiedByUser column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^modifiedByUser\\.displayName$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-sharedByUser": { + "description": "Document list's sharedByUser column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^sharedByUser\\.displayName$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-filesize": { + "description": "Document list's path column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^content\\.sizeInBytes$" }, + "type": { "type": "string", "pattern": "^fileSize$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-archivedAt": { + "description": "Document list's archivedAt column definition", + "type": "object", + "required": [ "key", "type", "title", "format", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^archivedAt$" }, + "type": { "type": "string", "pattern": "^date$" }, + "title": { "type": "string" }, + "format": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "document-list-archivedBy": { + "description": "Document list's archivedBy column definition", + "type": "object", + "required": [ "key", "type", "title", "sortable" ], + "properties": { + "key": { "type": "string", "pattern": "^archivedByUser.displayName$" }, + "type": { "type": "string", "pattern": "^text$" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + }, + "content-metadata-aspect": { + "description": "Content metadata's aspect definition", + "type": "object", + "patternProperties": { + ".*": { + "oneOf": [ + { + "description": "Wildcard for every property", + "type": "string", + "pattern": "^\\*$" + }, + { + "description": "Properties array", + "type": "array", + "items": { + "description": "Property name", + "type": "string" + } + } + ] + } + } + } + }, + + "type": "object", + "properties": { + "ecmHost": { + "description": "ECM host", + "type": "string" + }, + "bpmHost": { + "description": "BPM host", + "type": "string" + }, + "application": { + "description": "Application's global configuration", + "type": "object", + "properties": { + "name": { "type": "string", "description": "Name of the application" } + } + }, + "languages": { + "description": "Supported languages", + "type": "array", + "items": { "$ref": "#/definitions/language" } + }, + "pagination": { + "description": "Pagination configuration", + "type": "object", + "properties": { + "size": { "type": "number", "description": "Pagination's default page size" }, + "supportedPageSizes": { + "description": "Pagination's supported page sizes", + "type": "array", + "items": { "type": "number" } + } + } + }, + "files": { + "description": "Configuration of rules applied to file upload", + "type": "object", + "properties": { + "excluded": { + "description": "File exclusions", + "type": "array", + "items": { "type": "string" } + } + } + }, + "logLevel": { + "description": "Application's logging level", + "type": "string", + "enum": [ "trace", "debug", "info", "warn", "error", "silent" ] + }, + "activiti": { + "type": "object" + }, + "document-list": { + "description": "Document list configuration", + "type": "object", + "properties": { + "presets": { + "description": "Presets for document list component", + "type": "object", + "propertyNames": { + "enum": [ "-trashcan-", "-sites-", "-mysites-", "-favorites-", "-recent-", "-sharedlinks-", "default" ] + }, + "patternProperties": { + ".*": { + "description": "Document list's columns", + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/definitions/document-list-thumbnail" }, + { "$ref": "#/definitions/document-list-name" }, + { "$ref": "#/definitions/document-list-title" }, + { "$ref": "#/definitions/document-list-visibility" }, + { "$ref": "#/definitions/document-list-path" }, + { "$ref": "#/definitions/document-list-modifiedAt" }, + { "$ref": "#/definitions/document-list-modifiedByUser" }, + { "$ref": "#/definitions/document-list-sharedByUser" }, + { "$ref": "#/definitions/document-list-filesize" }, + { "$ref": "#/definitions/document-list-archivedAt" }, + { "$ref": "#/definitions/document-list-archivedBy" } + ] + } + } + } + } + } + }, + "adf-task-list": { + "description": "Task list component configuration", + "type": "object", + "properties": { + "presets": { + "description": "Presets for task list component", + "type": "object", + "patternProperties": { + ".*": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { "type": "string" }, + "type": { "type": "string" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + } + } + } + } + } + }, + "adf-process-list": { + "description": "Process list component configuration", + "type": "object", + "properties": { + "presets": { + "description": "Presets for process list component", + "type": "object", + "patternProperties": { + ".*": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { "type": "string" }, + "type": { "type": "string" }, + "title": { "type": "string" }, + "sortable": { "type": "boolean" } + } + } + } + } + } + } + }, + "content-metadata": { + "description": "Content metadata component's configuration", + "type": "object", + "required": [ "presets" ], + "properties": { + "presets": { + "description": "Presets for content metadata component", + "type": "object", + "patternProperties": { + ".*": { + "oneOf": [ + { "type": "string", "pattern": "^\\*$", "description": "Wildcard for every aspect"}, + { "$ref": "#/definitions/content-metadata-aspect" } + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/lib/package.json b/lib/package.json index edebf8c121..21a9200cff 100644 --- a/lib/package.json +++ b/lib/package.json @@ -23,7 +23,8 @@ "docindex": "node config/DocProcessor/docProcessor.js ../docs", "copy-i18n": "mkdir -p core/dist/bundles/assets/adf-core/i18n && cp -R core/i18n/* core/dist/bundles/assets/adf-core/i18n && mkdir -p content-services/dist/bundles/assets/adf-content-services/i18n && cp -R content-services/i18n/* content-services/dist/bundles/assets/adf-content-services/i18n && mkdir -p process-services/dist/bundles/assets/adf-process-services/i18n && cp -R process-services/i18n/* process-services/dist/bundles/assets/adf-process-services/i18n && mkdir -p insights/dist/bundles/assets/adf-insights/i18n && cp -R insights/i18n/* insights/dist/bundles/assets/adf-insights/i18n", "copy-assets": "cp -R core/assets/* core/dist/bundles/assets && cp -R content-services/assets/* content-services/dist/bundles/assets && cp -R process-services/assets/* process-services/dist/bundles/assets", - "new-build": "npm run build-bundles && npm run build-style-new && npm run copy-i18n && npm run copy-assets", + "copy-app-schema": "cp core/app-config/schema.json core/dist/app.config.schema.json", + "new-build": "npm run build-bundles && npm run build-style-new && npm run copy-i18n && npm run copy-assets && npm run copy-app-schema", "build-bundles": "npm run build-core && npm run link-core && npm run build-content && npm run link-content && npm run build-process && npm run build-insights", "link-core": "mkdir -p ./node_modules/@alfresco/adf-core/ && cp -R ./core/dist/* ./node_modules/@alfresco/adf-core/", "link-content": "mkdir -p ./node_modules/@alfresco/adf-content-services/ && cp -R ./content-services/dist/* ./node_modules/@alfresco/adf-content-services/",