Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement new util pattern #522

Closed
josephjclark opened this issue Apr 23, 2024 · 3 comments
Closed

Implement new util pattern #522

josephjclark opened this issue Apr 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Apr 23, 2024

I'm keen to start implementing this pattern:

  • All exported functions from an adaptor are OPERATIONS (take state, return state)
  • Any non-operation functions are exported onto the util (or utils? I think it should be singular) object.

Typically util functions will be in a util.js file but this is less important. What's important is that the main adaptor object includes a utils object.

When using non-operation functions in job code, you always do util.whatever, like util.fetch or util.jsonPath(state, path).

Doing this helps make it clear to job writers what is an operation (and needs state passing) and what is just a function. Because it's pretty confusing right now!

[SOLVED] Difficulty #1

The hardest thing about this pattern is the docs!

How do document an exported namespace?

We don't handle this well at the moment. There are no docs on the common/http helpers.

There is a commented out bit in the docs template for interfaces, I think. Maybe we just restore this, but it may not be very readable.

Basically for each adaptor we need to list Functions (actually, Operations); and Utils, with the note that utils are available on the utils object.

Difficulty #2

What do we do about common, which right now has http and util namespaces?

Also common.http is actually old stuff.

I think the answer, as in #507 , is just to add the http helpers to the util object (even though they're in the http namespace). It's fine :)

Difficulty #3

When every adaptor adopts this pattern we are living in utopia, nirvana, shangra-la.

But while migrating, we're basically just introducing even more inconsistency to the design :( It reduces predictability.

This just means we should migrate the top 10 adaptors quickly, but maybe even do a push on the next 20.

@josephjclark josephjclark added the enhancement New feature or request label Apr 23, 2024
@github-project-automation github-project-automation bot moved this to New Issues in v2 Apr 23, 2024
@christad92 christad92 moved this from New Issues to Icebox in v2 Apr 29, 2024
@aleksa-krolls aleksa-krolls moved this from Icebox to Backlog in v2 Jun 5, 2024
@aleksa-krolls aleksa-krolls moved this from Backlog to Ready in v2 Jun 5, 2024
@josephjclark josephjclark self-assigned this Jun 5, 2024
@josephjclark
Copy link
Collaborator Author

I will spike something here

@josephjclark
Copy link
Collaborator Author

As of right now, the doc site supports namespacing. So if we were to add a utils. namespace, the docsite can easily handle it. Hurrah!

@josephjclark josephjclark removed their assignment Aug 15, 2024
@josephjclark
Copy link
Collaborator Author

I think this is in-hand and all technical issue are resolved. common right now has several namespaces and salesforce 5.0 uses the util namespace for non-operations

@github-project-automation github-project-automation bot moved this from Ready to Done in v2 Jan 13, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant