fix(schema): add definition for log filters
MODIFY
packages/appium/test/fixtures/flattened-schema.js
packages/appium/test/fixtures/flattened-schema.js
@@ -252,11 +252,11 @@ export default [
ref: 'appium.json#/properties/server/properties/log-filters',
},
schema: {
- $comment: 'TODO',
description: 'One or more log filtering rules',
- items: {type: 'string'},
title: 'log-filters config',
type: 'array',
+ items: {$ref: '#/$defs/logFilter'},
+ appiumCliTransformer: 'json',
},
},
{

MODIFY
packages/schema/lib/appium-config-schema.js
packages/schema/lib/appium-config-schema.js
@@ -128,13 +128,11 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
type: 'string',
},
'log-filters': {
- $comment: 'TODO',
description: 'One or more log filtering rules',
- items: {
- type: 'string',
- },
title: 'log-filters config',
type: 'array',
+ items: {$ref: '#/$defs/logFilter'},
+ appiumCliTransformer: 'json',
},
'log-level': {
appiumCliDest: 'loglevel',
@@ -289,4 +287,60 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
},
title: 'Appium Configuration',
type: 'object',
+ $defs: {
+ logFilterText: {
+ type: 'object',
+ description: 'Log filter with plain text',
+ properties: {
+ text: {
+ description: 'Text to match',
+ type: 'string',
+ },
+ },
+ required: ['text'],
+ not: {
+ required: ['pattern'],
+ },
+ },
+ logFilterRegex: {
+ type: 'object',
+ description: 'Log filter with regular expression',
+ properties: {
+ pattern: {
+ description: 'Regex pattern to match',
+ type: 'string',
+ format: 'regex',
+ },
+ },
+ required: ['pattern'],
+ not: {
+ required: ['text'],
+ },
+ },
+ logFilter: {
+ type: 'object',
+ description: 'Log filtering rule',
+ allOf: [
+ {
+ type: 'object',
+ properties: {
+ replacer: {
+ description: 'Replacement string for matched text',
+ type: 'string',
+ default: '**SECURE**',
+ },
+ flags: {
+ description:
+ 'Matching flags; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags',
+ type: 'string',
+ pattern: '^[igmsduy](,[igmsduy])*$',
+ },
+ },
+ },
+ {
+ oneOf: [{$ref: '#/$defs/logFilterText'}, {$ref: '#/$defs/logFilterRegex'}],
+ },
+ ],
+ },
+ },
});

MODIFY
packages/schema/lib/appium-config.schema.json
packages/schema/lib/appium-config.schema.json
"type": "string"
},
"log-filters": {
- "$comment": "TODO",
"description": "One or more log filtering rules",
+ "title": "log-filters config",
+ "type": "array",
"items": {
- "type": "string"
+ "$ref": "#/$defs/logFilter"
},
- "title": "log-filters config",
- "type": "array"
+ "appiumCliTransformer": "json"
},
"log-level": {
"appiumCliDest": "loglevel",
}
},
"title": "Appium Configuration",
- "type": "object"
+ "type": "object",
+ "$defs": {
+ "logFilterText": {
+ "type": "object",
+ "description": "Log filter with plain text",
+ "properties": {
+ "text": {
+ "description": "Text to match",
+ "type": "string"
+ }
+ },
+ "required": [
+ "text"
+ ],
+ "not": {
+ "required": [
+ "pattern"
+ ]
+ }
+ },
+ "logFilterRegex": {
+ "type": "object",
+ "description": "Log filter with regular expression",
+ "properties": {
+ "pattern": {
+ "description": "Regex pattern to match",
+ "type": "string",
+ "format": "regex"
+ }
+ },
+ "required": [
+ "pattern"
+ ],
+ "not": {
+ "required": [
+ "text"
+ ]
+ }
+ },
+ "logFilter": {
+ "type": "object",
+ "description": "Log filtering rule",
+ "allOf": [
+ {
+ "type": "object",
+ "properties": {
+ "replacer": {
+ "description": "Replacement string for matched text",
+ "type": "string",
+ "default": "**SECURE**"
+ },
+ "flags": {
+ "description": "Matching flags; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags",
+ "type": "string",
+ "pattern": "^[igmsduy](,[igmsduy])*$"
+ }
+ }
+ },
+ {
+ "oneOf": [
+ {
+ "$ref": "#/$defs/logFilterText"
+ },
+ {
+ "$ref": "#/$defs/logFilterRegex"
+ }
+ ]
+ }
+ ]
+ }
+ }
}
\ No newline at end of file

MODIFY
packages/types/lib/appium-config.ts
packages/types/lib/appium-config.ts
@@ -49,10 +49,24 @@ export type LocalTimezoneConfig = boolean;
* Also send log output to this file
*/
export type LogConfig = string;
+/**
+ * Log filtering rule
+ */
+export type LogFilter = {
+ /**
+ * Replacement string for matched text
+ */
+ replacer?: string;
+ /**
+ * Matching flags; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags
+ */
+ flags?: string;
+ [k: string]: unknown;
+} & (LogFilterText | LogFilterRegex);
/**
* One or more log filtering rules
*/
-export type LogFiltersConfig = string[];
+export type LogFiltersConfig = LogFilter[];
/**
* Log level (console[:file])
*/
@@ -187,6 +201,26 @@ export interface DefaultCapabilitiesConfig {
export interface DriverConfig {
[k: string]: unknown;
}
+/**
+ * Log filter with plain text
+ */
+export interface LogFilterText {
+ /**
+ * Text to match
+ */
+ text: string;
+ [k: string]: unknown;
+}
+/**
+ * Log filter with regular expression
+ */
+export interface LogFilterRegex {
+ /**
+ * Regex pattern to match
+ */
+ pattern: string;
+ [k: string]: unknown;
+}
/**
* Path to configuration JSON file to register Appium as a node with Selenium Grid 3; otherwise the configuration itself
*/

fix(schema): add definition for log filters