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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/asana/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/azure-storage/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/bigquery/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/cartodb/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/cht/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/commcare/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/common/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
28 changes: 24 additions & 4 deletions packages/common/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,32 @@ export function asData(data, state) {
* the state's references.
* @public
* @function
* @example
* 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

* each($.data,
* insert("patient",
mtuchi marked this conversation as resolved.
Show resolved Hide resolved
* {
* patient_name: $.data.properties.case_name,
* patient_id: $.data.case_id
* }
* )
* )
* @example <caption>Inserting patitent data with custom transformations. (Only in v1)</caption>
mtuchi marked this conversation as resolved.
Show resolved Hide resolved
* each(
* $.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 ?

* patient_age: calculateAge(state.data.properties.birthdate),
* }))
* );
* @example <caption>Inserting patitent data with custom transformations. (v1 and v2)</caption>
mtuchi marked this conversation as resolved.
Show resolved Hide resolved
* each(
* "$.data[*]",
* insert("patient", (state) => ({
* patient_name: state.data.properties.case_name,
* patient_id: state.data.case_id,
* }))
* );
* @param {DataSource} dataSource - JSONPath referencing a point in `state`.
* @param {Operation} operation - The operation needed to be repeated.
* @returns {Operation}
Expand Down
13 changes: 12 additions & 1 deletion packages/dhis2/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/dynamics/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/facebook/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/fhir-ndr-et/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/fhir/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/godata/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
13 changes: 12 additions & 1 deletion packages/googlehealthcare/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,18 @@
},
{
"title": "example",
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
"description": "each($.data,\n insert(\"patient\",\n {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id\n }\n )\n)",
"caption": "Inserting patitent data using lazy state. (Only in v2)"
},
{
"title": "example",
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n patient_name: state.data.properties.case_name.toUpperCase(),\n patient_age: calculateAge(state.data.properties.birthdate),\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (Only in v1)"
},
{
"title": "example",
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
"caption": "Inserting patitent data with custom transformations. (v1 and v2)"
},
{
"title": "param",
Expand Down
Loading
Loading