Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

update each function examples #796

Merged
merged 8 commits into from
Oct 28, 2024
Merged

update each function examples #796

merged 8 commits into from
Oct 28, 2024

Conversation

mtuchi
Copy link
Collaborator

@mtuchi mtuchi commented Oct 24, 2024

Summary

I have added couple of examples that shows how to use each function and build the docs.

Details

The current example for each function is very confusing especially for beginners, Often times i see mistakes between the use of $.data and $.data[*]. And more often how to access data in the operation when using each.
Screenshot 2024-10-24 at 3 43 21 PM

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Review Checklist

Before merging, the reviewer should check the following items:

  • Does the PR do what it claims to do?
  • If this is a new adaptor, added the adaptor on marketing website ?
  • Are there any unit tests?
  • Is there a changeset associated with this PR? Should there be? Note that
    dev only changes don't need a changeset.
  • Have you ticked a box under AI Usage?

@mtuchi mtuchi changed the title Each docs update each function examples Oct 24, 2024
@mtuchi mtuchi marked this pull request as ready for review October 24, 2024 12:48
@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 24, 2024

@josephjclark i am not sure if docs changes need a changeset, should i add one ?

Copy link
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

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

The each explanation really isn't good, which is the bigger crime here to be honest. I'll take a look at that if you can fix the examples per my comments.

Regarding changeset - we technically don't need it. But it will result in the git tag being out of date, and it means that main has a diff from production.

So I would add a patch-level changeset on this.

packages/common/src/Adaptor.js Outdated Show resolved Hide resolved
* each("$.[*]",
* create("SObject",
* field("FirstName", sourceValue("$.firstName"))
* @example <caption>Inserting patitent data using lazy state. (Only in v2)</caption>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to specify v1 and v2 rules here? That might create more confusion that it solves, and I don't think we have any active in-development projects on v1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

$.data is lazy state loading and it doesn't work in v1. So i am bit worried there. I am not sure when officially we are going shutdown v1

Copy link
Collaborator

Choose a reason for hiding this comment

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

V1 will keep running for ages, but no-one is writing new jobs on it. Check with Aleksa.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Paging @aleksa-krolls 🔔Can we document stuff that won't work on v1?

I think we should be focusing our docs on V2. I also think talking about v1 and V2 is confusing for users. V1 of what?

Copy link
Member

Choose a reason for hiding this comment

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

@josephjclark I agree that we should focus the docs on v2... so no need to say Only in v2 as that should be assumed.

That said, I do think it's okay to document when an old example is from from/supported in openfn v1 ... because this helps our team and v1 users understand why old job code may look different than what they're seeing on the latest docs. But I'll leave this up to you and @mtuchi to decide.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a good steer, thanks. I'll double check this and see if I want to flag anything before merging, although I suspect not in this work

* $.data,
* insert("patient", (state) => ({
* patient_id: state.data.case_id,
* patient_name: state.data.properties.case_name.toUpperCase(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are too many props here which bloat the example. Maybe I'd just set patient_id and then spread state.data

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't understand what this mean, can you elaborate more ?

packages/common/src/Adaptor.js Outdated Show resolved Hide resolved
packages/common/src/Adaptor.js Outdated Show resolved Hide resolved
@josephjclark
Copy link
Collaborator

Thanks @mtuchi , I'll take this over from here

@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 25, 2024

Noted 👍🏽 @josephjclark but just a heads up, I didn't create a changeset for this, i am not sure if we need changeset for doc changes ?

@josephjclark
Copy link
Collaborator

I'm gonna hold off release until I've heard back from @aleksa-krolls about the v1 stuff (I'm 98% confident on that thought)

I've bumped versions but because a few packages are version locked to common - salesforce being the big one - not all adaptors will see this change

@josephjclark josephjclark marked this pull request as draft October 25, 2024 18:16
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-fhir-ndr-et",
"version": "0.1.4",
"version": "0.1.5",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, does this adaptor even export each? If it does, does it actually document it?

I think I need to double check the patches on this PR because I'm not sure that every adaptor is actually affected

@mtuchi mtuchi marked this pull request as ready for review October 28, 2024 08:18
@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 28, 2024

@josephjclark seems there is a merge conflict in packages/fhir-ndr-et/CHANGELOG.md

@josephjclark
Copy link
Collaborator

@mtuchi please don't merge this. I'm looking into a couple of things. I'll handle it!

@josephjclark josephjclark merged commit 1a8017f into main Oct 28, 2024
2 checks passed
@josephjclark josephjclark deleted the each-docs branch October 28, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants