Skip to content

Conversation

@ejseqera
Copy link
Member

@ejseqera ejseqera commented Nov 7, 2025

Adds a node for data-link creation and utility to resolve resourceName to resourceId for simpler HTTP request handling. The function works for credentials, pipelines, compute-envs, datasets, and data-links.

Screenshot 2025-11-07 at 2 13 15 pm

Changes made:

  1. nodes/_utils.js
  • Added resolveResource() function
  • Exported it in module.exports
  1. nodes/datalink-utils.js
  • Imports resolveResource from _utils.js
  1. Update CLAUDE.md with guidance

  2. Added nodemon config to auto-restart local instances for quicker development through npm run dev

@ejseqera ejseqera requested a review from ewels November 7, 2025 19:18
Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

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

Really nice! Haven't tested yet, but a quick scan of the code looks great, couple of v. minor comments.

What kind of use cases do you see for this? Just thinking about the examples.

Comment on lines +47 to +51
"devDependencies": {
"nodemon": "^3.1.10"
},
"scripts": {
"dev": "nodemon --exec 'node-red -u ./test-instance' --watch nodes --ext js"
Copy link
Member

Choose a reason for hiding this comment

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

Nice! Please could you document usage in CONTRIBUTING.md so that folks know how to use it? (and anywhere else that makes sense)

* @param {object} options - Options object with baseUrl and workspaceId
* @returns {Promise<string|null>} The resource ID, or null if resourceName is empty
*/
async function resolveResource(RED, node, msg, resourceType, resourceName, { baseUrl, workspaceId = null } = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need msg as an argument? Doesn't look like it's being used.

Comment on lines +56 to +65
/**
* Generic resource resolver for Seqera Platform API.
* Resolves a resource name to its ID by querying the appropriate endpoint.
*
* Supported resource types:
* - credentials: /credentials → credentials[].id
* - data-links: /data-links → dataLinks[].id
* - pipelines: /pipelines → pipelines[].pipelineId
* - compute-envs: /compute-envs → computeEnvs[].id
* - datasets: /datasets → datasets[].id
Copy link
Member

Choose a reason for hiding this comment

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

Super nice! I reckon we could delete a fair bit of code with some refactoring to use this, the lookup is done in quite a few places I think (doesn't have to be done in this PR but it'd be a nice follow-on).

responseKey: "datasets",
idField: "id",
nameField: "name",
queryParams: { max: "100" },
Copy link
Member

Choose a reason for hiding this comment

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

This seems a bit limiting, especially for datasets..

Could the function handle pagination do you think? I implemented pagination for datasets already here.

Ideally we would have an API endpoint to do this of course, rather than pulling thousands of dataset details just to do a simple lookup 👀

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.

3 participants