@openfn/language-khanacademy 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 +53 -0
- package/dist/index.cjs +13 -10
- package/dist/index.js +13 -10
- package/package.json +4 -4
- package/types/Adaptor.d.ts +1 -1
package/ast.json
CHANGED
|
@@ -45,6 +45,59 @@
|
|
|
45
45
|
},
|
|
46
46
|
"valid": true
|
|
47
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
|
+
},
|
|
48
101
|
{
|
|
49
102
|
"name": "sourceValue",
|
|
50
103
|
"params": [
|
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
field: () => import_language_common2.field,
|
|
35
35
|
fields: () => import_language_common2.fields,
|
|
36
36
|
fn: () => import_language_common2.fn,
|
|
37
|
+
fnIf: () => import_language_common2.fnIf,
|
|
37
38
|
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
38
39
|
merge: () => import_language_common2.merge,
|
|
39
40
|
sourceValue: () => import_language_common2.sourceValue
|
|
@@ -51,6 +52,7 @@ __export(Adaptor_exports, {
|
|
|
51
52
|
field: () => import_language_common2.field,
|
|
52
53
|
fields: () => import_language_common2.fields,
|
|
53
54
|
fn: () => import_language_common2.fn,
|
|
55
|
+
fnIf: () => import_language_common2.fnIf,
|
|
54
56
|
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
55
57
|
merge: () => import_language_common2.merge,
|
|
56
58
|
sourceValue: () => import_language_common2.sourceValue
|
|
@@ -99,8 +101,8 @@ function fetch(params) {
|
|
|
99
101
|
url: getTokenURL,
|
|
100
102
|
oauth: nativeOAuthOptions
|
|
101
103
|
},
|
|
102
|
-
function(
|
|
103
|
-
error = assembleError({ error, response });
|
|
104
|
+
function(err, response, body) {
|
|
105
|
+
const error = assembleError({ error: err, response });
|
|
104
106
|
if (error) {
|
|
105
107
|
console.error("Token request failed.... KHAAAAAAN!");
|
|
106
108
|
reject(error);
|
|
@@ -127,8 +129,8 @@ function fetch(params) {
|
|
|
127
129
|
url: authorizeURL,
|
|
128
130
|
form: bodyParams
|
|
129
131
|
},
|
|
130
|
-
function(
|
|
131
|
-
error = assembleError({ error, response });
|
|
132
|
+
function(err, response, body2) {
|
|
133
|
+
const error = assembleError({ error: err, response });
|
|
132
134
|
if (error) {
|
|
133
135
|
console.error("Token authorization failed... KHAAAAAAN!");
|
|
134
136
|
reject(error);
|
|
@@ -152,8 +154,8 @@ function fetch(params) {
|
|
|
152
154
|
url: accessTokenUrl,
|
|
153
155
|
oauth: hasToken
|
|
154
156
|
},
|
|
155
|
-
function(
|
|
156
|
-
error = assembleError({ error, response });
|
|
157
|
+
function(err, response, body) {
|
|
158
|
+
const error = assembleError({ error: err, response });
|
|
157
159
|
if (error) {
|
|
158
160
|
console.error("Token exchange failed.... KHAAAAAAN!");
|
|
159
161
|
reject(error);
|
|
@@ -177,8 +179,8 @@ function fetch(params) {
|
|
|
177
179
|
url: getUrl,
|
|
178
180
|
oauth: hasAccess
|
|
179
181
|
},
|
|
180
|
-
function(
|
|
181
|
-
error = assembleError({ error, response });
|
|
182
|
+
function(err, response, body2) {
|
|
183
|
+
const error = assembleError({ error: err, response });
|
|
182
184
|
if (error) {
|
|
183
185
|
console.error("GET failed.... KHAAAAAAN!");
|
|
184
186
|
reject(error);
|
|
@@ -197,8 +199,8 @@ function fetch(params) {
|
|
|
197
199
|
url: postUrl,
|
|
198
200
|
json: JSON.parse(body)
|
|
199
201
|
},
|
|
200
|
-
function(
|
|
201
|
-
error = assembleError({ error, response });
|
|
202
|
+
function(err, response, body2) {
|
|
203
|
+
const error = assembleError({ error: err, response });
|
|
202
204
|
if (error) {
|
|
203
205
|
console.error("POST failed.... KHAAAAAAN!");
|
|
204
206
|
reject(error);
|
|
@@ -225,6 +227,7 @@ var src_default = Adaptor_exports;
|
|
|
225
227
|
field,
|
|
226
228
|
fields,
|
|
227
229
|
fn,
|
|
230
|
+
fnIf,
|
|
228
231
|
lastReferenceValue,
|
|
229
232
|
merge,
|
|
230
233
|
sourceValue
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ __export(Adaptor_exports, {
|
|
|
15
15
|
field: () => field,
|
|
16
16
|
fields: () => fields,
|
|
17
17
|
fn: () => fn,
|
|
18
|
+
fnIf: () => fnIf,
|
|
18
19
|
lastReferenceValue: () => lastReferenceValue,
|
|
19
20
|
merge: () => merge,
|
|
20
21
|
sourceValue: () => sourceValue
|
|
@@ -28,6 +29,7 @@ import request from "request";
|
|
|
28
29
|
import qs from "qs";
|
|
29
30
|
import {
|
|
30
31
|
fn,
|
|
32
|
+
fnIf,
|
|
31
33
|
field,
|
|
32
34
|
sourceValue,
|
|
33
35
|
fields,
|
|
@@ -76,8 +78,8 @@ function fetch(params) {
|
|
|
76
78
|
url: getTokenURL,
|
|
77
79
|
oauth: nativeOAuthOptions
|
|
78
80
|
},
|
|
79
|
-
function(
|
|
80
|
-
error = assembleError({ error, response });
|
|
81
|
+
function(err, response, body) {
|
|
82
|
+
const error = assembleError({ error: err, response });
|
|
81
83
|
if (error) {
|
|
82
84
|
console.error("Token request failed.... KHAAAAAAN!");
|
|
83
85
|
reject(error);
|
|
@@ -104,8 +106,8 @@ function fetch(params) {
|
|
|
104
106
|
url: authorizeURL,
|
|
105
107
|
form: bodyParams
|
|
106
108
|
},
|
|
107
|
-
function(
|
|
108
|
-
error = assembleError({ error, response });
|
|
109
|
+
function(err, response, body2) {
|
|
110
|
+
const error = assembleError({ error: err, response });
|
|
109
111
|
if (error) {
|
|
110
112
|
console.error("Token authorization failed... KHAAAAAAN!");
|
|
111
113
|
reject(error);
|
|
@@ -129,8 +131,8 @@ function fetch(params) {
|
|
|
129
131
|
url: accessTokenUrl,
|
|
130
132
|
oauth: hasToken
|
|
131
133
|
},
|
|
132
|
-
function(
|
|
133
|
-
error = assembleError({ error, response });
|
|
134
|
+
function(err, response, body) {
|
|
135
|
+
const error = assembleError({ error: err, response });
|
|
134
136
|
if (error) {
|
|
135
137
|
console.error("Token exchange failed.... KHAAAAAAN!");
|
|
136
138
|
reject(error);
|
|
@@ -154,8 +156,8 @@ function fetch(params) {
|
|
|
154
156
|
url: getUrl,
|
|
155
157
|
oauth: hasAccess
|
|
156
158
|
},
|
|
157
|
-
function(
|
|
158
|
-
error = assembleError({ error, response });
|
|
159
|
+
function(err, response, body2) {
|
|
160
|
+
const error = assembleError({ error: err, response });
|
|
159
161
|
if (error) {
|
|
160
162
|
console.error("GET failed.... KHAAAAAAN!");
|
|
161
163
|
reject(error);
|
|
@@ -174,8 +176,8 @@ function fetch(params) {
|
|
|
174
176
|
url: postUrl,
|
|
175
177
|
json: JSON.parse(body)
|
|
176
178
|
},
|
|
177
|
-
function(
|
|
178
|
-
error = assembleError({ error, response });
|
|
179
|
+
function(err, response, body2) {
|
|
180
|
+
const error = assembleError({ error: err, response });
|
|
179
181
|
if (error) {
|
|
180
182
|
console.error("POST failed.... KHAAAAAAN!");
|
|
181
183
|
reject(error);
|
|
@@ -202,6 +204,7 @@ export {
|
|
|
202
204
|
field,
|
|
203
205
|
fields,
|
|
204
206
|
fn,
|
|
207
|
+
fnIf,
|
|
205
208
|
lastReferenceValue,
|
|
206
209
|
merge,
|
|
207
210
|
sourceValue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-khanacademy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A Khan Academy Language Pack for OpenFn",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"author": "Open Function Group",
|
|
@@ -12,12 +12,11 @@
|
|
|
12
12
|
"configuration-schema.json"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@openfn/language-common": "^1.
|
|
15
|
+
"@openfn/language-common": "^1.14.0",
|
|
16
16
|
"qs": "^6.11.0",
|
|
17
17
|
"request": "^2.88.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@openfn/buildtools": "^1.0.2",
|
|
21
20
|
"@openfn/simple-ast": "0.4.1",
|
|
22
21
|
"assertion-error": "^2.0.0",
|
|
23
22
|
"chai": "^4.3.7",
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
"test": "mocha --experimental-specifier-resolution=node --no-warnings",
|
|
46
45
|
"test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
|
|
47
46
|
"clean": "rimraf dist types docs",
|
|
48
|
-
"pack": "pnpm pack --pack-destination ../../dist"
|
|
47
|
+
"pack": "pnpm pack --pack-destination ../../dist",
|
|
48
|
+
"lint": "eslint src"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -22,4 +22,4 @@ export function execute(...operations: Operations): Operation;
|
|
|
22
22
|
* @returns {Operation}
|
|
23
23
|
*/
|
|
24
24
|
export function fetch(params: object): Operation;
|
|
25
|
-
export { fn, field, sourceValue, fields, alterState, merge, dataPath, dataValue, lastReferenceValue } from "@openfn/language-common";
|
|
25
|
+
export { fn, fnIf, field, sourceValue, fields, alterState, merge, dataPath, dataValue, lastReferenceValue } from "@openfn/language-common";
|