@openfn/language-kobotoolbox 1.2.0 → 1.3.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Language KoboToolbox [![Build Status](https://travis-ci.org/OpenFn/language-kobotoolbox.svg?branch=master)](https://travis-ci.org/OpenFn/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 `Getting Started` guide inside to get set up.
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
 
@@ -7,20 +7,29 @@
7
7
  "default": "https://kf.kobotoolbox.org",
8
8
  "description": "Kobotoolbox URL",
9
9
  "format": "uri",
10
- "minLength": 1
10
+ "minLength": 1,
11
+ "examples": [
12
+ "https://kf.kobotoolbox.org"
13
+ ]
11
14
  },
12
15
  "username": {
13
16
  "title": "Username",
14
17
  "type": "string",
15
18
  "description": "Kobotoolbox username",
16
- "minLength": 1
19
+ "minLength": 1,
20
+ "examples": [
21
+ "test@openfn.org"
22
+ ]
17
23
  },
18
24
  "password": {
19
25
  "title": "Password",
20
26
  "type": "string",
21
27
  "description": "Kobotoolbox password",
22
28
  "writeOnly": true,
23
- "minLength": 1
29
+ "minLength": 1,
30
+ "examples": [
31
+ "@some(!)Strongpassword"
32
+ ]
24
33
  },
25
34
  "apiVersion": {
26
35
  "title": "API Version",
@@ -31,7 +40,10 @@
31
40
  "v1",
32
41
  "v2"
33
42
  ],
34
- "minLength": 1
43
+ "minLength": 1,
44
+ "examples": [
45
+ "v2"
46
+ ]
35
47
  }
36
48
  },
37
49
  "type": "object",
package/dist/index.cjs CHANGED
@@ -28,6 +28,7 @@ __export(src_exports, {
28
28
  field: () => import_language_common2.field,
29
29
  fields: () => import_language_common2.fields,
30
30
  fn: () => import_language_common2.fn,
31
+ getDeploymentInfo: () => getDeploymentInfo,
31
32
  getForms: () => getForms,
32
33
  getSubmissions: () => getSubmissions,
33
34
  http: () => import_language_common2.http,
@@ -48,6 +49,7 @@ __export(Adaptor_exports, {
48
49
  field: () => import_language_common2.field,
49
50
  fields: () => import_language_common2.fields,
50
51
  fn: () => import_language_common2.fn,
52
+ getDeploymentInfo: () => getDeploymentInfo,
51
53
  getForms: () => getForms,
52
54
  getSubmissions: () => getSubmissions,
53
55
  http: () => import_language_common2.http,
@@ -110,6 +112,27 @@ function getSubmissions(params, callback) {
110
112
  });
111
113
  };
112
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
+ }
113
136
 
114
137
  // src/index.js
115
138
  var src_default = Adaptor_exports;
@@ -123,6 +146,7 @@ var src_default = Adaptor_exports;
123
146
  field,
124
147
  fields,
125
148
  fn,
149
+ getDeploymentInfo,
126
150
  getForms,
127
151
  getSubmissions,
128
152
  http,
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
+ getDeploymentInfo: () => getDeploymentInfo,
18
19
  getForms: () => getForms,
19
20
  getSubmissions: () => getSubmissions,
20
21
  http: () => http2,
@@ -94,6 +95,27 @@ function getSubmissions(params, callback) {
94
95
  });
95
96
  };
96
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
+ }
97
119
 
98
120
  // src/index.js
99
121
  var src_default = Adaptor_exports;
@@ -107,6 +129,7 @@ export {
107
129
  field,
108
130
  fields,
109
131
  fn,
132
+ getDeploymentInfo,
110
133
  getForms,
111
134
  getSubmissions,
112
135
  http2 as http,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-kobotoolbox",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "A Kobo Toolbox Language Pack for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -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
+ /**
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;
41
54
  export { fn, alterState, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";