@terascope/data-mate / index
index
References
AddArgs
Re-exports AddArgs
AdjustDateArgs
Re-exports AdjustDateArgs
AggregationFrame
Re-exports AggregationFrame
AggregationFrameOptions
Re-exports AggregationFrameOptions
AnyBuilder
Re-exports AnyBuilder
AnyVector
Re-exports AnyVector
ArgSchema
Re-exports ArgSchema
BatchConfig
Re-exports BatchConfig
BigIntBuilder
Re-exports BigIntBuilder
BigIntVector
Re-exports BigIntVector
BooleanBuilder
Re-exports BooleanBuilder
BooleanVector
Re-exports BooleanVector
Builder
Re-exports Builder
BuilderOptions
Re-exports BuilderOptions
CastArgs
Re-exports CastArgs
Column
Re-exports Column
ColumnConfig
Re-exports ColumnConfig
ColumnOptions
Re-exports ColumnOptions
ContainsArgs
Re-exports ContainsArgs
CreateIDArgs
Re-exports CreateIDArgs
CreateJoinQueryOptions
Re-exports CreateJoinQueryOptions
DataBuckets
Re-exports DataBuckets
DataFrame
Re-exports DataFrame
DataFrameAdapterOptions
Re-exports DataFrameAdapterOptions
DataFrameOptions
Re-exports DataFrameOptions
DataTypeFieldAndChildren
Re-exports DataTypeFieldAndChildren
DataValueTuple
Re-exports DataValueTuple
DateBuilder
Re-exports DateBuilder
DateVector
Re-exports DateVector
DivideArgs
Re-exports DivideArgs
DocumentMatcher
Re-exports DocumentMatcher
DynamicFrameFunctionContext
Re-exports DynamicFrameFunctionContext
DynamicFunctionContext
Re-exports DynamicFunctionContext
EmptyArgs
Re-exports EmptyArgs
EncodeArgs
Re-exports EncodeArgs
EncodeSHA1Args
Re-exports EncodeSHA1Args
EncodeSHAArgs
Re-exports EncodeSHAArgs
EndsWithArgs
Re-exports EndsWithArgs
EntropyArgs
Re-exports EntropyArgs
EqualsArgs
Re-exports EqualsArgs
ExtractArgs
Re-exports ExtractArgs
ExtractFieldConfig
Re-exports ExtractFieldConfig
FieldAgg
Re-exports FieldAgg
FieldAggregator
Renames and re-exports aggregations/field-aggregation
FieldArg
Re-exports FieldArg
FieldMetaTransform
Re-exports FieldMetaTransform
FieldTransformConfig
Re-exports FieldTransformConfig
FieldValidateConfig
Re-exports FieldValidateConfig
FieldValidator
Renames and re-exports validations/field-validator
FilterByFields
Re-exports FilterByFields
FilterByFn
Re-exports FilterByFn
FilterByRowsFn
Re-exports FilterByRowsFn
FloatBuilder
Re-exports FloatBuilder
FloatVector
Re-exports FloatVector
FormatDateArgs
Re-exports FormatDateArgs
FrameAdapterFn
Re-exports FrameAdapterFn
FunctionConfigRepository
Re-exports FunctionConfigRepository
FunctionContext
Re-exports FunctionContext
FunctionDefinitionCategory
Re-exports FunctionDefinitionCategory
FunctionDefinitionConfig
Re-exports FunctionDefinitionConfig
FunctionDefinitionExample
Re-exports FunctionDefinitionExample
FunctionDefinitionType
Re-exports FunctionDefinitionType
GeoBoundaryBuilder
Re-exports GeoBoundaryBuilder
GeoBoundaryVector
Re-exports GeoBoundaryVector
GeoContainsArgs
Re-exports GeoContainsArgs
GeoContainsPointArgs
Re-exports GeoContainsPointArgs
GeoDisjointArgs
Re-exports GeoDisjointArgs
GeoIntersectsArgs
Re-exports GeoIntersectsArgs
GeoJSONBuilder
Re-exports GeoJSONBuilder
GeoJSONVector
Re-exports GeoJSONVector
GeoPointBuilder
Re-exports GeoPointBuilder
GeoPointVector
Re-exports GeoPointVector
GeoPointWithinRangeArgs
Re-exports GeoPointWithinRangeArgs
GeoRelationArgs
Re-exports GeoRelationArgs
GeoWithinArgs
Re-exports GeoWithinArgs
GetTimeBetweenArgs
Re-exports GetTimeBetweenArgs
GetTimezoneOffsetArgs
Re-exports GetTimezoneOffsetArgs
GreaterThanArgs
Re-exports GreaterThanArgs
GreaterThanOrEqualToArgs
Re-exports GreaterThanOrEqualToArgs
IPBuilder
Re-exports IPBuilder
IPRangeBuilder
Re-exports IPRangeBuilder
IPRangeVector
Re-exports IPRangeVector
IPVector
Re-exports IPVector
InGeoBoundingBoxArgs
Re-exports InGeoBoundingBoxArgs
InIPRangeArgs
Re-exports InIPRangeArgs
InNumberRangeArg
Re-exports InNumberRangeArg
InitialFunctionContext
Re-exports InitialFunctionContext
InputType
Re-exports InputType
IntBuilder
Re-exports IntBuilder
IntToIPArgs
Re-exports IntToIPArgs
IntVector
Re-exports IntVector
IsAfterArgs
Re-exports IsAfterArgs
IsAlphaArgs
Re-exports IsAlphaArgs
IsAlphaNumericArgs
Re-exports IsAlphaNumericArgs
IsBeforeArgs
Re-exports IsBeforeArgs
IsBetweenArgs
Re-exports IsBetweenArgs
IsDateArgs
Re-exports IsDateArgs
IsEpochArgs
Re-exports IsEpochArgs
IsEpochMillisArgs
Re-exports IsEpochMillisArgs
IsHashArgs
Re-exports IsHashArgs
IsISDNArgs
Re-exports IsISDNArgs
IsLengthArgs
Re-exports IsLengthArgs
IsMACArgs
Re-exports IsMACArgs
IsPostalCodeArgs
Re-exports IsPostalCodeArgs
JoinArgs
Re-exports JoinArgs
JoinBy
Re-exports JoinBy
KeyAggFn
Re-exports KeyAggFn
KeyAggregation
Re-exports KeyAggregation
LessThanArgs
Re-exports LessThanArgs
LessThanOrEqualToArgs
Re-exports LessThanOrEqualToArgs
ListBuilder
Re-exports ListBuilder
ListVector
Re-exports ListVector
LookupArgs
Re-exports LookupArgs
MAX_16BIT_INT
Re-exports MAX_16BIT_INT
MAX_32BIT_INT
Re-exports MAX_32BIT_INT
MAX_8BIT_INT
Re-exports MAX_8BIT_INT
MakeKeyAggFn
Re-exports MakeKeyAggFn
MakeValueAgg
Re-exports MakeValueAgg
MatchValueFn
Re-exports MatchValueFn
ModulusArgs
Re-exports ModulusArgs
MultiplyArgs
Re-exports MultiplyArgs
ObjectBuilder
Re-exports ObjectBuilder
ObjectVector
Re-exports ObjectVector
OldData
Re-exports OldData
OutputType
Re-exports OutputType
ParsedNumericObject
Re-exports ParsedNumericObject
PowerArgs
Re-exports PowerArgs
ProcessMode
Re-exports ProcessMode
RandomArgs
Re-exports RandomArgs
ReadableData
Re-exports ReadableData
ReadonlySparseMap
Re-exports ReadonlySparseMap
RecordAggregator
Renames and re-exports aggregations/record-aggregation
RecordInput
Re-exports RecordInput
RecordTransformConfig
Re-exports RecordTransformConfig
RecordValidationConfig
Re-exports RecordValidationConfig
RecordValidator
Renames and re-exports validations/record-validator
ReplaceLiteralArgs
Re-exports ReplaceLiteralArgs
ReplaceRegexArgs
Re-exports ReplaceRegexArgs
RepoConfig
Re-exports RepoConfig
Repository
Re-exports Repository
SerializeOptions
Re-exports SerializeOptions
SetDateArgs
Re-exports SetDateArgs
SetDefaultArgs
Re-exports SetDefaultArgs
SetHoursArgs
Re-exports SetHoursArgs
SetMillisecondsArgs
Re-exports SetMillisecondsArgs
SetMinutesArgs
Re-exports SetMinutesArgs
SetMonthArgs
Re-exports SetMonthArgs
SetPrecisionArgs
Re-exports SetPrecisionArgs
SetSecondsArgs
Re-exports SetSecondsArgs
SetTimezoneArgs
Re-exports SetTimezoneArgs
SetYearArgs
Re-exports SetYearArgs
SplitArgs
Re-exports SplitArgs
StartsWithArgs
Re-exports StartsWithArgs
StringBuilder
Re-exports StringBuilder
StringVector
Re-exports StringVector
SubtractArgs
Re-exports SubtractArgs
TimeZoneArgs
Re-exports TimeZoneArgs
TimeZoneUsingLocationArgs
Re-exports TimeZoneUsingLocationArgs
ToCIDRArgs
Re-exports ToCIDRArgs
ToDateArgs
Re-exports ToDateArgs
TrimArgs
Re-exports TrimArgs
TrimEndArgs
Re-exports TrimEndArgs
TrimStartArgs
Re-exports TrimStartArgs
TruncateConfig
Re-exports TruncateConfig
TupleBuilder
Re-exports TupleBuilder
TupleVector
Re-exports TupleVector
ValidatedBatchConfig
Re-exports ValidatedBatchConfig
ValueAggregation
Re-exports ValueAggregation
ValueFromFn
Re-exports ValueFromFn
VariableState
Re-exports VariableState
Vector
Re-exports Vector
VectorOptions
Re-exports VectorOptions
VectorType
Re-exports VectorType
WritableData
Re-exports WritableData
_newBuilder
Re-exports _newBuilder
_newVector
Re-exports _newVector
booleanRepository
Re-exports booleanRepository
buildSearchMatcherForQuery
Re-exports buildSearchMatcherForQuery
copyVectorToBuilder
Re-exports copyVectorToBuilder
dataFrameAdapter
Re-exports dataFrameAdapter
dateRepository
Re-exports dateRepository
dynamicMapVectorEach
Re-exports dynamicMapVectorEach
dynamicMapVectorEachValue
Re-exports dynamicMapVectorEachValue
flattenStringArg
Re-exports flattenStringArg
freezeArray
Re-exports freezeArray
freezeObject
Re-exports freezeObject
functionConfigRepository
Re-exports functionConfigRepository
geoRepository
Re-exports geoRepository
getBuildersForConfig
Re-exports getBuildersForConfig
getChildDataTypeConfig
Re-exports getChildDataTypeConfig
getCommonFieldType
Re-exports getCommonFieldType
getCommonTupleType
Re-exports getCommonTupleType
getDataTypeFieldAndChildren
Re-exports getDataTypeFieldAndChildren
getFieldTypesFromFieldConfigAndChildConfig
Re-exports getFieldTypesFromFieldConfigAndChildConfig
getFieldsFromArg
Re-exports getFieldsFromArg
getNumericValues
Re-exports getNumericValues
getPointerArray
Re-exports getPointerArray
getTypedArrayClass
Re-exports getTypedArrayClass
getVectorId
Re-exports getVectorId
ipRepository
Re-exports ipRepository
isBuilder
Re-exports isBuilder
isFieldOperation
Re-exports isFieldOperation
isFieldTransform
Re-exports isFieldTransform
isFieldValidation
Re-exports isFieldValidation
isFloatLike
Re-exports isFloatLike
isIntLike
Re-exports isIntLike
isNumberLike
Re-exports isNumberLike
isNumericType
Re-exports isNumericType
isRecordTransform
Re-exports isRecordTransform
isRecordValidation
Re-exports isRecordValidation
isStringLike
Re-exports isStringLike
isTransformOperation
Re-exports isTransformOperation
isVector
Re-exports isVector
jexl
Re-exports jexl
jsonRepository
Re-exports jsonRepository
keyAggMap
Re-exports keyAggMap
makeUniqueKeyAgg
Re-exports makeUniqueKeyAgg
mapVectorEach
Re-exports mapVectorEach
mapVectorEachValue
Re-exports mapVectorEachValue
numericRepository
Re-exports numericRepository
numericTypes
Re-exports numericTypes
objectRepository
Re-exports objectRepository
runVectorAggregation
Re-exports runVectorAggregation
stringRepository
Re-exports stringRepository
stringTypes
Re-exports stringTypes
toXluceneQuery
Re-exports toXluceneQuery
transformVectorToBuilder
Re-exports transformVectorToBuilder
validateAccepts
Re-exports validateAccepts
validateFieldTransformArgs
Re-exports validateFieldTransformArgs
validateFunctionArgs
Re-exports validateFunctionArgs
valueAggMap
Re-exports valueAggMap
xLuceneQueryResult
Re-exports xLuceneQueryResult
Variables
FieldTransform
const
FieldTransform:object
Type declaration
repository
repository:
Repository
decodeBase64()
decodes a base64 encoded value if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const str = 'hello world';
const encoded = encodeBase64(str);
const results = FieldTransform.decodeBase64(encoded)
results === str
FieldTransform.decodeBase64([encoded]) === [str]
decodeHex()
decodes the hex encoded input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'hello world';
const encoded = encodeHex(source);
FieldTransform.decodeHex(encoded); // source;
FieldTransform.decodeHex([encoded]); // [source];
decodeURL()
decodes a URL encoded value if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'HELLO AND GOODBYE';
const encoded = 'HELLO%20AND%20GOODBYE';
FieldTransform.decodeURL(encoded); // source;
FieldTransform.decodeURL([encoded]); //[source];
encodeBase64()
converts a value into a base64 encoded value if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const str = 'hello world';
const encodedValue = FieldTransform.encodeBase64(str);
const arrayOfEncodedValues = FieldTransform.encodeBase64([str]);
encodeHex()
hex encodes the input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'hello world';
FieldTransform.encodeHex(source);
const arrayOfEncodedValues = FieldTransform.encodeHex([source]);
encodeMD5()
MD5 encodes the input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'hello world';
FieldTransform.encodeMD5(source);
const arrayOfEncodedValues = FieldTransform.encodeHex([source]);
encodeSHA()
SHA encodes the input to the hash specified
- if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | * |
_parentContext ? | unknown | - |
__namedParameters ? | object | - |
__namedParameters.digest ? | undefined | string | - |
__namedParameters.hash ? | undefined | string | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
*
* const data = 'some string';
* const config = { hash: 'sha256', digest: 'hex'};
* fieldTransform.encodeSHA(data , {}, config)
* const arrayOfEncodedValues = FieldTransform.encodeSHA([source], {}, config);
*
*
encodeSHA1()
converts the value to a SHA1 encoded value if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'hello world';
FieldTransform.encodeSHA1(source);
const arrayOfEncodedValues = FieldTransform.encodeSHA([source]);
encodeURL()
URL encodes a value if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const source = 'HELLO AND GOODBYE';
const encoded = 'HELLO%20AND%20GOODBYE';
FieldTransform.encodeURL(source); // encoded;
const arrayOfEncodedValues = FieldTransform.encodeURL([source]);
extract()
Can extract values from a string input. You may either specify a regex, a jexl expression, or specify the start and end from which the extraction will take all values between if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type |
---|---|
_input | unknown |
_parentContext | AnyObject |
_args | ExtractFieldConfig |
Returns
any
| null
returns null if input is null/undefined
Example
const config = { start: '<', end: '>' }
const results1 = FieldTransform.extract('<hello>', { field: '<hello>' }, config);
results1; // 'hello';
const results2 = FieldTransform.extract('bar', { foo: 'bar' }, { jexlExp: '[foo]' });
results2; // ['bar'];
const results3 = FieldTransform.extract('hello', { field: 'hello'}, { regex: 'he.*' });
results3; // ['hello'];
const config2 = { regex: 'he.*', isMultiValue: false };
const results = FieldTransform.extract('hello', { field: 'hello'}, config2);
results; // 'hello';
const context = { field: ['<hello>', '<world>'] };
const results = FieldTransform.extract(['<hello>', '<world>'], context, config);
results; // ['hello', 'world'];
formatDate()
Function that will format a number or date string to a given date format provided
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext | unknown | - |
args | FormatDateConfig | format is the shape that the date will be, resolution is only needed when input is a number |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const config = { format: 'MMM do yy' };
const results1 = FieldTransform.formatDate('2020-01-14T20:34:01.034Z', {}, config)
results1 === 'Jan 14th 20';
const results2 = FieldTransform.formatDate('March 3, 2019', {}, { format: 'M/d/yyyy' })
results2 === '3/3/2019';
const config = { format: 'yyyy-MM-dd', resolution: 'seconds' };
const results3 = FieldTransform.formatDate(1581013130, {}, config)
results3 === '2020-02-06';
const config = { format: 'yyyy-MM-dd' };
const results = FieldTransform.formatDate([1581013130856, undefined], {}, config)
results // ['2020-02-06']);
map()
This function is used to map an array of values with any FieldTransform method
Parameters
Parameter | Type | Description |
---|---|---|
input | any [] | an array of any value |
parentContext | any [] | - |
args | object | fn any FieldTransform function name, options is an object with any additional parameters needed |
args.fn | string | - |
args.options ? | any | - |
Returns
any
[] | null
returns the mapped values, return null if input is null/undefined
Example
const array = ['hello', 'world', 'goodbye'];
const results = FieldTransform.map(array, array, { fn: 'truncate', options: { size: 3 } }
results === ['hel', 'wor', 'goo']
parseDate()
Will use date-fns parse against the input and return a date object
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext | unknown | - |
args | ParseDateConfig |
Returns
Date
| (Date
| null
)[] | null
returns null if input is null/undefined
Example
const result = FieldTransform.parseDate('2020-01-10-00:00', {}, { format: 'yyyy-MM-ddxxx' })
result === new Date('2020-01-10T00:00:00.000Z');
const result = FieldTransform.parseDate('Jan 10, 2020-00:00', {}, { format: 'MMM dd, yyyyxxx' })
result === new Date('2020-01-10T00:00:00.000Z');
const result = FieldTransform.parseDate(1581025950223, {}, { format: 'T' })
result === new Date('2020-02-06T21:52:30.223Z');
const result = FieldTransform.parseDate(1581025950, {}, { format: 't' })
result === new Date('2020-02-06T21:52:30.000Z');
const result = FieldTransform.parseDate('1581025950', {} { format: 't' })
result === new Date('2020-02-06T21:52:30.000Z');
parseJSON()
Parses the json input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
any
| null
returns null if input is null/undefined
Example
const obj = { hello: 'world' };
const json = JSON.stringify(obj);
const results = FieldTransform.parseJSON(json);
results === obj
FieldTransform.parseJSON([json]); // [obj]
replaceLiteral()
This function replaces the searched value with the replace value
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | |
_parentContext | unknown | - |
__namedParameters | ReplaceLiteralConfig | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const context = { key: 'Hi bob' };
FieldTransform.replaceLiteral('Hi bob', context, { search: 'bob', replace: 'mel' }) === 'Hi mel';
FieldTransform.replaceLiteral('Hi Bob', context, { search: 'bob', replace: 'Mel' }) === 'Hi Bob';
const data = ['Hi bob', 'hello bob'];
const config = { search: 'bob', replace: 'mel' };
FieldTransform.replaceLiteral(data, {}, config) // ['Hi mel', 'hello mel'];
replaceRegex()
This function replaces chars in a string based off the regex value provided
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | |
_parentContext | unknown | - |
__namedParameters | ReplaceRegexConfig | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const config1 = { regex: 's|e', replace: 'd' };
const results1 = FieldTransform.replaceRegex('somestring', {}, config1)
results1 === 'domestring'
const config2 = { regex: 's|e', replace: 'd', global: true };
const results2 = FieldTransform.replaceRegex('somestring', {}, config)
results2 === 'domddtring'
const config3 = {
regex: 'm|t', replace: 'W', global: true, ignoreCase: true
};
const results3 = FieldTransform.replaceRegex('soMesTring', {}, config3))
results3 === 'soWesWring'
setDefault()
This function is used to set a value if input is null or undefined, otherwise the input value is returned
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext | unknown | - |
args | object | value is what will be given when input is null/undefined |
args.value | any | - |
Returns
any
Example
const results = FieldTransform.setDefault(undefined, {}, { value: 'someValue' });
results === 'someValue';
setField()
This function is not meant to be used programmatically
please use RecordTransform.setField
instead
Parameters
Parameter | Type | Description |
---|---|---|
_input | unknown | This value will be discarded |
_parentContext | unknown | - |
args | object | value will be used to set field |
args.value | any | - |
Returns
any
splitString()
Converts a string to an array of characters split by the delimiter provided
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
args ? | object | delimter defaults to an empty string |
args.delimiter ? | string | - |
Returns
string
[] | string
[][] | null
Example
FieldTransform.splitString('astring'); // ['a', 's', 't', 'r', 'i', 'n', 'g'];
FieldTransform.splitString('astring', {}, { delimiter: ',' }); // ['astring'];
expect(FieldTransform.splitString(
'a-stri-ng', {}, { delimiter: '-' }
)).toEqual(['a', 'stri', 'ng']);
toBoolean()
Converts values to booleans if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
boolean
| boolean
[] | null
returns null if input is null/undefined
Example
FieldTransform.toBoolean('0'); // false
FieldTransform.toBoolean(['foo', 'false', null]); // [true, false];
toCamelCase()
Will convert a string, or an array of strings to camel case;
Parameters
Parameter | Type | Description |
---|---|---|
input | string | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toCamelCase('I need camel case'); // 'iNeedCamelCase';
FieldTransform.toCamelCase('happyBirthday'); // 'happyBirthday';
FieldTransform.toCamelCase('what_is_this'); // 'whatIsThis';
const array = ['what_is_this', 'I need camel case'];
FieldTransform.toCamelCase(array); // ['whatIsThis', 'iNeedCamelCase'];
toGeoPoint()
Converts the value into a geo-point if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
object
| object
[] | null
returns null if input is null/undefined
Example
fieldTransform.toGeoPoint('60, 40'); // { lon: 40, lat: 60 };
fieldTransform.toGeoPoint([40, 60]); // { lon: 40, lat: 60 };
fieldTransform.toGeoPoint({ lat: 40, lon: 60 }); // { lon: 60, lat: 40 };
fieldTransform.toGeoPoint({ latitude: 40, longitude: 60 }); // { lon: 60, lat: 40 }
const results = FieldTransform.toGeoPoint(['60, 40', null, [50, 60]]);
results === [{ lon: 40, lat: 60 },{ lon: 50, lat: 60 }];
toISDN()
Parses a string or number to a fully validated phone number if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | string | string[] | number | number[] |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
a fully validated phone number, returns null if input is null/undefined
Example
FieldTransform.toISDN('+33-1-22-33-44-55'); // '33122334455';
FieldTransform.toISDN('1(800)FloWErs'); // '18003569377';
FieldTransform.toISDN(['1(800)FloWErs','+33-1-22-33-44-55' ]); // ['18003569377', '33122334455'];
toISO8601()
Converts a date string or number to an ISO date
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
args ? | object | if input is a number, you may specify the resolution of that number, defaults to seconds |
args.resolution ? | "seconds" | "milliseconds" | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toISO8601('2020-01-01'); // '2020-01-01T00:00:00.000Z';
const config = { resolution: 'seconds' };
FieldTransform.toISO8601(1580418907, {}, config); // '2020-01-30T21:15:07.000Z';
const data = ['2020-01-01', '2020-01-02'];
FieldTransform.toISO8601(data); // ['2020-01-01T00:00:00.000Z', '2020-01-02T00:00:00.000Z'];
toJSON()
Converts input to JSON if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
__namedParameters ? | object | - |
__namedParameters.pretty ? | undefined | boolean | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const obj = { hello: 'world' };
FieldTransform.toJSON(obj); // '{"hello": "world"}'
FieldTransform.toJSON([obj]); // ['{"hello": "world"}']
toKebabCase()
Will convert a string, or an array of strings to kebab case
Parameters
Parameter | Type | Description |
---|---|---|
input | string | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toKebabCase('I need kebab case'); // 'i-need-kebab-case';
FieldTransform.toKebabCase('happyBirthday'); // 'happy-birthday';
FieldTransform.toKebabCase('what_is_this'); // 'what-is-this';
FieldTransform.toKebabCase('this-should-be-kebab'); // 'this-should-be-kebab';
const array = ['happyBirthday', 'what_is_this']
FieldTransform.toKebabCase(array); // ['happy-birthday', 'what-is-this'];
toLowerCase()
Converts strings to lowercase if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string | string[] |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toLowerCase('UPPERCASE'); // 'uppercase';
FieldTransform.toLowerCase(['MixEd', null, 'UPPER']); // ['mixed', 'upper'];
toNumber()
Converts a value to a number if possible if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
args ? | object | |
args.booleanLike ? | boolean | - |
Returns
number
| number
[] | null
returns null if input is null/undefined
Example
FieldTransform.toNumber('12321'); // 12321;
FieldTransform.toNumber('000011'); // 11;
FieldTransform.toNumber('true', {}, { booleanLike: true }); // 1;
FieldTransform.toNumber(null, {}, { booleanLike: true }); // 0;
FieldTransform.toNumber(null); // null;
FieldTransform.toNumber(['000011', '12321']); // [11, 12321];
toPascalCase()
Converts a string, or an array of strings to pascal case
Parameters
Parameter | Type | Description |
---|---|---|
input | string | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toPascalCase('I need pascal case'); // 'INeedPascalCase';
FieldTransform.toPascalCase('happyBirthday'); // 'HappyBirthday';
FieldTransform.toPascalCase('what_is_this'); // 'WhatIsThis';
const array = ['happyBirthday', 'what_is_this']
FieldTransform.toKebabCase(array); // ['HappyBirthday', 'WhatIsThis'];
toSnakeCase()
Converts a string, or an array of strings to snake case
Parameters
Parameter | Type | Description |
---|---|---|
input | string | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toSnakeCase('I need snake case'); // 'i_need_snake_case';
FieldTransform.toSnakeCase('happyBirthday'); // 'happy_birthday';
FieldTransform.toSnakeCase('what_is_this'); // 'what_is_this';
const array = ['happyBirthday', 'what_is_this']
FieldTransform.toKebabCase(array); // ['happy_birthday', 'what_is_this'];
toString()
Converts values to strings if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toString(true); // 'true';
FieldTransform.toString([true, undefined, false]); // ['true', 'false'];
toTitleCase()
Converts a string, or an array of strings to title case
Parameters
Parameter | Type | Description |
---|---|---|
input | string | |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toTitleCase('I need some capitols'); // 'I Need Some Capitols';
FieldTransform.toTitleCase('happyBirthday'); // 'Happy Birthday';
FieldTransform.toTitleCase('what_is_this'); // 'What Is This';
toUnixTime()
Converts a given date to its time in milliseconds or seconds
Parameters
Parameter | Type | Description |
---|---|---|
input | unknown | |
_parentContext ? | unknown | - |
__namedParameters ? | object | - |
__namedParameters.ms ? | undefined | boolean | - |
Returns
number
| number
[] | null
returns null if input is null/undefined
Example
FieldTransform.toUnixTime('2020-01-01'); // 1577836800;
FieldTransform.toUnixTime('Jan 1, 2020 UTC'); // 1577836800;
FieldTransform.toUnixTime('2020 Jan, 1 UTC'); // 1577836800;
FieldTransform.toUnixTime(1580418907000); // 1580418907;
FieldTransform.toUnixTime(1580418907000, {}, { ms: true }); // 1580418907000;
FieldTransform.toUnixTime(['Jan 1, 2020 UTC', '2020 Jan, 1 UTC']); // [1577836800, 1577836800];
toUpperCase()
Converts strings to UpperCase if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string or string[] |
_parentContext ? | unknown | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.toUpperCase('lowercase'); // 'LOWERCASE';
FieldTransform.toUpperCase(['MixEd', null, 'lower']); // ['MIXED', 'LOWER'];
trim()
Will trim the input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string | string[] |
parentContext ? | unknown | - |
args ? | object | a single char or word that will be cut out |
args.char ? | string | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.trim('right '); // 'right';
FieldTransform.trim('fast cars race fast', {}, { char: 'fast' }); // ' cars race ';
FieldTransform.trim(' string ')).toBe('string');
FieldTransform.trim(' left')).toBe('left');
FieldTransform.trim('.*.*a regex test.*.*.*.* stuff', {}, { char: '.*' }); // 'a regex test'
FieldTransform.trim('\t\r\rtrim this\r\r', {}, { char: '\r' }); // 'trim this'
FieldTransform.trim(' '); // ''
FieldTransform.trim(['right ', ' left']); // ['right', 'left'];
trimEnd()
Will trim the end of the input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string | string[] |
_parentContext ? | unknown | - |
args ? | object | |
args.char ? | string | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.trimEnd(' Hello Bob '); // ' Hello Bob';
FieldTransform.trimEnd('iiii-wordiwords-iii', {}, { char: 'i' }); // 'iiii-wordiwords';
FieldTransform.trimEnd([' Hello Bob ', 'right ']); // [' Hello Bob', 'right'];
trimStart()
Will trim the beginning of the input if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string | string[] |
_parentContext ? | unknown | - |
args ? | object | |
args.char ? | string | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
const config = { char: 'i' };
FieldTransform.trimStart(' Hello Bob '); // 'Hello Bob ';
FieldTransform.trimStart('iiii-wordiwords-iii', {}, config); // '-wordiwords-iii';
FieldTransform.trimStart([' Hello Bob ', 'right ']); // ['Hello Bob ', 'right '];
truncate()
Will truncate the input to the length of the size given if given an array it will convert everything in the array excluding null/undefined values
Parameters
Parameter | Type | Description |
---|---|---|
input | StringInput | string | string[] |
_parentContext | unknown | - |
args | object | |
args.size | number | - |
Returns
string
| string
[] | null
returns null if input is null/undefined
Example
FieldTransform.truncate('thisisalongstring', {}, { size: 4 }); // 'this';
FieldTransform.truncate(['hello', null, 'world'], {}, { size: 2 }); // ['he', 'wo'];
Source
RecordTransform
const
RecordTransform:object
Type declaration
repository
repository:
Repository
copyField()
Will copy a field to another field
Parameters
Parameter | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | object | |
args.from | string | - |
args.to | string | - |
Returns
ts.AnyObject
| null
object
Example
const obj = { hello: 'world', other: 'stuff' };
const config = { from: 'other', to: 'myCopy' };
const results = RecordTransform.copyField(cloneDeep(obj), cloneDeep(obj), config);
results; // { hello: 'world', other: 'stuff', myCopy: 'stuff' };
dedupe()
returns an array with only unique values
Type parameters
Type parameter | Value |
---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
input | any [] | |
_parentContext ? | unknown [] | - |
Returns
T
[] | null
returns null if input is null/undefined
Example
const results = FieldTransform.dedupe([1, 2, 2, 3, 3, 3, undefined, 4])
results === [1, 2, 3, 4]
const results = RecordTransform.dedupe([
{ hello: 'world' },
{ hello: 'world' },
{ other: 'obj' },
])
results === [{ hello: 'world' }, { other: 'obj' }];
dropFields()
removes fields from a record
Parameters
Parameter | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | object | |
args.fields | string [] | - |
Returns
ts.AnyObject
| null
object
Example
const obj = { hello: 'world', other: 'stuff', last: 'thing' };
const config = { fields: ['other', 'last']} ;
const results = RecordTransform.dropFields(cloneDeep(obj), cloneDeep(obj), config);
results; // { hello: 'world' };
renameField()
This will migrate a fields value to a new field name
Parameters
Parameter | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | object | |
args.from | string | - |
args.to | string | - |
Returns
ts.AnyObject
| null
object
Example
const obj = { hello: 'world' };
const config = { from: 'hello', to: 'goodbye' };
const results = RecordTransform.renameField(cloneDeep(obj), cloneDeep(obj), config);
results === { goodbye: 'world' };
setField()
Sets a field on a record with the given value
Parameters
Parameter | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | object | |
args.field | string | - |
args.value | any | - |
Returns
ts.AnyObject
| null
object
Example
const obj = { hello: 'world' };
const config = { field: 'other', value: 'stuff' };
const results = RecordTransform.setField(cloneDeep(obj), cloneDeep(obj), config);
results === { hello: 'world', other: 'stuff' };
transformRecord()
Will execute a jexl expression. Can use data-mate functions inside the jexl expression. You do not need to specify the parent context argument as that is automatically the document used as to call it.
Parameters
Parameter | Type |
---|---|
_input | RecordInput |
_parentContext | RecordInput |
_args | any |
Returns
ts.AnyObject
| null
object
Example
const obj = { hello: 'world', other: 'stuff' };
const config = { query: '[hello]', field: 'final' };
const results = RecordTransform.transformRecord(clone, clone, config)
results === { hello: 'world', other: 'stuff', final: ['world'] });
const obj = { foo: 'bar' };
const config = {
jexlExp: 'foo|extract({ jexlExp: "foo|toUpperCase" })', field: 'final'
};
const mixedData = [obj, undefined, null];
const results = RecordTransform.transformRecord(
mixedData, mixedData, config
)
results === [{ foo: 'bar', final: 'BAR' }];