@trayio/connector-utils
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -11,2 +11,3 @@ /* eslint-disable no-console */ | ||
const generateAllTypes = require('./generateAllTypes'); | ||
const convertCustomFieldsArrToObj = require('./convertCustomFieldsArrToObj'); | ||
const { mustachedDDL, DDL } = require('./ddl'); | ||
@@ -79,2 +80,3 @@ const { | ||
generateAllTypes, | ||
convertCustomFieldsArrToObj, | ||
@@ -81,0 +83,0 @@ // Commenting for initial release pending functionality to add paths to treatAsArray |
{ | ||
"name": "@trayio/connector-utils", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Common utility functions used in connectors.", | ||
@@ -32,20 +32,20 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"eslint": "^7.12.1", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.0", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"jest": "^26.6.1", | ||
"jest-json-schema": "^2.1.0", | ||
"prettier": "^2.1.2" | ||
"eslint": "^8.13.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.1.4", | ||
"eslint-plugin-jsx-a11y": "^6.5.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"jest": "^27.5.1", | ||
"jest-json-schema": "^6.1.0", | ||
"prettier": "^2.6.2" | ||
}, | ||
"dependencies": { | ||
"deepdash": "^5.3.2", | ||
"deepdash": "^5.3.9", | ||
"deepmerge": "^4.2.2", | ||
"lodash": "^4.17.21", | ||
"mustache": "^4.0.1" | ||
"mustache": "^4.2.0" | ||
} | ||
} |
@@ -54,9 +54,9 @@ # Connector-utils | ||
<dt><a href="#ApiError">ApiError</a> ⇐ <code><a href="#GenericError">GenericError</a></code></dt> | ||
<dd><p>Class representing a ConnectorError</p> | ||
<dd><p>Class representing a ApiError</p> | ||
</dd> | ||
<dt><a href="#OAuthRefresh">OAuthRefresh</a> ⇐ <code><a href="#GenericError">GenericError</a></code></dt> | ||
<dd><p>Class representing a ConnectorError</p> | ||
<dd><p>Class representing a OAuthRefresh</p> | ||
</dd> | ||
<dt><a href="#NoTriggerError">NoTriggerError</a> ⇐ <code><a href="#GenericError">GenericError</a></code></dt> | ||
<dd><p>Class representing a ConnectorError</p> | ||
<dd><p>Class representing a NoTriggerError</p> | ||
</dd> | ||
@@ -127,2 +127,11 @@ </dl> | ||
</dd> | ||
</dd> | ||
<dt><a href="#convertCustomFieldsArrToObj">convertCustomFieldsArrToObj({ | ||
customFields, | ||
key, | ||
value, | ||
keyCase = 'camel', | ||
})</a></dt> | ||
<dd><p>Helper to convert an array into an object of key and values pairs.</p> | ||
</dd> | ||
</dl> | ||
@@ -542,3 +551,3 @@ | ||
```js | ||
generateAllTypes({}) | ||
generateAllTypes() | ||
@@ -550,2 +559,58 @@ // returns ['string','number','object','array','boolean','null'] | ||
// returns ['string','number','object','array'] | ||
``` | ||
<a name="convertCustomFieldsArrToObj"></a> | ||
## convertCustomFieldsArrToObj({customFields, key, value, keyCase = 'camel' }) | ||
Helper to convert an array into an object of key and values. | ||
**Kind**: global function | ||
| Param | Type | Default | Description | | ||
| ------------ | ------------------- | -------------------- | ----------------------------------------------------| | ||
| customFields | <code>Object</code> | | Array of objects that demonstrate key value pairs. | | ||
| key | <code>String</code> | | The name of the key e.g. field_name. | | ||
| value | <code>String</code> | | The value of the key e.g. field_value. | | ||
| keyCase | <code>String</code> | <code>'camel'</code> | Key case formatter. Options are: `camel` (Default), `snake`, and any other value for custom cases (Recommended value: `custom`) Optional. | | ||
| returns | <code>Object</code> | | An object with key value pairs. | | ||
**Example**: | ||
```js | ||
const customFields = [ | ||
{ | ||
field_name: 'some key', | ||
field_value: 'some value', | ||
}, | ||
{ | ||
field_name: 'helloWorld', | ||
field_value: 'hello world', | ||
}, | ||
{ | ||
field_name: 'foo_bar', | ||
field_value: 'foo bar', | ||
}, | ||
]; | ||
convertCustomFieldsArrToObj( | ||
{ | ||
customFields, | ||
key: 'field_name', | ||
value: 'field_value', | ||
}) | ||
// returns { someKey: 'some value', helloWorld: 'hello world', fooBar: 'foo bar' } | ||
convertCustomFieldsArrToObj( | ||
{ | ||
customFields, | ||
key: 'field_name', | ||
value: 'field_value', | ||
keyCase: 'snake' | ||
}) | ||
// returns { some_key: 'some value', hello_world: 'hello world', foo_bar: 'foo bar' } | ||
``` |
60509
18
907
612
Updateddeepdash@^5.3.9
Updatedmustache@^4.2.0