@openfn/language-mogli 0.3.4 → 0.5.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
@@ -2,6 +2,102 @@
2
2
  "operations": [],
3
3
  "exports": [],
4
4
  "common": [
5
+ {
6
+ "name": "fn",
7
+ "params": [
8
+ "func"
9
+ ],
10
+ "docs": {
11
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
12
+ "tags": [
13
+ {
14
+ "title": "public",
15
+ "description": null,
16
+ "type": null
17
+ },
18
+ {
19
+ "title": "example",
20
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
21
+ },
22
+ {
23
+ "title": "function",
24
+ "description": null,
25
+ "name": null
26
+ },
27
+ {
28
+ "title": "param",
29
+ "description": "is the function",
30
+ "type": {
31
+ "type": "NameExpression",
32
+ "name": "Function"
33
+ },
34
+ "name": "func"
35
+ },
36
+ {
37
+ "title": "returns",
38
+ "description": null,
39
+ "type": {
40
+ "type": "NameExpression",
41
+ "name": "Operation"
42
+ }
43
+ }
44
+ ]
45
+ },
46
+ "valid": true
47
+ },
48
+ {
49
+ "name": "fnIf",
50
+ "params": [
51
+ "condition",
52
+ "operation"
53
+ ],
54
+ "docs": {
55
+ "description": "A custom operation that will only execute the function if the condition returns true",
56
+ "tags": [
57
+ {
58
+ "title": "public",
59
+ "description": null,
60
+ "type": null
61
+ },
62
+ {
63
+ "title": "example",
64
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
65
+ },
66
+ {
67
+ "title": "function",
68
+ "description": null,
69
+ "name": null
70
+ },
71
+ {
72
+ "title": "param",
73
+ "description": "The condition that returns true",
74
+ "type": {
75
+ "type": "NameExpression",
76
+ "name": "Boolean"
77
+ },
78
+ "name": "condition"
79
+ },
80
+ {
81
+ "title": "param",
82
+ "description": "The operation needed to be executed.",
83
+ "type": {
84
+ "type": "NameExpression",
85
+ "name": "Operation"
86
+ },
87
+ "name": "operation"
88
+ },
89
+ {
90
+ "title": "returns",
91
+ "description": null,
92
+ "type": {
93
+ "type": "NameExpression",
94
+ "name": "Operation"
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ "valid": true
100
+ },
5
101
  {
6
102
  "name": "sourceValue",
7
103
  "params": [
package/dist/index.cjs CHANGED
@@ -37,6 +37,8 @@ __export(src_exports, {
37
37
  execute: () => execute,
38
38
  field: () => import_language_common3.field,
39
39
  fields: () => import_language_common3.fields,
40
+ fn: () => import_language_common3.fn,
41
+ fnIf: () => import_language_common3.fnIf,
40
42
  index: () => import_language_common3.index,
41
43
  join: () => import_language_common3.join,
42
44
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
@@ -68,6 +70,8 @@ __export(Adaptor_exports, {
68
70
  execute: () => execute,
69
71
  field: () => import_language_common3.field,
70
72
  fields: () => import_language_common3.fields,
73
+ fn: () => import_language_common3.fn,
74
+ fnIf: () => import_language_common3.fnIf,
71
75
  index: () => import_language_common3.index,
72
76
  join: () => import_language_common3.join,
73
77
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
@@ -139,8 +143,8 @@ var createSMS = curry(function(params, state) {
139
143
  },
140
144
  json: body
141
145
  },
142
- function(error, response, postResponseBody) {
143
- error = assembleError({ error, response });
146
+ function(err, response, postResponseBody) {
147
+ const error = assembleError({ error: err, response });
144
148
  if (error) {
145
149
  console.error("POST failed.");
146
150
  reject(error);
@@ -186,8 +190,8 @@ var updateSMS = curry(function(params, state) {
186
190
  },
187
191
  json: body
188
192
  },
189
- function(error, response, postResponseBody) {
190
- error = assembleError({ error, response });
193
+ function(err, response, postResponseBody) {
194
+ const error = assembleError({ error: err, response });
191
195
  if (error) {
192
196
  console.error("POST failed.");
193
197
  reject(error);
@@ -268,6 +272,8 @@ var src_default = Adaptor_exports;
268
272
  execute,
269
273
  field,
270
274
  fields,
275
+ fn,
276
+ fnIf,
271
277
  index,
272
278
  join,
273
279
  lastReferenceValue,
package/dist/index.js CHANGED
@@ -18,6 +18,8 @@ __export(Adaptor_exports, {
18
18
  execute: () => execute,
19
19
  field: () => field2,
20
20
  fields: () => fields,
21
+ fn: () => fn,
22
+ fnIf: () => fnIf,
21
23
  index: () => index,
22
24
  join: () => join,
23
25
  lastReferenceValue: () => lastReferenceValue,
@@ -73,7 +75,9 @@ import {
73
75
  beta,
74
76
  toArray,
75
77
  arrayToString,
76
- alterState
78
+ alterState,
79
+ fn,
80
+ fnIf
77
81
  } from "@openfn/language-common";
78
82
  var { curry, mapValues, flatten } = pkg;
79
83
  var createSMS = curry(function(params, state) {
@@ -108,8 +112,8 @@ var createSMS = curry(function(params, state) {
108
112
  },
109
113
  json: body
110
114
  },
111
- function(error, response, postResponseBody) {
112
- error = assembleError({ error, response });
115
+ function(err, response, postResponseBody) {
116
+ const error = assembleError({ error: err, response });
113
117
  if (error) {
114
118
  console.error("POST failed.");
115
119
  reject(error);
@@ -155,8 +159,8 @@ var updateSMS = curry(function(params, state) {
155
159
  },
156
160
  json: body
157
161
  },
158
- function(error, response, postResponseBody) {
159
- error = assembleError({ error, response });
162
+ function(err, response, postResponseBody) {
163
+ const error = assembleError({ error: err, response });
160
164
  if (error) {
161
165
  console.error("POST failed.");
162
166
  reject(error);
@@ -237,6 +241,8 @@ export {
237
241
  execute,
238
242
  field2 as field,
239
243
  fields,
244
+ fn,
245
+ fnIf,
240
246
  index,
241
247
  join,
242
248
  lastReferenceValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-mogli",
3
- "version": "0.3.4",
3
+ "version": "0.5.0",
4
4
  "description": "A Mogli SMS 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.7.5",
15
+ "@openfn/language-common": "^1.14.0",
16
16
  "JSONPath": "^0.10.0",
17
17
  "jsforce": "1.5.1",
18
18
  "lodash-fp": "^0.10.4",
@@ -21,7 +21,6 @@
21
21
  "yargs": "^3.32.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",
@@ -50,6 +49,7 @@
50
49
  "test": "mocha --experimental-specifier-resolution=node --no-warnings",
51
50
  "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
52
51
  "clean": "rimraf dist types docs",
53
- "pack": "pnpm pack --pack-destination ../../dist"
52
+ "pack": "pnpm pack --pack-destination ../../dist",
53
+ "lint": "eslint src"
54
54
  }
55
55
  }
@@ -26,4 +26,4 @@ export type State = {
26
26
  };
27
27
  export type Operation = Function;
28
28
  export { lookup, relationship } from "./sourceHelpers";
29
- export { each, join, fields, field, source, sourceValue, map, combine, merge, dataPath, dataValue, referencePath, lastReferenceValue, index, beta, toArray, arrayToString, alterState } from "@openfn/language-common";
29
+ export { each, join, fields, field, source, sourceValue, map, combine, merge, dataPath, dataValue, referencePath, lastReferenceValue, index, beta, toArray, arrayToString, alterState, fn, fnIf } from "@openfn/language-common";