Skip to content

Add Ternary block integration#326

Merged
rita-gorokhod merged 7 commits intomainfrom
quilyx
Apr 3, 2025
Merged

Add Ternary block integration#326
rita-gorokhod merged 7 commits intomainfrom
quilyx

Conversation

@StephanQuilyx
Copy link
Copy Markdown
Contributor

@StephanQuilyx StephanQuilyx commented Mar 28, 2025

Fixes OPS-1517.

Ternary connection & sample action

New connection using the Ternary API
Fields:

  • API key (JWT) generated in Ternary
  • Tenant ID (1 tenant per connection)
  • API URL (this can vary based on the Ternary environment

Additional Notes

The supporting API call checks if the JWT (API KEY) is valid before accessing the URL.

Testing Checklist

Check all that apply:

  • [x ] I tested the feature thoroughly, including edge cases

  • [x ] I verified all affected areas still work as expected

  • Automated tests were added/updated if necessary

  • Changes are backwards compatible with any existing data, otherwise a migration script is provided

@StephanQuilyx
Copy link
Copy Markdown
Contributor Author

Note; please replace the Ternary image with one uploaded to the static section of the OpenOps website

}
try {
const decoded = jwtDecode(token);
if (decoded && decoded.exp && dayjs().isAfter(dayjs.unix(decoded.exp))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor: for readability, would be better to extract this to a var and be explicit in the name. Also note that the IF will evaluate to false if the decoding failed/there is no exp. Perhaps it should be something like:

var isValid = decoded && decoded.exp && dayjs().isBefore(dayjs.unix(decoded.exp));

return isValid;

(that said, is it a valid use case in ternary tokens that there is no exp?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-used this from 'allow-logged-in-user-only-guard.tsx'. Altered it for better readability. However the function expects a boolean in return so I had to work around that in the return.
Do you have a better solution?

@@ -0,0 +1,42 @@
import {
AuthenticationType,
// HttpMessageBody,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: unused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -0,0 +1,17 @@
import { createBlock } from '@openops/blocks-framework';
// import { ternaryAuth } from '@openops/common';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

auth: ternaryCloudAuth,
minimumSupportedRelease: '0.20.0',
logoUrl:
'https://firebasestorage.googleapis.com/v0/b/quilops-712fd.firebasestorage.app/o/public%2Fternary-logo.png?alt=media&token=20820a50-f4ae-4385-942b-bb58cb7cb5cf',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploaded to static.openops.com/blocks/ternary.png

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated link

@@ -17,100 +17,47 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened here? some auto-linter change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not touched this, must be auto changed.

package.json Outdated
"ts-node": "10.9.1",
"turbowatch": "2.29.4",
"typescript": "5.5.4",
"verdaccio": "^5.0.4",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never really used it, did you see any improvement?
The blocks are not published to npm anyway, it's all loaded locally with npm link.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never installed this, don't even know what it is/does

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I reverted it, not sure where it came from

@StephanQuilyx
Copy link
Copy Markdown
Contributor Author

@rita-gorokhod I've updated the files

@linear
Copy link
Copy Markdown

linear bot commented Apr 3, 2025

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2025

@rita-gorokhod rita-gorokhod changed the title Ternary connection & sample action Add Ternary block integration Apr 3, 2025
@rita-gorokhod rita-gorokhod merged commit e87b908 into main Apr 3, 2025
16 checks passed
@rita-gorokhod rita-gorokhod deleted the quilyx branch April 3, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants