|
|
|
@ -16,10 +16,29 @@ export interface FormatRegistryItem extends RegistryItem { |
|
|
|
|
formatter(options: FormatOptions, variable: VariableModel): string; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export enum FormatRegistryID { |
|
|
|
|
lucene = 'lucene', |
|
|
|
|
raw = 'raw', |
|
|
|
|
regex = 'regex', |
|
|
|
|
pipe = 'pipe', |
|
|
|
|
distributed = 'distributed', |
|
|
|
|
csv = 'csv', |
|
|
|
|
html = 'html', |
|
|
|
|
json = 'json', |
|
|
|
|
percentEncode = 'percentencode', |
|
|
|
|
singleQuote = 'singlequote', |
|
|
|
|
doubleQuote = 'doublequote', |
|
|
|
|
sqlString = 'sqlstring', |
|
|
|
|
date = 'date', |
|
|
|
|
glob = 'glob', |
|
|
|
|
text = 'text', |
|
|
|
|
queryParam = 'queryparam', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
const formats: FormatRegistryItem[] = [ |
|
|
|
|
{ |
|
|
|
|
id: 'lucene', |
|
|
|
|
id: FormatRegistryID.lucene, |
|
|
|
|
name: 'Lucene', |
|
|
|
|
description: 'Values are lucene escaped and multi-valued variables generate an OR expression', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -39,13 +58,13 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'raw', |
|
|
|
|
id: FormatRegistryID.raw, |
|
|
|
|
name: 'raw', |
|
|
|
|
description: 'Keep value as is', |
|
|
|
|
formatter: ({ value }) => value, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'regex', |
|
|
|
|
id: FormatRegistryID.regex, |
|
|
|
|
name: 'Regex', |
|
|
|
|
description: 'Values are regex escaped and multi-valued variables generate a (<value>|<value>) expression', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -61,7 +80,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'pipe', |
|
|
|
|
id: FormatRegistryID.pipe, |
|
|
|
|
name: 'Pipe', |
|
|
|
|
description: 'Values are separated by | character', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -72,7 +91,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'distributed', |
|
|
|
|
id: FormatRegistryID.distributed, |
|
|
|
|
name: 'Distributed', |
|
|
|
|
description: 'Multiple values are formatted like variable=value', |
|
|
|
|
formatter: ({ value }, variable) => { |
|
|
|
@ -91,7 +110,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'csv', |
|
|
|
|
id: FormatRegistryID.csv, |
|
|
|
|
name: 'Csv', |
|
|
|
|
description: 'Comma-separated values', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -102,7 +121,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'html', |
|
|
|
|
id: FormatRegistryID.html, |
|
|
|
|
name: 'HTML', |
|
|
|
|
description: 'HTML escaping of values', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -113,7 +132,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'json', |
|
|
|
|
id: FormatRegistryID.json, |
|
|
|
|
name: 'JSON', |
|
|
|
|
description: 'JSON stringify valu', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -121,7 +140,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'percentencode', |
|
|
|
|
id: FormatRegistryID.percentEncode, |
|
|
|
|
name: 'Percent encode', |
|
|
|
|
description: 'Useful for URL escaping values', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -133,7 +152,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'singlequote', |
|
|
|
|
id: FormatRegistryID.singleQuote, |
|
|
|
|
name: 'Single quote', |
|
|
|
|
description: 'Single quoted values', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -146,7 +165,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'doublequote', |
|
|
|
|
id: FormatRegistryID.doubleQuote, |
|
|
|
|
name: 'Double quote', |
|
|
|
|
description: 'Double quoted values', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -159,7 +178,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'sqlstring', |
|
|
|
|
id: FormatRegistryID.sqlString, |
|
|
|
|
name: 'SQL string', |
|
|
|
|
description: 'SQL string quoting and commas for use in IN statements and other scenarios', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -172,7 +191,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'date', |
|
|
|
|
id: FormatRegistryID.date, |
|
|
|
|
name: 'Date', |
|
|
|
|
description: 'Format date in different ways', |
|
|
|
|
formatter: ({ value, args }) => { |
|
|
|
@ -191,7 +210,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'glob', |
|
|
|
|
id: FormatRegistryID.glob, |
|
|
|
|
name: 'Glob', |
|
|
|
|
description: 'Format multi-valued variables using glob syntax, example {value1,value2}', |
|
|
|
|
formatter: ({ value }) => { |
|
|
|
@ -202,7 +221,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'text', |
|
|
|
|
id: FormatRegistryID.text, |
|
|
|
|
name: 'Text', |
|
|
|
|
description: 'Format variables in their text representation. Example in multi-variable scenario A + B + C.', |
|
|
|
|
formatter: (options, variable) => { |
|
|
|
@ -220,7 +239,7 @@ export const formatRegistry = new Registry<FormatRegistryItem>(() => { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'queryparam', |
|
|
|
|
id: FormatRegistryID.queryParam, |
|
|
|
|
name: 'Query parameter', |
|
|
|
|
description: |
|
|
|
|
'Format variables as URL parameters. Example in multi-variable scenario A + B + C => var-foo=A&var-foo=B&var-foo=C.', |
|
|
|
|