diff --git a/.changeset/red-coats-argue.md b/.changeset/red-coats-argue.md new file mode 100644 index 000000000..cf142c13a --- /dev/null +++ b/.changeset/red-coats-argue.md @@ -0,0 +1,5 @@ +--- +'@openfn/language-kobotoolbox': major +--- + +Renaming `baseURL` to `baseUrl` to match all other adaptors, and logging a warning if `baseURL` is used diff --git a/packages/kobotoolbox/ast.json b/packages/kobotoolbox/ast.json index df4b851e0..3202d4f40 100644 --- a/packages/kobotoolbox/ast.json +++ b/packages/kobotoolbox/ast.json @@ -4,7 +4,7 @@ "name": "getForms", "params": [], "docs": { - "description": "Make a request to fetch all survey forms accessible to the user's API token. The url is `/assets/?asset_type=survey`.", + "description": "Make a request to fetch all survey forms accessible to the user's API token. Calls `/api/v2/assets/?asset_type=survey`.", "tags": [ { "title": "public", @@ -20,6 +20,10 @@ "description": null, "name": null }, + { + "title": "state", + "description": "data - an array of form objects" + }, { "title": "returns", "description": null, @@ -39,7 +43,7 @@ "options" ], "docs": { - "description": "Get submissions for a specific form", + "description": "Get submissions for a specific form. Calls `/api/v2/assets//data/`.", "tags": [ { "title": "example", @@ -83,6 +87,10 @@ "name": "options", "default": "{}" }, + { + "title": "state", + "description": "data - an array of submission objects" + }, { "title": "returns", "description": null, @@ -101,7 +109,7 @@ "formId" ], "docs": { - "description": "Get deployment information for a specific form", + "description": "Get deployment information for a specific form. Calls `/api/v2/assets//deployment/`.", "tags": [ { "title": "example", @@ -126,6 +134,10 @@ }, "name": "formId" }, + { + "title": "state", + "description": "data - an object containing deployment information" + }, { "title": "returns", "description": null, diff --git a/packages/kobotoolbox/configuration-schema.json b/packages/kobotoolbox/configuration-schema.json index 15150c865..0be0c64b6 100644 --- a/packages/kobotoolbox/configuration-schema.json +++ b/packages/kobotoolbox/configuration-schema.json @@ -1,8 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { - "baseURL": { - "title": "Base URL", + "baseUrl": { + "title": "Base Url", "type": "string", "default": "https://kf.kobotoolbox.org", "description": "Kobotoolbox URL", @@ -46,7 +46,7 @@ "additionalProperties": true, "required": [ "username", - "baseURL", + "baseUrl", "password", "apiVersion" ] diff --git a/packages/kobotoolbox/src/Utils.js b/packages/kobotoolbox/src/Utils.js index 956e45e07..9e2f518cf 100644 --- a/packages/kobotoolbox/src/Utils.js +++ b/packages/kobotoolbox/src/Utils.js @@ -17,6 +17,17 @@ export const prepareNextState = (state, response) => { export async function request(state, method, path, opts) { const { baseURL, apiVersion, username, password } = state.configuration; + let baseUrl; + + if (!state.configuration.baseUrl && baseURL) { + baseUrl = baseURL; + console.warn( + 'No baseUrl found in state.configuration. baseURL will be used instead, but this will be deprecated in the future.' + ); + } else { + baseUrl = state.configuration.baseUrl; + } + const { data = {}, query = {}, @@ -41,7 +52,7 @@ export async function request(state, method, path, opts) { ...query, }, parseAs, - baseUrl: `${baseURL}/api/${apiVersion}`, + baseUrl: `${baseUrl}/api/${apiVersion}`, }; if (paginate) { diff --git a/packages/kobotoolbox/test/index.js b/packages/kobotoolbox/test/index.js index 88ade6da5..9a1e603ce 100644 --- a/packages/kobotoolbox/test/index.js +++ b/packages/kobotoolbox/test/index.js @@ -22,7 +22,7 @@ const configuration = { username: 'test', password: 'strongpassword', apiVersion: 'v2', - baseURL: 'https://test.kobotoolbox.org', + baseUrl: 'https://test.kobotoolbox.org', }; const defaultObjects = [