diff --git a/packages/msgraph/package.json b/packages/msgraph/package.json index 9c787b942..6866c1ede 100644 --- a/packages/msgraph/package.json +++ b/packages/msgraph/package.json @@ -27,7 +27,8 @@ "configuration-schema.json" ], "dependencies": { - "@openfn/language-common": "^1.10.1" + "@openfn/language-common": "^1.10.1", + "undici": "^5.22.1" }, "devDependencies": { "@openfn/buildtools": "workspace:^1.0.2", @@ -37,8 +38,7 @@ "deep-eql": "4.1.1", "esno": "^0.16.3", "mocha": "9.2.2", - "rimraf": "3.0.2", - "undici": "^5.22.1" + "rimraf": "3.0.2" }, "repository": { "type": "git", diff --git a/packages/msgraph/src/Adaptor.js b/packages/msgraph/src/Adaptor.js index 346e1fca2..c93a1146d 100644 --- a/packages/msgraph/src/Adaptor.js +++ b/packages/msgraph/src/Adaptor.js @@ -1,7 +1,7 @@ import { execute as commonExecute } from '@openfn/language-common'; import { expandReferences } from '@openfn/language-common/util'; -import { request, setAuth, setUrl, handleResponse } from './Utils'; +import { request, setAuth, getUrl, handleResponse } from './Utils'; /** * Execute a sequence of operations. @@ -51,7 +51,7 @@ export function create(resource, data, callback) { const { accessToken, apiVersion } = state.configuration; - const url = setUrl({ apiVersion, resolveResource }); + const url = getUrl({ apiVersion, resolveResource }); const auth = setAuth(accessToken); const options = { @@ -81,7 +81,7 @@ export function get(path, query, callback = false) { const { accessToken, apiVersion } = state.configuration; const [resolvePath, resolveQuery] = expandReferences(state, path, query); - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); return request(url, { ...resolveQuery, ...auth }).then(response => @@ -128,7 +128,7 @@ export function getDrive(drive, callback) { resolvePath = `${resource}/${resourceId}/drive`; } - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); return request(url, { ...auth }).then(response => @@ -170,7 +170,7 @@ export function listDrives(resource, callback) { resolvePath = `${resource}/${resourceId}/drives`; } - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); return request(url, { ...auth }).then(response => diff --git a/packages/msgraph/src/Sharepoint.js b/packages/msgraph/src/Sharepoint.js index 91b90ef74..2ae37e3f3 100644 --- a/packages/msgraph/src/Sharepoint.js +++ b/packages/msgraph/src/Sharepoint.js @@ -1,6 +1,6 @@ import { expandReferences } from '@openfn/language-common/util'; -import { request, setAuth, setUrl, handleResponse } from './Utils'; +import { request, setAuth, getUrl, handleResponse } from './Utils'; /** * Get a SharePoint site using msgraph API @@ -22,7 +22,7 @@ export function getSites(sharepointSite, callback = s => s) { const resolvePath = resolvedRootSite ? `sites/${resolvedRootSite}` : 'sites/root'; - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); @@ -62,7 +62,7 @@ export function getLists( ? `sites/${siteId}/lists/${listId}` : `sites/${siteId}/lists`; - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); return request(url, { ...auth }).then(response => @@ -109,7 +109,7 @@ export function getItems( ? `sites/${siteId}/drive/items/${itemId}${content}` : `sites/${siteId}/lists/${listId}/items`; - const url = setUrl({ apiVersion, resolvePath }); + const url = getUrl({ apiVersion, resolvePath }); const auth = setAuth(accessToken); diff --git a/packages/msgraph/src/Utils.js b/packages/msgraph/src/Utils.js index 5eb5d4b8e..aeb68548a 100644 --- a/packages/msgraph/src/Utils.js +++ b/packages/msgraph/src/Utils.js @@ -1,6 +1,7 @@ +import { fetch } from 'undici'; import { composeNextState } from '@openfn/language-common'; -export function setUrl(urlParams) { +export function getUrl(urlParams) { const { apiVersion, resolvePath } = urlParams; if (isValidHttpUrl(resolvePath)) return resolvePath; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4521ac4a..8a94502e5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -761,6 +761,7 @@ importers: undici: ^5.22.1 dependencies: '@openfn/language-common': link:../common + undici: 5.22.1 devDependencies: '@openfn/buildtools': link:../../tools/build '@openfn/simple-ast': 0.4.1 @@ -770,7 +771,6 @@ importers: esno: 0.16.3 mocha: 9.2.2 rimraf: 3.0.2 - undici: 5.22.1 packages/mssql: specifiers: @@ -4305,7 +4305,6 @@ packages: engines: {node: '>=10.16.0'} dependencies: streamsearch: 1.1.0 - dev: true /bytes/3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} @@ -11043,7 +11042,6 @@ packages: /streamsearch/1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} - dev: true /strict-uri-encode/1.1.0: resolution: {integrity: sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==} @@ -11963,7 +11961,6 @@ packages: engines: {node: '>=14.0'} dependencies: busboy: 1.6.0 - dev: true /union-value/1.0.1: resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==}