-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connectors): add math connector
- Loading branch information
Showing
19 changed files
with
340 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.base.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# connectors-math-helper | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build connectors-math-helper` to build the library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@linkerry/math-helper", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"tslib": "^2.3.0" | ||
}, | ||
"type": "commonjs", | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "connectors-math-helper", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/connectors/math-helper/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/libs/connectors/math-helper", | ||
"main": "libs/connectors/math-helper/src/index.ts", | ||
"tsConfig": "libs/connectors/math-helper/tsconfig.lib.json", | ||
"assets": ["libs/connectors/math-helper/*.md"], | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"updateBuildableProjectDepsInPackageJson": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ConnectorAuth, Property, createAction } from '@linkerry/connectors-framework' | ||
|
||
export const addition = createAction({ | ||
name: 'addition_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Addition', | ||
description: 'Add the first number and the second number', | ||
descriptionLong: 'Add the first number and the second number', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
return context.propsValue['first_number'] + context.propsValue['second_number'] | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ConnectorAuth, | ||
Property, | ||
Validators, | ||
createAction, | ||
} from '@linkerry/connectors-framework'; | ||
|
||
export const division = createAction({ | ||
name: 'division_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Division', | ||
description: 'Divide first number by the second number', | ||
descriptionLong: 'Divide first number by the second number', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
validators: [Validators.nonZero], | ||
}), | ||
}, | ||
async run(context) { | ||
return ( | ||
context.propsValue['first_number'] / context.propsValue['second_number'] | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
ConnectorAuth, | ||
Property, | ||
createAction, | ||
} from '@linkerry/connectors-framework'; | ||
|
||
export const generateRandom = createAction({ | ||
name: 'generateRandom_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Generate Random Number', | ||
description: 'Generate random number between two numbers (inclusive)', | ||
descriptionLong: 'Generate random number between two numbers (inclusive)', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
const min = context.propsValue['first_number']; | ||
const max = context.propsValue['second_number']; | ||
return Math.floor(Math.random() * (max - min + 1) + min); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
ConnectorAuth, | ||
Property, | ||
createAction, | ||
} from '@linkerry/connectors-framework'; | ||
|
||
export const modulo = createAction({ | ||
name: 'modulo_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Modulo', | ||
description: 'Get the remainder of the first number divided by second number', | ||
descriptionLong: 'Get the remainder of the first number divided by second number', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
return ( | ||
context.propsValue['first_number'] % context.propsValue['second_number'] | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
ConnectorAuth, | ||
Property, | ||
createAction, | ||
} from '@linkerry/connectors-framework'; | ||
|
||
export const multiplication = createAction({ | ||
name: 'multiplication_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Multiplication', | ||
description: 'Multiply first number by the second number', | ||
descriptionLong: 'Multiply first number by the second number', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
return ( | ||
context.propsValue['first_number'] * context.propsValue['second_number'] | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
ConnectorAuth, | ||
Property, | ||
createAction, | ||
} from '@linkerry/connectors-framework'; | ||
|
||
export const subtraction = createAction({ | ||
name: 'subtraction_math', | ||
auth: ConnectorAuth.None(), | ||
displayName: 'Subtraction', | ||
description: 'Subtract the first number from the second number', | ||
descriptionLong: 'Subtract the first number from the second number', | ||
errorHandlingOptions: { | ||
continueOnFailure: { | ||
hide: true, | ||
}, | ||
retryOnFailure: { | ||
hide: true, | ||
}, | ||
}, | ||
props: { | ||
first_number: Property.Number({ | ||
displayName: 'First Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
second_number: Property.Number({ | ||
displayName: 'Second Number', | ||
description: undefined, | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
return ( | ||
context.propsValue['second_number'] - context.propsValue['first_number'] | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ConnectorAuth, createConnector } from '@linkerry/connectors-framework' | ||
import { addition } from './actions/addition' | ||
import { division } from './actions/division' | ||
import { generateRandom } from './actions/generateRandom' | ||
import { modulo } from './actions/modulo' | ||
import { multiplication } from './actions/multiplication' | ||
import { subtraction } from './actions/subtraction' | ||
|
||
|
||
export const math = createConnector({ | ||
displayName: 'Math Helper', | ||
description: 'Perform mathematical operations on a data.', | ||
descriptionLong: 'Perform mathematical operations on data. For example, if the input data you want to use is in a different annotation format (e.g., $14 as 1400), you can divide it and create a new annotation number to fit your other input.', | ||
auth: ConnectorAuth.None(), | ||
minimumSupportedRelease: '0.0.0', | ||
logoUrl: '/images/connectors/math-helper.png', | ||
tags: ['data management', 'core'], | ||
actions: [addition, subtraction, multiplication, division, modulo, generateRandom], | ||
triggers: [], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters