![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@trayio/connector-utils
Advanced tools
Common utility functions used in connectors.
The connector-utils
package will be inherently included as part of a new connector scaffold (as part of the Trayio yeoman generator).
When adding the package as part of an existing connector, first ensure you have the appropriate .npmrc
present, then in your terminal, run:
npm i @trayio/connector-utils --save
To require the package, require as @trayio/connector-utils
:
const utils = require('@trayio/connector-utils')
This will give full access to the library. We can then reference utilities such as UserInputError
by using:
utils.error.UserInputError('custom error message')
A better usage alternative is to use destructuring, as in the example:
const { UserInputError } = require('@trayio/connector-utils').errors
A full breakdown of available utilities is included in the documentation below.
Please be sure to add any discovered issues or improvement recommendations to the Issues
tab of this repo.
Error
Class representing the base error for all connector errors
GenericError
Class representing a UserInputError
GenericError
Class representing a ConnectorError
GenericError
Class representing a ConnectorError
GenericError
Class representing a ConnectorError
GenericError
Class representing a ConnectorError
Takes value paths as mustached values and returns correct DDL outputs. A custom flag is in place to allow for keeping integer types for the value key if required, as mustaching will convert an integer to string.
Takes value paths as explicit strings and returns correct DDL outputs.
Maps object keys and formats according to specified casing.
Return a User Input Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Return a Connector Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Return a API Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Return a oAuth Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Return a No Trigger Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Generates a lookup object for DDL operations.
Recursively removes empty objects, arrays and strings from a collection. It's important to note that this method will remove objects if they become empty as a result of the nested key/value containing an empty object (the same goes for arrays).
Helper for validating user pagination input for a given range.
Helper for generating an operation input schema.
Error
Class representing the base error for all connector errors
Kind: global class
Extends: Error
GenericError
Class representing a UserInputError
Kind: global class
Extends: GenericError
Custom error to throw for issues concerning User Input.
Param | Type | Description |
---|---|---|
message | String | Custom error message to return. |
...errorArgs | any | Error args allowing for extra parameters native to the normal Error class. |
GenericError
Class representing a ConnectorError
Kind: global class
Extends: GenericError
Custom error to throw for issues concerning the Connector.
Param | Type | Description |
---|---|---|
message | String | Custom error message to return. |
...errorArgs | any | Error args allowing for extra parameters native to the normal Error class. |
GenericError
Class representing a ConnectorError
Kind: global class
Extends: GenericError
Custom error to throw for issues concerning the Api;;.
Param | Type | Description |
---|---|---|
message | String | Custom error message to return. |
...errorArgs | any | Error args allowing for extra parameters native to the normal Error class. |
GenericError
Class representing a ConnectorError
Kind: global class
Extends: GenericError
Custom error to throw when an oAuth token has expired.
Param | Type | Description |
---|---|---|
message | String | Custom error message to return. |
...errorArgs | any | Error args allowing for extra parameters native to the normal Error class. |
GenericError
Class representing a ConnectorError
Kind: global class
Extends: GenericError
Custom error to throw for issues when a trigger request is ignored.
Param | Type | Description |
---|---|---|
message | String | Custom error message to return. |
...errorArgs | any | Error args allowing for extra parameters native to the normal Error class. |
Takes value paths as mustached values and returns correct DDL outputs. A custom flag is in place to allow for keeping integer types for the value key if required, as mustaching will convert an integer to string. If there does not exist a path, the whole result will not return.
Kind: global function
Param | Type | Description |
---|---|---|
arr | Object | An array of objects with keys to iterate over and format. |
text | String | The path for the required text value. |
value | String | The path for the required value, value. |
isInteger | Boolean | Flag for whether or not the value field needs to an integer rather than a string. |
Takes value paths as explicit strings and returns correct DDL outputs. If a text value does not exist, the DDL falls back to using the 'value' path.
Kind: global function
Param | Type | Description |
---|---|---|
arr | Object | An array of objects with keys to iterate over and format. |
textPath | String | The path for the required text value. |
valuePath | String | The path fot the required value, value. |
options | String | Options to provide to the DDL |
Maps object keys and formats according to specified casing.
Kind: global function
Param | Type | Description |
---|---|---|
collection | Object | The collection with keys to iterate over and format. |
iteratee | function | The format function used to format keys IE Lodash _.camelCase('some_string'). |
Return a User Input Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Kind: global function
Param | Type | Description |
---|---|---|
message | String | The error message to be returned. |
body | any | Custom body to be returned when providing more error context. |
Return a Connector Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Kind: global function
Param | Type | Description |
---|---|---|
message | String | The error message to be returned. |
body | any | Custom body to be returned when providing more error context. |
Return a API Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Kind: global function
Param | Type | Description |
---|---|---|
message | String | The error message to be returned. |
body | any | Custom body to be returned when providing more error context. |
Return a oAuth Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Kind: global function
Param | Type | Description |
---|---|---|
message | String | The error message to be returned. |
body | any | Custom body to be returned when providing more error context. |
Return a No Trigger Error with option to pass a body argument. The use case for this over the custom Error class is to pass a body to provide error context.
Kind: global function
Param | Type | Description |
---|---|---|
message | String | The error message to be returned. |
body | any | Custom body to be returned when providing more error context. |
Generates a lookup object for DDL operations.
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
message | String | The DDL operation that is run when the lookup is executed. | |
[step_settings] | Object | {} | The custom step settings for the lookup. |
Recursively removes empty objects, arrays and strings from a collection. It's important to note that this method will remove objects if they become empty as a result of the nested key/value containing an empty object (the same goes for arrays).
Kind: global function
Param | Type | Description |
---|---|---|
collection | Object | The collection from which to remove empty objects. |
Helper for validating user pagination input for a given range.
Kind: global function
Param | Type | Description |
---|---|---|
value | Integer | String | The value specified by user input. |
validation | Object | Values relating specifically to the validation requirements. |
validation.minRange | Integer | String | The minimum range specified by the API. |
validation.maxRange | Integer | String | The maximum range specified by the API. |
validation.inputName | String | The name of the input the range is associated with. |
Helper for generating an operation input schema.
Will log to the console if:
type
or description
keys are missingWill not log to the console if requested key does not exist, but is overridden with at least a type and description.
Kind: global function
Param | Type | Description |
---|---|---|
schema | Object | The full connector schema definition. |
keys | Object | The keys that you wish to extract from the schema with any override values. |
operation | String | 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.
Example
generateInputSchema({
operation: 'operationName',
schema: fullSchema,
keys: {
full_schema_key_1: {},
full_schema_key_2: {},
full_schema_key_3: {},
},
});
/**
* `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
*/
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',
},
},
});
/**
* `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
*/
FAQs
Common utility functions used in connectors.
The npm package @trayio/connector-utils receives a total of 0 weekly downloads. As such, @trayio/connector-utils popularity was classified as not popular.
We found that @trayio/connector-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.