Skip to content

Commit

Permalink
feat(connectors): add math connector
Browse files Browse the repository at this point in the history
  • Loading branch information
anteqkois committed Jun 8, 2024
1 parent b162183 commit 7976d7a
Show file tree
Hide file tree
Showing 19 changed files with 340 additions and 3 deletions.
Binary file modified apps/web/public/images/connectors/binance.png
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.
Binary file modified apps/web/public/images/connectors/stripe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions libs/connectors/math-helper/.eslintrc.json
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"
}
}
]
}
7 changes: 7 additions & 0 deletions libs/connectors/math-helper/README.md
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.
10 changes: 10 additions & 0 deletions libs/connectors/math-helper/package.json
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"
}
21 changes: 21 additions & 0 deletions libs/connectors/math-helper/project.json
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
}
}
}
}
32 changes: 32 additions & 0 deletions libs/connectors/math-helper/src/actions/addition.ts
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']
},
})
40 changes: 40 additions & 0 deletions libs/connectors/math-helper/src/actions/division.ts
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']
);
},
});
38 changes: 38 additions & 0 deletions libs/connectors/math-helper/src/actions/generateRandom.ts
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);
},
});
38 changes: 38 additions & 0 deletions libs/connectors/math-helper/src/actions/modulo.ts
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']
);
},
});
38 changes: 38 additions & 0 deletions libs/connectors/math-helper/src/actions/multiplication.ts
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']
);
},
});
38 changes: 38 additions & 0 deletions libs/connectors/math-helper/src/actions/subtraction.ts
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']
);
},
});
20 changes: 20 additions & 0 deletions libs/connectors/math-helper/src/index.ts
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: [],
})
19 changes: 19 additions & 0 deletions libs/connectors/math-helper/tsconfig.json
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"
}
]
}
10 changes: 10 additions & 0 deletions libs/connectors/math-helper/tsconfig.lib.json
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"]
}
2 changes: 1 addition & 1 deletion libs/connectors/openai/src/actions/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// // HttpMethod,
// // httpClient,
// // } from '@activepieces/pieces-common';
// // import { Property, createAction } from '@activepieces/pieces-framework';
// // import { Property, createAction } from '@linkerry/connectors-framework';
// // import { openaiAuth } from '../..';
// // import FormData from 'form-data';
// // import mime from 'mime-types';
Expand Down
2 changes: 1 addition & 1 deletion libs/connectors/openai/src/actions/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// HttpMethod,
// httpClient,
// } from '@activepieces/pieces-common';
// import { Property, createAction } from '@activepieces/pieces-framework';
// import { Property, createAction } from '@linkerry/connectors-framework';
// import { openaiAuth } from '../..';
// import FormData from 'form-data';
// import mime from 'mime-types';
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"@linkerry/common-exchanges": ["libs/connectors/common-exchanges/src/index.ts"],
"@linkerry/connectors-common": ["libs/connectors/common/src/index.ts"],
"@linkerry/connectors-framework": ["libs/connectors/framework/src/index.ts"],
"@linkerry/fakturownia": ["libs/connectors/fakturownia/src/index.ts"],
"@linkerry/math-helper": ["libs/connectors/math-helper/src/index.ts"],
"@linkerry/discord": ["libs/connectors/discord/src/index.ts"],
"@linkerry/engine": ["libs/engine/src/index.ts"],
"@linkerry/fakturownia": ["libs/connectors/fakturownia/src/index.ts"],
"@linkerry/google-sheets": ["libs/connectors/google-sheets/src/index.ts"],
"@linkerry/kucoin": ["libs/connectors/kucoin/src/index.ts"],
"@linkerry/linkerry-schedule": ["libs/connectors/schedule/src/index.ts"],
Expand Down

0 comments on commit 7976d7a

Please sign in to comment.