@openfn/language-kobotoolbox 1.1.1 → 1.3.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/README.md +3 -2
- package/ast.json +43 -0
- package/dist/index.cjs +54 -3
- package/dist/index.js +40 -2
- package/package.json +1 -1
- package/types/Adaptor.d.ts +14 -1
- package/types/index.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Language KoboToolbox
|
|
1
|
+
# Language KoboToolbox
|
|
2
2
|
|
|
3
3
|
Language Pack for building expressions and operations to interact with the
|
|
4
4
|
[TEMPLATE] API.
|
|
@@ -43,7 +43,8 @@ getSubmissions(
|
|
|
43
43
|
|
|
44
44
|
## Development
|
|
45
45
|
|
|
46
|
-
Clone the [adaptors monorepo](https://github.com/OpenFn/adaptors). Follow the
|
|
46
|
+
Clone the [adaptors monorepo](https://github.com/OpenFn/adaptors). Follow the
|
|
47
|
+
`Getting Started` guide inside to get set up.
|
|
47
48
|
|
|
48
49
|
Run tests using `pnpm run test` or `pnpm run test:watch`
|
|
49
50
|
|
package/ast.json
CHANGED
|
@@ -56,6 +56,49 @@
|
|
|
56
56
|
],
|
|
57
57
|
"exports": [],
|
|
58
58
|
"common": [
|
|
59
|
+
{
|
|
60
|
+
"name": "fn",
|
|
61
|
+
"params": [
|
|
62
|
+
"func"
|
|
63
|
+
],
|
|
64
|
+
"docs": {
|
|
65
|
+
"description": "Creates a custom step (or operation) for more flexible job writing.",
|
|
66
|
+
"tags": [
|
|
67
|
+
{
|
|
68
|
+
"title": "public",
|
|
69
|
+
"description": null,
|
|
70
|
+
"type": null
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"title": "example",
|
|
74
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"title": "function",
|
|
78
|
+
"description": null,
|
|
79
|
+
"name": null
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"title": "param",
|
|
83
|
+
"description": "is the function",
|
|
84
|
+
"type": {
|
|
85
|
+
"type": "NameExpression",
|
|
86
|
+
"name": "Function"
|
|
87
|
+
},
|
|
88
|
+
"name": "func"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"title": "returns",
|
|
92
|
+
"description": null,
|
|
93
|
+
"type": {
|
|
94
|
+
"type": "NameExpression",
|
|
95
|
+
"name": "Operation"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"valid": true
|
|
101
|
+
},
|
|
59
102
|
{
|
|
60
103
|
"name": "sourceValue",
|
|
61
104
|
"params": [
|
package/dist/index.cjs
CHANGED
|
@@ -19,8 +19,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/index.js
|
|
20
20
|
var src_exports = {};
|
|
21
21
|
__export(src_exports, {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
alterState: () => import_language_common2.alterState,
|
|
23
|
+
dataPath: () => import_language_common2.dataPath,
|
|
24
|
+
dataValue: () => import_language_common2.dataValue,
|
|
25
|
+
default: () => src_default,
|
|
26
|
+
each: () => import_language_common2.each,
|
|
27
|
+
execute: () => execute,
|
|
28
|
+
field: () => import_language_common2.field,
|
|
29
|
+
fields: () => import_language_common2.fields,
|
|
30
|
+
fn: () => import_language_common2.fn,
|
|
31
|
+
getDeploymentInfo: () => getDeploymentInfo,
|
|
32
|
+
getForms: () => getForms,
|
|
33
|
+
getSubmissions: () => getSubmissions,
|
|
34
|
+
http: () => import_language_common2.http,
|
|
35
|
+
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
36
|
+
merge: () => import_language_common2.merge,
|
|
37
|
+
sourceValue: () => import_language_common2.sourceValue
|
|
24
38
|
});
|
|
25
39
|
module.exports = __toCommonJS(src_exports);
|
|
26
40
|
|
|
@@ -34,6 +48,8 @@ __export(Adaptor_exports, {
|
|
|
34
48
|
execute: () => execute,
|
|
35
49
|
field: () => import_language_common2.field,
|
|
36
50
|
fields: () => import_language_common2.fields,
|
|
51
|
+
fn: () => import_language_common2.fn,
|
|
52
|
+
getDeploymentInfo: () => getDeploymentInfo,
|
|
37
53
|
getForms: () => getForms,
|
|
38
54
|
getSubmissions: () => getSubmissions,
|
|
39
55
|
http: () => import_language_common2.http,
|
|
@@ -96,10 +112,45 @@ function getSubmissions(params, callback) {
|
|
|
96
112
|
});
|
|
97
113
|
};
|
|
98
114
|
}
|
|
115
|
+
function getDeploymentInfo(params, callback) {
|
|
116
|
+
return (state) => {
|
|
117
|
+
params = (0, import_language_common.expandReferences)(params)(state);
|
|
118
|
+
const { baseURL, apiVersion, username, password } = state.configuration;
|
|
119
|
+
const { formId } = params;
|
|
120
|
+
const url = `${baseURL}/api/${apiVersion}/assets/${formId}/deployment/?format=json`;
|
|
121
|
+
const auth = { username, password };
|
|
122
|
+
const config = {
|
|
123
|
+
url,
|
|
124
|
+
params: params.query,
|
|
125
|
+
auth
|
|
126
|
+
};
|
|
127
|
+
return import_language_common.http.get(config)(state).then((response) => {
|
|
128
|
+
console.log("\u2713", "deployment information fetched.");
|
|
129
|
+
const nextState = (0, import_language_common.composeNextState)(state, response.data);
|
|
130
|
+
if (callback)
|
|
131
|
+
return callback(nextState);
|
|
132
|
+
return nextState;
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
}
|
|
99
136
|
|
|
100
137
|
// src/index.js
|
|
101
138
|
var src_default = Adaptor_exports;
|
|
102
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
140
|
0 && (module.exports = {
|
|
104
|
-
|
|
141
|
+
alterState,
|
|
142
|
+
dataPath,
|
|
143
|
+
dataValue,
|
|
144
|
+
each,
|
|
145
|
+
execute,
|
|
146
|
+
field,
|
|
147
|
+
fields,
|
|
148
|
+
fn,
|
|
149
|
+
getDeploymentInfo,
|
|
150
|
+
getForms,
|
|
151
|
+
getSubmissions,
|
|
152
|
+
http,
|
|
153
|
+
lastReferenceValue,
|
|
154
|
+
merge,
|
|
155
|
+
sourceValue
|
|
105
156
|
});
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,8 @@ __export(Adaptor_exports, {
|
|
|
14
14
|
execute: () => execute,
|
|
15
15
|
field: () => field,
|
|
16
16
|
fields: () => fields,
|
|
17
|
+
fn: () => fn,
|
|
18
|
+
getDeploymentInfo: () => getDeploymentInfo,
|
|
17
19
|
getForms: () => getForms,
|
|
18
20
|
getSubmissions: () => getSubmissions,
|
|
19
21
|
http: () => http2,
|
|
@@ -28,6 +30,7 @@ import {
|
|
|
28
30
|
http
|
|
29
31
|
} from "@openfn/language-common";
|
|
30
32
|
import {
|
|
33
|
+
fn,
|
|
31
34
|
alterState,
|
|
32
35
|
dataPath,
|
|
33
36
|
dataValue,
|
|
@@ -92,10 +95,45 @@ function getSubmissions(params, callback) {
|
|
|
92
95
|
});
|
|
93
96
|
};
|
|
94
97
|
}
|
|
98
|
+
function getDeploymentInfo(params, callback) {
|
|
99
|
+
return (state) => {
|
|
100
|
+
params = expandReferences(params)(state);
|
|
101
|
+
const { baseURL, apiVersion, username, password } = state.configuration;
|
|
102
|
+
const { formId } = params;
|
|
103
|
+
const url = `${baseURL}/api/${apiVersion}/assets/${formId}/deployment/?format=json`;
|
|
104
|
+
const auth = { username, password };
|
|
105
|
+
const config = {
|
|
106
|
+
url,
|
|
107
|
+
params: params.query,
|
|
108
|
+
auth
|
|
109
|
+
};
|
|
110
|
+
return http.get(config)(state).then((response) => {
|
|
111
|
+
console.log("\u2713", "deployment information fetched.");
|
|
112
|
+
const nextState = composeNextState(state, response.data);
|
|
113
|
+
if (callback)
|
|
114
|
+
return callback(nextState);
|
|
115
|
+
return nextState;
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
}
|
|
95
119
|
|
|
96
120
|
// src/index.js
|
|
97
121
|
var src_default = Adaptor_exports;
|
|
98
122
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
123
|
+
alterState,
|
|
124
|
+
dataPath,
|
|
125
|
+
dataValue,
|
|
126
|
+
src_default as default,
|
|
127
|
+
each,
|
|
128
|
+
execute,
|
|
129
|
+
field,
|
|
130
|
+
fields,
|
|
131
|
+
fn,
|
|
132
|
+
getDeploymentInfo,
|
|
133
|
+
getForms,
|
|
134
|
+
getSubmissions,
|
|
135
|
+
http2 as http,
|
|
136
|
+
lastReferenceValue,
|
|
137
|
+
merge,
|
|
138
|
+
sourceValue
|
|
101
139
|
};
|
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -38,4 +38,17 @@ export function getForms(params: object, callback: Function): Operation;
|
|
|
38
38
|
* @returns {Operation}
|
|
39
39
|
*/
|
|
40
40
|
export function getSubmissions(params: object, callback: Function): Operation;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Get deployment information for a specific form
|
|
43
|
+
* @example
|
|
44
|
+
* getDeploymentInfo({formId: 'aXecHjmbATuF6iGFmvBLBX'}, state => {
|
|
45
|
+
* console.log(state.data);
|
|
46
|
+
* return state;
|
|
47
|
+
* });
|
|
48
|
+
* @function
|
|
49
|
+
* @param {object} params - Form Id and data to make the fetch or filter
|
|
50
|
+
* @param {function} callback - (Optional) Callback function to execute after fetching form deployment information
|
|
51
|
+
* @returns {Operation}
|
|
52
|
+
*/
|
|
53
|
+
export function getDeploymentInfo(params: object, callback: Function): Operation;
|
|
54
|
+
export { fn, alterState, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|
package/types/index.d.ts
CHANGED