@trayio/connector-utils
Advanced tools
Comparing version 0.2.2 to 0.3.1
@@ -7,2 +7,3 @@ /* eslint-disable no-console */ | ||
const generateInputSchema = require('./generateInputSchema'); | ||
const formatters = require('./formatters'); | ||
// const xmlFormatter = require('./xmlFormatter'); | ||
@@ -65,2 +66,3 @@ const { mustachedDDL, DDL } = require('./ddl'); | ||
}, | ||
deepMapKeys, | ||
@@ -73,2 +75,4 @@ removeEmptyObjects, | ||
generateInputSchema, | ||
formatters, | ||
// Commenting for initial release pending functionality to add paths to treatAsArray | ||
@@ -75,0 +79,0 @@ // xml: { |
@@ -51,5 +51,5 @@ const _ = require('lodash'); | ||
} | ||
return undefined; | ||
return collection; | ||
}; | ||
module.exports = removeEmptyObjects; |
{ | ||
"name": "@trayio/connector-utils", | ||
"version": "0.2.2", | ||
"description": "Common utility functions used in connectors.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"coverage": "npm run test -- --coverage", | ||
"lint": "./node_modules/.bin/eslint . --fix", | ||
"test": "jest tests", | ||
"test:watch": "jest tests --watch --notify" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/trayio/falafel-utils.git" | ||
}, | ||
"keywords": [ | ||
"falafel", | ||
"connectors" | ||
], | ||
"files": [ | ||
"index.js", | ||
"/lib" | ||
], | ||
"author": "tray.io", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/trayio/connector-utils/issues" | ||
}, | ||
"homepage": "https://github.com/trayio/connector-utils#readme", | ||
"devDependencies": { | ||
"@trayio/connector-test-runner": "^0.5.0", | ||
"@trayio/falafel": "^1.26.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"jest": "^25.1.0", | ||
"jest-json-schema": "^2.1.0", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"prettier": "^1.19.1" | ||
}, | ||
"dependencies": { | ||
"lodash": "~4.17.15", | ||
"mustache": "^4.0.1" | ||
} | ||
} | ||
"name": "@trayio/connector-utils", | ||
"version": "0.3.1", | ||
"description": "Common utility functions used in connectors.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"coverage": "npm run test -- --coverage", | ||
"lint": "./node_modules/.bin/eslint . --fix", | ||
"test": "jest tests", | ||
"test:watch": "jest tests --watch --notify" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/trayio/falafel-utils.git" | ||
}, | ||
"keywords": [ | ||
"falafel", | ||
"connectors" | ||
], | ||
"files": [ | ||
"index.js", | ||
"/lib" | ||
], | ||
"author": "tray.io", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/trayio/connector-utils/issues" | ||
}, | ||
"homepage": "https://github.com/trayio/connector-utils#readme", | ||
"devDependencies": { | ||
"@trayio/connector-test-runner": "^0.5.0", | ||
"@trayio/falafel": "^1.26.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"jest": "^25.1.0", | ||
"jest-json-schema": "^2.1.0", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"prettier": "^1.19.1" | ||
}, | ||
"dependencies": { | ||
"lodash": "~4.17.15", | ||
"mustache": "^4.0.1" | ||
} | ||
} |
@@ -32,3 +32,3 @@ # Connector-utils | ||
``` | ||
const { UserInputError } = require('@trayio/connector-utils').errors | ||
const { UserInputError } = require('@trayio/connector-utils').error | ||
``` | ||
@@ -114,2 +114,8 @@ | ||
</dd> | ||
<dt><a href="#formatArrayToDelimitedList">formatArray(arrayToFormat)</a></dt> | ||
<dd><p>Helper to take an array of strings and return a comma-delimited string. Alias of <code><a href="#formatArrayToDelimitedList">formatArrayToDelimitedList({ arrayToFormat, delimiter: ',' })</a></code></p> | ||
</dd> | ||
<dt><a href="#formatArrayToDelimitedList">formatArrayToDelimitedList({ arrayToFormat, [delimiter] })</a></dt> | ||
<dd><p>Helper to take an array of strings and return a string that is a list, delimited by the specified delimiter ('<code>,</code>' by default).</p> | ||
</dd> | ||
</dl> | ||
@@ -381,2 +387,4 @@ | ||
<a name="generateInputSchema"></a> | ||
## generateInputSchema({ schema, keys, operation = 'schema' }) | ||
@@ -454,1 +462,37 @@ | ||
``` | ||
<a name="formatArrayToDelimitedList"></a> | ||
## formatArrayToDelimitedList({ arrayToFormat, [delimiter] }) | ||
Helper that takes an array and returns a string that is a delimited list of the given array. | ||
Alternatively, you can instead use `formatArray(arrayToFormat)`, which is an alias of `formatArrayToDelimitedList({ arrayToFormat })` and simply uses the default delimiter (`,`). | ||
Using `formatArrayToDelimitedList({ arrayToFormat, [delimiter] })` will allow you to specify an alternative delimiter. | ||
The envisioned use-case is in an operation model to format user array input into a delimited string to assign to a parameter. If it was an optional input and not supplied then the parameter should be `undefined`. This is reflected by the function returning `undefined` if it does not receive an array. | ||
**Kind**: global function | ||
| Param | Type | Default | Description | | ||
| ------------- | ------------------- | -------------- | -------------------------------------------------------------------------------- | | ||
| arrayToFormat | <code>Array</code> | | Usually an array of Strings, or else equivalent string representations are used. | | ||
| [delimiter] | <code>String</code> | <code>,</code> | A string that will be used to separate the values. | | ||
**Example**: | ||
```js | ||
const inputArray = [1, 2, 'third', 'fourth']; | ||
formatArrayToDelimitedList({ arrayToFormat: inputArray }); | ||
// returns '1,2,third,fourth' | ||
``` | ||
```js | ||
formatArrayToDelimitedList({ arrayToFormat: undefined }); | ||
// returns undefined | ||
``` |
48620
14
737
494