@openfn/language-magpi 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ast.json CHANGED
@@ -132,6 +132,59 @@
132
132
  },
133
133
  "valid": true
134
134
  },
135
+ {
136
+ "name": "fnIf",
137
+ "params": [
138
+ "condition",
139
+ "operation"
140
+ ],
141
+ "docs": {
142
+ "description": "A custom operation that will only execute the function if the condition returns true",
143
+ "tags": [
144
+ {
145
+ "title": "public",
146
+ "description": null,
147
+ "type": null
148
+ },
149
+ {
150
+ "title": "example",
151
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
152
+ },
153
+ {
154
+ "title": "function",
155
+ "description": null,
156
+ "name": null
157
+ },
158
+ {
159
+ "title": "param",
160
+ "description": "The condition that returns true",
161
+ "type": {
162
+ "type": "NameExpression",
163
+ "name": "Boolean"
164
+ },
165
+ "name": "condition"
166
+ },
167
+ {
168
+ "title": "param",
169
+ "description": "The operation needed to be executed.",
170
+ "type": {
171
+ "type": "NameExpression",
172
+ "name": "Operation"
173
+ },
174
+ "name": "operation"
175
+ },
176
+ {
177
+ "title": "returns",
178
+ "description": null,
179
+ "type": {
180
+ "type": "NameExpression",
181
+ "name": "Operation"
182
+ }
183
+ }
184
+ ]
185
+ },
186
+ "valid": true
187
+ },
135
188
  {
136
189
  "name": "sourceValue",
137
190
  "params": [
package/dist/index.cjs CHANGED
@@ -35,6 +35,7 @@ __export(src_exports, {
35
35
  field: () => import_language_common2.field,
36
36
  fields: () => import_language_common2.fields,
37
37
  fn: () => import_language_common2.fn,
38
+ fnIf: () => import_language_common2.fnIf,
38
39
  lastReferenceValue: () => import_language_common2.lastReferenceValue,
39
40
  merge: () => import_language_common2.merge,
40
41
  sourceValue: () => import_language_common2.sourceValue,
@@ -54,6 +55,7 @@ __export(Adaptor_exports, {
54
55
  field: () => import_language_common2.field,
55
56
  fields: () => import_language_common2.fields,
56
57
  fn: () => import_language_common2.fn,
58
+ fnIf: () => import_language_common2.fnIf,
57
59
  lastReferenceValue: () => import_language_common2.lastReferenceValue,
58
60
  merge: () => import_language_common2.merge,
59
61
  sourceValue: () => import_language_common2.sourceValue,
@@ -170,7 +172,7 @@ function fetchSurveyData(params) {
170
172
  }
171
173
  function submitRecord(jsonData) {
172
174
  return (state) => {
173
- const jsonBody = (0, import_language_common.expandReferences)(data)(state);
175
+ const jsonBody = (0, import_language_common.expandReferences)(jsonData)(state);
174
176
  const body = (0, import_js2xmlparser.default)("form", jsonBody);
175
177
  const { username, password, apiUrl } = state.configuration;
176
178
  const url = (0, import_url.resolve)(apiUrl + "/", "mobileApi/uploadData");
@@ -193,6 +195,7 @@ var src_default = Adaptor_exports;
193
195
  field,
194
196
  fields,
195
197
  fn,
198
+ fnIf,
196
199
  lastReferenceValue,
197
200
  merge,
198
201
  sourceValue,
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ __export(Adaptor_exports, {
16
16
  field: () => field,
17
17
  fields: () => fields,
18
18
  fn: () => fn,
19
+ fnIf: () => fnIf,
19
20
  lastReferenceValue: () => lastReferenceValue,
20
21
  merge: () => merge,
21
22
  sourceValue: () => sourceValue,
@@ -31,6 +32,7 @@ import request from "request";
31
32
  import xml2js from "xml2js";
32
33
  import {
33
34
  fn,
35
+ fnIf,
34
36
  alterState,
35
37
  field,
36
38
  fields,
@@ -146,7 +148,7 @@ function fetchSurveyData(params) {
146
148
  }
147
149
  function submitRecord(jsonData) {
148
150
  return (state) => {
149
- const jsonBody = expandReferences(data)(state);
151
+ const jsonBody = expandReferences(jsonData)(state);
150
152
  const body = js2xmlparser("form", jsonBody);
151
153
  const { username, password, apiUrl } = state.configuration;
152
154
  const url = resolveUrl(apiUrl + "/", "mobileApi/uploadData");
@@ -169,6 +171,7 @@ export {
169
171
  field,
170
172
  fields,
171
173
  fn,
174
+ fnIf,
172
175
  lastReferenceValue,
173
176
  merge,
174
177
  sourceValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-magpi",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "A Magpi Language Pack for OpenFn",
5
5
  "main": "dist/index.cjs",
6
6
  "author": "Open Function Group",
@@ -12,7 +12,7 @@
12
12
  "configuration-schema.json"
13
13
  ],
14
14
  "dependencies": {
15
- "@openfn/language-common": "^1.8.1",
15
+ "@openfn/language-common": "^1.14.0",
16
16
  "JSONPath": "^0.10.0",
17
17
  "js2xmlparser": "^3.0.0",
18
18
  "lodash-fp": "^0.10.4",
@@ -21,7 +21,6 @@
21
21
  "xml2js": "0.5.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@openfn/buildtools": "^1.0.2",
25
24
  "@openfn/simple-ast": "0.4.1",
26
25
  "assertion-error": "^2.0.0",
27
26
  "chai": "^4.3.7",
@@ -35,4 +35,4 @@ export function fetchSurveyData(params: object): Operation;
35
35
  * @returns {Operation}
36
36
  */
37
37
  export function submitRecord(jsonData: object): Operation;
38
- export { fn, alterState, field, fields, sourceValue, each, merge, dataPath, dataValue, lastReferenceValue } from "@openfn/language-common";
38
+ export { fn, fnIf, alterState, field, fields, sourceValue, each, merge, dataPath, dataValue, lastReferenceValue } from "@openfn/language-common";