New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trayio/connector-utils

Package Overview
Dependencies
Maintainers
11
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trayio/connector-utils - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

lib/generateInputSchema.js

2

lib/index.js

@@ -6,2 +6,3 @@ /* eslint-disable no-console */

const validatePaginationRange = require('./validatePaginationRange');
const generateInputSchema = require('./generateInputSchema');
// const xmlFormatter = require('./xmlFormatter');

@@ -70,2 +71,3 @@ const { mustachedDDL, DDL } = require('./ddl');

validatePaginationRange,
generateInputSchema,
// Commenting for initial release pending functionality to add paths to treatAsArray

@@ -72,0 +74,0 @@ // xml: {

95

package.json
{
"name": "@trayio/connector-utils",
"version": "0.2.1",
"description": "Common utility functions used in connectors.",
"main": "lib/index.js",
"scripts": {
"test": "jest tests",
"test:watch": "jest tests --watch",
"lint": "eslint ./ --fix"
},
"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": "github:trayio/connector-test-runner",
"@trayio/falafel": "^1.26.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^22.21.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"jest": "^24.9.0",
"jest-json-schema": "^2.1.0",
"jsdoc-to-markdown": "^5.0.1",
"prettier": "^1.19.1"
},
"dependencies": {
"lodash": "~4.17.15",
"mustache": "^3.1.0"
}
"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"
}
}

@@ -32,3 +32,3 @@ # Connector-utils

```
const { UserInputError } = require('@trayio/connector-utils/lib/errors')
const { UserInputError } = require('@trayio/connector-utils').errors
```

@@ -111,2 +111,5 @@

</dd>
<dt><a href="#generateInputSchema">generateInputSchema({ schema, keys, operation = 'schema' })</a></dt>
<dd><p>Helper for generating an operation input schema.</p>
</dd>
</dl>

@@ -378,19 +381,73 @@

## generateInputSchema({ schema, keys, operation = 'schema' })
Helper for generating an operation input schema.
Will log to the console if:
- a requested key does not exist, or
- `type` or `description` keys are missing
Will not log to the console if requested key does not exist, but is overridden with at least a type and description.
- @param {Object} schema The full connector schema definition.
- @param {Object} keys The keys that you wish to extract from the schema with any override values.
- @param {String} operation The name of the connector operation that you are generating the schema for.
- This will be used as the root of the object path when logging validation issues.
- @return {object} A copy of the requested schema elements.
\*/
**Kind**: global function
| Param | Type | Description |
| --------- | ------------------- | --------------------------------------------------------------------------- |
| schema | <code>Object</code> | The full connector schema definition. |
| keys | <code>Object</code> | The keys that you wish to extract from the schema with any override values. |
| operation | <code>String</code> | The name of the connector operation that you are generating the schema for. |
For more information on how to use the schema generator, please see [schema-generation.md](./schema-generation.md).
**Example**
```js
validatePaginationRange(50, {
minRange: 1,
maxRange: 100,
inputName: 'page size',
generateInputSchema({
operation: 'operationName',
schema: fullSchema,
keys: {
full_schema_key_1: {},
full_schema_key_2: {},
full_schema_key_3: {},
},
});
// no error thrown as pagination is within range
/**
* `fullSchema` is the complete schema definition for the connector
* `full_schema_key_1` is extracted from the full schema without modification
* `full_schema_key_2` is extracted from the full schema without modification
* `full_schema_key_3` is extracted from the full schema without modification
*/
validatePaginationRange(101, {
minRange: 1,
maxRange: 100,
inputName: 'page size',
generateInputSchema({
operation: 'operationName',
schema: fullSchema,
keys: {
full_schema_key_1: {},
full_schema_key_2: {
required: true,
description: 'Override key values.',
default: 'value',
},
new_key: {
type: 'string',
description: 'New date key, not in full schema.',
format: 'datetime',
date_mask: 'X',
},
},
});
// will throw a UserInputError as the pageSize is outside the range
// Error message returned: 'The page size must be between 1 - 100.'
/**
* `fullSchema` is the complete schema definition for the connector
* `full_schema_key_1` is extracted from the full schema without modification
* `full_schema_key_2` is extracted from the full schema and extended/overridden with extra keys and values
* `new_key` is not in the full schema but it's full keys and values are supplied
*/
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc