@hubspot/cms-lib
Advanced tools
Comparing version 0.0.21-beta.1 to 0.0.22-beta.0
@@ -10,2 +10,14 @@ const http = require('../http'); | ||
*/ | ||
async function fetchMenus(portalId, query = {}) { | ||
return http.get(portalId, { | ||
uri: `${DESIGN_MANAGER_API_PATH}/menus`, | ||
query, | ||
}); | ||
} | ||
/** | ||
* @async | ||
* @param {number} portalId | ||
* @returns {Promise} | ||
*/ | ||
async function fetchBuiltinMapping(portalId) { | ||
@@ -19,2 +31,3 @@ return http.get(portalId, { | ||
fetchBuiltinMapping, | ||
fetchMenus, | ||
}; |
@@ -24,2 +24,13 @@ const fs = require('fs-extra'); | ||
} | ||
if (typeof source !== 'string') { | ||
// JSON responses will have already been parsed. | ||
// TODO: Directly write the stream so we don't lose fidelity like whitespace. | ||
try { | ||
source = JSON.stringify(source, null, 2); | ||
} catch (err) { | ||
throw new TypeError( | ||
`Unable to parse "${filePath}" source: ${typeof source}` | ||
); | ||
} | ||
} | ||
const node = { | ||
@@ -26,0 +37,0 @@ source, |
15
http.js
@@ -69,4 +69,17 @@ const request = require('request-promise-native'); | ||
const addQueryParams = (requestOptions, params = {}) => { | ||
const { qs } = requestOptions; | ||
return { | ||
...requestOptions, | ||
qs: { | ||
...qs, | ||
...params, | ||
}, | ||
}; | ||
}; | ||
const getRequest = async (portalId, options) => { | ||
return request.get(await withAuth(portalId, options)); | ||
const { query, ...rest } = options; | ||
const requestOptions = addQueryParams(rest, query); | ||
return request.get(await withAuth(portalId, requestOptions)); | ||
}; | ||
@@ -73,0 +86,0 @@ |
{ | ||
"name": "@hubspot/cms-lib", | ||
"version": "0.0.21-beta.1", | ||
"version": "0.0.22-beta.0", | ||
"description": "Library for working with the HubSpot CMS", | ||
@@ -26,3 +26,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "d1be995482c0d9334d494718df89d36cd5bd986f" | ||
"gitHead": "8c4960b91d6badcafc71af98c18a2597ec4bf67a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82243
32
2523